From 4a80eb319206c71203b52e6b945312d4acd4a2d3 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Thu, 29 Sep 2011 11:06:30 +0200 Subject: [PATCH] implemented GUI for the future "View" tab --- qgroundcontrol.pro | 9 +- src/Waypoint.cc | 2 +- src/ui/WaypointList.cc | 4 +- src/ui/WaypointList.ui | 439 +++++++++++++++++++-------------- src/ui/WaypointViewViewOnly.cc | 158 ++++++++++++ src/ui/WaypointViewViewOnly.h | 37 +++ src/ui/WaypointViewViewOnly.ui | 244 ++++++++++++++++++ 7 files changed, 706 insertions(+), 187 deletions(-) create mode 100644 src/ui/WaypointViewViewOnly.cc create mode 100644 src/ui/WaypointViewViewOnly.h create mode 100644 src/ui/WaypointViewViewOnly.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 2fc7577b29..78919616d5 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -209,7 +209,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/mission/QGCMissionConditionWidget.ui \ src/ui/map/QGCMapTool.ui \ src/ui/map/QGCMapToolBar.ui \ - src/ui/QGCMAVLinkInspector.ui + src/ui/QGCMAVLinkInspector.ui \ + src/ui/WaypointViewViewOnly.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -323,7 +324,8 @@ HEADERS += src/MG.h \ src/QGCGeo.h \ src/ui/QGCToolBar.h \ src/ui/QGCMAVLinkInspector.h \ - src/ui/MAVLinkDecoder.h + src/ui/MAVLinkDecoder.h \ + src/ui/WaypointViewViewOnly.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|win32-msvc2008|win32-msvc2010::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -449,7 +451,8 @@ SOURCES += src/main.cc \ src/ui/map/QGCMapToolBar.cc \ src/ui/QGCToolBar.cc \ src/ui/QGCMAVLinkInspector.cc \ - src/ui/MAVLinkDecoder.cc + src/ui/MAVLinkDecoder.cc \ + src/ui/WaypointViewViewOnly.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|win32-msvc2008|win32-msvc2010::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/Waypoint.cc b/src/Waypoint.cc index 93cd17a6d9..1f42cd364c 100644 --- a/src/Waypoint.cc +++ b/src/Waypoint.cc @@ -206,7 +206,7 @@ void Waypoint::setFrame(MAV_FRAME frame) void Waypoint::setAutocontinue(bool autoContinue) { - if (this->autocontinue != autocontinue) { + if (this->autocontinue != autoContinue) { this->autocontinue = autoContinue; emit changed(this); } diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index b2ff8cd891..4eee0d1e92 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -51,11 +51,11 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) : { m_ui->setupUi(this); - listLayout = new QVBoxLayout(m_ui->listWidget); + listLayout = new QVBoxLayout(m_ui->editableListWidget); listLayout->setSpacing(0); listLayout->setMargin(0); listLayout->setAlignment(Qt::AlignTop); - m_ui->listWidget->setLayout(listLayout); + m_ui->editableListWidget->setLayout(listLayout); // ADD WAYPOINT // Connect add action, set right button icon and connect action to this class diff --git a/src/ui/WaypointList.ui b/src/ui/WaypointList.ui index 7c9784276f..8791277c3a 100644 --- a/src/ui/WaypointList.ui +++ b/src/ui/WaypointList.ui @@ -6,8 +6,8 @@ 0 0 - 798 - 218 + 854 + 398 @@ -19,44 +19,266 @@ Form - - - 4 - - - 4 - - - - - true - - - - - 0 - 0 - 786 - 174 - - - - - 0 - - - 4 - - - + + + + + 0 + + + + Tab 1 + + + + + + true + + + + + 0 + 0 + 812 + 271 + + + + + 0 + + + 4 + + + + + Waypoint list. The list is empty until you issue a read command or add waypoints. + + + Waypoint list. The list is empty until you issue a read command or add waypoints. + + + Waypoint list. The list is empty until you issue a read command or add waypoints. + + + + + + + + + + + Save waypoints to a file on the local harddisk. Does not save them on the MAV. + + + Save waypoints to a file on the local harddisk. Does not save them on the MAV. + + + Save waypoints to a file on the local harddisk. Does not save them on the MAV. + + + Save WPs + + + + + + + Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. + + + Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. + + + Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. + + + Load WPs + + + + + + + Qt::Horizontal + + + + 127 + 20 + + + + + + - Waypoint list. The list is empty until you issue a read command or add waypoints. + Set the current vehicle position as new waypoint - Waypoint list. The list is empty until you issue a read command or add waypoints. + Set the current vehicle position as new waypoint - Waypoint list. The list is empty until you issue a read command or add waypoints. + Set the current vehicle position as new waypoint + + + ... + + + + :/images/actions/go-bottom.svg:/images/actions/go-bottom.svg + + + + + + + Add a new waypoint to this list. Transmit via write to the MAV. + + + Add a new waypoint to this list. Transmit via write to the MAV. + + + Add a new waypoint to this list. Transmit via write to the MAV. + + + ... + + + + :/images/actions/list-add.svg:/images/actions/list-add.svg + + + + + + + Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. + + + Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. + + + Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. + + + ... + + + + :/images/actions/process-stop.svg:/images/actions/process-stop.svg + + + + + + + Read all waypoints from the MAV. Clears the list on this computer. + + + Read all waypoints from the MAV. Clears the list on this computer. + + + Read all waypoints from the MAV. Clears the list on this computer. + + + Read + + + + :/images/status/software-update-available.svg:/images/status/software-update-available.svg + + + + + + + Transmit all waypoints on this list to the MAV. + + + Transmit all waypoints on this list to the MAV. + + + Transmit all waypoints on this list to the MAV. + + + Write + + + + :/images/devices/network-wireless.svg:/images/devices/network-wireless.svg + + + + + + + + Tab 2 + + + + + + true + + + + + 0 + 0 + 812 + 271 + + + + true + + + + + + true + + + + + + + + + + + Qt::Horizontal + + + + 714 + 20 + + + + + + + + Read all waypoints from the MAV and display in View tab.. + + + Read all waypoints from the MAV and display in View tab.. + + + Read all waypoints from the MAV and display in View tab. + + + Refresh + + + + :/images/actions/go-jump.svg:/images/actions/go-jump.svg @@ -64,152 +286,7 @@ - - - - Read all waypoints from the MAV. Clears the list on this computer. - - - Read all waypoints from the MAV. Clears the list on this computer. - - - Read all waypoints from the MAV. Clears the list on this computer. - - - Read - - - - :/images/status/software-update-available.svg:/images/status/software-update-available.svg - - - - - - - Transmit all waypoints on this list to the MAV. - - - Transmit all waypoints on this list to the MAV. - - - Transmit all waypoints on this list to the MAV. - - - Write - - - - :/images/devices/network-wireless.svg:/images/devices/network-wireless.svg - - - - - - - Add a new waypoint to this list. Transmit via write to the MAV. - - - Add a new waypoint to this list. Transmit via write to the MAV. - - - Add a new waypoint to this list. Transmit via write to the MAV. - - - ... - - - - :/images/actions/list-add.svg:/images/actions/list-add.svg - - - - - - - Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. - - - Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. - - - Load waypoints from a file on the local harddisk. Does not load the waypoints on the MAV. - - - Load WPs - - - - - - - Save waypoints to a file on the local harddisk. Does not save them on the MAV. - - - Save waypoints to a file on the local harddisk. Does not save them on the MAV. - - - Save waypoints to a file on the local harddisk. Does not save them on the MAV. - - - Save WPs - - - - - - - Qt::Horizontal - - - - 127 - 20 - - - - - - - - Set the current vehicle position as new waypoint - - - Set the current vehicle position as new waypoint - - - Set the current vehicle position as new waypoint - - - ... - - - - :/images/actions/go-bottom.svg:/images/actions/go-bottom.svg - - - - - - - Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. - - - Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. - - - Delete all waypoints from this list. You have to click write to clear the list on the MAV as well. - - - ... - - - - :/images/actions/process-stop.svg:/images/actions/process-stop.svg - - - - + The current waypoint transmission status diff --git a/src/ui/WaypointViewViewOnly.cc b/src/ui/WaypointViewViewOnly.cc new file mode 100644 index 0000000000..3f9ddad155 --- /dev/null +++ b/src/ui/WaypointViewViewOnly.cc @@ -0,0 +1,158 @@ +#include +#include "WaypointViewViewOnly.h" +#include "ui_WaypointViewViewOnly.h" + +WaypointViewViewOnly::WaypointViewViewOnly(Waypoint* wp, QWidget *parent) : + QWidget(parent), + m_ui(new Ui::WaypointViewViewOnly) +{ + m_ui->setupUi(this); + this->wp = wp; + updateValues(); + + connect(m_ui->current, SIGNAL(stateChanged(int)), this, SLOT(changedCurrent(int))); + connect(m_ui->autoContinue, SIGNAL(stateChanged(int)),this, SLOT(changedAutoContinue(int))); +} + +void WaypointViewViewOnly::changedAutoContinue(int state) +{ + bool new_value = false; + if (state != 0) + { + new_value = true; + } + m_ui->autoContinue->blockSignals(true); + m_ui->autoContinue->setChecked(state); + m_ui->autoContinue->blockSignals(false); + wp->setAutocontinue(new_value); + emit changeAutoContinue(wp->getId(),new_value); + } + +void WaypointViewViewOnly::changedCurrent(int state) +{ + qDebug() << "Trof: WaypointViewViewOnly::changedCurrent(" << state << ") ID:" << wp->getId(); + + if (state == 0) + { + if (wp->getCurrent() == true) //User clicked on the waypoint, that is already current + { + m_ui->current->setChecked(true); + m_ui->current->setCheckState(Qt::Checked); + } + else + { + m_ui->current->setChecked(false); + m_ui->current->setCheckState(Qt::Unchecked); + wp->setCurrent(false); + } + } + else + { + wp->setCurrent(true); + emit changeCurrentWaypoint(wp->getId()); //the slot changeCurrentWaypoint() in WaypointList sets all other current flags to false + } +} + +void WaypointViewViewOnly::setCurrent(bool state) +{ + m_ui->current->blockSignals(true); + m_ui->current->setChecked(state); + m_ui->current->blockSignals(false); +} + +void WaypointViewViewOnly::updateValues() +{ + qDebug() << "Trof: WaypointViewViewOnly::updateValues() ID:" << wp->getId(); + // Check if we just lost the wp, delete the widget + // accordingly + if (!wp) + { + deleteLater(); + return; + } + // Deactivate signals from the WP + wp->blockSignals(true); + // update frame + + m_ui->idLabel->setText(QString("%1").arg(wp->getId())); + + if (m_ui->current->isChecked() != wp->getCurrent()) + { + m_ui->current->setChecked(wp->getCurrent()); + } + if (m_ui->autoContinue->isChecked() != wp->getAutoContinue()) + { + m_ui->autoContinue->setChecked(wp->getAutoContinue()); + } + +switch (wp->getAction()) +{ +case MAV_CMD_NAV_WAYPOINT: + { + if (wp->getParam1()>0) + { + m_ui->displayBar->setText(QString("Go to (%1, %2, %3) and wait there for %4 sec; yaw: %5; rad: %6").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam1()).arg(wp->getParam4()).arg(wp->getParam2())); + } + else + { + m_ui->displayBar->setText(QString("Go to (%1, %2, %3); yaw: %4; rad: %5").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4()).arg(wp->getParam2())); + } + break; + } +case MAV_CMD_NAV_LAND: + { + m_ui->displayBar->setText(QString("LAND. Go to (%1, %2, %3) and descent; yaw: %4").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4())); + break; + } +case MAV_CMD_NAV_TAKEOFF: + { + m_ui->displayBar->setText(QString("TAKEOFF. Go to (%1, %2, %3); yaw: %4").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4())); + break; + } +case MAV_CMD_DO_JUMP: + { + if (wp->getParam2()>0) + { + m_ui->displayBar->setText(QString("Jump to waypoint %1. Jumps left: %2").arg(wp->getParam1()).arg(wp->getParam2())); + } + else + { + m_ui->displayBar->setText(QString("No jumps left. Proceed to next waypoint.")); + } + break; + } +case MAV_CMD_CONDITION_DELAY: + { + m_ui->displayBar->setText(QString("Delay: %1 sec").arg(wp->getParam1())); + break; + } +case 237: //MAV_CMD_DO_START_SEARCH + { + m_ui->displayBar->setText(QString("Start searching for pattern. Success when got more than %2 detections with confidence %1").arg(wp->getParam1()).arg(wp->getParam2())); + break; + } +case 238: //MAV_CMD_DO_FINISH_SEARCH + { + m_ui->displayBar->setText(QString("Check if search was successful. yes -> jump to %1, no -> jump to %2. Jumps left: %3").arg(wp->getParam1()).arg(wp->getParam2()).arg(wp->getParam3())); + break; + } +case 240: //MAV_CMD_DO_SWEEP + { + m_ui->displayBar->setText(QString("Sweep. Corners: (%1,%2) and (%3,%4); z: %5; scan radius: %6").arg(wp->getParam3()).arg(wp->getParam4()).arg(wp->getParam5()).arg(wp->getParam6()).arg(wp->getParam7()).arg(wp->getParam1())); + break; + } +default: + { + m_ui->displayBar->setText(QString("Unknown Command ID (%1) : %2, %3, %4, %5, %6, %7, %8").arg(wp->getAction()).arg(wp->getParam1()).arg(wp->getParam2()).arg(wp->getParam3()).arg(wp->getParam4()).arg(wp->getParam5()).arg(wp->getParam6()).arg(wp->getParam7())); + break; + } +} + + + wp->blockSignals(false); +} + +WaypointViewViewOnly::~WaypointViewViewOnly() +{ + delete m_ui; +} diff --git a/src/ui/WaypointViewViewOnly.h b/src/ui/WaypointViewViewOnly.h new file mode 100644 index 0000000000..36475f9c39 --- /dev/null +++ b/src/ui/WaypointViewViewOnly.h @@ -0,0 +1,37 @@ +#ifndef WAYPOINTVIEWVIEWONLY_H +#define WAYPOINTVIEWVIEWONLY_H + +#include +#include "Waypoint.h" +#include + +namespace Ui { + class WaypointViewViewOnly; +} + +class WaypointViewViewOnly : public QWidget +{ + Q_OBJECT + +public: + explicit WaypointViewViewOnly(Waypoint* wp, QWidget *parent = 0); + ~WaypointViewViewOnly(); + +public slots: +void changedCurrent(int state); +void changedAutoContinue(int state); +void updateValues(void); +void setCurrent(bool state); + +signals: + void changeCurrentWaypoint(quint16); + void changeAutoContinue(quint16, bool); + +protected: +Waypoint* wp; + +private: + Ui::WaypointViewViewOnly *m_ui; +}; + +#endif // WAYPOINTVIEWVIEWONLY_H diff --git a/src/ui/WaypointViewViewOnly.ui b/src/ui/WaypointViewViewOnly.ui new file mode 100644 index 0000000000..b3cc426429 --- /dev/null +++ b/src/ui/WaypointViewViewOnly.ui @@ -0,0 +1,244 @@ + + + WaypointViewViewOnly + + + + 0 + 0 + 381 + 55 + + + + + 0 + 0 + + + + Form + + + QWidget#colorIcon {} + +QWidget { +background-color: #252528; +color: #DDDDDF; +border-color: #EEEEEE; +background-clip: border; +} + +QCheckBox { +background-color: #252528; +color: #454545; +} + +QGroupBox { + border: 1px solid #EEEEEE; + border-radius: 5px; + padding: 0px 0px 0px 0px; +margin-top: 1ex; /* leave space at the top for the title */ + margin: 0px; +} + + QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top center; /* position at the top center */ + margin: 0 3px 0px 3px; + padding: 0 3px 0px 0px; + font: bold 8px; + } + +QGroupBox#heartbeatIcon { + background-color: red; +} + + QDockWidget { + font: bold; + border: 1px solid #32345E; +} + +QPushButton { + font-weight: bold; + font-size: 12px; + border: 1px solid #999999; + border-radius: 10px; + min-width:22px; + max-width: 36px; + min-height: 16px; + max-height: 16px; + padding: 2px; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777777, stop: 1 #555555); +} + +QPushButton:pressed { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #555555); +} + +QPushButton#landButton { + color: #000000; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #ffee01, stop:1 #ae8f00) url("ICONDIR/control/emergency-button.png"); +} + +QPushButton:pressed#landButton { + color: #000000; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #bbaa00, stop:1 #a05b00) url("ICONDIR/control/emergency-button.png"); +} + +QPushButton#killButton { + color: #000000; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #ffb917, stop:1 #b37300) url("ICONDIR/control/emergency-button.png"); +} + +QPushButton:pressed#killButton { + color: #000000; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 #bb8500, stop:1 #903000) url("ICONDIR/control/emergency-button.png"); +} + +QProgressBar { + border: 1px solid white; + border-radius: 4px; + text-align: center; + padding: 2px; + color: white; + background-color: #111111; +} + +QProgressBar:horizontal { + height: 12px; +} + +QProgressBar QLabel { + font-size: 8px; +} + +QProgressBar:vertical { + width: 12px; +} + +QProgressBar::chunk { + background-color: #656565; +} + +QProgressBar::chunk#batteryBar { + background-color: green; +} + +QProgressBar::chunk#speedBar { + background-color: yellow; +} + +QProgressBar::chunk#thrustBar { + background-color: orange; +} + + + + 2 + + + 0 + + + 2 + + + 0 + + + + + true + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + false + + + + 2 + + + 2 + + + + + Currently executed waypoint + + + Currently executed waypoint + + + + + + + + + + ID + + + + + + + + 0 + 0 + + + + + 16777215 + 31 + + + + + 8 + + + + QFrame::NoFrame + + + QFrame::Sunken + + + + + + + Automatically continue after this waypoint + + + Automatically continue after this waypoint + + + + + + + + + + + + + + -- GitLab