围栏可以从文件导入
This commit is contained in:
+31
-18
@@ -83,17 +83,27 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2147"/>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2170"/>
|
||||
<source>开始上传航点,总数%1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2337"/>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2385"/>
|
||||
<source>上传失败%1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2361"/>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2411"/>
|
||||
<source>polygons</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2414"/>
|
||||
<source>circles</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/opmapwidget.cpp" line="2422"/>
|
||||
<source>recieve way point group:%1 seq:%2</source>
|
||||
<translation>收到航点:第%1组,第%2点</translation>
|
||||
</message>
|
||||
@@ -119,86 +129,89 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic
|
||||
<context>
|
||||
<name>mapcontrol::WayPointItem</name>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="373"/>
|
||||
<source>waypoint </source>
|
||||
<translation>航点 </translation>
|
||||
<translation type="vanished">航点 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="376"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="389"/>
|
||||
<source>return </source>
|
||||
<translation>返航 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="379"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="392"/>
|
||||
<source>landing </source>
|
||||
<translation>降落 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="382"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="395"/>
|
||||
<source>takeoff </source>
|
||||
<translation>起飞 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="385"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="398"/>
|
||||
<source>unknow </source>
|
||||
<translation>未知类型 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="393"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="406"/>
|
||||
<source>hold
|
||||
</source>
|
||||
<translation>保持
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="396"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="410"/>
|
||||
<source>cas
|
||||
</source>
|
||||
<translation>表速
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="399"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="414"/>
|
||||
<source>Vz
|
||||
</source>
|
||||
<translation>快升
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="402"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="418"/>
|
||||
<source>onAB
|
||||
</source>
|
||||
<translation>开加力
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="405"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="422"/>
|
||||
<source>offAB
|
||||
</source>
|
||||
<translation>关加力
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="408"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="426"/>
|
||||
<source>unknow
|
||||
</source>
|
||||
<translation>未知指令
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="414"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="433"/>
|
||||
<source>
|
||||
</source>
|
||||
<translation>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="417"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="411"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="415"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="419"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="423"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="427"/>
|
||||
<source>Speed: %1m/s</source>
|
||||
<translation>速度:%1m/s</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="418"/>
|
||||
<location filename="mapwidget/waypointitem.cpp" line="436"/>
|
||||
<source>Height: %1m
|
||||
%2</source>
|
||||
<translation>高度:%1m
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#include "geoFencecircle.h"
|
||||
#include <QDateTime>
|
||||
namespace mapcontrol {
|
||||
geoFencecircle::geoFencecircle(int g, int count, int index, bool inclusion, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed, int width) :
|
||||
QGraphicsEllipseItem(map),m_center(center), coord(center->coord), m_brush(color), m_map(map),dashed(dashed),lineWidth(width)
|
||||
{
|
||||
|
||||
this->setZValue(3);
|
||||
|
||||
m_inclusion = inclusion;
|
||||
m_radius = radius;
|
||||
m_group = g; //2
|
||||
m_latitude = coord.Lat();//5
|
||||
m_longitide = coord.Lng();//6
|
||||
|
||||
|
||||
connect(center, SIGNAL(localPositionChanged(QPointF, geoFenceitem *)), this, SLOT(refreshLocations()));
|
||||
connect(center, SIGNAL(aboutToBeDeleted(geoFenceitem *)), this, SLOT(waypointdeleted()));
|
||||
refreshLocations();
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
}
|
||||
|
||||
|
||||
int geoFencecircle::type() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setOpacity(0.4);
|
||||
|
||||
QPointF p1;
|
||||
QPointF p2;
|
||||
p1 = QPointF(line.p1().x(), line.p1().y() + line.length());
|
||||
p2 = QPointF(line.p1().x(), line.p1().y() - line.length());
|
||||
QPen myPen = painter->pen();
|
||||
myPen.setWidth(lineWidth);
|
||||
myPen.setColor(m_brush.color());
|
||||
painter->setPen(myPen);
|
||||
|
||||
|
||||
if (dashed) {
|
||||
QVector<qreal> dashes;
|
||||
dashes << 4 << 8;
|
||||
myPen.setDashPattern(dashes);
|
||||
}
|
||||
|
||||
|
||||
painter->translate(-line.length(), -line.length());
|
||||
|
||||
|
||||
if(m_inclusion)
|
||||
{
|
||||
painter->setBrush(m_brush);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
}
|
||||
|
||||
|
||||
painter->drawEllipse(this->rect());
|
||||
}
|
||||
|
||||
void geoFencecircle::refreshLocations()
|
||||
{
|
||||
|
||||
//qDebug() << my_center->pos();
|
||||
|
||||
internals::PointLatLng C;
|
||||
C = m_map->FromLocalToLatLng(m_center->x(),m_center->y());
|
||||
C.SetLat(C.Lat() + m_radius/111133.3333f);
|
||||
|
||||
|
||||
|
||||
line = QLineF(m_center->pos().x(),m_center->pos().y(),m_center->pos().x(),m_map->FromLatLngToLocal(C).Y());
|
||||
this->setRect(m_center->pos().x(), m_center->pos().y(), 2 * line.length(), 2 * line.length());
|
||||
this->update();
|
||||
}
|
||||
|
||||
void geoFencecircle::waypointdeleted()
|
||||
{
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
void geoFencecircle::setOpacitySlot(qreal opacity)
|
||||
{
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef GEOFENCECIRCLE_H
|
||||
#define GEOFENCECIRCLE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "pointlatlng.h"
|
||||
#include <QObject>
|
||||
#include "mapgraphicitem.h"
|
||||
#include "geoFenceitem.h"
|
||||
|
||||
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 g, int count, int index, bool inclusion, geoFenceitem *center, double radius, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
|
||||
|
||||
int type() const;
|
||||
internals::PointLatLng coord;
|
||||
int number;
|
||||
private:
|
||||
QBrush m_brush;
|
||||
MapGraphicItem *m_map;
|
||||
|
||||
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;
|
||||
|
||||
geoFenceitem *m_center;
|
||||
|
||||
|
||||
bool dashed;
|
||||
int lineWidth;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
public slots:
|
||||
void refreshLocations();
|
||||
void waypointdeleted();
|
||||
void setOpacitySlot(qreal opacity);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // GEOFENCECIRCLE_H
|
||||
@@ -1,15 +1,20 @@
|
||||
#include "geoFenceitem.h"
|
||||
#include <QDateTime>
|
||||
namespace mapcontrol {
|
||||
geoFenceitem::geoFenceitem(int index, internals::PointLatLng const & coord, int const & altitude, QBrush color, MapGraphicItem *map) : QGraphicsItem(map), number(index) , coord(coord), m_brush(color), m_map(map)
|
||||
geoFenceitem::geoFenceitem(int g, int count, int index, bool inclusion, internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed, int width) :
|
||||
QGraphicsPolygonItem(map), number(index) , coord(coord), m_brush(color), m_map(map), dashed(dashed), lineWidth(width)
|
||||
{
|
||||
//qDebug() << "geoFenceitem:" << index << coord.Lat() << coord.Lng();
|
||||
|
||||
this->setZValue(3);
|
||||
|
||||
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
|
||||
|
||||
//qDebug() << this->pos();
|
||||
|
||||
m_inclusion = inclusion;
|
||||
m_Vertex = count;//1
|
||||
m_group = g; //2
|
||||
m_latitude = coord.Lat();//5
|
||||
m_longitide = coord.Lng();//6
|
||||
|
||||
|
||||
RefreshPos();
|
||||
}
|
||||
|
||||
@@ -18,12 +23,50 @@ void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setBrush(m_brush);
|
||||
painter->drawPoint(0,0);
|
||||
}
|
||||
QRectF geoFenceitem::boundingRect() const
|
||||
{
|
||||
return QRectF(-2, -2, 4, 4);
|
||||
painter->setOpacity(0.4);
|
||||
|
||||
QPen myPen = painter->pen();
|
||||
myPen.setWidth(lineWidth);
|
||||
myPen.setColor(m_brush.color());
|
||||
painter->setPen(myPen);
|
||||
|
||||
|
||||
if (dashed) {
|
||||
QVector<qreal> dashes;
|
||||
dashes << 4 << 8;
|
||||
myPen.setDashPattern(dashes);
|
||||
}
|
||||
|
||||
if(m_inclusion)
|
||||
{
|
||||
painter->setBrush(m_brush);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
}
|
||||
|
||||
painter->drawPoint(0, 0);
|
||||
|
||||
/*
|
||||
QPolygonF polygon;
|
||||
for(internals::PointLatLng p:points)
|
||||
{
|
||||
QPointF pf;
|
||||
pf.setX(m_map->FromLatLngToLocal(p).X());
|
||||
pf.setY(m_map->FromLatLngToLocal(p).Y());
|
||||
polygon.push_back(pf);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
painter->drawPolygon(polygon());
|
||||
|
||||
|
||||
qDebug() << polygon();
|
||||
|
||||
|
||||
}
|
||||
|
||||
int geoFenceitem::type() const
|
||||
@@ -35,6 +78,19 @@ void geoFenceitem::setPosSLOT()
|
||||
{
|
||||
//qDebug() << "virtual set pos";
|
||||
|
||||
QPolygonF polygon;
|
||||
for(internals::PointLatLng LatLng:points)
|
||||
{
|
||||
QPointF pf;
|
||||
pf.setX(m_map->FromLatLngToLocal(LatLng).X() - m_map->FromLatLngToLocal(this->coord).X());
|
||||
pf.setY(m_map->FromLatLngToLocal(LatLng).Y() - m_map->FromLatLngToLocal(this->coord).Y());
|
||||
|
||||
polygon.append(pf);
|
||||
}
|
||||
setPolygon(polygon);
|
||||
|
||||
|
||||
|
||||
setPos(m_map->FromLatLngToLocal(this->coord).X(), m_map->FromLatLngToLocal(this->coord).Y());
|
||||
emit localPositionChanged(this->pos(),this);
|
||||
}
|
||||
@@ -44,6 +100,29 @@ void geoFenceitem::RefreshPos()
|
||||
setPosSLOT();
|
||||
}
|
||||
|
||||
void geoFenceitem::setPoints(QList<internals::PointLatLng> p)
|
||||
{
|
||||
points = p;
|
||||
|
||||
//QPolygonF polygon;
|
||||
/*
|
||||
m_polygon.clear();
|
||||
for(internals::PointLatLng LatLng:points)
|
||||
{
|
||||
QPointF pf;
|
||||
pf.setX(m_map->FromLatLngToLocal(LatLng).X());
|
||||
pf.setY(m_map->FromLatLngToLocal(LatLng).Y());
|
||||
|
||||
m_polygon.append(pf);
|
||||
}
|
||||
setPolygon(m_polygon);
|
||||
|
||||
qDebug() << m_polygon;
|
||||
*/
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,24 +12,41 @@ namespace mapcontrol {
|
||||
|
||||
#ifdef QtopmapWidget
|
||||
#include <mapwidgetglobal.h>
|
||||
class OPMAPWIDGETSHARED_EXPORT geoFenceitem : public QObject, public QGraphicsItem {
|
||||
class OPMAPWIDGETSHARED_EXPORT geoFenceitem : public QObject, public QGraphicsPolygonItem {
|
||||
#else
|
||||
class geoFenceitem : public QObject, public QGraphicsItem {
|
||||
class geoFenceitem : public QObject, public QGraphicsPolygonItem {
|
||||
#endif
|
||||
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 11 };
|
||||
geoFenceitem(int index,internals::PointLatLng const & coord, int const & altitude, QBrush color, MapGraphicItem *map);
|
||||
enum { Type = UserType + 5 };
|
||||
geoFenceitem(int g,int count,int index, bool inclusion,internals::PointLatLng const & coord, QBrush color, MapGraphicItem *map, bool dashed = false, int width = 3);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
int type() const;
|
||||
internals::PointLatLng coord;
|
||||
int number;
|
||||
|
||||
|
||||
QList<internals::PointLatLng> points;
|
||||
|
||||
void setPoints(QList<internals::PointLatLng> p);
|
||||
|
||||
private:
|
||||
QBrush m_brush;
|
||||
MapGraphicItem *m_map;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
public slots:
|
||||
void setPosSLOT();
|
||||
|
||||
|
||||
@@ -15,12 +15,6 @@ geoFenceitemline::geoFenceitemline(geoFenceitem *from, geoFenceitem *to, MapGrap
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
|
||||
isEdit = true;
|
||||
|
||||
//qDebug() << "virtual line create";
|
||||
|
||||
//qDebug() << this->pos();
|
||||
|
||||
lineWidth = 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,47 +35,22 @@ void geoFenceitemline::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
//qDebug() << "virtual line update";
|
||||
|
||||
QPen myPen = pen();
|
||||
|
||||
|
||||
myPen.setColor(myColor);
|
||||
|
||||
|
||||
|
||||
//qreal arrowSize = 10;
|
||||
painter->setPen(myPen);
|
||||
|
||||
/*
|
||||
if(isEdit == false)
|
||||
{
|
||||
painter->setBrush(myColor);
|
||||
}
|
||||
*/
|
||||
|
||||
double angle = ::acos(line().dx() / line().length());
|
||||
if (line().dy() >= 0) {
|
||||
angle = (M_PI * 2) - angle;
|
||||
}
|
||||
|
||||
/*
|
||||
QPointF arrowP1 = line().pointAt(0.5) + QPointF(sin(angle + M_PI / 3) * arrowSize,
|
||||
cos(angle + M_PI / 3) * arrowSize);
|
||||
QPointF arrowP2 = line().pointAt(0.5) + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize,
|
||||
cos(angle + M_PI - M_PI / 3) * arrowSize);
|
||||
arrowHead.clear();
|
||||
arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2;
|
||||
painter->drawPolygon(arrowHead);
|
||||
*/
|
||||
|
||||
if (dashed) {
|
||||
QVector<qreal> dashes;
|
||||
dashes << 4 << 8;
|
||||
myPen.setDashPattern(dashes);
|
||||
}
|
||||
|
||||
|
||||
myPen.setWidth(lineWidth);
|
||||
|
||||
painter->setPen(myPen);
|
||||
|
||||
@@ -26,7 +26,7 @@ class geoFenceitemline : public QObject, public QGraphicsLineItem {
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 12 };
|
||||
geoFenceitemline(geoFenceitem *from, geoFenceitem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = 2);
|
||||
geoFenceitemline(geoFenceitem *from, geoFenceitem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = 3);
|
||||
int type() const;
|
||||
QPainterPath shape() const;
|
||||
void setColor(const QColor &color)
|
||||
|
||||
@@ -51,6 +51,7 @@ SOURCES += $$PWD/mapgraphicitem.cpp \
|
||||
$$PWD/AltitudeItem.cpp \
|
||||
$$PWD/waypointbutton.cpp \
|
||||
$$PWD/waypointsetting.cpp \
|
||||
geoFencecircle.cpp \
|
||||
geoFenceitem.cpp \
|
||||
geoFenceitemline.cpp \
|
||||
measureline.cpp
|
||||
@@ -74,6 +75,7 @@ HEADERS += $$PWD/mapgraphicitem.h \
|
||||
$$PWD/AltitudeItem.h \
|
||||
$$PWD/waypointbutton.h \
|
||||
$$PWD/waypointsetting.h \
|
||||
geoFencecircle.h \
|
||||
geoFenceitem.h \
|
||||
geoFenceitemline.h \
|
||||
measureline.h
|
||||
|
||||
+264
-51
@@ -242,6 +242,177 @@ void OPMapWidget::table_clicked(void)
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*
|
||||
void OPMapWidget::AddgeoPolygon(int type,int index,double lat,double lng,double alt,QColor color)
|
||||
{
|
||||
qDebug() << "AddVirtualMargin" << type << index;
|
||||
|
||||
internals::PointLatLng LatLng;
|
||||
LatLng.SetLat(lat);
|
||||
LatLng.SetLng(lng);
|
||||
|
||||
QMap<int,VirtualMargin *> virtualmarginmap = VirtualMarginPoints.value(type);
|
||||
QMap<int,VirtualMarginLine *> virtualmarginlinemap = VirtualMarginlinemapLines.value(type);
|
||||
|
||||
|
||||
VirtualMargin *vm = new VirtualMargin(index,LatLng,alt,color,map);
|
||||
virtualmarginmap.insert(index,vm);
|
||||
|
||||
foreach (VirtualMarginLine *l, virtualmarginlinemap) {
|
||||
if(l){
|
||||
disconnect(l,nullptr,nullptr,nullptr);
|
||||
delete l;
|
||||
}
|
||||
}
|
||||
|
||||
virtualmarginlinemap.clear();
|
||||
|
||||
|
||||
for(QMap<int,VirtualMargin *>::iterator i = virtualmarginmap.begin();i != virtualmarginmap.end();++i)
|
||||
{
|
||||
VirtualMargin *v = i.value();
|
||||
if(v)
|
||||
{
|
||||
if(v->number > 0)
|
||||
{
|
||||
VirtualMarginLine *l = new VirtualMarginLine(virtualmarginmap.value(v->number - 1),v,map,color);
|
||||
l->setOpacity(overlayOpacity);
|
||||
l->show();
|
||||
|
||||
virtualmarginlinemap.insert(virtualmarginlinemap.size(),l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(virtualmarginmap.size() >= 2)
|
||||
{
|
||||
VirtualMargin *vm_first = virtualmarginmap.first();
|
||||
VirtualMargin *vm_last = virtualmarginmap.last();
|
||||
|
||||
if((vm_first)&&(vm_last))
|
||||
{
|
||||
VirtualMarginLine *l = new VirtualMarginLine(vm_first,vm_last,map,color);
|
||||
l->setOpacity(overlayOpacity);
|
||||
l->show();
|
||||
|
||||
virtualmarginlinemap.insert(virtualmarginlinemap.size(),l);
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMarginPoints.insert(type,virtualmarginmap);
|
||||
VirtualMarginlinemapLines.insert(type,virtualmarginlinemap);
|
||||
|
||||
//FlushVirtualMargin(type);
|
||||
|
||||
|
||||
foreach (VirtualMargin *v, virtualmarginmap) {
|
||||
qDebug() << "create a virtual point" << v->number;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OPMapWidget::ClosegeoPolygon(int type)
|
||||
{
|
||||
if(type == 0)
|
||||
{
|
||||
if(virtualmarginmap_red.size() >= 2)
|
||||
{
|
||||
VirtualMargin *vm_first = virtualmarginmap_red.first();
|
||||
VirtualMargin *vm_last = virtualmarginmap_red.last();
|
||||
|
||||
if((vm_first)&&(vm_last))
|
||||
{
|
||||
VirtualMarginLine *l = new VirtualMarginLine(vm_first,vm_last,map,WarningColor);
|
||||
l->setOpacity(overlayOpacity);
|
||||
l->show();
|
||||
|
||||
virtualmarginlinemap_red.insert(virtualmarginlinemap_red.size(),l);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
if(virtualmarginmap_orange.size() >= 2)
|
||||
{
|
||||
VirtualMargin *vm_first = virtualmarginmap_orange.first();
|
||||
VirtualMargin *vm_last = virtualmarginmap_orange.last();
|
||||
|
||||
if((vm_first)&&(vm_last))
|
||||
{
|
||||
VirtualMarginLine *l = new VirtualMarginLine(vm_first,vm_last,map,NoticeColor);
|
||||
l->setOpacity(overlayOpacity);
|
||||
l->show();
|
||||
|
||||
virtualmarginlinemap_orange.insert(virtualmarginlinemap_orange.size(),l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OPMapWidget::RemovegeoPolygon(int type)
|
||||
{
|
||||
|
||||
QMap<int,VirtualMargin*> virtualmarginmap = VirtualMarginPoints.value(type);
|
||||
QMap<int,VirtualMarginLine *> virtualmarginlinemap = VirtualMarginlinemapLines.value(type);
|
||||
|
||||
//移除虚拟边界
|
||||
foreach (VirtualMargin *vm, virtualmarginmap) {
|
||||
if(vm)
|
||||
{
|
||||
qDebug() << "del vm" << vm->number << vm->coord.Lat() << vm->coord.Lng();
|
||||
disconnect(vm,nullptr,nullptr,nullptr);
|
||||
delete vm;
|
||||
}
|
||||
}
|
||||
//从列表删除所有
|
||||
virtualmarginmap.clear();
|
||||
|
||||
//移除虚拟边界
|
||||
foreach (VirtualMarginLine *l, virtualmarginlinemap) {
|
||||
if(l)
|
||||
{
|
||||
disconnect(l,nullptr,nullptr,nullptr);
|
||||
delete l;
|
||||
}
|
||||
}
|
||||
//从列表删除所有
|
||||
virtualmarginlinemap.clear();
|
||||
|
||||
VirtualMarginPoints.remove(type);
|
||||
VirtualMarginlinemapLines.remove(type);
|
||||
|
||||
}
|
||||
|
||||
void OPMapWidget::FlushgeoPolygon(int type)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
for(QMap<int,VirtualMargin *>::iterator i = virtualmarginmap_red.begin();i != virtualmarginmap_red.end();++i)
|
||||
{
|
||||
VirtualMargin *vm = i.value();
|
||||
if(vm)
|
||||
{
|
||||
qDebug() << "vm" << vm->number << vm->coord.Lat() << vm->coord.Lng();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
for(QMap<int,VirtualMargin *>::iterator i = virtualmarginmap_orange.begin();i != virtualmarginmap_orange.end();++i)
|
||||
{
|
||||
VirtualMargin *vm = i.value();
|
||||
if(vm)
|
||||
{
|
||||
qDebug() << "vm" << vm->number << vm->coord.Lat() << vm->coord.Lng();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -819,6 +990,10 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
emit MouseDoubleClickEvent(event);
|
||||
@@ -1337,9 +1512,11 @@ void OPMapWidget::ConnectWP(WayPointItem *item)
|
||||
item, SLOT(setWPProperty(float,float,float,float,int32_t,int32_t,float,uint16_t,uint16_t,uint16_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
connect(item, SIGNAL(WPProperty(float,float,float,float,int32_t,int32_t,float,uint16_t,uint16_t,uint16_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t)),
|
||||
this, SLOT(find_PointNumber()),Qt::DirectConnection);
|
||||
this, SLOT(find_PointNumber(int)),Qt::DirectConnection);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
connect(item, SIGNAL(WPFollowPrevious(bool,WayPointItem*)),
|
||||
@@ -1877,46 +2054,13 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
|
||||
|
||||
/*
|
||||
"circles": [
|
||||
{
|
||||
"circle": {
|
||||
"center": [
|
||||
32.04290131170435,
|
||||
118.81779757301473
|
||||
],
|
||||
"radius": 104.72920614551222
|
||||
},
|
||||
"inclusion": true,
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"circle": {
|
||||
"center": [
|
||||
32.04275580264579,
|
||||
118.8194498137916
|
||||
],
|
||||
"radius": 91.2720266761384
|
||||
},
|
||||
"inclusion": true,
|
||||
"version": 1
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//安全区解码
|
||||
//栅栏解码
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
|
||||
for(QJsonValue item: circlesArray) {
|
||||
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonObject circle = item.toObject().value("circle").toObject();
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
QJsonArray center = circle.value("center").toArray();
|
||||
|
||||
@@ -1924,26 +2068,94 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
qreal lng = center.at(1).toDouble();
|
||||
qreal radius = circle.value("radius").toDouble();
|
||||
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
qDebug() << "circle" << inclusion << lat << lng << radius << version;
|
||||
//生成一个⚪
|
||||
|
||||
|
||||
geoFenceitem *centeritem = new geoFenceitem(0,1,1, inclusion ,internals::PointLatLng(lat,lng),QColor("#FF8000"),map);
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(0,1,1,inclusion,centeritem,radius,QColor("#FF8000"),map);
|
||||
|
||||
}
|
||||
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray();
|
||||
for(QJsonValue item: polygonsArray) {
|
||||
|
||||
//每个item是一个组
|
||||
QList<internals::PointLatLng> points;
|
||||
QList<geoFenceitem *> polyitems;
|
||||
//获得边界
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonArray polygon = item.toObject().value("polygon").toArray();
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
qreal lat_sum = 0;
|
||||
qreal lng_sum = 0;
|
||||
|
||||
for (QJsonValue point: polygon) {
|
||||
qreal lat = point.toArray().at(0).toDouble();
|
||||
qreal lng = point.toArray().at(1).toDouble();
|
||||
|
||||
//生成一个多边形
|
||||
points.push_back(internals::PointLatLng(lat,lng));
|
||||
|
||||
qDebug() << "polygon" << inclusion << version << lat << lng;
|
||||
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
}
|
||||
|
||||
int version = item.toObject().value("version").toInt();
|
||||
internals::PointLatLng center;
|
||||
|
||||
center.SetLat(lat_sum/polygon.size());
|
||||
center.SetLng(lng_sum/polygon.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(0,points.size(),0, inclusion ,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(points);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
int count = 0;
|
||||
for(internals::PointLatLng p : points)
|
||||
{
|
||||
geoFenceitem *polyitem = new geoFenceitem(0,points.size(),count, inclusion ,p,QColor("#FF8000"),map);
|
||||
count ++;
|
||||
polyitems.push_back(polyitem);
|
||||
|
||||
}
|
||||
|
||||
geoFenceitem *last;
|
||||
|
||||
for(geoFenceitem *p : polyitems)
|
||||
{
|
||||
if(p == polyitems.first())
|
||||
{
|
||||
last = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p == polyitems.last())
|
||||
{
|
||||
geoFenceitemline *polyline = new geoFenceitemline(last, polyitems.first(),map,QColor("#FF8000"));
|
||||
}
|
||||
else
|
||||
{
|
||||
geoFenceitemline *polyline = new geoFenceitemline(last, p,map,QColor("#FF8000"));
|
||||
last = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
qDebug() << "polygon" << inclusion << version << item.toObject();
|
||||
|
||||
}
|
||||
|
||||
@@ -2241,9 +2453,6 @@ void OPMapWidget::groupchanged(int value)
|
||||
return;
|
||||
}
|
||||
|
||||
//一下这里判断有问题,有bug
|
||||
|
||||
|
||||
//将不是当前的全部变成灰色,当前的显示
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
@@ -2400,6 +2609,8 @@ void OPMapWidget::WPGroup(int value)
|
||||
|
||||
emit settableGroup(currentGroup);
|
||||
|
||||
find_PointNumber(currentGroup);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -2645,7 +2856,7 @@ void OPMapWidget::updateMessage(void)
|
||||
emit TotalDistanceUpdate(totalDistance);
|
||||
}
|
||||
|
||||
void OPMapWidget::find_PointNumber()
|
||||
void OPMapWidget::find_PointNumber(int group)
|
||||
{
|
||||
QList<int> nums;
|
||||
nums.clear();
|
||||
@@ -2656,12 +2867,14 @@ void OPMapWidget::find_PointNumber()
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
if (w)
|
||||
{
|
||||
|
||||
number = w->Number();
|
||||
|
||||
if(w->Command() < MAV_CMD::MAV_CMD_NAV_LAST)
|
||||
if(w->MissionType() == group)//如果组别一样,那么就赋值
|
||||
{
|
||||
nums.append(number);
|
||||
number = w->Number();
|
||||
|
||||
if(w->Command() < MAV_CMD::MAV_CMD_NAV_LAST)
|
||||
{
|
||||
nums.append(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,11 @@
|
||||
|
||||
#include "measureline.h"
|
||||
|
||||
#include "geoFencecircle.h"
|
||||
#include "geoFenceitem.h"
|
||||
#include "geoFenceitemline.h"
|
||||
|
||||
|
||||
|
||||
namespace mapcontrol {
|
||||
|
||||
@@ -647,7 +652,7 @@ public slots:
|
||||
void groupchanged(int value);
|
||||
|
||||
|
||||
void find_PointNumber();
|
||||
void find_PointNumber(int group);
|
||||
|
||||
void updateMessage(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user