添加标签按键
This commit is contained in:
+297
-373
@@ -98,6 +98,10 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
|
||||
// WPnearPoint
|
||||
|
||||
|
||||
connect(waypointsetting,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)));
|
||||
|
||||
connect(waypointsetting,SIGNAL(WPnearPoint(int)),
|
||||
this,SLOT(WPnearPoint(int)));
|
||||
|
||||
@@ -129,6 +133,12 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
this,SLOT(WPsearchall()));
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
connect(waypointsetting,SIGNAL(UAVShowTip(bool)),
|
||||
this,SLOT(UAVTip_clicked(bool)));
|
||||
|
||||
connect(waypointsetting,SIGNAL(WPRuler()),
|
||||
this,SLOT(ruler_clicked()));
|
||||
|
||||
@@ -152,8 +162,8 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
point_begin.SetLat(0);
|
||||
point_begin.SetLng(0);
|
||||
|
||||
point_end.SetLat(0);
|
||||
point_end.SetLng(0);
|
||||
point_end.SetLat(1);
|
||||
point_end.SetLng(1);
|
||||
|
||||
measureline = new MeasureLine(point_begin, point_end, map, QColor("#FFFF00"));
|
||||
mscene.addItem(measureline);
|
||||
@@ -197,6 +207,19 @@ void OPMapWidget::dropEvent(QDropEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::UAVTip_clicked(bool flag)
|
||||
{
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
|
||||
u->setShowTip(flag);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OPMapWidget::ruler_clicked(void)
|
||||
{
|
||||
if(isMeasure)
|
||||
@@ -208,6 +231,19 @@ void OPMapWidget::ruler_clicked(void)
|
||||
measureline->hide();
|
||||
|
||||
}
|
||||
|
||||
if(map)
|
||||
{
|
||||
map->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
if (w) {
|
||||
w->setAcceptDrops(true);
|
||||
w->setAcceptedMouseButtons(Qt::AllButtons);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -219,8 +255,21 @@ void OPMapWidget::ruler_clicked(void)
|
||||
measureline->show();
|
||||
}
|
||||
|
||||
//QPixmap pix(":/markers/images/ruler.png");
|
||||
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
|
||||
if(map)
|
||||
{
|
||||
map->setAcceptDrops(false);
|
||||
}
|
||||
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
if (w) {
|
||||
w->setAcceptDrops(false);
|
||||
w->setAcceptedMouseButtons(Qt::NoButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
emit measureState(isMeasure);
|
||||
@@ -244,178 +293,6 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::SetShowDiagnostics(bool const & value)
|
||||
@@ -929,13 +806,15 @@ void OPMapWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
emit MouseReleaseEvent(event);
|
||||
|
||||
if(isMeasure)
|
||||
{
|
||||
//QPixmap pix(":/markers/images/ruler.png");
|
||||
//this->setCursor(QCursor(pix.scaled(QSize(50,50), Qt::KeepAspectRatio)));
|
||||
}
|
||||
|
||||
//qDebug() << "relea";
|
||||
|
||||
if(event->button() == Qt::RightButton)
|
||||
{
|
||||
if(isMeasure)
|
||||
{
|
||||
ruler_clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
@@ -1684,10 +1563,13 @@ void OPMapWidget::userRipMap(bool start, qreal lat_l, qreal lng_l, qreal lat_r,
|
||||
connect(mapRipper,SIGNAL(ripfinished()),
|
||||
this,SIGNAL(ripfinished()));
|
||||
|
||||
emit showMessage(tr("start rip map"));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
emit cancelRequest();
|
||||
emit showMessage(tr("stop rip map"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1937,11 +1819,13 @@ void OPMapWidget::setWPCreate(bool const & value)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
waypointsetting->show();
|
||||
//waypointsetting->show();
|
||||
waypointsetting->setMode(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
waypointsetting->hide();
|
||||
//waypointsetting->hide();
|
||||
waypointsetting->setMode(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2240,24 +2124,40 @@ void OPMapWidget::delFence(int group)
|
||||
|
||||
//重新整理一下fenceCount
|
||||
|
||||
/*
|
||||
fenceCount = 0;
|
||||
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
w->setGroup(fenceCount++);
|
||||
if(w->Group() > group)
|
||||
{
|
||||
|
||||
int old = w->Group();
|
||||
w->setGroup(w->Group() - 1);
|
||||
int cur = w->Group();
|
||||
|
||||
emit FenceGroupChanged(old,cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
w->setGroup(fenceCount++);
|
||||
if(w->Group() > group)
|
||||
{
|
||||
int old = w->Group();
|
||||
w->setGroup(w->Group() - 1);
|
||||
int cur = w->Group();
|
||||
|
||||
emit FenceGroupChanged(old,cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
fenceCount --;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2268,8 +2168,6 @@ void OPMapWidget::delFence(int group)
|
||||
//先清除再读取
|
||||
void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
{
|
||||
//清除所有
|
||||
WPDeleteAll();//清除当前航线
|
||||
//fenceCount = 0;
|
||||
qDebug() << "WPLoad" << path;
|
||||
//读取
|
||||
@@ -2291,53 +2189,73 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
|
||||
//栅栏解码
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray();
|
||||
for(QJsonValue item: polygonsArray) {
|
||||
|
||||
//每个item是一个组
|
||||
QList<internals::PointLatLng> points;
|
||||
QList<QPointF> latlng;
|
||||
//获得边界
|
||||
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));
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
|
||||
latlng.push_back(QPointF(lat,lng));
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
emit showMessage(tr("Load Geo Fence File :%1").arg(path));
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
internals::PointLatLng center;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
center.SetLat(lat_sum/polygon.size());
|
||||
center.SetLng(lng_sum/polygon.size());
|
||||
fenceCount = 1;
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,version,center,QColor("#FF8000"),map);
|
||||
//栅栏解码
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray();
|
||||
for(QJsonValue item: polygonsArray) {
|
||||
|
||||
polyitem->setPoints(points);
|
||||
//每个item是一个组
|
||||
QList<internals::PointLatLng> points;
|
||||
QList<QPointF> latlng;
|
||||
//获得边界
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonArray polygon = item.toObject().value("polygon").toArray();
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
emit createFencePolygon(fenceCount++,points.size(),inclusion,latlng);
|
||||
qreal lat_sum = 0;
|
||||
qreal lng_sum = 0;
|
||||
|
||||
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
|
||||
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
|
||||
}
|
||||
for (QJsonValue point: polygon) {
|
||||
qreal lat = point.toArray().at(0).toDouble();
|
||||
qreal lng = point.toArray().at(1).toDouble();
|
||||
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
|
||||
for(QJsonValue item: circlesArray) {
|
||||
//生成一个多边形
|
||||
points.push_back(internals::PointLatLng(lat,lng));
|
||||
|
||||
lat_sum += lat;
|
||||
lng_sum += lng;
|
||||
|
||||
|
||||
latlng.push_back(QPointF(lat,lng));
|
||||
|
||||
}
|
||||
|
||||
internals::PointLatLng center;
|
||||
|
||||
center.SetLat(lat_sum/polygon.size());
|
||||
center.SetLng(lng_sum/polygon.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,version,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(points);
|
||||
|
||||
emit createFencePolygon(fenceCount++,points.size(),inclusion,latlng);
|
||||
|
||||
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
|
||||
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
|
||||
}
|
||||
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
|
||||
for(QJsonValue item: circlesArray) {
|
||||
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonObject circle = item.toObject().value("circle").toObject();
|
||||
@@ -2357,71 +2275,88 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
connect(c,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)),
|
||||
this,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(currentGroup >= 3)
|
||||
{
|
||||
|
||||
emit showMessage(tr("Load Mission File:Group %1,%2").arg(QString::number(currentGroup)).arg(path));
|
||||
//清除所有
|
||||
//删除一个组
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
|
||||
|
||||
//任务解码
|
||||
QJsonArray itemsArray = json.value("mission").toObject().value("items").toArray();
|
||||
|
||||
for(QJsonValue item: itemsArray) {
|
||||
if (!item.isObject()) {
|
||||
return;
|
||||
if (w) {
|
||||
if(w->MissionType() == currentGroup)
|
||||
{
|
||||
emit WPDeleted(w->Number(), w);
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t AMSLAltAboveTerrain = item.toObject().find("AMSLAltAboveTerrain").value().toInt();
|
||||
uint8_t Altitude = item.toObject().find("Altitude").value().toDouble();
|
||||
uint8_t AltitudeMode = item.toObject().find("AltitudeMode").value().toInt();
|
||||
uint8_t autocontinue = item.toObject().find("autoContinue").value().toBool()?(1):(0);//bool
|
||||
uint16_t command = item.toObject().find("command").value().toInt();
|
||||
uint16_t seq = item.toObject().find("doJumpId").value().toInt();
|
||||
uint8_t frame = item.toObject().find("frame").value().toInt();
|
||||
QJsonArray params = item.toObject().find("params").value().toArray();//array
|
||||
//uint8_t mission_type = item.toObject().find("type").value().toInt();
|
||||
uint8_t mission_type = currentGroup;
|
||||
//任务解码
|
||||
QJsonArray itemsArray = json.value("mission").toObject().value("items").toArray();
|
||||
|
||||
float param1 = params.at(0).toDouble();
|
||||
float param2 = params.at(1).toDouble();
|
||||
float param3 = params.at(2).toDouble();
|
||||
float param4 = params.at(3).toDouble();
|
||||
int32_t x = params.at(4).toDouble() * 10e6;
|
||||
int32_t y = params.at(5).toDouble() * 10e6;
|
||||
float z = params.at(6).toDouble();
|
||||
for(QJsonValue item: itemsArray) {
|
||||
if (!item.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
internals::PointLatLng LatLng;
|
||||
LatLng.SetLat(x * 10e-8);
|
||||
LatLng.SetLng(y * 10e-8);
|
||||
uint8_t AMSLAltAboveTerrain = item.toObject().find("AMSLAltAboveTerrain").value().toInt();
|
||||
uint8_t Altitude = item.toObject().find("Altitude").value().toDouble();
|
||||
uint8_t AltitudeMode = item.toObject().find("AltitudeMode").value().toInt();
|
||||
uint8_t autocontinue = item.toObject().find("autoContinue").value().toBool()?(1):(0);//bool
|
||||
uint16_t command = item.toObject().find("command").value().toInt();
|
||||
uint16_t seq = item.toObject().find("doJumpId").value().toInt();
|
||||
uint8_t frame = item.toObject().find("frame").value().toInt();
|
||||
QJsonArray params = item.toObject().find("params").value().toArray();//array
|
||||
//uint8_t mission_type = item.toObject().find("type").value().toInt();
|
||||
uint8_t mission_type = currentGroup;
|
||||
|
||||
qDebug() << "LatLng" << LatLng.Lat() << LatLng.Lng();
|
||||
float param1 = params.at(0).toDouble();
|
||||
float param2 = params.at(1).toDouble();
|
||||
float param3 = params.at(2).toDouble();
|
||||
float param4 = params.at(3).toDouble();
|
||||
int32_t x = params.at(4).toDouble() * 10e6;
|
||||
int32_t y = params.at(5).toDouble() * 10e6;
|
||||
float z = params.at(6).toDouble();
|
||||
|
||||
WayPointItem *Item = WPCreate(LatLng,z);
|
||||
internals::PointLatLng LatLng;
|
||||
LatLng.SetLat(x * 10e-8);
|
||||
LatLng.SetLng(y * 10e-8);
|
||||
|
||||
Item->SetNumber(seq);
|
||||
qDebug() << "LatLng" << LatLng.Lat() << LatLng.Lng();
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq,
|
||||
mission_type,//当前组
|
||||
command,
|
||||
0,
|
||||
0,
|
||||
frame,
|
||||
0,
|
||||
autocontinue,
|
||||
mission_type);
|
||||
WayPointItem *Item = WPCreate(LatLng,z);
|
||||
|
||||
Item->SetNumber(seq);
|
||||
|
||||
emit setWPProperty(param1,param2,param3,param4,
|
||||
x,y,z,
|
||||
seq,
|
||||
mission_type,//当前组
|
||||
command,
|
||||
0,
|
||||
0,
|
||||
frame,
|
||||
0,
|
||||
autocontinue,
|
||||
mission_type);
|
||||
|
||||
|
||||
Item->emitWPProperty();
|
||||
Item->emitWPProperty();
|
||||
|
||||
|
||||
|
||||
WayPointItem *w_last = WPFind(Item->MissionType(),Item->Number() - 1);
|
||||
WayPointItem *w_last = WPFind(Item->MissionType(),Item->Number() - 1);
|
||||
|
||||
if(w_last)
|
||||
{
|
||||
WPLineCreate(w_last,Item,Qt::green,false,2);
|
||||
if(w_last)
|
||||
{
|
||||
WPLineCreate(w_last,Item,Qt::green,false,2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2437,72 +2372,89 @@ void OPMapWidget::WPSave(QString path)//带文件目录参数
|
||||
QJsonObject rallyPoints;
|
||||
|
||||
|
||||
//geoFence节点写入 (mission type == 1,2)
|
||||
//判断围栏数量大于0时写入,否则不写
|
||||
|
||||
QJsonArray circles;
|
||||
QJsonArray polygons;
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
//geoFence节点写入 (mission type == 1,2)
|
||||
//判断围栏数量大于0时写入,否则不写
|
||||
|
||||
QJsonArray polygon;
|
||||
QJsonObject polygonObj;
|
||||
emit showMessage(tr("Save Fence File:%1").arg(path));
|
||||
|
||||
QList<internals::PointLatLng> points = w->points;
|
||||
QJsonArray circles;
|
||||
QJsonArray polygons;
|
||||
{
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
|
||||
for(internals::PointLatLng ll:points)
|
||||
{
|
||||
QJsonArray polygon;
|
||||
QJsonObject polygonObj;
|
||||
|
||||
QJsonArray latlng;
|
||||
latlng.append(ll.Lat());
|
||||
latlng.append(ll.Lng());
|
||||
QList<internals::PointLatLng> points = w->points;
|
||||
|
||||
polygon.push_back(latlng);
|
||||
for(internals::PointLatLng ll:points)
|
||||
{
|
||||
|
||||
QJsonArray latlng;
|
||||
latlng.append(ll.Lat());
|
||||
latlng.append(ll.Lng());
|
||||
|
||||
polygon.push_back(latlng);
|
||||
}
|
||||
|
||||
polygonObj["inclusion"] = w->Inclusion();
|
||||
polygonObj["polygon"] = polygon;
|
||||
polygonObj["version"] = 1;
|
||||
|
||||
|
||||
polygons.push_back(polygonObj);
|
||||
}
|
||||
}
|
||||
|
||||
polygonObj["inclusion"] = w->Inclusion();
|
||||
polygonObj["polygon"] = polygon;
|
||||
polygonObj["version"] = 1;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
QJsonObject circle;
|
||||
QJsonObject circleObj;
|
||||
|
||||
|
||||
polygons.push_back(polygonObj);
|
||||
QJsonArray center;
|
||||
center.append(w->Latitude());
|
||||
center.append(w->Longitude());
|
||||
|
||||
double radius = w->Radius();
|
||||
|
||||
circle["center"] = center;
|
||||
circle["radius"] = radius;
|
||||
|
||||
|
||||
circleObj["inclusion"] = w->Inclusion();
|
||||
circleObj["circle"] = circle;
|
||||
circleObj["version"] = 1;
|
||||
|
||||
|
||||
circles.push_back(circleObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
geoFence.insert("circles",circles);
|
||||
geoFence.insert("polygons",polygons);
|
||||
geoFence.insert("version",2);
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
QJsonObject circle;
|
||||
QJsonObject circleObj;
|
||||
|
||||
|
||||
QJsonArray center;
|
||||
center.append(w->Latitude());
|
||||
center.append(w->Longitude());
|
||||
|
||||
double radius = w->Radius();
|
||||
|
||||
circle["center"] = center;
|
||||
circle["radius"] = radius;
|
||||
|
||||
|
||||
circleObj["inclusion"] = w->Inclusion();
|
||||
circleObj["circle"] = circle;
|
||||
circleObj["version"] = 1;
|
||||
|
||||
|
||||
circles.push_back(circleObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
geoFence.insert("circles",circles);
|
||||
geoFence.insert("polygons",polygons);
|
||||
geoFence.insert("version",2);
|
||||
|
||||
//mission节点写入 (mission type == 3...)
|
||||
else if(currentGroup == 2)
|
||||
{
|
||||
//rallyPoints节点写入
|
||||
|
||||
QJsonArray points;
|
||||
rallyPoints.insert("points",points);
|
||||
rallyPoints.insert("version",2);
|
||||
|
||||
}
|
||||
else if(currentGroup >= 3)
|
||||
{
|
||||
emit showMessage(tr("Save Mission File:Group %1,%2").arg(QString::number(currentGroup)).arg(path));
|
||||
|
||||
|
||||
QJsonArray items;
|
||||
|
||||
QJsonArray plannedHomePosition;
|
||||
@@ -2574,12 +2526,7 @@ void OPMapWidget::WPSave(QString path)//带文件目录参数
|
||||
mission.insert("version",2);
|
||||
}
|
||||
|
||||
//rallyPoints节点写入
|
||||
{
|
||||
QJsonArray points;
|
||||
rallyPoints.insert("points",points);
|
||||
rallyPoints.insert("version",2);
|
||||
}
|
||||
|
||||
|
||||
//根节点写入
|
||||
root.insert("fileType","Plan");
|
||||
@@ -2616,7 +2563,7 @@ void OPMapWidget::WPDownload(void)
|
||||
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
fenceCount = 0;
|
||||
fenceCount = 1;
|
||||
}
|
||||
|
||||
int sysid = 0;
|
||||
@@ -2711,12 +2658,12 @@ void OPMapWidget::WPUpload(void)
|
||||
|
||||
if(FenceItemExit == false)
|
||||
{
|
||||
emit showMessage("请先载入围栏");
|
||||
emit showMessage(tr("please load fence first"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
emit showMessage(tr("开始上传围栏,总数%1").arg(FecneSeq));
|
||||
emit showMessage(tr("start upload fence,total:%1").arg(FecneSeq));
|
||||
|
||||
//选择当前ID号
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
@@ -2754,12 +2701,12 @@ void OPMapWidget::WPUpload(void)
|
||||
|
||||
if(list.size() <= 0)
|
||||
{
|
||||
emit showMessage("请先载入任务航线");
|
||||
emit showMessage(tr("please load mission first"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
emit showMessage(tr("开始上传航点,总数%1").arg(list.size()));
|
||||
emit showMessage(tr("start upload mission %1,total %2").arg(currentGroup).arg(list.size()));
|
||||
|
||||
//选择当前ID号
|
||||
|
||||
@@ -2879,8 +2826,6 @@ void OPMapWidget::WPGroup(int value)
|
||||
{
|
||||
currentGroup = value;
|
||||
|
||||
|
||||
|
||||
qDebug() << "group checkout" << value;
|
||||
|
||||
//切换当前航线,其他都隐藏,或者高亮当前
|
||||
@@ -2957,17 +2902,6 @@ void OPMapWidget::WPGroup(int value)
|
||||
|
||||
find_PointNumber(currentGroup);
|
||||
|
||||
/*
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
isWPCreate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isWPCreate = true;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
update();
|
||||
}
|
||||
@@ -2978,14 +2912,14 @@ void OPMapWidget::WPGroup(int value)
|
||||
if(flag == true)
|
||||
{
|
||||
QString str;
|
||||
str.append("上传航点");
|
||||
str.append("upload Mission");
|
||||
str.append(QString::number(seq));
|
||||
emit showMessage(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString str;
|
||||
str.append(tr("上传失败%1").arg(seq));
|
||||
str.append(tr("upload fail %1").arg(seq));
|
||||
emit showMessage(str);
|
||||
}
|
||||
|
||||
@@ -3007,27 +2941,14 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
|
||||
qDebug() << "receivers Point";
|
||||
|
||||
QString typestr;
|
||||
|
||||
switch (mission_type - 2) {
|
||||
case -1:
|
||||
{
|
||||
typestr = tr("fence");
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
typestr = QString::number(mission_type - 2);
|
||||
}break;
|
||||
}
|
||||
|
||||
emit showMessage(tr("recieve way point group:%1 seq:%2").arg(typestr).arg(seq + 1));
|
||||
|
||||
if((mission_type - 2) == -1)
|
||||
{
|
||||
qDebug() << command << seq << param1 << param2 << param3 << param4 << x << y;
|
||||
|
||||
if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION )
|
||||
{
|
||||
emit showMessage(tr("recieve fence polygon inclusion: %1").arg(seq + 1));
|
||||
|
||||
static int PolygonCount = 0;
|
||||
static QList<internals::PointLatLng> PolygonPoints;
|
||||
|
||||
@@ -3073,6 +2994,8 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION )
|
||||
{
|
||||
emit showMessage(tr("recieve fence polygon exclusion: %1").arg(seq + 1));
|
||||
|
||||
static int PolygonCount = 0;
|
||||
static QList<internals::PointLatLng> PolygonPoints;
|
||||
|
||||
@@ -3120,6 +3043,8 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION )
|
||||
{
|
||||
emit showMessage(tr("recieve fence circle inclusion: %1").arg(seq + 1));
|
||||
|
||||
bool inclusion = true;
|
||||
qreal radius = param1;
|
||||
|
||||
@@ -3131,6 +3056,8 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION )
|
||||
{
|
||||
emit showMessage(tr("recieve fence circle exclusion: %1").arg(seq + 1));
|
||||
|
||||
bool inclusion = false;
|
||||
qreal radius = param1;
|
||||
|
||||
@@ -3147,6 +3074,8 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
}
|
||||
else
|
||||
{
|
||||
emit showMessage(tr("recieve way point group:%1 seq:%2").arg(mission_type - 2).arg(seq + 1));
|
||||
|
||||
bool isExist = false;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
@@ -3242,8 +3171,6 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::getMapTypes(void)
|
||||
{
|
||||
emit MapTypes(Helper::MapTypes());
|
||||
@@ -3254,9 +3181,6 @@ void OPMapWidget::setMapTypes(QVariant value)
|
||||
this->SetMapType(Helper::MapTypeFromString(value.toString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::ElevationChanged(int seq,double value)
|
||||
{
|
||||
QMap<int,float> Info;
|
||||
|
||||
Reference in New Issue
Block a user