From b8a8697a4d09d56dea7ed19e46a058ccc21b9b9e Mon Sep 17 00:00:00 2001 From: hm Date: Mon, 9 May 2022 17:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9C=B0=E5=9B=BE=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/MissionUI/MissionUI.cpp | 34 +++++++++++- App/MissionUI/MissionUI.h | 2 + App/mainwindow.cpp | 6 +-- opmap/MAP_zh_CN.qm | Bin 833 -> 1619 bytes opmap/MAP_zh_CN.ts | 84 ++++++++++++++++++++++++++++-- opmap/mapwidget/measureline.cpp | 2 +- opmap/mapwidget/measureline.h | 2 +- opmap/mapwidget/opmapwidget.cpp | 65 ++++++++++++++++++----- opmap/mapwidget/opmapwidget.h | 2 + opmap/mapwidget/trailitem.cpp | 2 + opmap/mapwidget/traillineitem.cpp | 2 +- opmap/mapwidget/waypointitem.cpp | 75 +++++++++++++++++++++----- 12 files changed, 240 insertions(+), 36 deletions(-) diff --git a/App/MissionUI/MissionUI.cpp b/App/MissionUI/MissionUI.cpp index 5b59a90..5b56daf 100644 --- a/App/MissionUI/MissionUI.cpp +++ b/App/MissionUI/MissionUI.cpp @@ -273,6 +273,37 @@ void MissionUI::settableGroup(int group) ui->tabWidget->setCurrentIndex(index); } +void MissionUI::on_tabWidget_tabBarClicked(int index) +{ + int group = 3; + + switch (index) { + case 0: + group = 1; + break; + case 1: + group = 3; + break; + case 2: + group = 4; + break; + case 3: + group = 5; + break; + case 4: + group = 6; + break; + default: + break; + } + + QTableWidget *widget = tablelist.value(group); + int idx = widget->currentRow() + 1; + + qDebug() << "tabWidget_currentChanged" << group << idx; + + emit waypointSelect(group,idx); +} void MissionUI::on_tabWidget_currentChanged(int index) @@ -304,7 +335,7 @@ void MissionUI::on_tabWidget_currentChanged(int index) qDebug() << "tabWidget_currentChanged" << group << idx; - emit waypointSelect(group,idx); + //emit waypointSelect(group,idx); } void MissionUI::on_pushButton_load_clicked() @@ -754,3 +785,4 @@ void MissionUI::itemDoubleClicked(QTableWidgetItem *item) } + diff --git a/App/MissionUI/MissionUI.h b/App/MissionUI/MissionUI.h index e463ff7..8f01e33 100644 --- a/App/MissionUI/MissionUI.h +++ b/App/MissionUI/MissionUI.h @@ -66,6 +66,8 @@ private slots: + void on_tabWidget_tabBarClicked(int index); + signals: void setCommand(QVariant value); diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index bfcd690..dbedb05 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -1061,9 +1061,9 @@ void MainWindow::updateUI()//事件驱动式更新数据 } - QElapsedTimer ElapsedTimer; + //QElapsedTimer ElapsedTimer; - ElapsedTimer.start(); + //ElapsedTimer.start(); copk->setAttitude(dlink->mavlinknode->vehicle.attitude.pitch * 57.3, @@ -2434,7 +2434,7 @@ void MainWindow::updateUI()//事件驱动式更新数据 toolsui->senser->setDAS(2,8,QString::number(dlink->mavlinknode->vehicle.scaled_pressure.press_abs,'f',3)); - qDebug() << "nsecsElapsed" << ElapsedTimer.nsecsElapsed(); + //qDebug() << "nsecsElapsed" << ElapsedTimer.nsecsElapsed(); } diff --git a/opmap/MAP_zh_CN.qm b/opmap/MAP_zh_CN.qm index 4015c8cff38911a918f04685dc4c12eb8c22fc73..b88cb57d3248d7e51892f212447a221756955d6a 100644 GIT binary patch delta 553 zcmX@ec9~~_Nc|251_mw$21Wq}hG-y@)r)~4b`_9+je%{36$1kk4?|R?Do|XIA)2`h zsNgn3eiBd(lQTo@iD0{B0aE(FzO<%&8pS%o~9G zYK}E`zXRnbbDTa|02J5etkPe^z+lhlz}a_H7-(TH=eN@VKn0h$xHeY-En39Q{b?7F z&g2OS;{s|}0HhxP>3h6&3X_2144FVzHEt{tVdP_C;Nk#@umLe6*W`_iN|W0dr-`t| zzYcasl41_40!xarb!1GCN0MMkPAmq?h_U(KO=d)rVa>?TNdZeqvQ6`Cv1L$zTf~u* zn3s~7m#zS^Pm&|BIA}r8Y$UC0`Dtm6PGG$f9PtcjvaI=eFiE!lD@|HR2D2BXmXsFd zLCj_AEuV1@Ns^-^F*_A#GFVoID_yJnX)?Rt6C``tOY^ex^2@;%Llo3hhj$|x0aXAt dL5i(Ot6(RRBxiYIWkG&sUI|!wvka3eBLGU9c1r*N delta 114 zcmcc2bC7Le1JewKs7h5J9nTQW+yxZ4&AemHRR#veWgKhneh1PIIji&+ z0ciowzN5lGI+pX>=>VX51um}5RY3KNxVb;=0@9hhbqbS!G(#p(^8Ch2B8-#8n5J#k IV^w7Y0G=itHvj+t diff --git a/opmap/MAP_zh_CN.ts b/opmap/MAP_zh_CN.ts index 842c733..e04b4c6 100644 --- a/opmap/MAP_zh_CN.ts +++ b/opmap/MAP_zh_CN.ts @@ -83,17 +83,17 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic - + 开始上传航点,总数%1 - + 上传失败%1 - + recieve way point group:%1 seq:%2 收到航点:第%1组,第%2点 @@ -119,12 +119,86 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic mapcontrol::WayPointItem - + + waypoint + 航点 + + + + return + 返航 + + + + landing + 降落 + + + + takeoff + 起飞 + + + + unknow + 未知类型 + + + + hold + + 保持 + + + + + cas + + 表速 + + + + + Vz + + 快升 + + + + + onAB + + 开加力 + + + + + offAB + + 关加力 + + + + + unknow + + 未知指令 + + + + + + + + + + + Speed: %1m/s 速度:%1m/s - + Height: %1m %2 高度:%1m diff --git a/opmap/mapwidget/measureline.cpp b/opmap/mapwidget/measureline.cpp index 9c38f12..d69bc18 100644 --- a/opmap/mapwidget/measureline.cpp +++ b/opmap/mapwidget/measureline.cpp @@ -42,7 +42,7 @@ MeasureLine::MeasureLine(internals::PointLatLng from, internals::PointLatLng to, //connect(to, SIGNAL(aboutToBeDeleted(WayPointItem *)), this, SLOT(waypointdeleted())); - this->setZValue(5); + this->setZValue(7); connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal))); diff --git a/opmap/mapwidget/measureline.h b/opmap/mapwidget/measureline.h index 7465203..85c841c 100644 --- a/opmap/mapwidget/measureline.h +++ b/opmap/mapwidget/measureline.h @@ -48,7 +48,7 @@ class MeasureLine : public QObject, public QGraphicsLineItem { Q_OBJECT Q_INTERFACES(QGraphicsItem) public: - enum { Type = UserType + 8 }; + enum { Type = UserType + 10 }; MeasureLine(internals::PointLatLng from, internals::PointLatLng to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1); int type() const; QPainterPath shape() const; diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index 76f947e..f222344 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -842,6 +842,7 @@ WayPointItem *OPMapWidget::WPCreate() emit WPCreated(position, item); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); return item; } WayPointItem *OPMapWidget::magicWPCreate() @@ -856,6 +857,7 @@ WayPointItem *OPMapWidget::magicWPCreate() item->SetMissionType(currentGroup); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); return item; } void OPMapWidget::WPCreate(WayPointItem *item) @@ -868,6 +870,7 @@ void OPMapWidget::WPCreate(WayPointItem *item) setOverlayOpacity(overlayOpacity); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); } WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int const & altitude) { @@ -884,6 +887,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co setOverlayOpacity(overlayOpacity); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); return item; } WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int const & altitude, QString const & description) @@ -901,6 +905,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co setOverlayOpacity(overlayOpacity); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); return item; } WayPointItem *OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, const QString &description) @@ -918,6 +923,7 @@ WayPointItem *OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, co setOverlayOpacity(overlayOpacity); setSelectedWP(item); item->emitWPProperty(); + item->setisShowTip(isShowTip); return item; } @@ -1009,6 +1015,7 @@ void OPMapWidget::WPInsert() setSelectedWP(item); item->emitWPProperty();//这个没有执行 + item->setisShowTip(isShowTip); //调整编号 foreach(QGraphicsItem * i, map->childItems()) { @@ -1060,6 +1067,7 @@ void OPMapWidget::WPInsert(WayPointItem *item, const int &position) item->SetMissionType(currentGroup); emit WPInserted(position, item); setOverlayOpacity(overlayOpacity); + item->setisShowTip(isShowTip); } WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int const & altitude, const int &position) { @@ -1071,6 +1079,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co item->SetMissionType(currentGroup); emit WPInserted(position, item); setOverlayOpacity(overlayOpacity); + item->setisShowTip(isShowTip); return item; } WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int const & altitude, QString const & description, const int &position) @@ -1094,6 +1103,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co emit WPValuesChanged(item); } setOverlayOpacity(overlayOpacity); + item->setisShowTip(isShowTip); return item; } WayPointItem *OPMapWidget::WPInsert(distBearingAltitude const & relative, QString const & description, const int &position) @@ -1106,6 +1116,7 @@ WayPointItem *OPMapWidget::WPInsert(distBearingAltitude const & relative, QStrin item->SetMissionType(currentGroup); emit WPInserted(position, item); setOverlayOpacity(overlayOpacity); + item->setisShowTip(isShowTip); return item; } @@ -2175,12 +2186,11 @@ void OPMapWidget::groupchanged(int value) //一下这里判断有问题,有bug - /* + //将不是当前的全部变成灰色,当前的显示 foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) { - qDebug() << "missiontype" << w->MissionType(); if(w->MissionType() == currentMissionType) { w->setisActive(true); @@ -2197,8 +2207,22 @@ void OPMapWidget::groupchanged(int value) WayPointLine *l = qgraphicsitem_cast(i); if (l) { - WayPointItem *from = qgraphicsitem_cast(l->WPLineFrom()); - WayPointItem *to = qgraphicsitem_cast(l->WPLineTo()); + WayPointItem *from = nullptr; + WayPointItem *to = nullptr; + + QGraphicsItem *_f = l->WPLineFrom(); + QGraphicsItem *_t = l->WPLineTo(); + + if(_f) + { + from = qgraphicsitem_cast(_f); + } + + if(_t) + { + to = qgraphicsitem_cast(_t); + } + if((from)||(to)) { @@ -2215,7 +2239,7 @@ void OPMapWidget::groupchanged(int value) } else if(to) { - if(from->MissionType() == currentMissionType) + if(to->MissionType() == currentMissionType) { l->setisActive(true); } @@ -2226,12 +2250,12 @@ void OPMapWidget::groupchanged(int value) } else//不知道这句对不对 { - l->setisActive(false); + //l->setisActive(false); } } } } - */ + } @@ -2253,7 +2277,6 @@ void OPMapWidget::WPGroup(int value) foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) { - qDebug() << "missiontype" << w->MissionType(); if(w->MissionType() == currentGroup) { w->setisActive(true); @@ -2270,8 +2293,21 @@ void OPMapWidget::WPGroup(int value) WayPointLine *l = qgraphicsitem_cast(i); if (l) { - WayPointItem *from = qgraphicsitem_cast(l->WPLineFrom()); - WayPointItem *to = qgraphicsitem_cast(l->WPLineTo()); + WayPointItem *from = nullptr; + WayPointItem *to = nullptr; + + QGraphicsItem *_f = l->WPLineFrom(); + QGraphicsItem *_t = l->WPLineTo(); + + if(_f) + { + from = qgraphicsitem_cast(_f); + } + + if(_t) + { + to = qgraphicsitem_cast(_t); + } if((from)||(to)) { @@ -2288,7 +2324,7 @@ void OPMapWidget::WPGroup(int value) } else if(to) { - if(from->MissionType() == currentGroup) + if(to->MissionType() == currentGroup) { l->setisActive(true); } @@ -2299,7 +2335,7 @@ void OPMapWidget::WPGroup(int value) } else//不知道这句对不对 { - l->setisActive(false); + //l->setisActive(false); } } } @@ -2429,6 +2465,7 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par Item->emitWPProperty(); + Item->setisShowTip(isShowTip); qDebug() << "waypoint not exist:" << Item->Number() << seq+1 <childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) @@ -2598,6 +2637,8 @@ void OPMapWidget::WPShowTip(bool flag) w->setisShowTip(flag); } } + + update(); } diff --git a/opmap/mapwidget/opmapwidget.h b/opmap/mapwidget/opmapwidget.h index d84f8aa..4e54be6 100644 --- a/opmap/mapwidget/opmapwidget.h +++ b/opmap/mapwidget/opmapwidget.h @@ -506,6 +506,8 @@ private: int measurenumber = 1; + bool isShowTip = false; + private slots: void diagRefresh(); diff --git a/opmap/mapwidget/trailitem.cpp b/opmap/mapwidget/trailitem.cpp index 2b7857a..5f2f9b1 100644 --- a/opmap/mapwidget/trailitem.cpp +++ b/opmap/mapwidget/trailitem.cpp @@ -33,6 +33,8 @@ TrailItem::TrailItem(internals::PointLatLng const & coord, int const & altitude, QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6); setToolTip(QString(tr("Position:") + "%1\n" + tr("Altitude:") + "%2\n" + tr("Time:") + "%3").arg(coord_str).arg(QString::number(altitude)).arg(time.toString())); + this->setZValue(3); + } void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) diff --git a/opmap/mapwidget/traillineitem.cpp b/opmap/mapwidget/traillineitem.cpp index 6cfd3fb..c7d7018 100644 --- a/opmap/mapwidget/traillineitem.cpp +++ b/opmap/mapwidget/traillineitem.cpp @@ -35,7 +35,7 @@ TrailLineItem::TrailLineItem(internals::PointLatLng const & coord1, internals::P pen.setWidth(2); this->setPen(pen); - + this->setZValue(3); } diff --git a/opmap/mapwidget/waypointitem.cpp b/opmap/mapwidget/waypointitem.cpp index a093c50..c7567d8 100644 --- a/opmap/mapwidget/waypointitem.cpp +++ b/opmap/mapwidget/waypointitem.cpp @@ -70,7 +70,7 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos())); connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal))); - this->setZValue(3); + this->setZValue(5); } @@ -118,7 +118,7 @@ WayPointItem::WayPointItem(int seq,int missiontype, MapGraphicItem *map, bool ma connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos())); connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal))); - this->setZValue(3); + this->setZValue(5); } WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude,int seq, int missiontype, const QString &description, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(description), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type) { @@ -155,7 +155,7 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos())); connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal))); - this->setZValue(3); + this->setZValue(5); } WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate,int seq,int missiontype, const QString &description, MapGraphicItem *map) : relativeCoord(relativeCoordenate), reached(false), description(description), shownumber(true), isDragging(false), map(map) @@ -193,7 +193,7 @@ WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate,int seq connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos())); connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal))); - this->setZValue(3); + this->setZValue(5); } void WayPointItem::setWPType(wptype type) @@ -220,21 +220,21 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti if(isEdit == true) { if (this->isSelected()) { - this->setZValue(4); + this->setZValue(6); } else { - this->setZValue(3); + this->setZValue(5); } } else { if (Command() < MAV_CMD::MAV_CMD_NAV_LAST) { - this->setZValue(4); + this->setZValue(6); } else { - this->setZValue(3); + this->setZValue(5); } } @@ -344,7 +344,7 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti if(isShowTip) { - QRectF rect = QRectF(-50,-60,100,40); + QRectF rect = QRectF(-50,-70,100,50); //画一块底色#58ACFA painter->setBrush(QColor("#A9F5F2")); @@ -353,7 +353,7 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti ePen.setColor(QColor("#58ACFA")); ePen.setWidth(2); painter->setPen(ePen); - painter->drawRect(rect); + painter->drawRoundedRect(rect,5,5); //画字 QFont font; @@ -365,10 +365,57 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti ePen.setColor(QColor("#000000")); painter->setPen(ePen); - QString _v = tr("Speed: %1m/s").arg(QString::number(property.param4,'f',0)); - QString _h = tr("Height: %1m\n%2").arg(QString::number(property.z,'f',0)).arg(_v); + QString _h; + QString _v; + switch (property.command) { + case 16: + _h = tr(""); + break; + case 20: + _h = tr("return "); + break; + case 21: + _h = tr("landing "); + break; + case 22: + _h = tr("takeoff "); + break; + default: + _h = tr("unknow "); + break; + } + if(property.command == 16) + { + switch ((int32_t)property.param1) { + case 0: + _h.append(tr("hold\n")); + break; + case -1: + _h.append(tr("cas\n")); + break; + case -2: + _h.append(tr("Vz\n")); + break; + case -3: + _h.append(tr("onAB\n")); + break; + case -4: + _h.append(tr("offAB\n")); + break; + default: + _h.append(tr("unknow\n")); + break; + } + } + else + { + _h.append(tr("\n")); + } + + _v = tr("Speed: %1m/s").arg(QString::number(property.param4,'f',0)); + _h.append(tr("Height: %1m\n%2").arg(QString::number(property.z,'f',0)).arg(_v)); painter->drawText(QRectF(rect.x() + 2,rect.y()+2,rect.width() - 4,rect.height() - 4),Qt::AlignLeft | Qt::AlignVCenter,_h); } } @@ -649,12 +696,16 @@ void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayP qDebug() << "set property.seq" << property.seq; } } + + int WayPointItem::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } + + WayPointItem::~WayPointItem() { emit aboutToBeDeleted(this);