155 lines
3.4 KiB
C++
155 lines
3.4 KiB
C++
#ifndef GEOFENCECIRCLE_H
|
|
#define GEOFENCECIRCLE_H
|
|
|
|
#include <QGraphicsItem>
|
|
#include <QPainter>
|
|
#include <QLabel>
|
|
#include "pointlatlng.h"
|
|
#include <QObject>
|
|
#include "mapgraphicitem.h"
|
|
#include "geoFenceitem.h"
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
|
|
namespace mapcontrol {
|
|
|
|
#ifdef QtopmapWidget
|
|
#include <mapwidgetglobal.h>
|
|
class OPMAPWIDGETSHARED_EXPORT geoFencecircle : public QObject, public QGraphicsEllipseItem {
|
|
#else
|
|
class geoFencecircle : public QObject, public QGraphicsEllipseItem {
|
|
#endif
|
|
|
|
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
|
public:
|
|
enum { Type = UserType + 11 };
|
|
//geoFencecircle(int group,bool inclusion, int version, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
|
|
geoFencecircle(int group,bool inclusion, int version, internals::PointLatLng const ¢er, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
|
|
int type() const;
|
|
internals::PointLatLng coord;
|
|
int number;
|
|
|
|
|
|
int Group(void)
|
|
{
|
|
return m_group;
|
|
}
|
|
|
|
void setGroup(int value)
|
|
{
|
|
m_group = value;
|
|
|
|
//emit updateFenceCircle(m_group,m_radius,m_inclusion,m_latitude,m_longitide);
|
|
update();
|
|
}
|
|
|
|
bool Inclusion(void)
|
|
{
|
|
return m_inclusion;
|
|
}
|
|
|
|
void setInclusion(int value)
|
|
{
|
|
m_inclusion = value;
|
|
update();
|
|
}
|
|
|
|
qreal Radius(void)
|
|
{
|
|
return m_radius;
|
|
}
|
|
|
|
void setRadius(qreal value)
|
|
{
|
|
m_radius = value;
|
|
refreshLocations();
|
|
}
|
|
|
|
qreal Latitude(void)
|
|
{
|
|
return m_latitude;
|
|
}
|
|
|
|
void setLatitude(qreal value)
|
|
{
|
|
m_latitude = value;
|
|
coord.SetLat(m_latitude);
|
|
refreshLocations();
|
|
}
|
|
qreal Longitude(void)
|
|
{
|
|
return m_longitide;
|
|
}
|
|
|
|
void setLongitude(qreal value)
|
|
{
|
|
m_longitide = value;
|
|
coord.SetLng(m_longitide);
|
|
refreshLocations();
|
|
}
|
|
|
|
void setParameter(int group,qreal radius, bool inclusion, qreal lat, qreal lng)
|
|
{
|
|
m_group = group;
|
|
m_radius = radius;
|
|
m_inclusion = inclusion;
|
|
|
|
m_latitude = lat;
|
|
coord.SetLat(m_latitude);
|
|
|
|
m_longitide = lng;
|
|
coord.SetLng(m_longitide);
|
|
|
|
refreshLocations();
|
|
}
|
|
|
|
private:
|
|
QBrush m_brush;
|
|
MapGraphicItem *m_map;
|
|
|
|
int m_version = 0; //2
|
|
|
|
bool m_inclusion = true;
|
|
qreal m_radius = 0;//1
|
|
int m_group = 0; //2
|
|
qreal m_latitude = 0;//5
|
|
qreal m_longitide = 0;//6
|
|
|
|
QLineF line;
|
|
|
|
internals::PointLatLng m_center;
|
|
|
|
|
|
bool dashed;
|
|
int lineWidth;
|
|
|
|
QRectF rectangle;
|
|
|
|
bool isDragging = false;
|
|
bool enter = false;
|
|
|
|
|
|
protected:
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
public slots:
|
|
void refreshLocations();
|
|
void waypointdeleted();
|
|
void setOpacitySlot(qreal opacity);
|
|
|
|
|
|
signals:
|
|
|
|
void updateFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
|
|
void localPositionChanged(QPointF point, geoFencecircle *p);
|
|
|
|
};
|
|
}
|
|
#endif // GEOFENCECIRCLE_H
|