From 51b5ba03ff9c68a830250ce2bfdb3eda25f90441 Mon Sep 17 00:00:00 2001 From: hm Date: Wed, 8 Jun 2022 17:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A3=9E=E6=8E=A7=E6=96=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/MenuBarUI/MenuBarUI.cpp | 5 ++++- App/mainwindow.cpp | 12 +++++++++--- MavLinkNode/missionprocess.cpp | 7 +++++++ MavLinkNode/missionprocess.h | 1 + dlink/dlink.cpp | 14 ++++++++++---- opmap/mapwidget/geoFencecircle.cpp | 2 +- opmap/mapwidget/geoFenceitem.cpp | 2 +- opmap/mapwidget/opmapwidget.cpp | 24 +++++++++++++++--------- opmap/mapwidget/uavitem.cpp | 21 ++++++++++++++++++++- opmap/mapwidget/waypointitem.cpp | 3 ++- opmap/mapwidget/waypointsetting.cpp | 2 +- 11 files changed, 71 insertions(+), 22 deletions(-) diff --git a/App/MenuBarUI/MenuBarUI.cpp b/App/MenuBarUI/MenuBarUI.cpp index a2d0aa7..fc0c468 100644 --- a/App/MenuBarUI/MenuBarUI.cpp +++ b/App/MenuBarUI/MenuBarUI.cpp @@ -264,7 +264,10 @@ void MenuBarUI::MessageTimeOut(void) void MenuBarUI::setTargetPoint(int Value) { - ui->label_TargetPoint->setText(tr("%1Group%2Point").arg(QString::number(missionGroup)).arg(QString::number(Value,'f',0))); + int group = Value /1000; + int seq = Value %1000; + + ui->label_TargetPoint->setText(tr("%1Group%2Point").arg(QString::number(group + 1)).arg(QString::number(seq,'f',0))); } void MenuBarUI::setTargetAlt(QVariant Value) diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index b02a3bd..304a79c 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -958,7 +958,7 @@ void MainWindow::onTabIndexChanged(const int &index)//界面选择管理 //得到航线组数,数据为1,2,3,4 - emit currentGroup(group + 2); + //emit currentGroup(group + 1); } else { @@ -1452,7 +1452,7 @@ void MainWindow::updateUI()//事件驱动式更新数据 menuBarUI->setX(dlink->mavlinknode->vehicle.nav_controller_output.xtrack_error); - menuBarUI->setwp_Dist(((float)dlink->mavlinknode->vehicle.nav_controller_output.wp_dist) * 0.001); + menuBarUI->setwp_Dist(((float)dlink->mavlinknode->vehicle.nav_controller_output.wp_dist) * 0.01); @@ -1736,8 +1736,12 @@ void MainWindow::updateUI()//事件驱动式更新数据 //get 9-10 //得到航线组数,数据为1,2,3,4 - group = (int)(getBit(enable,11) << 2) | (int)(getBit(enable,10) << 1) | (int)(getBit(enable,9)); + //group = (int)(getBit(enable,11) << 2) | (int)(getBit(enable,10) << 1) | (int)(getBit(enable,9)); + //group = dlink->mavlinknode->vehicle. + + + /* if(group_old != group)//有变化的时候就发出去 { emit currentGroup(group + 2); @@ -1748,6 +1752,8 @@ void MainWindow::updateUI()//事件驱动式更新数据 menuBarUI->setMissionGroup(group); + */ + } diff --git a/MavLinkNode/missionprocess.cpp b/MavLinkNode/missionprocess.cpp index 27e030c..d72ce7c 100644 --- a/MavLinkNode/missionprocess.cpp +++ b/MavLinkNode/missionprocess.cpp @@ -269,7 +269,14 @@ void MissionProcess::Parse(mavlink_message_t msg) }break; case MAVLINK_MSG_ID_MISSION_CURRENT: { mavlink_msg_mission_current_decode(&msg,&mission_current); + + int group = mission_current.seq /1000; + int seq = mission_current.seq %1000; + + //emit currentGroup(group); + // emit currentPoint(seq + 1); emit currentPoint(mission_current.seq + 1); + }break; case MAVLINK_MSG_ID_MISSION_SET_CURRENT: { mavlink_msg_mission_set_current_decode(&msg,&mission_set_current); diff --git a/MavLinkNode/missionprocess.h b/MavLinkNode/missionprocess.h index ffabf78..66aba9f 100644 --- a/MavLinkNode/missionprocess.h +++ b/MavLinkNode/missionprocess.h @@ -163,6 +163,7 @@ signals: uint8_t autocontinue, uint8_t mission_type); + //void currentGroup(int group); void currentPoint(int seq); private: diff --git a/dlink/dlink.cpp b/dlink/dlink.cpp index da1f424..6a7f4b4 100644 --- a/dlink/dlink.cpp +++ b/dlink/dlink.cpp @@ -53,14 +53,20 @@ DLink::~DLink() void DLink::timeout() { - //qDebug() << Byte_Out_ALL << Byte_Out_per; + static qint64 last = QDateTime::currentMSecsSinceEpoch(); - Byte_Out_per = Byte_Out_ALL; - Byte_Out_ALL = 0; + qint64 time = QDateTime::currentMSecsSinceEpoch() - last; + if(time >= 2000) + { + Byte_Out_per = (double)Byte_Out_ALL / (time * 0.001); - emit byteCount(Byte_In_per,Byte_Out_per); + Byte_Out_ALL = 0; + last = QDateTime::currentMSecsSinceEpoch(); + + emit byteCount(Byte_In_per,Byte_Out_per); + } } int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len) diff --git a/opmap/mapwidget/geoFencecircle.cpp b/opmap/mapwidget/geoFencecircle.cpp index 5f7cb29..52be528 100644 --- a/opmap/mapwidget/geoFencecircle.cpp +++ b/opmap/mapwidget/geoFencecircle.cpp @@ -11,7 +11,7 @@ geoFencecircle::geoFencecircle(int group, bool inclusion, int version, internals { this->setAcceptHoverEvents(true); - this->setZValue(3); + this->setZValue(2); //this->setFlag(QGraphicsEllipseItem::ItemIsMovable, true); //this->setFlag(QGraphicsEllipseItem::ItemIgnoresTransformations, true); diff --git a/opmap/mapwidget/geoFenceitem.cpp b/opmap/mapwidget/geoFenceitem.cpp index fec3900..b9c2a2a 100644 --- a/opmap/mapwidget/geoFenceitem.cpp +++ b/opmap/mapwidget/geoFenceitem.cpp @@ -8,7 +8,7 @@ geoFenceitem::geoFenceitem(int group, bool inclusion, int version, internals::Po QGraphicsPolygonItem(map), number(0) , coord(coord), m_brush(color), m_map(map), dashed(dashed), lineWidth(width) { this->setAcceptHoverEvents(true); - this->setZValue(3); + this->setZValue(2); //this->setFlag(QGraphicsPolygonItem::ItemIsMovable, true); //this->setFlag(QGraphicsPolygonItem::ItemIgnoresTransformations, true); diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index 8a02cd8..5cf6fb4 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -1742,18 +1742,24 @@ void OPMapWidget::setWPLock(bool const & lock) void OPMapWidget::WPSetCurrent(int seq) { + int group = seq /1000 + 3; + int num = seq %1000; + + groupchanged(group); + foreach(QGraphicsItem * i, map->childItems()) { WayPointItem *w = qgraphicsitem_cast(i); if (w) { - - if(w->Number() == seq) + if(w->MissionType() == group) { - w->WPSetCurrent(true); - //qDebug() << "map WPSetCurrent" << seq; - } - else - { - w->WPSetCurrent(false); + if(w->Number() == num) + { + w->WPSetCurrent(true); + } + else + { + w->WPSetCurrent(false); + } } } } @@ -2741,7 +2747,7 @@ void OPMapWidget::groupchanged(int value) } else//飞行界面 { - qDebug() << "show current group" << currentMissionType; + //qDebug() << "show current group" << currentMissionType; if(currentMissionType > 6) { diff --git a/opmap/mapwidget/uavitem.cpp b/opmap/mapwidget/uavitem.cpp index 1601af7..3eee7a3 100644 --- a/opmap/mapwidget/uavitem.cpp +++ b/opmap/mapwidget/uavitem.cpp @@ -195,8 +195,17 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q painter->drawText(QRectF(rect.x() + 2,rect.y()+2,rect.width() - 4,rect.height() - 4),Qt::AlignLeft | Qt::AlignVCenter,_h); painter->restore(); + + + } + painter->save(); + + painter->drawRect(boundingRect()); + + painter->restore(); + } @@ -340,7 +349,17 @@ QRectF UAVItem::boundingRect() const return QRectF(-boundingRectSize, -boundingRectSize, 2 * boundingRectSize, 2 * boundingRectSize); } } else { - return QRectF(-pic.width() * 2, -pic.height() * 2, pic.width() * 4, pic.height() * 4); + + if(isShowTip) + { + return QRectF(-pic.width() * 1.3, -pic.height() * 1.3, pic.width() * 2.6, pic.height() * 2.6); + } + else + { + return QRectF(-pic.width() * 0.5, -pic.height() * 0.5, pic.width() * 1, pic.height() * 1); + } + + } } diff --git a/opmap/mapwidget/waypointitem.cpp b/opmap/mapwidget/waypointitem.cpp index 7cedc31..92ab1eb 100644 --- a/opmap/mapwidget/waypointitem.cpp +++ b/opmap/mapwidget/waypointitem.cpp @@ -515,7 +515,8 @@ void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if(Command() < MAV_CMD::MAV_CMD_NAV_LAST) { - emit SetCurrent(this->Number()); + //不允许点击界面修改航点 + //emit SetCurrent(this->Number()); } } } diff --git a/opmap/mapwidget/waypointsetting.cpp b/opmap/mapwidget/waypointsetting.cpp index 1df42ed..310a52b 100644 --- a/opmap/mapwidget/waypointsetting.cpp +++ b/opmap/mapwidget/waypointsetting.cpp @@ -199,7 +199,7 @@ WayPointSetting::WayPointSetting(MapGraphicItem *map, QColor background) : myMap QRectF WayPointSetting::boundingRect() const //鼠标可以操作的大小 { - qDebug() << rect; + //qDebug() << rect; return rect; //return QRectF(0,0,100,370);