添加仪表上方信息显示,修改指令增加翻页

This commit is contained in:
hm
2020-11-15 09:11:18 +08:00
parent 32e83c5fe5
commit 0c1919ae7b
11 changed files with 2073 additions and 1864 deletions
+40 -110
View File
@@ -12,6 +12,7 @@ const char* CommandUI::_versionJsonKey = "version";
const char* CommandUI::_commentJsonKey = "comment";
const char* CommandUI::_CommandButtonJsonKey = "CommandButton";
const char* CommandUI::_spacingJsonKey = "spacing";
const char* CommandUI::_WidthJsonKey = "Width";
const char* CommandUI::_HeightJsonKey = "Height";
@@ -20,7 +21,7 @@ const char* CommandUI::_TextJsonKey = "Text";
const char* CommandUI::_rowJsonKey = "row";
const char* CommandUI::_columnJsonKey = "column";
const char* CommandUI::_pageJsonKey = "Page";
const char* CommandUI::_noticeJsonKey = "Notice";
const char* CommandUI::_param1JsonKey = "param1";
const char* CommandUI::_param2JsonKey = "param2";
@@ -69,33 +70,9 @@ CommandUI::CommandUI(QWidget *parent) :
//载入json
loadCommandJson(CommandFile);
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
//ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
return;
}
CommandButton *btn = new CommandButton(ui->groupBox_Command);
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
btn->setFixedSize(CMDwidth,CMDheight);
ui->gridLayout_Command->addWidget(btn,
info.toObject().find(_rowJsonKey).value().toInt(),
info.toObject().find(_columnJsonKey).value().toInt());
btn->setProperty("state",state::success);
btn->style()->unpolish(btn);
btn->style()->polish(btn);
connect(btn,SIGNAL(clicked(bool)),
this,SLOT(on_commandClicked()));
}
updateUI();
DoubleClickTimer = new QTimer(this);
@@ -112,6 +89,7 @@ CommandUI::~CommandUI()
void CommandUI::wheelEvent(QWheelEvent *e)
{
/*
QObjectList list = ui->groupBox_Command->children();
foreach (QObject *obj, list) {
@@ -131,6 +109,7 @@ void CommandUI::wheelEvent(QWheelEvent *e)
}
}
}
*/
}
void CommandUI::keyPressEvent(QKeyEvent *event) //键盘按下事件
@@ -151,7 +130,7 @@ void CommandUI::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::MiddleButton)
{
QObjectList olist = ui->groupBox_Command->children();
QObjectList olist = ui->tabWidget_Command->children();
foreach (QObject *obj, olist) {
CommandButton *btn = qobject_cast<CommandButton *>(obj);
@@ -172,32 +151,7 @@ void CommandUI::mousePressEvent(QMouseEvent *event)
loadCommandJson(CommandFile);
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
return;
}
CommandButton *btn = new CommandButton(ui->groupBox_Command);
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
//btn->setMinimumSize(CMDwidth,CMDheight);
//btn->resize(CMDwidth,CMDheight);
btn->setFixedSize(CMDwidth,CMDheight);
ui->gridLayout_Command->addWidget(btn,
info.toObject().find(_rowJsonKey).value().toInt(),
info.toObject().find(_columnJsonKey).value().toInt());
btn->setProperty("state",state::success);
btn->style()->unpolish(btn);
btn->style()->polish(btn);
connect(btn,SIGNAL(clicked(bool)),
this,SLOT(on_commandClicked()));
}
updateUI();
}
else if (event->button() == Qt::RightButton)
{
@@ -216,61 +170,39 @@ void CommandUI::mousePressEvent(QMouseEvent *event)
}
else if(event->modifiers() == Qt::AltModifier)
{
CommandEditor *edit = new CommandEditor();
edit->show();
//CommandEditor *edit = new CommandEditor();
//edit->show();
}
}
}
void CommandUI::closeEvent(QCloseEvent *event)
void CommandUI::updateUI(void)
{
setFloat();
event->ignore();
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
return;
}
void CommandUI::contextMenuEvent(QContextMenuEvent *event)
{
/*
QMenu *menu = new QMenu(this);
CommandButton *btn = new CommandButton(ui->tabWidget_Command->widget(info.toObject().find(_pageJsonKey).value().toInt()));
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
btn->resize(m_width,m_height);
btn->move(info.toObject().find(_columnJsonKey).value().toInt() * (m_width + m_spacing) + m_spacing,
info.toObject().find(_rowJsonKey).value().toInt() * (m_height + m_spacing)+ m_spacing);
btn->setProperty("state",state::success);
btn->style()->unpolish(btn);
btn->style()->polish(btn);
QAction *pAction = new QAction("float",this);
connect(pAction,SIGNAL(triggered(bool)),
this,SLOT(setFloat()));
menu->addAction(pAction);
menu->move(cursor().pos());
menu->show();
*/
}
void CommandUI::setFloat(void)
{
if(floatflag)
{
if(this->parent())
{
this->setParent(nullptr);
}
else
{
this->setParent(m_parent);
this->move(0,0);
}
this->show();
connect(btn,SIGNAL(clicked(bool)),
this,SLOT(on_commandClicked()));
}
}
void CommandUI::setFloatFlag(bool flag)
{
floatflag = flag;
}
void CommandUI::setCommandFile(QString File)
{
@@ -281,7 +213,7 @@ void CommandUI::setCommandFile(QString File)
CommandFile = File;
QObjectList olist = ui->groupBox_Command->children();
QObjectList olist = ui->tabWidget_Command->children();
foreach (QObject *obj, olist) {
CommandButton *btn = qobject_cast<CommandButton *>(obj);
@@ -302,22 +234,21 @@ void CommandUI::setCommandFile(QString File)
loadCommandJson(CommandFile);
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
//ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
return;
}
CommandButton *btn = new CommandButton(ui->groupBox_Command);
CommandButton *btn = new CommandButton(ui->tabWidget_Command);
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
btn->setFixedSize(CMDwidth,CMDheight);
btn->resize(m_width,m_height);
ui->gridLayout_Command->addWidget(btn,
info.toObject().find(_rowJsonKey).value().toInt(),
info.toObject().find(_columnJsonKey).value().toInt());
btn->move(info.toObject().find(_columnJsonKey).value().toInt() * (m_width + m_spacing) + m_spacing,
info.toObject().find(_rowJsonKey).value().toInt() * (m_height + m_spacing)+ m_spacing);
btn->setProperty("state",state::success);
btn->style()->unpolish(btn);
@@ -357,9 +288,9 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
CMD_version = json.value(_versionJsonKey).toInt();
qDebug() << "command version :" << CMD_version;
CMDwidth = json.value(_WidthJsonKey).toInt();
CMDheight = json.value(_HeightJsonKey).toInt();
m_width = json.value(_WidthJsonKey).toInt();
m_height = json.value(_HeightJsonKey).toInt();
m_spacing = json.value(_spacingJsonKey).toInt();
QJsonValue jsonValue = json.value(_CommandButtonJsonKey);
@@ -383,7 +314,7 @@ void CommandUI::setSecondConfirm(QVariant value)
{
if(value.toBool() == true)
{
QObjectList list = ui->groupBox_Command->children();
QObjectList list = ui->tabWidget_Command->children();
foreach (QObject *obj, list) {
CommandButton *btn = qobject_cast<CommandButton *>(obj);
@@ -424,7 +355,7 @@ void CommandUI::setSecondConfirm(QVariant value)
void CommandUI::setSecondValue(QVariant value)
{
QObjectList list = ui->groupBox_Command->children();
QObjectList list = ui->tabWidget_Command->children();
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
@@ -550,7 +481,6 @@ void CommandUI::on_commandClicked()
uint32_t dialogValue = info.toObject().find(_dialogJsonKey).value().toInt();
if(dialogValue != 0)
{
if(dialogValue == 1)
{
//根据这个comfirm 确定要输入的参数
@@ -623,7 +553,7 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
bool isFundSender = false;
QString string;
//找到消息的发送者
QObjectList list = ui->groupBox_Command->children();
QObjectList list = ui->tabWidget_Command->children();
if(command == m_command)
{
+7 -8
View File
@@ -56,8 +56,6 @@ public:
~CommandUI();
protected:
void closeEvent(QCloseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
void wheelEvent(QWheelEvent *e);
void mousePressEvent(QMouseEvent *event);
@@ -66,9 +64,6 @@ protected:
void loadCommandJson(const QString& jsonFilename);
public slots:
void setFloat(void);
void setFloatFlag(bool flag);
void commandAccepted(bool flag,uint16_t command,uint8_t result);
void missionConfirm(int seq);
@@ -92,6 +87,7 @@ signals:
*/
private slots:
void updateUI(void);
void on_commandClicked();
@@ -116,14 +112,16 @@ private:
static const char* _commentJsonKey;
static const char* _CommandButtonJsonKey;
static const char* _spacingJsonKey;
static const char* _WidthJsonKey;
static const char* _HeightJsonKey;
static const char* _dialogJsonKey;
static const char* _TextJsonKey;
static const char* _rowJsonKey;
static const char* _columnJsonKey;
static const char* _pageJsonKey;
static const char* _noticeJsonKey;
static const char* _param1JsonKey;
static const char* _param2JsonKey;
@@ -137,8 +135,9 @@ private:
QJsonArray CMD_infoArray;
int CMDwidth = 60;
int CMDheight = 60;
int m_spacing = 5;
int m_width = 75;
int m_height = 30;
int CMD_version = 0;
+9 -47
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>418</width>
<height>490</height>
<height>348</height>
</rect>
</property>
<property name="windowTitle">
@@ -81,53 +81,15 @@
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_Command">
<property name="title">
<string>Command</string>
<widget class="QTabWidget" name="tabWidget_Command">
<property name="currentIndex">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_Command"/>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>BaseCommand</string>
</attribute>
</widget>
</widget>
</item>
</layout>
+64 -6
View File
@@ -1,4 +1,4 @@
#include "MenuBarUI.h"
#include "MenuBarUI.h"
#include "ui_MenuBarUI.h"
@@ -16,15 +16,28 @@ MenuBarUI::MenuBarUI(QWidget *parent) :
this->setStyleSheet(stylesheet);
file.close();
timeRecord = new QDateTime();
timeRecord->setTime(QDateTime::currentDateTime().time());
qDebug() << "time" << timeRecord->time();
ui->label_RecordTime->setText("00:00:00");
recordTimer = new QTimer(this);
recordTimer->setInterval(1000);
connect(recordTimer,SIGNAL(timeout()),
this,SLOT(RecordTimeOut()));
MessageTimer = new QTimer(this);
connect(MessageTimer,SIGNAL(timeout()),
this,SLOT(MessageTimeOut()));
showMessage(tr("Starting...\n"),5000);
@@ -37,6 +50,7 @@ MenuBarUI::MenuBarUI(QWidget *parent) :
//setArm(true);
}
MenuBarUI::~MenuBarUI()
@@ -202,9 +216,53 @@ void MenuBarUI::MessageTimeOut(void)
}
void MenuBarUI::RecordTimeOut(void)
{
ui->label_RecordTime->setText(QTime::fromMSecsSinceStartOfDay(timeRecord->time().msecsTo(QDateTime::currentDateTime().time())).toString("HH:mm:ss"));
}
void MenuBarUI::setTargetPoint(int Value)
{
ui->label_TargetPoint->setText(QString::number(Value,'f',0));
}
void MenuBarUI::setTargetAlt(float Value)
{
ui->label_TargteAlt->setText(QString::number(Value,'f',1));
}
void MenuBarUI::setX(float Value)
{
ui->label_X->setText(QString::number(Value,'f',1));
}
void MenuBarUI::setHeading(float Value)
{
ui->label_Heading->setText(QString::number(Value,'f',1));
}
void MenuBarUI::setTagetAirspeed(float Value)
{
ui->label_TargetAirSpeed->setText(QString::number(Value,'f',1));
}
void MenuBarUI::setArm(bool Value)//解锁
{
if(Value)
{
timeRecord->setTime(QDateTime::currentDateTime().time());
if(recordTimer->isActive())
{
recordTimer->stop();
}
recordTimer->start();
}
else
{
recordTimer->stop();
}
}
+19 -1
View File
@@ -1,4 +1,4 @@
#ifndef MENUBARUI_H
#ifndef MENUBARUI_H
#define MENUBARUI_H
#include <QWidget>
@@ -10,6 +10,7 @@
#include <QBitmap>
#include "QTimer"
#include "QDateTime"
#include <QCommonStyle>
#include "QStyle"
@@ -41,6 +42,15 @@ public slots:
void showMessage(const QString &message,int TimeOut = 0);
void clearMessage();
void setTargetPoint(int Value);
void setTargetAlt(float Value);
void setX(float Value);
void setHeading(float Value);
void setTagetAirspeed(float Value);
void setArm(bool Value);
signals:
void IndexChanged(int);
@@ -52,6 +62,10 @@ private slots:
void onClicked(void);
void MessageTimeOut(void);
void RecordTimeOut(void);
void on_pushButton_Setting_clicked();
@@ -71,6 +85,10 @@ private:
QTimer *MessageTimer = nullptr;
QTimer *recordTimer = nullptr;
QDateTime *timeRecord = nullptr;
};
#endif // MENUBARUI_H
+7 -2
View File
@@ -1,4 +1,4 @@
.QWidget {
@@ -10,7 +10,7 @@
}
.QLabel {
.QLabel#label_Status{
background-color: white;
background-attachment: scroll;
@@ -26,6 +26,11 @@
}
.QLabel{
font :20px;
font-weight:bold;
}
.QPushButton[state="0"]{
font :20px;
+158 -2
View File
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>858</width>
<width>1074</width>
<height>85</height>
</rect>
</property>
@@ -59,10 +59,166 @@
<item row="0" column="0">
<widget class="QLabel" name="label_Status">
<property name="text">
<string>TextLabel</string>
<string>0</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QFrame" name="frame_2">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>340</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QLabel" name="label_Heading">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_X">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>目标空速</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>侧偏距</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>方位</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>目标高度</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>目标航点</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_TargteAlt">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_RecordTime">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_TargetPoint">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_TargetAirSpeed">
<property name="styleSheet">
<string notr="true">background-color: rgb(189, 189, 189);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>飞行时间</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
+1262 -1249
View File
File diff suppressed because it is too large Load Diff
+7
View File
@@ -8,6 +8,13 @@ Diagram::Diagram(QWidget *parent) :
ui->setupUi(this);
m_parent = parent;
QFile file(":/qss/PowerSystem.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
int w = 60;
int h = 25;
+57 -2
View File
@@ -95,6 +95,9 @@ MainWindow::MainWindow(QWidget *parent)
statusui->hide();
healthui = new HealthUI(this);
healthui->hide();
//指令
commandUI = new CommandUI(this);
@@ -319,6 +322,11 @@ MainWindow::MainWindow(QWidget *parent)
connect(dlink->mavlinknode->Mission,SIGNAL(currentPoint(int)),
map,SLOT(WPSetCurrent(int)),Qt::DirectConnection);
connect(dlink->mavlinknode->Mission,SIGNAL(currentPoint(int)),
menuBarUI,SLOT(setTargetPoint(int)),Qt::DirectConnection);
//==== showmessage=====
connect(toolsui->command,SIGNAL(showMessage(QString,int)),this,SLOT(showMessage(QString,int)));
connect(commandUI,SIGNAL(showMessage(QString,int)),this,SLOT(showMessage(QString,int)));
@@ -424,9 +432,16 @@ void MainWindow::resizeEvent(QResizeEvent *event)
if(!healthui->isHidden())
{
commandUI->setGeometry(this->width() - copk->width(),menuBarUI->height() + copk->height() + healthui->height(),
copk->width(),this->height() - menuBarUI->height() - copk->height() - healthui->height());
}
else
{
commandUI->setGeometry(this->width() - copk->width(),menuBarUI->height() + copk->height(),
copk->width(),this->height() - menuBarUI->height() - copk->height());
}
toolsui->setGeometry(0,menuBarUI->height(),
@@ -438,7 +453,20 @@ void MainWindow::resizeEvent(QResizeEvent *event)
//这个是不必要的,因为每个部件都有自己相应的动作
void MainWindow::mousePressEvent(QMouseEvent* event)
{
Q_UNUSED(event)
if(event->buttons() == Qt::MiddleButton)
{
if(!healthui->isHidden())
{
healthui->hide();
}
else
{
healthui->show();
}
}
resizeEvent(nullptr);
}
void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
@@ -839,7 +867,17 @@ void MainWindow::updateUI()//事件驱动式更新数据
//解锁后清除航迹
if(state == MAV_MODE_FLAG::MAV_MODE_FLAG_SAFETY_ARMED)
{
if(menuBarUI)
menuBarUI->setArm(true);
map->DeleteTrail();
StartPoint = map->CurrentPosition();
}
else
{
if(menuBarUI)
menuBarUI->setArm(false);
}
}
else
@@ -972,6 +1010,23 @@ void MainWindow::updateUI()//事件驱动式更新数据
dlink->mavlinknode->vehicle.attitude.yaw * 57.3);
menuBarUI->setTargetAlt(dlink->mavlinknode->vehicle.gps_raw_int.alt * 10e-4
+dlink->mavlinknode->vehicle.nav_controller_output.alt_error);
menuBarUI->setX(dlink->mavlinknode->vehicle.nav_controller_output.xtrack_error);
//menuBarUI->setHeading(internals::PureProjection::courseBetweenLatLng(StartPoint,map->CurrentPosition()));
menuBarUI->setTagetAirspeed(dlink->mavlinknode->vehicle.emb_atom_com.Airspeed
+dlink->mavlinknode->vehicle.nav_controller_output.aspd_error);
/*
if(MainIndex == 3)//飞行界面
{
+6
View File
@@ -23,6 +23,8 @@
#include "InspectUI/InspectUI.h"
#include "ToolsUI/ToolsUI.h"
#include "HealthUI/HealthUI.h"
#include "pureprojection.h"
//sub widget
#include "About/About.h"
#include "Help/Help.h"
@@ -30,6 +32,7 @@
#include "QTextToSpeech"
//cmd ui
#include "QQuickWidget"
#include "QQuickView"
@@ -127,6 +130,9 @@ protected:
bool isCommunicationLost = true;
internals::PointLatLng StartPoint;
};
#endif // MAINWINDOW_H