多航线可以上下传和修改,目前采用每次切换都要下载的方式

This commit is contained in:
hm
2022-04-10 12:04:50 +08:00
parent a96c7d143e
commit 3f84a2441f
11 changed files with 193 additions and 42 deletions
+103 -19
View File
@@ -804,6 +804,7 @@ WayPointItem *OPMapWidget::WPCreate()
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
int position = item->Number();
emit WPCreated(position, item);
return item;
@@ -814,12 +815,14 @@ WayPointItem *OPMapWidget::magicWPCreate()
item->SetShowNumber(false);
item->setParentItem(map);
item->SetMissionType(currentGroup);
return item;
}
void OPMapWidget::WPCreate(WayPointItem *item)
{
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
int position = item->Number();
emit WPCreated(position, item);
setOverlayOpacity(overlayOpacity);
@@ -830,6 +833,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
int position = item->Number();
emit WPCreated(position, item);
setOverlayOpacity(overlayOpacity);
@@ -841,6 +845,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
int position = item->Number();
emit WPCreated(position, item);
setOverlayOpacity(overlayOpacity);
@@ -852,6 +857,7 @@ WayPointItem *OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, co
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
int position = item->Number();
emit WPCreated(position, item);
setOverlayOpacity(overlayOpacity);
@@ -917,6 +923,7 @@ void OPMapWidget::WPInsert()
ConnectWP(item);
item->SetNumber(position);
item->setParentItem(map);
item->SetMissionType(currentGroup);
setOverlayOpacity(overlayOpacity);
setSelectedWP(item);
@@ -988,6 +995,7 @@ void OPMapWidget::WPInsert(WayPointItem *item, const int &position)
item->SetNumber(position);
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
emit WPInserted(position, item);
setOverlayOpacity(overlayOpacity);
}
@@ -998,6 +1006,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co
item->SetNumber(position);
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
emit WPInserted(position, item);
setOverlayOpacity(overlayOpacity);
return item;
@@ -1017,6 +1026,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co
item->SetNumber(position);
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
emit WPInserted(position, item);
if (reloc) {
emit WPValuesChanged(item);
@@ -1031,6 +1041,7 @@ WayPointItem *OPMapWidget::WPInsert(distBearingAltitude const & relative, QStrin
item->SetNumber(position);
ConnectWP(item);
item->setParentItem(map);
item->SetMissionType(currentGroup);
emit WPInserted(position, item);
setOverlayOpacity(overlayOpacity);
return item;
@@ -2000,23 +2011,6 @@ void OPMapWidget::WPUpload(void)
}
}
/*
foreach(QGraphicsItem * i, map->childItems()) {
WayPointLine *l = qgraphicsitem_cast<WayPointLine *>(i);
if (l) {
l->setVisible(false);
}
}
*/
//qDebug() << "WPUpload" << list.size();
if(list.size() <= 0)
{
emit showMessage("请先载入任务航线");
@@ -2046,17 +2040,107 @@ void OPMapWidget::WPUpload(void)
}
}
void OPMapWidget::groupchanged(int value)
{
//如果当前是在飞行界面,那么就下载,否则不动
if(isWPCreate == true)//编辑界面
{
}
else//飞行界面
{
WPDeleteAll();
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();
emit signal_WPDownload(sysid,compid,value);
}
}
}
}
update();
}
void OPMapWidget::WPGroup(int value)
{
currentGroup = value;
qDebug() << "group" << value;
qDebug() << "group checkout" << value;
//切换当前航线,显示当前航线,其他都隐藏,或者高亮当前
//切换当前航线,其他都隐藏,或者高亮当前
/*
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) {
if(w->MissionType() != currentGroup)
{
w->setVisible(false);
}
else
{
w->setVisible(true);
}
}
}
foreach(QGraphicsItem * i, map->childItems()) {
WayPointLine *l = qgraphicsitem_cast<WayPointLine *>(i);
if (l) {
if(l->MissionType() != currentGroup)
{
l->setVisible(false);
}
}
}
*/
//按照当前的组生成新的航点和航线
/*
WPDeleteAll();
QMap<int,WayPointItem *> group;
group = waypointgroups.value(currentGroup);
*/
WPDeleteAll();
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();
emit signal_WPDownload(sysid,compid,currentGroup);
}
}
}
update();
}
+6 -1
View File
@@ -397,6 +397,8 @@ public:
int currentGroup = 0;//编辑情况
int currentMissionType = 0;
QMap<int,QMap<int,WayPointItem *>> waypointgroups;//group index point
void SetShowUAV(bool const & value);
bool ShowUAV() const
@@ -459,7 +461,7 @@ public:
}
QMap<int,WayPointItem *> waypointgroups;
private:
internals::Core *core;
@@ -630,6 +632,9 @@ signals:
public slots:
void groupchanged(int value);
void find_PointNumber();
void updateMessage(void);
+2 -2
View File
@@ -774,14 +774,14 @@ void WayPointItem::SetDefault(double lat,double lng,float alt,uint16_t seq)
property.y = lng * 10e6;
property.z = alt;
property.seq = seq;
property.group = 0;
property.group = 3;
property.command = MAV_CMD::MAV_CMD_NAV_WAYPOINT;
property.target_system = 0;
property.target_component = 0;
property.frame = MAV_FRAME::MAV_FRAME_GLOBAL;
property.current = 0;
property.autocontinue = true;
property.mission_type = 0;
property.mission_type = 3;
if(property.command > MAV_CMD::MAV_CMD_NAV_LAST)
{