添加读取所有航点功能

This commit is contained in:
hm
2022-05-06 17:53:06 +08:00
parent e5a843d8ab
commit 4176bde466
7 changed files with 142 additions and 51 deletions
+69 -39
View File
@@ -921,6 +921,7 @@ int OPMapWidget::getWaypointSize(int group)
void OPMapWidget::WPInsert()
{
bool isExist = false;
//获取位置和组号
int position = 0;
int group = 3;
@@ -930,12 +931,23 @@ void OPMapWidget::WPInsert()
if (w) {
if (w->isSelected()) {
position = w->Number();
group = w->MissionType();
if(currentGroup == w->MissionType())
{
position = w->Number();
group = w->MissionType();
isExist = true;
break;
}
}
}
}
if(isExist == false)//没有选中的点
{
return;
}
//刷新全部连线,目前连线很乱
internals::PointLatLng latlng;
@@ -1125,52 +1137,43 @@ void OPMapWidget::WPDelete(void)
int number = 0;
int group = 3;
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) {
if (w->isSelected()) {
if (w) {
if (w->isSelected()) {
number = w->Number();
group = w->MissionType();
emit WPDeleted(w->Number(), w);//这个会修改编号
delete w;
}
number = w->Number();
group = w->MissionType();
emit WPDeleted(w->Number(), w);//这个会修改编号
delete w;
}
}
}
//当前选中为上一点
WayPointItem *item = WPFind(group,number -1);
if(item)
{
setSelectedWP(item);
item->emitWPProperty();
//当前选中为上一点
WayPointItem *item = WPFind(group,number -1);
if(item)
{
setSelectedWP(item);
item->emitWPProperty();
WayPointItem *item_next = WPFind(group,number);
if (item_next) {
WPLineCreate(item,item_next,Qt::green,false,2);
}
}
else
{
WayPointItem *ww = WPFind(group,number);
if(ww)
{
setSelectedWP(ww);
ww->emitWPProperty();
}
WayPointItem *item_next = WPFind(group,number);
if (item_next) {
WPLineCreate(item,item_next,Qt::green,false,2);
}
/*
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) {
WPFollowPrevious(w->FollowPrevious(),w);
}
}
*/
}
else
{
WayPointItem *ww = WPFind(group,number);
if(ww)
{
setSelectedWP(ww);
ww->emitWPProperty();
}
}
}
WayPointItem *OPMapWidget::WPFind(int group,int number)
@@ -2532,5 +2535,32 @@ void OPMapWidget::find_PointNumber()
emit PointNumber(nums);
}
void OPMapWidget::getAllPoints(int group)
{
QMap<int,WayPointItem *> points;
points.clear();
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w)
{
if(w->MissionType() == group)
{
points.insert(w->Number(),w);
}
}
}
QMapIterator<int,WayPointItem *> iter(points);
while (iter.hasNext()) {
iter.next();
WayPointItem *Item = iter.value();
Item->emitWPProperty();
}
}
}