155 lines
3.1 KiB
C++
155 lines
3.1 KiB
C++
|
|
#ifndef GEOFENCEITEM_H
|
||
|
|
#define GEOFENCEITEM_H
|
||
|
|
|
||
|
|
#include <QGraphicsItem>
|
||
|
|
#include <QPainter>
|
||
|
|
#include <QLabel>
|
||
|
|
#include "pointlatlng.h"
|
||
|
|
#include <QObject>
|
||
|
|
#include "mapgraphicitem.h"
|
||
|
|
#include <QGraphicsSceneMouseEvent>
|
||
|
|
|
||
|
|
namespace mapcontrol {
|
||
|
|
|
||
|
|
#ifdef QtopmapWidget
|
||
|
|
#include <mapwidgetglobal.h>
|
||
|
|
class OPMAPWIDGETSHARED_EXPORT geoFenceitem : public QObject, public QGraphicsPolygonItem {
|
||
|
|
#else
|
||
|
|
class geoFenceitem : public QObject, public QGraphicsPolygonItem {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||
|
|
public:
|
||
|
|
enum { Type = UserType + 5 };
|
||
|
|
geoFenceitem(int group,bool inclusion,int version,internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
|
||
|
|
|
||
|
|
int type() const;
|
||
|
|
internals::PointLatLng coord;
|
||
|
|
int number;
|
||
|
|
|
||
|
|
|
||
|
|
QList<internals::PointLatLng> points;
|
||
|
|
|
||
|
|
void setPoints(QList<internals::PointLatLng> p);
|
||
|
|
QList<internals::PointLatLng> Points(void)
|
||
|
|
{
|
||
|
|
return points;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
int Group(void)
|
||
|
|
{
|
||
|
|
return m_group;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setGroup(int value)
|
||
|
|
{
|
||
|
|
m_group = value;
|
||
|
|
|
||
|
|
QList<QPointF> latlng;
|
||
|
|
|
||
|
|
|
||
|
|
for(internals::PointLatLng p:points)
|
||
|
|
{
|
||
|
|
latlng.push_back(QPointF(p.Lat(),p.Lng()));
|
||
|
|
}
|
||
|
|
|
||
|
|
//emit updateFencePolygon(m_group,m_Vertex,m_inclusion,latlng);
|
||
|
|
|
||
|
|
RefreshPos();
|
||
|
|
}
|
||
|
|
|
||
|
|
bool Inclusion(void)
|
||
|
|
{
|
||
|
|
return m_inclusion;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setInclusion(int value)
|
||
|
|
{
|
||
|
|
m_inclusion = value;
|
||
|
|
RefreshPos();
|
||
|
|
}
|
||
|
|
|
||
|
|
qreal Vertex(void)
|
||
|
|
{
|
||
|
|
return m_Vertex;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setVertex(qreal value)
|
||
|
|
{
|
||
|
|
m_Vertex = value;
|
||
|
|
RefreshPos();
|
||
|
|
}
|
||
|
|
|
||
|
|
qreal Latitude(void)
|
||
|
|
{
|
||
|
|
return m_latitude;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setLatitude(qreal value)
|
||
|
|
{
|
||
|
|
m_latitude = value;
|
||
|
|
coord.SetLat(m_latitude);
|
||
|
|
RefreshPos();
|
||
|
|
}
|
||
|
|
qreal Longitude(void)
|
||
|
|
{
|
||
|
|
return m_longitide;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setLongitude(qreal value)
|
||
|
|
{
|
||
|
|
m_longitide = value;
|
||
|
|
coord.SetLng(m_longitide);
|
||
|
|
RefreshPos();
|
||
|
|
qDebug() << "set logitide";
|
||
|
|
}
|
||
|
|
|
||
|
|
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);
|
||
|
|
|
||
|
|
private:
|
||
|
|
QBrush m_brush;
|
||
|
|
MapGraphicItem *m_map;
|
||
|
|
|
||
|
|
|
||
|
|
int m_version = 0;//-1
|
||
|
|
|
||
|
|
bool m_inclusion = true;
|
||
|
|
qreal m_Vertex = 0;//1
|
||
|
|
int m_group = 0; //2
|
||
|
|
qreal m_latitude = 0;//5
|
||
|
|
qreal m_longitide = 0;//6
|
||
|
|
|
||
|
|
bool dashed;
|
||
|
|
int lineWidth;
|
||
|
|
|
||
|
|
QPolygonF m_polygon;
|
||
|
|
|
||
|
|
bool isDragging = false;
|
||
|
|
|
||
|
|
|
||
|
|
bool enter = false;
|
||
|
|
|
||
|
|
public slots:
|
||
|
|
void setPosSLOT();
|
||
|
|
|
||
|
|
void RefreshPos();
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void updateFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng);
|
||
|
|
|
||
|
|
void localPositionChanged(QPointF point, geoFenceitem *p);
|
||
|
|
void aboutToBeDeleted(geoFenceitem *);
|
||
|
|
|
||
|
|
};
|
||
|
|
}
|
||
|
|
#endif // GEOFENCEITEM_H
|