From 13eed268654ed0f194d7c33ef0c3697d2548b31b Mon Sep 17 00:00:00 2001 From: hm Date: Fri, 10 Jun 2022 17:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=B5=8B=E9=87=8F?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E5=B9=B6=E5=AE=8C=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/CommandUI/CommandUI.qss | 6 +- App/MissionUI/MissionUI.h | 2 + App/MissionUI/MissionUI.pri | 9 +- App/MissionUI/propertyui.cpp | 44 +- App/MissionUI/propertyui.h | 17 +- App/MissionUI/ruledialog.cpp | 153 ++ App/MissionUI/ruledialog.h | 62 + .../mapwidget => App/MissionUI}/ruledialog.ui | 30 - App/StatusUI/StatusUI.cpp | 3 + App/StatusUI/StatusUI.ui | 1326 +++++++++-------- App/mainwindow.cpp | 25 +- Cockpit/Cockpit.cpp | 8 +- opmap/internals/pureprojection.cpp | 2 + opmap/mapwidget/measureline.cpp | 32 +- opmap/mapwidget/measureline.h | 4 + opmap/mapwidget/opmapwidget.cpp | 72 +- opmap/mapwidget/opmapwidget.h | 13 + opmap/mapwidget/ruledialog.cpp | 98 -- opmap/mapwidget/ruledialog.h | 62 - 19 files changed, 1090 insertions(+), 878 deletions(-) create mode 100644 App/MissionUI/ruledialog.cpp create mode 100644 App/MissionUI/ruledialog.h rename {opmap/mapwidget => App/MissionUI}/ruledialog.ui (89%) delete mode 100644 opmap/mapwidget/ruledialog.cpp delete mode 100644 opmap/mapwidget/ruledialog.h diff --git a/App/CommandUI/CommandUI.qss b/App/CommandUI/CommandUI.qss index 61d6adb..d35a387 100644 --- a/App/CommandUI/CommandUI.qss +++ b/App/CommandUI/CommandUI.qss @@ -57,9 +57,9 @@ CommandButton:pressed[state="2"] { } .QTabBar::tab{ - max-width: 75px; - min-width: 75px; - min-height: 40px; + max-width: 55px; + min-width: 55px; + min-height: 30px; } .QTabBar::tab:!selected { diff --git a/App/MissionUI/MissionUI.h b/App/MissionUI/MissionUI.h index 0296c70..1631262 100644 --- a/App/MissionUI/MissionUI.h +++ b/App/MissionUI/MissionUI.h @@ -57,6 +57,8 @@ public slots: void clearTable(); + + protected slots: void closeEvent(QCloseEvent *event); void resizeEvent(QResizeEvent *event); diff --git a/App/MissionUI/MissionUI.pri b/App/MissionUI/MissionUI.pri index 92ef754..b64512f 100644 --- a/App/MissionUI/MissionUI.pri +++ b/App/MissionUI/MissionUI.pri @@ -18,19 +18,22 @@ INCLUDEPATH += $$PWD/../ComponentUI/Confirm FORMS += \ $$PWD/MissionUI.ui \ - $$PWD/propertyui.ui + $$PWD/propertyui.ui \ + $$PWD/ruledialog.ui HEADERS += \ $$PWD/CustomButton.h \ $$PWD/JsonHelper.h \ $$PWD/MissionUI.h \ - $$PWD/propertyui.h + $$PWD/propertyui.h \ + $$PWD/ruledialog.h SOURCES += \ $$PWD/CustomButton.cpp \ $$PWD/JsonHelper.cc \ $$PWD/MissionUI.cpp \ - $$PWD/propertyui.cpp + $$PWD/propertyui.cpp \ + $$PWD/ruledialog.cpp RESOURCES += \ $$PWD/MissionUIres.qrc diff --git a/App/MissionUI/propertyui.cpp b/App/MissionUI/propertyui.cpp index 7dcad50..65a7e36 100644 --- a/App/MissionUI/propertyui.cpp +++ b/App/MissionUI/propertyui.cpp @@ -280,6 +280,7 @@ propertyui::propertyui(QWidget *parent) : } + void propertyui::clearLayout(QLayout *layout) { QLayoutItem *item; @@ -1055,6 +1056,12 @@ propertyui::~propertyui() table->deleteLater(); } + if(ruler) + { + ruler->deleteLater(); + } + + delete ui; } @@ -2227,7 +2234,39 @@ void propertyui::measureState(bool flag) void propertyui::on_pushButton_Ruler_clicked() { - emit ruler_clicked(); + if(ruler) + { + ruler->deleteLater(); + ruler = nullptr; + } + else + { + ruler = new RuleDialog(); + ruler->show(); + ruler->showNormal(); + ruler->activateWindow(); + + + connect(ruler,&RuleDialog::exitRuler, + this,&propertyui::exitRuler); + + connect(this,&propertyui::mousePosition, + ruler,&RuleDialog::ShowMousePos); + + connect(this,&propertyui::MeasurePosition, + ruler,&RuleDialog::RulePoint); + + connect(this,&propertyui::Lineinfo, + ruler,&RuleDialog::Lineinfo); + + connect(ruler,&RuleDialog::valuechanged, + this,&propertyui::valuechanged); + + + } + + + } void propertyui::on_pushButton_Table_clicked() @@ -2235,6 +2274,9 @@ void propertyui::on_pushButton_Table_clicked() if(table->isHidden()) { table->show(); + table->showNormal(); + table->activateWindow(); + } else { diff --git a/App/MissionUI/propertyui.h b/App/MissionUI/propertyui.h index a9b4a04..79a4ad4 100644 --- a/App/MissionUI/propertyui.h +++ b/App/MissionUI/propertyui.h @@ -37,6 +37,7 @@ #include "QtQmlDepends" #include "MissionUI.h" +#include "ruledialog.h" #ifdef QtopmapWidget @@ -260,7 +261,7 @@ Q_SIGNALS: void getAllPoints(int group); - void ruler_clicked(); + // void ruler_clicked(); void createFenceCircle(int,qreal radius, bool inclusion, qreal lat, qreal lng); @@ -283,6 +284,17 @@ Q_SIGNALS: void clearTable(); + + void GetPoint(quint8); + void exitRuler(); + + void mousePosition(qreal lat,qreal lng); + + void MeasurePosition(int num,qreal lat,qreal lng); + + void Lineinfo(qreal dis,qreal bearing); + void valuechanged(int num,qreal value); + private slots: void GroupChanged(int value); @@ -405,7 +417,8 @@ private: Ui::propertyui *ui; - MissionUI *table; + MissionUI *table = nullptr; + RuleDialog *ruler = nullptr; QByteArray allBytes; diff --git a/App/MissionUI/ruledialog.cpp b/App/MissionUI/ruledialog.cpp new file mode 100644 index 0000000..30f68d9 --- /dev/null +++ b/App/MissionUI/ruledialog.cpp @@ -0,0 +1,153 @@ +#include "ruledialog.h" +#include "ui_ruledialog.h" +#include "qmessagebox.h" + +RuleDialog::RuleDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::RuleDialog) +{ + ui->setupUi(this); + setWindowFlags(Qt::WindowStaysOnTopHint); + CurrentPoint = 1; + + + ui->MouseLatitude->setReadOnly(true); + ui->MouseLongitude->setReadOnly(true); + + + ui->ConformButton->setEnabled(false); + + ui->FirstPointLatitude->setEnabled(false); + ui->FirstPointLongitude->setEnabled(false); + ui->SecondPointLatitude->setEnabled(false); + ui->SecondPointLongitude->setEnabled(false); + + ui->TwoPointDistance->setEnabled(false); + ui->TwoPointAngle->setEnabled(false); + +} + +RuleDialog::~RuleDialog() +{ + delete ui; +} + +void RuleDialog::closeEvent(QCloseEvent *event) +{ + event->ignore(); + //退出测量 + emit exitRuler(); + + //event->accept(); +} + + + +double RuleDialog::GetDiatance(qreal lat1,qreal lng1,qreal lat2 ,qreal lng2) +{ + double EarthRadiusKm = 6378.137; + + double dLat1InRad = lat1 * (M_PI / 180); + double dLong1InRad = lng1 * (M_PI / 180); + double dLat2InRad = lat2 * (M_PI / 180); + double dLong2InRad = lng2 * (M_PI / 180); + double dLongitude = dLong2InRad - dLong1InRad; + double dLatitude = dLat2InRad - dLat1InRad; + double a = pow(sin(dLatitude / 2), 2) + cos(dLat1InRad) * cos(dLat2InRad) * pow(sin(dLongitude / 2), 2); + double c = 2 * atan2(sqrt(a), sqrt(1 - a)); + double dDistance = EarthRadiusKm * c; + + return dDistance; +} + +double RuleDialog::GetHeading(qreal lat1,qreal lng1,qreal lat2 ,qreal lng2) +{ + double temp; + double mLat = lat2 - lat1; + double mLon = (lng2 - lng1)* cos(((lat2 + lat1)/2)* 0.0174532925); + temp = 90.0 + atan2(-mLat, mLon) * 57.2957795; + if(temp < 0)temp += 360.0; + return temp; +} + +void RuleDialog::RulePoint(int num,qreal lat,qreal lng) +{ + switch(num) { + case 1:{ + Point1.lat = lat; + Point1.lng = lng; + ui->FirstPointLatitude->setText(QString::number(lat,'f',8)); + ui->FirstPointLongitude->setText(QString::number(lng,'f',8)); + } break; + case 2:{ + Point2.lat = lat; + Point2.lng = lng; + ui->SecondPointLatitude->setText(QString::number(lat,'f',8)); + ui->SecondPointLongitude->setText(QString::number(lng,'f',8)); + + on_ConformButton_clicked(); + + } break; + default: + break; + } +} + +void RuleDialog::ShowMousePos(qreal lat,qreal lng) +{ + ui->MouseLatitude->setText(QString::number(lat,'f',8)); + ui->MouseLongitude->setText(QString::number(lng,'f',8)); +} + + +void RuleDialog::Lineinfo(qreal dis,qreal bearing) +{ + ui->ConformButton->setEnabled(true); + + ui->FirstPointLatitude->setEnabled(true); + ui->FirstPointLongitude->setEnabled(true); + ui->SecondPointLatitude->setEnabled(true); + ui->SecondPointLongitude->setEnabled(true); + + ui->TwoPointDistance->setEnabled(true); + ui->TwoPointAngle->setEnabled(true); + + ui->TwoPointDistance->setText(QString::number(dis * 0.001,'f',3) + "km"); + ui->TwoPointAngle->setText(QString::number(bearing * 57.3,'f',1) + "°"); +} + + +void RuleDialog::on_ConformButton_clicked() +{ + bool flag = false; + qreal value = ui->FirstPointLatitude->text().toDouble(&flag); + if(flag) + { + Point1.lat = value; + emit valuechanged(1,value); + } + + flag = false; + value = ui->FirstPointLongitude->text().toDouble(&flag); + if(flag) + { + Point1.lat = value; + emit valuechanged(2,value); + } + + flag = false; + value = ui->SecondPointLatitude->text().toDouble(&flag); + if(flag) + { + Point1.lat = value; + emit valuechanged(3,value); + } + + flag = false; + value = ui->SecondPointLongitude->text().toDouble(&flag); + if(flag) + { + Point1.lat = value; + emit valuechanged(4,value); + } +} diff --git a/App/MissionUI/ruledialog.h b/App/MissionUI/ruledialog.h new file mode 100644 index 0000000..94be4b5 --- /dev/null +++ b/App/MissionUI/ruledialog.h @@ -0,0 +1,62 @@ +#ifndef RULEDIALOG_H +#define RULEDIALOG_H + +#include +#include +#include "QCloseEvent" + +namespace Ui { +class RuleDialog; +} + +class RuleDialog : public QDialog +{ + Q_OBJECT +public: + + typedef struct + { + qreal lat = 0; + qreal lng = 0; + }point_t; + + explicit RuleDialog(QWidget *parent = 0); + ~RuleDialog(); + +signals: + void isWindowClose(char); + + void exitRuler(); + + + void valuechanged(int num,qreal value); + +public slots: + double GetDiatance(qreal lat1,qreal lng1,qreal lat2 ,qreal lng2); + double GetHeading(qreal lat1,qreal lng1,qreal lat2 ,qreal lng2); + + void RulePoint(int num, qreal lat, qreal lng); + void ShowMousePos(qreal lat,qreal lng); + + void Lineinfo(qreal dis,qreal bearing); + +protected: + + void closeEvent(QCloseEvent *event); + +private slots: + + void on_ConformButton_clicked(); + + +private: + Ui::RuleDialog *ui; + point_t Point1; + point_t Point2; + + + quint8 CurrentPoint; + +}; + +#endif // RULEDIALOG_H diff --git a/opmap/mapwidget/ruledialog.ui b/App/MissionUI/ruledialog.ui similarity index 89% rename from opmap/mapwidget/ruledialog.ui rename to App/MissionUI/ruledialog.ui index fa7c37c..25e1c24 100644 --- a/opmap/mapwidget/ruledialog.ui +++ b/App/MissionUI/ruledialog.ui @@ -148,36 +148,6 @@ - - - - - 微软雅黑 - 11 - 75 - true - - - - 选取第一点 - - - - - - - - 微软雅黑 - 11 - 75 - true - - - - 选取第二点 - - - diff --git a/App/StatusUI/StatusUI.cpp b/App/StatusUI/StatusUI.cpp index a701fb5..785c9a1 100644 --- a/App/StatusUI/StatusUI.cpp +++ b/App/StatusUI/StatusUI.cpp @@ -15,6 +15,9 @@ StatusUI::StatusUI(QWidget *parent) : this->setStyleSheet(stylesheet); file.close(); + setFixedWidth(465); + + /* ui->label_Warning_1_1->hide(); ui->label_Warning_1_2->hide(); diff --git a/App/StatusUI/StatusUI.ui b/App/StatusUI/StatusUI.ui index 44e685b..ab2e9b2 100644 --- a/App/StatusUI/StatusUI.ui +++ b/App/StatusUI/StatusUI.ui @@ -6,8 +6,8 @@ 0 0 - 469 - 811 + 573 + 754 @@ -16,56 +16,7 @@ - - 9 - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 飞行模式 - - - - - - - Qt::Horizontal - - - - - Adobe 黑体 Std R - 12 - true - - - - 发动机 - - - - - - - - 纵/横向模态 - - - - + @@ -77,85 +28,10 @@ - - - - background-color: rgb(189, 189, 189); - + + - 0 - - - Qt::AlignCenter - - - - - - - 航迹角[°] - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); - - - 0 - - - Qt::AlignCenter - - - - - - - 右升降[°] - - - - - - - 舵机电源[V/A] - - - - - - - 左副翼[°] - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter + 飞行模式 @@ -172,7 +48,176 @@ color: rgb(0, 128, 0); - + + + + 纵/横向模态 + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Adobe 黑体 Std R + 12 + true + + + + 基本信息 + + + + + + + 纵向过载[m/s2] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 侧向过载[m/s2] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 滚转角[°] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + 俯仰角[°] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + 航迹角[°] + + + + background-color: rgb(189, 189, 189); @@ -185,27 +230,7 @@ color: rgb(0, 128, 0); - - - - Qt::Horizontal - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - + @@ -231,121 +256,14 @@ color: rgb(0, 128, 0); - - + + - 表速[m/s] + 海拔[m] - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 剩余油量[kg] - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); - - - 0 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - - - - - Adobe 黑体 Std R - 12 - true - - - - 基本信息 - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - + background-color: rgb(189, 189, 189); @@ -358,8 +276,29 @@ color: rgb(0, 128, 0); - - + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + 表速[m/s] + + + + + background-color: rgb(189, 189, 189); @@ -371,8 +310,29 @@ color: rgb(0, 128, 0); - - + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + 真空速[m/s] + + + + + background-color: rgb(189, 189, 189); @@ -384,33 +344,7 @@ color: rgb(0, 128, 0); - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - + background-color: rgb(189, 189, 189); @@ -424,8 +358,15 @@ color: rgb(0, 128, 0); + + + + 地速[m/s] + + + - + background-color: rgb(189, 189, 189); @@ -437,40 +378,59 @@ color: rgb(0, 128, 0); - - + + - 舱温上/右[℃] + 马赫数[Ma] - - + + + + background-color: rgb(189, 189, 189); + - 方向舵[°] + 0 + + + Qt::AlignCenter - - + + - 油门[%/rpm] + 爬升率[m/s] - - + + + + background-color: rgb(189, 189, 189); + - 右副翼[°] + 0 + + + Qt::AlignCenter - - + + Qt::Horizontal - + + + + + + Qt::Horizontal + + Adobe 黑体 Std R @@ -479,13 +439,32 @@ color: rgb(0, 128, 0); - 电池 + 舵面状态 - - + + + + 左副翼[°] + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + background-color: rgb(189, 189, 189); @@ -497,48 +476,7 @@ color: rgb(0, 128, 0); - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 纵向过载[m/s2] - - - - - - - 马赫数[Ma] - - - - - - - 油箱压力[kPa] - - - - - - - 机载电源[V/A] - - - - + @@ -564,8 +502,28 @@ color: rgb(0, 128, 0); - - + + + + 右副翼[°] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + background-color: rgb(189, 189, 189); color: rgb(0, 128, 0); @@ -578,7 +536,27 @@ color: rgb(0, 128, 0); - + + + + 左升降[°] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + background-color: rgb(189, 189, 189); @@ -592,232 +570,14 @@ color: rgb(0, 128, 0); - - + + - 真空速[m/s] + 右升降[°] - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 爬升率[m/s] - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - - Adobe 黑体 Std R - 12 - true - - - - 舵面状态 - - - - - - - - Qt::Horizontal - - - - - - - 海拔[m] - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 滚转角[°] - - - - - - - Qt::Horizontal - - - - - Adobe 黑体 Std R - 12 - true - - - - 数据链 - - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - 信号[%-B/s] - - - - - - - Qt::Horizontal - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); - - - 0 - - - Qt::AlignCenter - - - - - - - 侧向过载[m/s2] - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); - - - 0 - - - Qt::AlignCenter - - - - + background-color: rgb(189, 189, 189); @@ -830,8 +590,29 @@ color: rgb(0, 128, 0); - - + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + 方向舵[°] + + + + + background-color: rgb(189, 189, 189); @@ -843,7 +624,156 @@ color: rgb(0, 128, 0); - + + + + background-color: rgb(189, 189, 189); +color: rgb(0, 128, 0); + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + Adobe 黑体 Std R + 12 + true + + + + 发动机 + + + + + + + + 油门[%/rpm] + + + + + + + background-color: rgb(168, 168, 168); + + + 0 + + + Qt::AlignCenter + + + %v + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 剩余油量[kg] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 油箱压力[kPa] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 舱温上/右[℃] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + background-color: rgb(189, 189, 189); @@ -856,41 +786,40 @@ color: rgb(0, 128, 0); - - - - 左升降[°] + + + + Qt::Horizontal - - + + + + Qt::Horizontal + + + + + Adobe 黑体 Std R + 12 + true + + + + 电池 + + + + + + - 俯仰角[°] + 机载电源[V/A] - - - - 地速[m/s] - - - - - - - background-color: rgb(189, 189, 189); - - - 0 - - - Qt::AlignCenter - - - - + @@ -915,34 +844,10 @@ color: rgb(0, 128, 0); - - - - Qt::Horizontal - - - - - + + - background-color: rgb(168, 168, 168); - - - 0 - - - Qt::AlignCenter - - - %v - - - - - - - background-color: rgb(189, 189, 189); -color: rgb(0, 128, 0); + background-color: rgb(189, 189, 189); 0 @@ -952,21 +857,140 @@ color: rgb(0, 128, 0); + + + + 舵机电源[V/A] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + Adobe 黑体 Std R + 12 + true + + + + 数据链 + + + + + + + + 信号[%-B/s] + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + background-color: rgb(189, 189, 189); + + + 0 + + + Qt::AlignCenter + + + + + + + 当前值 + + + Qt::AlignCenter + + + + + + + 目标值 + + + Qt::AlignCenter + + + + + + + 目标值 + + + Qt::AlignCenter + + + + + + + 当前值 + + + Qt::AlignCenter + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index 003ee2b..46e9179 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -434,15 +434,22 @@ MainWindow::MainWindow(QWidget *parent) connect(map,SIGNAL(settableGroup(int)), missionUI,SIGNAL(settableGroup(int))); - connect(missionUI,SIGNAL(ruler_clicked()), - map,SLOT(ruler_clicked())); - connect(map,SIGNAL(measureState(bool)), missionUI,SLOT(measureState(bool))); connect(map,SIGNAL(settableClicked()), missionUI,SLOT(on_pushButton_Table_clicked())); + connect(map,SIGNAL(setrulerClicked()), + missionUI,SLOT(on_pushButton_Ruler_clicked())); + + + connect(map,SIGNAL(mousePosition(qreal,qreal)), + missionUI,SIGNAL(mousePosition(qreal,qreal))); + + connect(missionUI,SIGNAL(exitRuler()), + map,SLOT(ruler_clicked())); + connect(map,SIGNAL(createFenceCircle(int,qreal,bool,qreal,qreal)), missionUI,SIGNAL(createFenceCircle(int,qreal,bool,qreal,qreal))); @@ -489,6 +496,18 @@ MainWindow::MainWindow(QWidget *parent) missionUI,SLOT(clearTable()),Qt::DirectConnection); + connect(map,SIGNAL(MeasurePosition(int,qreal,qreal)), + missionUI,SIGNAL(MeasurePosition(int,qreal,qreal)),Qt::DirectConnection); + + connect(map,SIGNAL(Lineinfo(qreal,qreal)), + missionUI,SIGNAL(Lineinfo(qreal,qreal)),Qt::DirectConnection); + + + connect(missionUI,SIGNAL(valuechanged(int,qreal)), + map,SLOT(MeasureValueChanged(int,qreal))); + + + //dlink ----- map connect(map,SIGNAL(signal_WPDownload(uint8_t,uint8_t,int)), dlink->mavlinknode->Mission,SLOT(ReadCmd(uint8_t,uint8_t,int)),Qt::DirectConnection); diff --git a/Cockpit/Cockpit.cpp b/Cockpit/Cockpit.cpp index 3d64dcb..bea19e2 100644 --- a/Cockpit/Cockpit.cpp +++ b/Cockpit/Cockpit.cpp @@ -2101,13 +2101,13 @@ void Cockpit::drawYawScale(QPainter *painter) painter->rotate(-m_State.yaw); static const QPointF Npoints[3] = { - QPointF(-70,0), + QPointF(-35,0), QPointF( 0,-300), - QPointF( 70,0)}; + QPointF( 35,0)}; static const QPointF Spoints[3] = { - QPointF(-70,0), + QPointF(-35,0), QPointF( 0,300), - QPointF( 70,0)}; + QPointF( 35,0)}; painter->setPen(Qt::NoPen); painter->setBrush(QColor("#FF0000")); diff --git a/opmap/internals/pureprojection.cpp b/opmap/internals/pureprojection.cpp index 6762241..dbfa49a 100644 --- a/opmap/internals/pureprojection.cpp +++ b/opmap/internals/pureprojection.cpp @@ -207,6 +207,7 @@ void PureProjection::FromCartesianTGeodetic(const double &X, const double &Y, co } double PureProjection::courseBetweenLatLng(PointLatLng const & p1, PointLatLng const & p2) { + double lon1 = p1.Lng() * (M_PI / 180); double lat1 = p1.Lat() * (M_PI / 180); double lon2 = p2.Lng() * (M_PI / 180); @@ -230,6 +231,7 @@ double PureProjection::DistanceBetweenLatLng(PointLatLng const & p1, PointLatLng double d = R * c; return d; + } void PureProjection::offSetFromLatLngs(PointLatLng p1, PointLatLng p2, double &distance, double &bearing) diff --git a/opmap/mapwidget/measureline.cpp b/opmap/mapwidget/measureline.cpp index d69bc18..8eb96d8 100644 --- a/opmap/mapwidget/measureline.cpp +++ b/opmap/mapwidget/measureline.cpp @@ -107,6 +107,33 @@ void MeasureLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio font.setFamily("黑体");//非衬线 painter->setFont(font); painter->drawText(line().p2().x(),line().p2().y() - 5,QString("%1km %2°").arg(QString::number(distance * 0.001,'f',3)).arg(QString::number(bearing * 57.3,'f',1))); + + + + painter->save(); + painter->setOpacity(0.8); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#FFFFFF")); + painter->drawEllipse(line().p1(),5,5); + painter->drawEllipse(line().p2(),5,5); + painter->restore(); + + //画字 + painter->save(); + painter->setOpacity(1); + font.setWeight(QFont::ExtraBold); + font.setFamily("Arial");//非衬线 + font.setPixelSize(8); + painter->setFont(font); + + myPen.setWidth(1); + myPen.setColor(QColor("#000000")); + painter->setPen(myPen); + painter->drawText(QRect(line().p1().x() - 20,line().p1().y()-5,40,10),Qt::AlignCenter,QString::number(1)); + painter->drawText(QRect(line().p2().x() - 20,line().p2().y()-5,40,10),Qt::AlignCenter,QString::number(2)); + painter->restore(); + + } @@ -152,6 +179,8 @@ void MeasureLine::setFrom(internals::PointLatLng p) my_map->Projection()->offSetFromLatLngs(source,destination,distance,bearing); + emit Lineinfo(distance,bearing); + refreshLocations(); update(); @@ -164,8 +193,9 @@ void MeasureLine::setTo(internals::PointLatLng p) my_map->Projection()->offSetFromLatLngs(source,destination,distance,bearing); - refreshLocations(); + emit Lineinfo(distance,bearing); + refreshLocations(); update(); } diff --git a/opmap/mapwidget/measureline.h b/opmap/mapwidget/measureline.h index 85c841c..e11327c 100644 --- a/opmap/mapwidget/measureline.h +++ b/opmap/mapwidget/measureline.h @@ -85,6 +85,10 @@ private: double bearing; +signals: + + void Lineinfo(qreal dis,qreal bearing); + protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); public slots: diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index adec1ea..920dec2 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -171,6 +171,12 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView measureline->hide(); + connect(measureline,SIGNAL(Lineinfo(qreal,qreal)), + this,SIGNAL(Lineinfo(qreal,qreal))); + + + + NoOperationTimer = new QTimer(this); connect(NoOperationTimer,SIGNAL(timeout()), this,SLOT(NOPTimeout())); @@ -223,6 +229,9 @@ void OPMapWidget::UAVTip_clicked(bool flag) void OPMapWidget::ruler_clicked(void) { + + emit setrulerClicked(); + if(isMeasure) { isMeasure = false; @@ -279,20 +288,6 @@ void OPMapWidget::ruler_clicked(void) void OPMapWidget::table_clicked(void) { emit settableClicked(); - - /* - if(missiontable) - { - if(missiontable->isHidden()) - { - missiontable->show(); - } - else - { - missiontable->hide(); - } - } - */ } @@ -704,12 +699,14 @@ void OPMapWidget::mouseMoveEvent(QMouseEvent *event) QPointF p = event->pos(); p = map->mapFromParent(p); point_end = map->FromLocalToLatLng(p.x(), p.y()); - //measurenumber = 1; + + emit mousePosition(point_end.Lat(),point_end.Lng()); if(measureline) { if(measurenumber == 2)//取了第一个点后 { + emit MeasurePosition(measurenumber,point_end.Lat(),point_end.Lng()); measureline->setTo(point_end); } } @@ -765,19 +762,24 @@ void OPMapWidget::mousePressEvent(QMouseEvent *event) QPointF p = event->pos(); p = map->mapFromParent(p); point_begin = map->FromLocalToLatLng(p.x(), p.y()); + + + emit MeasurePosition(measurenumber,point_begin.Lat(),point_begin.Lng()); measurenumber ++; if(measureline) { measureline->setFrom(point_begin); } - } else { QPointF p = event->pos(); p = map->mapFromParent(p); point_end = map->FromLocalToLatLng(p.x(), p.y()); + + + emit MeasurePosition(measurenumber,point_end.Lat(),point_end.Lng()); measurenumber = 1; if(measureline) @@ -814,14 +816,19 @@ void OPMapWidget::mouseReleaseEvent(QMouseEvent *event) emit MouseReleaseEvent(event); - - if(event->button() == Qt::RightButton) + /* + if(isMeasure) { - if(isMeasure) + if(event->button() == Qt::RightButton) { ruler_clicked(); } } + */ + + + + } void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event) @@ -902,7 +909,32 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event) emit MouseDoubleClickEvent(event); } - +void OPMapWidget::MeasureValueChanged(int num,qreal value) +{ + if(measureline) + { + switch (num) { + case 1: + point_begin.SetLat(value); + measureline->setFrom(point_begin); + break; + case 2: + point_begin.SetLng(value); + measureline->setFrom(point_begin); + break; + case 3: + point_end.SetLat(value); + measureline->setTo(point_end); + break; + case 4: + point_end.SetLng(value); + measureline->setTo(point_end); + break; + default: + break; + } + } +} ////////////////WAYPOINT//////////////////////// diff --git a/opmap/mapwidget/opmapwidget.h b/opmap/mapwidget/opmapwidget.h index d43c271..17bbad4 100644 --- a/opmap/mapwidget/opmapwidget.h +++ b/opmap/mapwidget/opmapwidget.h @@ -543,6 +543,7 @@ signals: void ripfinished(); void settableClicked(void); + void setrulerClicked(void); void showMessage(const QString &message,int TimeOut = 0); @@ -680,6 +681,13 @@ signals: void clearTable(); + + void mousePosition(qreal lat,qreal lng); + void MeasurePosition(int num,qreal lat,qreal lng); + + + void Lineinfo(qreal dis,qreal bearing); + public slots: void getAllPoints(int group); @@ -796,6 +804,11 @@ public slots: void userRipMap(bool start,qreal lat_l,qreal lng_l,qreal lat_r,qreal lng_r,qint8 zoom); + + void MeasureValueChanged(int num,qreal value); + + + }; } #endif // OPMAPWIDGET_H diff --git a/opmap/mapwidget/ruledialog.cpp b/opmap/mapwidget/ruledialog.cpp deleted file mode 100644 index 0b17e69..0000000 --- a/opmap/mapwidget/ruledialog.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "ruledialog.h" -#include "ui_ruledialog.h" -#include "qmessagebox.h" - -RuleDialog::RuleDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::RuleDialog) -{ - ui->setupUi(this); - setWindowFlags(Qt::WindowStaysOnTopHint); - setUrlFactory = new core::UrlFactory; - CurrentPoint = 1; -} - -RuleDialog::~RuleDialog() -{ - delete ui; -} - -double RuleDialog::GetDiatance(internals::PointLatLng P1,internals::PointLatLng P2) -{ - double EarthRadiusKm = 6378.137; - - double dLat1InRad = P1.Lat() * (M_PI / 180); - double dLong1InRad = P1.Lng() * (M_PI / 180); - double dLat2InRad = P2.Lat() * (M_PI / 180); - double dLong2InRad = P2.Lng() * (M_PI / 180); - double dLongitude = dLong2InRad - dLong1InRad; - double dLatitude = dLat2InRad - dLat1InRad; - double a = pow(sin(dLatitude / 2), 2) + cos(dLat1InRad) * cos(dLat2InRad) * pow(sin(dLongitude / 2), 2); - double c = 2 * atan2(sqrt(a), sqrt(1 - a)); - double dDistance = EarthRadiusKm * c; - - return dDistance; -} - -double RuleDialog::GetHeading(internals::PointLatLng P1,internals::PointLatLng P2) -{ - double temp; - double mLat = P2.Lat() - P1.Lat(); - double mLon = (P2.Lng() - P1.Lng())* cos(((P2.Lat() + P1.Lat())/2)* 0.0174532925); - temp = 90.0 + atan2(-mLat, mLon) * 57.2957795; - if(temp < 0)temp += 360.0; - return temp; -} - -void RuleDialog::RulePoint(internals::PointLatLng LatLng) -{ - switch(CurrentPoint) { - case 1:{ - Point1.SetLat(LatLng.Lat()); - Point1.SetLng(LatLng.Lng()); - ui->FirstPointLatitude->setText(QString::number(LatLng.Lat(),'f',8)); - ui->FirstPointLongitude->setText(QString::number(LatLng.Lng(),'f',8)); - CurrentPoint = 2; - } break; - case 2:{ - Point2.SetLat(LatLng.Lat()); - Point2.SetLng(LatLng.Lng()); - ui->SecondPointLatitude->setText(QString::number(LatLng.Lat(),'f',8)); - ui->SecondPointLongitude->setText(QString::number(LatLng.Lng(),'f',8)); - } break; - default: LatLng = LatLng; - break; - } -} - -void RuleDialog::ShowMousePos(internals::PointLatLng LatLng) -{ - ui->MouseLatitude->setText(QString::number(LatLng.Lat(),'f',8)); - ui->MouseLongitude->setText(QString::number(LatLng.Lng(),'f',8)); -} - - -void RuleDialog::on_SelectFirstPointButton_clicked() -{ - CurrentPoint = 1; - emit GetPoint(1); -} - -void RuleDialog::on_SelectSecondPointButton_clicked() -{ - CurrentPoint = 2; - emit GetPoint(2); -} - -void RuleDialog::on_ConformButton_clicked() -{ - double Distance; - Distance = GetDiatance(Point1,Point2); - ui->TwoPointDistance->setText(QString::number(Distance,'f',6) + "km"); - - double Heading; - Heading = GetHeading(Point1,Point2); - ui->TwoPointAngle->setText(QString::number(Heading,'f',2) + "°"); - - CurrentPoint = 1;//获取结束后从新选择第一点 -} diff --git a/opmap/mapwidget/ruledialog.h b/opmap/mapwidget/ruledialog.h deleted file mode 100644 index 71cbee7..0000000 --- a/opmap/mapwidget/ruledialog.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef RULEDIALOG_H -#define RULEDIALOG_H - -#include -#include "urlfactory.h" -#include "opmapwidget.h" -#include "qmessagebox.h" - -namespace Ui { -class RuleDialog; -} - - -#ifdef QtopmapWidget -#include -class OPMAPWIDGETSHARED_EXPORT RuleDialog : public QDialog { -#else -class RuleDialog : public QDialog -{ -#endif - Q_OBJECT - -public: - enum WindowsId{ ID = 5 }; - - explicit RuleDialog(QWidget *parent = 0); - ~RuleDialog(); - -signals: - void isWindowClose(char); - void GetPoint(quint8); - - -private slots: - double GetDiatance(internals::PointLatLng P1,internals::PointLatLng P2); - double GetHeading(internals::PointLatLng P1,internals::PointLatLng P2); - - void RulePoint(internals::PointLatLng LatLng); - void ShowMousePos(internals::PointLatLng LatLng); - - void on_SelectFirstPointButton_clicked(); - - void on_SelectSecondPointButton_clicked(); - - void on_ConformButton_clicked(); - - -private: - Ui::RuleDialog *ui; - - core::UrlFactory *setUrlFactory; - - internals::PointLatLng Point1; - internals::PointLatLng Point2; - - quint8 CurrentPoint; - - QMessageBox *Box1; - -}; - -#endif // RULEDIALOG_H