添加了围栏的删除功能
This commit is contained in:
+96
-47
@@ -20,23 +20,31 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
//围栏编辑
|
||||
CustomButton *btn_addCircle = new CustomButton(this);
|
||||
CustomButton *btn_addPolygon = new CustomButton(this);
|
||||
CustomButton *btn_deleteCircle = new CustomButton(this);
|
||||
CustomButton *btn_deletePolygon = new CustomButton(this);
|
||||
|
||||
btn_addCircle->setText(tr("addCircle"));
|
||||
btn_addPolygon->setText(tr("addPolygon"));
|
||||
btn_deleteCircle->setText(tr("delCircle"));
|
||||
btn_deletePolygon->setText(tr("delPolygon"));
|
||||
btn_addCircle->setText(tr("Circle"));
|
||||
btn_addPolygon->setText(tr("Polygon"));
|
||||
|
||||
btn_addCircle->setFixedSize(100,40);
|
||||
btn_addPolygon->setFixedSize(100,40);
|
||||
btn_deleteCircle->setFixedSize(100,40);
|
||||
btn_deletePolygon->setFixedSize(100,40);
|
||||
|
||||
btn_addCircle->hide();
|
||||
btn_addPolygon->hide();
|
||||
btn_deleteCircle->hide();
|
||||
btn_deletePolygon->hide();
|
||||
|
||||
|
||||
connect(btn_addCircle,&CustomButton::clicked,[=](){
|
||||
|
||||
emit addCircle();
|
||||
});
|
||||
|
||||
connect(btn_addPolygon,&CustomButton::clicked,[=](){
|
||||
|
||||
emit addPolygon();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//航线编辑
|
||||
CustomButton *btn_load = new CustomButton(this);
|
||||
@@ -78,9 +86,7 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
ui->gridLayout_btn->addWidget(btn_add, btn_Count++,0,1,1);
|
||||
|
||||
ui->gridLayout_btn->addWidget(btn_addCircle, btn_Count++,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_deleteCircle, btn_Count++,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_addPolygon, btn_Count++,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_deletePolygon, btn_Count++,0,1,1);
|
||||
|
||||
ui->gridLayout_btn->setRowStretch(btn_Count++,1);
|
||||
|
||||
@@ -134,9 +140,16 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
break;
|
||||
}
|
||||
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
for(int row = 0;row < widget->rowCount();row++)
|
||||
{
|
||||
widget->removeRow(0);
|
||||
}
|
||||
|
||||
for(int row = widget->rowCount() - 1;row >= 0; row--)
|
||||
{
|
||||
widget->removeRow(row);
|
||||
}
|
||||
|
||||
emit WPDownload();
|
||||
});
|
||||
|
||||
@@ -174,31 +187,57 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
if(tab_idx == 0)
|
||||
{
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
int row_id = widget->currentRow();
|
||||
if(row_id >= 0)
|
||||
{
|
||||
int group = widget->item(row_id,0)->data(Qt::DisplayRole).toInt();//得到group
|
||||
qDebug() << "group" << group << row_id;
|
||||
emit delFence(group);
|
||||
|
||||
|
||||
for(int row = 0;row < widget->rowCount();row++)
|
||||
{
|
||||
if(group == widget->item(row,0)->data(Qt::DisplayRole).toInt())
|
||||
widget->removeRow(row);
|
||||
}
|
||||
|
||||
for(int row = widget->rowCount() - 1;row >= 0; row--)
|
||||
{
|
||||
if(group == widget->item(row,0)->data(Qt::DisplayRole).toInt())
|
||||
widget->removeRow(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
int idx = widget->currentRow();
|
||||
widget->removeRow(idx);
|
||||
emit WPDelete();
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(tablelist.key(widget));
|
||||
}
|
||||
int idx = widget->currentRow();
|
||||
widget->removeRow(idx);
|
||||
emit WPDelete();
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(tablelist.key(widget));
|
||||
});
|
||||
|
||||
connect(btn_clean,&CustomButton::clicked,[=](){
|
||||
@@ -206,6 +245,7 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
@@ -225,16 +265,28 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
default:
|
||||
break;
|
||||
}
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
|
||||
for(int row = 0;row < widget->rowCount();row++)
|
||||
{
|
||||
widget->removeRow(0);
|
||||
}
|
||||
|
||||
for(int row = widget->rowCount() - 1;row >= 0; row--)
|
||||
{
|
||||
widget->removeRow(row);
|
||||
}
|
||||
|
||||
emit WPDeleteAll();
|
||||
|
||||
});
|
||||
|
||||
connect(btn_add,&CustomButton::clicked,[=](){
|
||||
emit WPAdd();
|
||||
int group = 3;
|
||||
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
emit WPAdd();
|
||||
int group = 3;
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
group = 1;
|
||||
@@ -255,6 +307,7 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
break;
|
||||
}
|
||||
emit getAllPoints(group);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -383,15 +436,13 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
{
|
||||
btn_addCircle->show();
|
||||
btn_addPolygon->show();
|
||||
btn_deleteCircle->show();
|
||||
btn_deletePolygon->show();
|
||||
|
||||
btn_load->hide();
|
||||
btn_save->hide();
|
||||
//btn_upload->hide();
|
||||
//btn_download->hide();
|
||||
btn_insert->hide();
|
||||
btn_delete->hide();
|
||||
//btn_delete->hide();
|
||||
btn_clean->hide();
|
||||
btn_add->hide();
|
||||
}
|
||||
@@ -399,15 +450,13 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
{
|
||||
btn_addCircle->hide();
|
||||
btn_addPolygon->hide();
|
||||
btn_deleteCircle->hide();
|
||||
btn_deletePolygon->hide();
|
||||
|
||||
btn_load->show();
|
||||
btn_save->show();
|
||||
//btn_upload->show();
|
||||
//btn_download->show();
|
||||
btn_insert->show();
|
||||
btn_delete->show();
|
||||
//btn_delete->show();
|
||||
btn_clean->show();
|
||||
btn_add->show();
|
||||
}
|
||||
|
||||
@@ -98,8 +98,9 @@ signals:
|
||||
void setFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng);
|
||||
|
||||
|
||||
|
||||
|
||||
void addCircle();
|
||||
void addPolygon();
|
||||
void delFence(int group);
|
||||
|
||||
private:
|
||||
Ui::MissionUI *ui;
|
||||
|
||||
@@ -181,6 +181,14 @@ propertyui::propertyui(QWidget *parent) :
|
||||
this,&propertyui::setFencePolygon);
|
||||
|
||||
|
||||
connect(table,&MissionUI::addCircle,
|
||||
this,&propertyui::addCircle);
|
||||
|
||||
connect(table,&MissionUI::addPolygon,
|
||||
this,&propertyui::addPolygon);
|
||||
|
||||
connect(table,&MissionUI::delFence,
|
||||
this,&propertyui::delFence);
|
||||
|
||||
//初始化参数
|
||||
setWayPointProperty(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3);
|
||||
|
||||
@@ -269,6 +269,10 @@ Q_SIGNALS:
|
||||
void setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
|
||||
void setFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng);
|
||||
|
||||
void addCircle();
|
||||
void addPolygon();
|
||||
void delFence(int group);
|
||||
|
||||
private slots:
|
||||
|
||||
void GroupChanged(int value);
|
||||
|
||||
@@ -440,6 +440,14 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(missionUI,SIGNAL(setFencePolygon(int,qreal,bool,QList<QPointF>)),
|
||||
map,SLOT(setFencePolygon(int,qreal,bool,QList<QPointF>)));
|
||||
|
||||
connect(missionUI,SIGNAL(addCircle()),
|
||||
map,SLOT(addCircle()));
|
||||
|
||||
connect(missionUI,SIGNAL(addPolygon()),
|
||||
map,SLOT(addPolygon()));
|
||||
|
||||
connect(missionUI,SIGNAL(delFence(int)),
|
||||
map,SLOT(delFence(int)));
|
||||
|
||||
//dlink ----- map
|
||||
connect(map,SIGNAL(signal_WPDownload(uint8_t,uint8_t,int)),
|
||||
@@ -470,6 +478,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(dlink->mavlinknode->Mission,SIGNAL(sendItemOK(uint16_t,bool)),
|
||||
map,SLOT(WPSendItemOK(uint16_t,bool)));
|
||||
|
||||
connect(map,SIGNAL(sendFence(qreal,qreal,qreal,qreal,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)),
|
||||
dlink->mavlinknode->Mission,SLOT(sendFence(qreal,qreal,qreal,qreal,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)),Qt::DirectConnection);
|
||||
|
||||
|
||||
//航点确认窗口
|
||||
connect(map,SIGNAL(setCurrent(int)),
|
||||
commandUI,SLOT(missionConfirm(int)));
|
||||
|
||||
@@ -88,6 +88,50 @@ void MissionProcess::SetCurrentPoint(int seq)
|
||||
}
|
||||
}
|
||||
|
||||
void MissionProcess::sendFence(qreal Vertex,
|
||||
qreal group,
|
||||
qreal Lat,
|
||||
qreal Lng,
|
||||
uint16_t FecneSeq,
|
||||
uint16_t command,
|
||||
uint16_t sysid,
|
||||
uint16_t compid,
|
||||
uint16_t mission_type)
|
||||
{
|
||||
|
||||
mapcontrol::WayPointItem::_property item;
|
||||
|
||||
qDebug() << Vertex
|
||||
<< group
|
||||
<< Lat
|
||||
<< Lng
|
||||
<< FecneSeq
|
||||
<< command
|
||||
<< sysid
|
||||
<< compid
|
||||
<< mission_type;
|
||||
|
||||
item.param1 = Vertex;
|
||||
item.param2 = group;
|
||||
item.param3 = 0;
|
||||
item.param4 = 0;
|
||||
item.x = Lat * 10e6;
|
||||
item.y = Lng * 10e6;
|
||||
item.z = 0;
|
||||
item.seq = FecneSeq;
|
||||
item.group = 0;
|
||||
item.command = command;
|
||||
item.target_system = sysid;
|
||||
item.target_component = compid;
|
||||
item.frame = 0;
|
||||
item.current = 0;
|
||||
item.autocontinue = 0;
|
||||
item.mission_type = mission_type;
|
||||
|
||||
items.insert(item.seq,item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MissionProcess::transmitPoint(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
|
||||
@@ -94,6 +94,15 @@ public slots:
|
||||
uint8_t autocontinue,
|
||||
uint8_t mission_type);
|
||||
|
||||
void sendFence(qreal Vertex,
|
||||
qreal group,
|
||||
qreal Lat,
|
||||
qreal Lng,
|
||||
uint16_t FecneSeq,
|
||||
uint16_t command,
|
||||
uint16_t sysid,
|
||||
uint16_t compid,
|
||||
uint16_t mission_type);
|
||||
|
||||
private slots:
|
||||
//线程私有接口
|
||||
@@ -182,6 +191,8 @@ private:
|
||||
|
||||
QMap<int,mapcontrol::WayPointItem::_property> items;
|
||||
|
||||
QMap<int,mapcontrol::WayPointItem::_property> FenceItems;
|
||||
|
||||
|
||||
};
|
||||
#endif // MISSIONPROCESS_H
|
||||
|
||||
@@ -66,10 +66,22 @@ void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
painter->setBrush(m_brush);
|
||||
}
|
||||
|
||||
|
||||
|
||||
painter->drawPoint(0, 0);
|
||||
//painter->drawEllipse(QPointF(0,0),line.length(),line.length());
|
||||
painter->drawEllipse(rectangle);
|
||||
|
||||
QFont font;
|
||||
font.setWeight(QFont::ExtraBold);
|
||||
font.setFamily("Arial");//非衬线
|
||||
font.setPixelSize(40);
|
||||
painter->setFont(font);
|
||||
|
||||
myPen.setWidth(lineWidth);
|
||||
myPen.setColor(QColor("#FFFFFF"));
|
||||
painter->setPen(myPen);
|
||||
painter->drawText(rectangle,Qt::AlignCenter,QString::number(m_group));
|
||||
|
||||
}
|
||||
|
||||
void geoFencecircle::refreshLocations()
|
||||
|
||||
@@ -52,6 +52,19 @@ void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
|
||||
painter->drawPoint(0, 0);
|
||||
painter->drawPolygon(polygon());
|
||||
|
||||
|
||||
QFont font;
|
||||
font.setWeight(QFont::ExtraBold);
|
||||
font.setFamily("Arial");//非衬线
|
||||
font.setPixelSize(40);
|
||||
painter->setFont(font);
|
||||
|
||||
myPen.setWidth(lineWidth);
|
||||
myPen.setColor(QColor("#FFFFFF"));
|
||||
painter->setPen(myPen);
|
||||
painter->drawText(boundingRect(),Qt::AlignCenter,QString::number(m_group));
|
||||
|
||||
}
|
||||
|
||||
int geoFenceitem::type() const
|
||||
|
||||
@@ -30,6 +30,11 @@ public:
|
||||
QList<internals::PointLatLng> points;
|
||||
|
||||
void setPoints(QList<internals::PointLatLng> p);
|
||||
QList<internals::PointLatLng> Points(void)
|
||||
{
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
int Group(void)
|
||||
{
|
||||
|
||||
+227
-37
@@ -1447,6 +1447,26 @@ void OPMapWidget::WPDeleteAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
bool OPMapWidget::WPPresent()
|
||||
{
|
||||
@@ -1529,9 +1549,6 @@ void OPMapWidget::ConnectWP(WayPointItem *item)
|
||||
connect(item,SIGNAL(SetCurrent(int)),
|
||||
this,SIGNAL(setCurrent(int)), Qt::DirectConnection);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(item,SIGNAL(ElevationChanged(int,double)),
|
||||
this,SLOT(ElevationChanged(int,double)), Qt::DirectConnection);
|
||||
|
||||
@@ -1786,9 +1803,6 @@ void OPMapWidget::WPSetCurrent(int seq)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OPMapWidget::WPsearchall(void)
|
||||
{
|
||||
//重新排序一下
|
||||
@@ -2062,12 +2076,96 @@ void OPMapWidget::setFencePolygon(int group,qreal vertex,bool inclusion,QList<QP
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::addCircle()
|
||||
{
|
||||
bool inclusion = true;
|
||||
int version = 1;
|
||||
|
||||
internals::PointLatLng center = GetFromLocalToLatLng(QPointF(this->pos().x() + this->width()/2,this->pos().y() + this->height()/2));
|
||||
|
||||
qreal lat = center.Lat();
|
||||
qreal lng = center.Lng();
|
||||
qreal radius = 10000;
|
||||
|
||||
//生成一个⚪
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,lat,lng);
|
||||
}
|
||||
|
||||
void OPMapWidget::addPolygon()
|
||||
{
|
||||
|
||||
//找到地图中心,做4个点
|
||||
bool inclusion = true;
|
||||
int version = 1;
|
||||
|
||||
internals::PointLatLng center = GetFromLocalToLatLng(QPointF(this->pos().x() + this->width()/2,this->pos().y() + this->height()/2));
|
||||
|
||||
QList<QPointF> latlng;
|
||||
QList<internals::PointLatLng> points;
|
||||
latlng.clear();
|
||||
points.clear();
|
||||
|
||||
|
||||
|
||||
qreal lat = center.Lat();
|
||||
qreal lng = center.Lng();
|
||||
|
||||
//生成一个多边形
|
||||
points.push_back(internals::PointLatLng(lat + 0.2,lng - 0.2));
|
||||
points.push_back(internals::PointLatLng(lat + 0.2,lng + 0.2));
|
||||
points.push_back(internals::PointLatLng(lat - 0.2,lng + 0.2));
|
||||
points.push_back(internals::PointLatLng(lat - 0.2,lng - 0.2));
|
||||
|
||||
latlng.push_back(QPointF(points.value(0).Lat(),points.value(0).Lng()));
|
||||
latlng.push_back(QPointF(points.value(1).Lat(),points.value(1).Lng()));
|
||||
latlng.push_back(QPointF(points.value(2).Lat(),points.value(2).Lng()));
|
||||
latlng.push_back(QPointF(points.value(3).Lat(),points.value(3).Lng()));
|
||||
|
||||
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,version,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(points);
|
||||
|
||||
emit createFencePolygon(fenceCount++,latlng.size(),inclusion,latlng);
|
||||
|
||||
}
|
||||
|
||||
void OPMapWidget::delFence(int group)
|
||||
{
|
||||
//找出编号为group的栅栏,删除
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
|
||||
if(w->Group() == group)
|
||||
{
|
||||
w->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
if(w->Group() == group)
|
||||
{
|
||||
w->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//先清除再读取
|
||||
void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
{
|
||||
//清除所有
|
||||
WPDeleteAll();//清除当前航线
|
||||
//fenceCount = 0;
|
||||
qDebug() << "WPLoad" << path;
|
||||
//读取
|
||||
QFile jsonFile(path);
|
||||
@@ -2089,27 +2187,6 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
QJsonObject json = doc.object();
|
||||
|
||||
//栅栏解码
|
||||
int fenceCount = 0;
|
||||
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();
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
QJsonArray center = circle.value("center").toArray();
|
||||
|
||||
qreal lat = center.at(0).toDouble();
|
||||
qreal lng = center.at(1).toDouble();
|
||||
qreal radius = circle.value("radius").toDouble();
|
||||
|
||||
|
||||
//生成一个⚪
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,lat,lng);
|
||||
|
||||
}
|
||||
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray();
|
||||
for(QJsonValue item: polygonsArray) {
|
||||
|
||||
@@ -2151,6 +2228,26 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
emit createFencePolygon(fenceCount++,points.size(),inclusion,latlng);
|
||||
}
|
||||
|
||||
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();
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
QJsonArray center = circle.value("center").toArray();
|
||||
|
||||
qreal lat = center.at(0).toDouble();
|
||||
qreal lng = center.at(1).toDouble();
|
||||
qreal radius = circle.value("radius").toDouble();
|
||||
|
||||
|
||||
//生成一个⚪
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,version,internals::PointLatLng(lat,lng),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(fenceCount++,radius,inclusion,lat,lng);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//任务解码
|
||||
@@ -2362,6 +2459,11 @@ void OPMapWidget::WPDownload(void)
|
||||
|
||||
WPDeleteAll();
|
||||
|
||||
if(currentGroup == 1)
|
||||
{
|
||||
//fenceCount = 0;
|
||||
}
|
||||
|
||||
int sysid = 0;
|
||||
int compid = 0;
|
||||
|
||||
@@ -2383,7 +2485,98 @@ void OPMapWidget::WPUpload(void)
|
||||
{
|
||||
if(currentGroup == 1)//这是栅栏
|
||||
{
|
||||
int sysid = 0;
|
||||
int compid = 0;
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
if(u->Select() == true)
|
||||
{
|
||||
sysid = u->SysID();
|
||||
compid = u->CompID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int FecneSeq = 0;
|
||||
|
||||
//查找所有的子类
|
||||
bool FenceItemExit = false;
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
|
||||
if (w) {
|
||||
FenceItemExit = true;
|
||||
|
||||
QList<internals::PointLatLng> latlng = w->Points();
|
||||
bool inclusion = w->Inclusion();
|
||||
qreal Vertex = w->Vertex();
|
||||
qreal group = w->Group();
|
||||
|
||||
for(internals::PointLatLng p:latlng)
|
||||
{
|
||||
emit sendFence(Vertex,
|
||||
group,
|
||||
p.Lat(),
|
||||
p.Lng(),
|
||||
FecneSeq++,
|
||||
(inclusion)?(MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION):(MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION) ,
|
||||
sysid,
|
||||
compid,
|
||||
1);
|
||||
|
||||
qDebug() << "send fence to thread";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
|
||||
if (w) {
|
||||
FenceItemExit = true;
|
||||
|
||||
internals::PointLatLng p = w->coord;
|
||||
bool inclusion = w->Inclusion();
|
||||
qreal Vertex = w->Radius();
|
||||
qreal group = w->Group();
|
||||
|
||||
emit sendFence(Vertex,
|
||||
group,
|
||||
p.Lat(),
|
||||
p.Lng(),
|
||||
FecneSeq++,
|
||||
(inclusion)?(MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION ):(MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION ),
|
||||
sysid,
|
||||
compid,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(FenceItemExit == false)
|
||||
{
|
||||
emit showMessage("请先载入围栏");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
emit showMessage(tr("开始上传围栏,总数%1").arg(FecneSeq));
|
||||
|
||||
//选择当前ID号
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
if(u->Select() == true)
|
||||
{
|
||||
sysid = u->SysID();
|
||||
compid = u->CompID();
|
||||
|
||||
//如果有选中,那么就发送,选中几个就发几个
|
||||
emit signal_WPUpload(sysid,compid,FecneSeq,1);//直接发送全部围栏到
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2520,7 +2713,6 @@ void OPMapWidget::groupchanged(int value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2665,7 +2857,7 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
|
||||
if((mission_type - 2) == -1)
|
||||
{
|
||||
qDebug() << command << param1 << param2 << param3 << param4 << x << y;
|
||||
qDebug() << command << seq << param1 << param2 << param3 << param4 << x << y;
|
||||
|
||||
if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION )
|
||||
{
|
||||
@@ -2675,10 +2867,8 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
PolygonCount ++;
|
||||
bool inclusion = true;
|
||||
|
||||
|
||||
PolygonPoints.push_back(internals::PointLatLng(x * 10e-8,y * 10e-8));
|
||||
|
||||
|
||||
if(PolygonCount >= param1)
|
||||
{
|
||||
|
||||
@@ -2701,11 +2891,11 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
center.SetLat(lat_sum/latlng.size());
|
||||
center.SetLng(lng_sum/latlng.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(PolygonCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(PolygonPoints);
|
||||
|
||||
emit createFencePolygon(PolygonCount,PolygonPoints.size(),inclusion,latlng);
|
||||
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
|
||||
|
||||
PolygonCount = 0;
|
||||
PolygonPoints.clear();
|
||||
@@ -2745,11 +2935,11 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
center.SetLat(lat_sum/latlng.size());
|
||||
center.SetLng(lng_sum/latlng.size());
|
||||
|
||||
geoFenceitem *polyitem = new geoFenceitem(PolygonCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
|
||||
|
||||
polyitem->setPoints(PolygonPoints);
|
||||
|
||||
emit createFencePolygon(PolygonCount,PolygonPoints.size(),inclusion,latlng);
|
||||
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
|
||||
|
||||
PolygonCount = 0;
|
||||
PolygonPoints.clear();
|
||||
@@ -2760,7 +2950,7 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
bool inclusion = true;
|
||||
qreal radius = param1;
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(1,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount++,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(0,radius,inclusion,x * 10e-8,y * 10e-8);
|
||||
|
||||
}
|
||||
@@ -2769,7 +2959,7 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
bool inclusion = false;
|
||||
qreal radius = param1;
|
||||
|
||||
geoFencecircle *c = new geoFencecircle(1,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
geoFencecircle *c = new geoFencecircle(fenceCount++,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
|
||||
emit createFenceCircle(0,radius,inclusion,x * 10e-8,y * 10e-8);
|
||||
}
|
||||
else if(command == MAV_CMD_NAV_RALLY_POINT )
|
||||
|
||||
@@ -513,6 +513,7 @@ private:
|
||||
|
||||
bool isShowTip = false;
|
||||
|
||||
int fenceCount = 0;
|
||||
|
||||
private slots:
|
||||
void diagRefresh();
|
||||
@@ -622,6 +623,7 @@ signals:
|
||||
void signal_WPDownload(uint8_t m_sysid, uint8_t m_compid,int missiontype);
|
||||
void signal_WPUpload(uint8_t m_sysid, uint8_t m_compid, uint32_t count,int missiontype);
|
||||
|
||||
void signal_FenceUpload(uint8_t m_sysid, uint8_t m_compid, uint32_t count,int missiontype);
|
||||
|
||||
void transmitPoint(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
@@ -649,6 +651,18 @@ signals:
|
||||
void createFenceCircle(int group,qreal radius,bool inclusion,qreal lat,qreal lng);
|
||||
void createFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng);
|
||||
|
||||
void sendFence(qreal Vertex,
|
||||
qreal group,
|
||||
qreal Lat,
|
||||
qreal Lng,
|
||||
uint16_t FecneSeq,
|
||||
uint16_t command,
|
||||
uint16_t sysid,
|
||||
uint16_t compid,
|
||||
uint16_t currentGroup);
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -736,6 +750,12 @@ public slots:
|
||||
void setFenceCircle(int group,qreal radius, bool inclusion, qreal lat, qreal lng);
|
||||
void setFencePolygon(int group,qreal vertex,bool inclusion,QList<QPointF> latlng);
|
||||
|
||||
void addCircle();
|
||||
void addPolygon();
|
||||
void delFence(int group);
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
#endif // OPMAPWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user