From 62d953650f2063ddc215880979574809cbe41ced Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 5 Oct 2015 09:13:06 -0700 Subject: [PATCH] Replaced by toolbar dropdowns --- src/ui/UASControl.ui | 262 ------------- src/ui/UASList.ui | 33 -- src/ui/UASView.ui | 626 ------------------------------ src/ui/uas/UASControlWidget.cc | 194 --------- src/ui/uas/UASControlWidget.h | 84 ---- src/ui/uas/UASListWidget.cc | 260 ------------- src/ui/uas/UASListWidget.h | 78 ---- src/ui/uas/UASView.cc | 690 --------------------------------- src/ui/uas/UASView.h | 156 -------- 9 files changed, 2383 deletions(-) delete mode 100644 src/ui/UASControl.ui delete mode 100644 src/ui/UASList.ui delete mode 100644 src/ui/UASView.ui delete mode 100644 src/ui/uas/UASControlWidget.cc delete mode 100644 src/ui/uas/UASControlWidget.h delete mode 100644 src/ui/uas/UASListWidget.cc delete mode 100644 src/ui/uas/UASListWidget.h delete mode 100644 src/ui/uas/UASView.cc delete mode 100644 src/ui/uas/UASView.h diff --git a/src/ui/UASControl.ui b/src/ui/UASControl.ui deleted file mode 100644 index 446e3313a..000000000 --- a/src/ui/UASControl.ui +++ /dev/null @@ -1,262 +0,0 @@ - - - uasControl - - - - 0 - 0 - 200 - 228 - - - - - 0 - 0 - - - - - 200 - 150 - - - - - 267 - 16777215 - - - - Form - - - Control widget to send basic control actions to the micro air vehicle - - - - 4 - - - - - Qt::Horizontal - - - - 31 - 159 - - - - - - - - - 0 - 10 - - - - Currently controlled system - - - Currently controlled system - - - UNCONNECTED - - - Qt::AlignCenter - - - 0 - - - - - - - Qt::Vertical - - - - 216 - 17 - - - - - - - - 6 - - - - - - 25 - 16 - - - - Liftoff / Launch - - - Liftoff / Launch - - - Start - - - - - - - - 25 - 16 - - - - Fly straight to landing spot - - - Fly straight to landing spot - - - Land - - - - - - - - 25 - 16 - - - - Only active on the ground: Poweroff system - - - Only active on the ground: Poweroff system - - - Halt - - - - - - - - - - 25 - 16 - - - - Select MAV operation mode - - - Select MAV operation mode - - - - - - - - 25 - 16 - - - - Transmit and enable mode on MAV - - - Transmit and enable mode on MAV - - - Set - - - - - - - - 0 - 10 - - - - Status label - - - Status label - - - No actions executed so far - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Horizontal - - - - 30 - 159 - - - - - - - - - 0 - 30 - - - - Main control button - - - Main control button - - - Activate Engine - - - - - - - Qt::Vertical - - - - 20 - 5 - - - - - - - - - diff --git a/src/ui/UASList.ui b/src/ui/UASList.ui deleted file mode 100644 index 6e85444fc..000000000 --- a/src/ui/UASList.ui +++ /dev/null @@ -1,33 +0,0 @@ - - - UASList - - - - 0 - 0 - 500 - 300 - - - - - 0 - 0 - - - - Form - - - - 6 - - - 3 - - - - - - diff --git a/src/ui/UASView.ui b/src/ui/UASView.ui deleted file mode 100644 index c7a35466d..000000000 --- a/src/ui/UASView.ui +++ /dev/null @@ -1,626 +0,0 @@ - - - UASView - - - - 0 - 0 - 360 - 155 - - - - - 0 - 0 - - - - - 260 - 0 - - - - - 360 - 16777215 - - - - Form - - - - - - - 5 - - - - - 0 - - - - - 0 - - - - - System type - - - System type - - - System type - - - - - - :/res/mavs/Unknown - - - - - - - 0 - - - - - Heartbeat - - - - - - - - - - - 18 - 0 - - - - - 18 - 40 - - - - - - - Battery Fuel - - - Battery Fuel - - - 0 - - - false - - - Qt::Vertical - - - - - - - - - - - 2 - - - 0 - - - - - - 50 - false - false - - - - Current Waypoint - - - Current Waypoint - - - --- - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 26 - 22 - - - - - 38 - 22 - - - - Liftoff / Launch - - - Liftoff / Launch - - - - - - - :/res/Launch:/res/Launch - - - - - - - - 0 - 0 - - - - - 26 - 22 - - - - - 38 - 22 - - - - Emergency land system at closest possible site - - - Emergency land system at closest possible site - - - - - - - :/res/Stop:/res/Stop - - - - - - - - 26 - 22 - - - - - 38 - 22 - - - - Loiter / Wait at current position - - - Loiter / Wait at current position - - - - - - - :/res/Pause:/res/Pause - - - - - - - - 26 - 22 - - - - - 38 - 22 - - - - Continue flightplan - - - Continue flightplan - - - - - - - :/res/Play:/res/Play - - - - - - - - 26 - 22 - - - - - 38 - 22 - - - - Fly straight to landing location - - - Fly straight to landing location - - - - - - - :/res/Land:/res/Land - - - - - - - - 26 - 22 - - - - - 38 - 22 - - - - Kill immediately all onboard power - - - Kill immediately all onboard power - - - - - - - :/res/Kill:/res/Kill - - - - - - - - 38 - 22 - - - - Only in standby mode: Power off system - - - Only in standby mode: Power off system - - - - - - - :/res/Shutdown:/res/Shutdown - - - - - - - 4 - - - QLayout::SetMinimumSize - - - - - - - - - - - - 16777215 - 16 - - - - - 75 - false - true - - - - System Name - - - System Name - - - UAS001 - - - - - - - - - - 50 - false - false - - - - Remaining flight time - - - Remaining flight time - - - 00:00:00 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 50 - false - false - - - - Uptime - - - Uptime - - - 00:00:00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 50 - false - false - - - - Altitude - - - Altitude - - - 00.00 m - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 50 - false - false - - - - Ground Speed - - - Ground Speed - - - 00.0 m/s - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - 16777215 - 12 - - - - - 50 - false - false - - - - STATE - - - - - - - - - - - - 16777215 - 16 - - - - - 50 - false - false - - - - MODE - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 0 - 12 - - - - - 16777215 - 12 - - - - - 50 - false - false - - - - Current Position - - - Current Position - - - 00.0 00.0 00.0 m - - - - - - - - - - Current throttle - - - Current throttle - - - 0 - - - throttle %p% - - - - - - - - 50 - false - false - - - - NAV - - - - - - - - - - - Waiting for first status update.. - - - - - - - - - - diff --git a/src/ui/uas/UASControlWidget.cc b/src/ui/uas/UASControlWidget.cc deleted file mode 100644 index 668da4bfe..000000000 --- a/src/ui/uas/UASControlWidget.cc +++ /dev/null @@ -1,194 +0,0 @@ -/*===================================================================== - -PIXHAWK Micro Air Vehicle Flying Robotics Toolkit - -(c) 2009, 2010 PIXHAWK PROJECT - -This file is part of the PIXHAWK project - - PIXHAWK is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - PIXHAWK is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PIXHAWK. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Definition of widget controlling one MAV - * - * @author Lorenz Meier - * - */ - -#include -#include -#include -#include -#include - -#include "UASControlWidget.h" -#include "MultiVehicleManager.h" -#include "UAS.h" -#include "QGC.h" -#include "AutoPilotPluginManager.h" -#include "FirmwarePluginManager.h" - -UASControlWidget::UASControlWidget(QWidget *parent) : QWidget(parent), - _uas(NULL), - armed(false) -{ - ui.setupUi(this); - - _activeVehicleChanged(MultiVehicleManager::instance()->activeVehicle()); - - connect(MultiVehicleManager::instance(), &MultiVehicleManager::activeVehicleChanged, this, &UASControlWidget::_activeVehicleChanged); - connect(ui.setModeButton, SIGNAL(clicked()), this, SLOT(transmitMode())); - - ui.liftoffButton->hide(); - ui.landButton->hide(); - ui.shutdownButton->hide(); - - ui.gridLayout->setAlignment(Qt::AlignTop); -} - -void UASControlWidget::updateModesList() -{ - if (!_uas) { - return; - } - _modeList = FirmwarePluginManager::instance()->firmwarePluginForAutopilot((MAV_AUTOPILOT)_uas->getAutopilotType())->flightModes(); - - // Set combobox items - ui.modeComboBox->clear(); - foreach (QString flightMode, _modeList) { - ui.modeComboBox->addItem(flightMode); - } - - // Select first mode in list - ui.modeComboBox->setCurrentIndex(0); - ui.modeComboBox->update(); -} - -void UASControlWidget::_activeVehicleChanged(Vehicle* vehicle) -{ - if (_uas) { - disconnect(ui.controlButton, SIGNAL(clicked()), _uas, SLOT(armSystem())); - disconnect(ui.liftoffButton, SIGNAL(clicked()), _uas, SLOT(launch())); - disconnect(ui.landButton, SIGNAL(clicked()), _uas, SLOT(home())); - disconnect(ui.shutdownButton, SIGNAL(clicked()), _uas, SLOT(shutdown())); - disconnect(_uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int))); - _uas = NULL; - } - - // Connect user interface controls - if (vehicle) { - _uas = vehicle->uas(); - connect(ui.controlButton, SIGNAL(clicked()), this, SLOT(cycleContextButton())); - connect(ui.liftoffButton, SIGNAL(clicked()), _uas, SLOT(launch())); - connect(ui.landButton, SIGNAL(clicked()), _uas, SLOT(home())); - connect(ui.shutdownButton, SIGNAL(clicked()), _uas, SLOT(shutdown())); - connect(_uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int))); - - ui.controlStatusLabel->setText(tr("Connected to ") + _uas->getUASName()); - - setBackgroundColor(_uas->getColor()); - - this->updateModesList(); - this->updateArmText(); - } -} - -UASControlWidget::~UASControlWidget() -{ - -} - -void UASControlWidget::updateArmText() -{ - if (armed) { - ui.controlButton->setText(tr("DISARM SYSTEM")); - } else { - ui.controlButton->setText(tr("ARM SYSTEM")); - } -} - -/** - * Set the background color based on the MAV color. If the MAV is selected as the - * currently actively controlled system, the frame color is highlighted - */ -void UASControlWidget::setBackgroundColor(QColor color) -{ - // UAS color - QColor uasColor = color; - QString colorstyle; - QString borderColor = "#4A4A4F"; - borderColor = "#FA4A4F"; - uasColor = uasColor.darker(400); - colorstyle = colorstyle.sprintf("QLabel { border-radius: 3px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X; border: 0px solid %s; }", - uasColor.red(), uasColor.green(), uasColor.blue(), borderColor.toStdString().c_str()); - setStyleSheet(colorstyle); - QPalette palette = this->palette(); - palette.setBrush(QPalette::Window, QBrush(uasColor)); - setPalette(palette); - setAutoFillBackground(true); -} - - -void UASControlWidget::updateState(int state) -{ - switch (state) { - case (int)MAV_STATE_ACTIVE: - armed = true; - break; - case (int)MAV_STATE_STANDBY: - armed = false; - break; - } - this->updateArmText(); -} - -void UASControlWidget::transmitMode() -{ - if (_uas) { - uint8_t base_mode; - uint32_t custom_mode; - QString flightMode = ui.modeComboBox->itemText(ui.modeComboBox->currentIndex()); - - if (FirmwarePluginManager::instance()->firmwarePluginForAutopilot((MAV_AUTOPILOT)_uas->getAutopilotType())->setFlightMode(flightMode, &base_mode, &custom_mode)) { - if (armed) { - base_mode |= MAV_MODE_FLAG_SAFETY_ARMED; - } - - if (_uas->isHilEnabled() || _uas->isHilActive()) { - base_mode |= MAV_MODE_FLAG_HIL_ENABLED; - } - - _uas->setMode(base_mode, custom_mode); - QString modeText = ui.modeComboBox->currentText(); - - ui.lastActionLabel->setText(QString("Sent new mode %1 to %2").arg(flightMode).arg(_uas->getUASName())); - } - } -} - -void UASControlWidget::cycleContextButton() -{ - if (_uas) { - if (!armed) { - _uas->armSystem(); - ui.lastActionLabel->setText(QString("Arm %1").arg(_uas->getUASName())); - } else { - _uas->disarmSystem(); - ui.lastActionLabel->setText(QString("Disarm %1").arg(_uas->getUASName())); - } - } -} diff --git a/src/ui/uas/UASControlWidget.h b/src/ui/uas/UASControlWidget.h deleted file mode 100644 index aa19493fb..000000000 --- a/src/ui/uas/UASControlWidget.h +++ /dev/null @@ -1,84 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2010 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Definition of class UASControlWidget - * - * @author Lorenz Meier - * - */ - -#ifndef _UASCONTROLWIDGET_H_ -#define _UASCONTROLWIDGET_H_ - -#include -#include -#include -#include - -#include "ui_UASControl.h" -#include "UASInterface.h" -#include "Vehicle.h" - -/** - * @brief Widget controlling one MAV - */ -class UASControlWidget : public QWidget -{ - Q_OBJECT - -public: - UASControlWidget(QWidget *parent = 0); - ~UASControlWidget(); - -public slots: - /** @brief Update modes list for selected system */ - void updateModesList(); - /** @brief Trigger next context action */ - void cycleContextButton(); - /** @brief Transmit the operation mode */ - void transmitMode(); - /** @brief Update state */ - void updateState(int state); - /** @brief Update internal state machine */ - void updateArmText(); - -protected slots: - /** @brief Set the background color for the widget */ - void setBackgroundColor(QColor color); - -protected: - UAS* _uas; - QStringList _modeList; ///< Mode list for the current UAS - bool armed; ///< Engine state - -private slots: - void _activeVehicleChanged(Vehicle* vehicle); - -private: - Ui::uasControl ui; - -}; - -#endif // _UASCONTROLWIDGET_H_ diff --git a/src/ui/uas/UASListWidget.cc b/src/ui/uas/UASListWidget.cc deleted file mode 100644 index e7a8b028c..000000000 --- a/src/ui/uas/UASListWidget.cc +++ /dev/null @@ -1,260 +0,0 @@ -/*===================================================================== - -PIXHAWK Micro Air Vehicle Flying Robotics Toolkit - -(c) 2009, 2010 PIXHAWK PROJECT - -This file is part of the PIXHAWK project - - PIXHAWK is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - PIXHAWK is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PIXHAWK. If not, see . - -======================================================================*/ - -/** - * @file - * @brief List of unmanned vehicles - * @author Lorenz Meier - * - */ - -#include -#include -#include -#include -#include - -#include "MG.h" -#include "UASListWidget.h" -#include "MultiVehicleManager.h" -#include "UAS.h" -#include "UASView.h" -#include "QGCUnconnectedInfoWidget.h" -#include "MainWindow.h" -#include "LinkManager.h" - -UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), - uWidget(NULL), - m_ui(new Ui::UASList) -{ - // Use a timer to update the link health display. - updateTimer = new QTimer(this); - connect(updateTimer,SIGNAL(timeout()),this,SLOT(updateStatus())); - - m_ui->setupUi(this); - m_ui->verticalLayout->setAlignment(Qt::AlignTop); - - this->setMinimumWidth(262); - - linkToBoxMapping = QMap(); - uasToBoxMapping = QMap(); - uasViews = QMap(); - - this->setVisible(false); - - connect(LinkManager::instance(), SIGNAL(linkDeleted(LinkInterface*)), this, SLOT(removeLink(LinkInterface*))); - - connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &UASListWidget::_vehicleAdded); - connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleRemoved, this, &UASListWidget::_vehicleRemoved); - - // Get a list of all existing UAS - foreach (Vehicle* vehicle, MultiVehicleManager::instance()->vehicles()) - { - _vehicleAdded(vehicle); - } -} - -UASListWidget::~UASListWidget() -{ - delete m_ui; -} - -void UASListWidget::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) - { - case QEvent::LanguageChange: - m_ui->retranslateUi(this); - break; - default: - break; - } -} - -// XXX This is just to prevent -// upfront crashes, will probably need further inspection -void UASListWidget::removeLink(LinkInterface* link) -{ - QGroupBox* box = linkToBoxMapping.value(link, NULL); - - if (box) { - // Just stop updating the status for now - we should - // remove the UAS probably - linkToBoxMapping.remove(link); - } -} - -void UASListWidget::updateStatus() -{ - QMapIterator i(linkToBoxMapping); - while (i.hasNext()) { - i.next(); - LinkInterface* link = i.key(); - - // Paranoid sanity check - if (!LinkManager::instance()->containsLink(link)) - continue; - - if (!link) - continue; - - MAVLinkProtocol* mavlink = MAVLinkProtocol::instance(); - - // Build the tooltip out of the protocol parsing data: received, dropped, and parsing errors. - QString displayString(""); - int c; - if ((c = mavlink->getReceivedPacketCount(link)) != -1) - { - displayString += QString(tr("
Received: %2")).arg(QString::number(c)); - } - if ((c = mavlink->getDroppedPacketCount(link)) != -1) - { - displayString += QString(tr("
Dropped: %2")).arg(QString::number(c)); - } - if ((c = mavlink->getParsingErrorCount(link)) != -1) - { - displayString += QString(tr("
Errors: %2")).arg(QString::number(c)); - } - if (!displayString.isEmpty()) - { - displayString = QString("%1").arg(i.key()->getName()) + displayString; - } -// qDebug() << p << ": " + displayString; - i.value()->setToolTip(displayString); - } -} - -void UASListWidget::_vehicleAdded(Vehicle* vehicle) -{ - UAS* uas = vehicle->uas(); - - // If the list was empty, remove the unconnected widget and start the update timer. - if (uasViews.isEmpty()) - { - updateTimer->start(5000); - - if (uWidget) - { - m_ui->verticalLayout->removeWidget(uWidget); - delete uWidget; - uWidget = NULL; - } - } - - if (!uasViews.contains(uas)) - { - // Only display the UAS in a single link. - QList x = vehicle->links(); - if (x.size()) - { - LinkInterface* li = x.first(); - - // Find an existing QGroupBox for this LinkInterface or create a - // new one. - QGroupBox* newBox; - if (linkToBoxMapping.contains(li)) - { - newBox = linkToBoxMapping[li]; - } - else - { - newBox = new QGroupBox(li->getName(), this); - QVBoxLayout* boxLayout = new QVBoxLayout(newBox); - newBox->setLayout(boxLayout); - m_ui->verticalLayout->addWidget(newBox); - linkToBoxMapping[li] = newBox; - updateStatus(); // Update the link status for this GroupBox. - } - - // And add the new UAS to the UASList - UASView* newView = new UASView(vehicle, newBox); - uasViews.insert(uas, newView); - uasToBoxMapping[uas] = newBox; - newBox->layout()->addWidget(newView); - } - } - - UASView* view = uasViews.value(uas, NULL); - if (view) { - view->setUASasActive(true); - } -} - -/** - * If the UAS was removed, check to see if it was the last one in the QGroupBox and delete - * the QGroupBox if so. - */ -void UASListWidget::_vehicleRemoved(Vehicle* vehicle) -{ - UAS* uas = vehicle->uas(); - - // Remove the UASView and check if its parent GroupBox has any other children, - // delete it if it doesn't. - QGroupBox* box = uasToBoxMapping[uas]; - uasToBoxMapping.remove(uas); - uasViews.remove(uas); - int otherViews = 0; - foreach (UASView* view, box->findChildren()) - { - if (view->uas == uas) - { - view->deleteLater(); - } - else - { - ++otherViews; - } - } - if (otherViews == 0) - { - // Delete the groupbox. - QMap::const_iterator i = linkToBoxMapping.constBegin(); - while (i != linkToBoxMapping.constEnd()) { - if (i.value() == box) - { - linkToBoxMapping.remove(i.key()); - break; - } - ++i; - } - box->deleteLater(); - - // And if no other QGroupBoxes are left, put the initial widget back. - // We also stop the update timer as there's nothing to update at this point. - int otherBoxes = 0; - foreach (const QGroupBox* otherBox, findChildren()) - { - if (otherBox != box) - { - ++otherBoxes; - } - } - if (otherBoxes == 0) - { - uWidget = new QGCUnconnectedInfoWidget(this); - m_ui->verticalLayout->addWidget(uWidget); - updateTimer->stop(); - } - } -} diff --git a/src/ui/uas/UASListWidget.h b/src/ui/uas/UASListWidget.h deleted file mode 100644 index f614c3025..000000000 --- a/src/ui/uas/UASListWidget.h +++ /dev/null @@ -1,78 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2010 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief List of unmanned vehicles - * @author Lorenz Meier - * - */ - -#ifndef _UASLISTWIDGET_H_ -#define _UASLISTWIDGET_H_ - -#include -#include -#include -#include -#include -#include "UASInterface.h" -#include "UASView.h" -#include "QGCUnconnectedInfoWidget.h" -#include "ui_UASList.h" -#include "Vehicle.h" - -class UASListWidget : public QWidget -{ - Q_OBJECT - -public: - UASListWidget(QWidget *parent = 0); - ~UASListWidget(); - -public slots: - void removeLink(LinkInterface* link); - -protected: - // Keep a mapping from UASes to their GroupBox. Useful for determining when groupboxes are empty. - QMap uasToBoxMapping; - // Keep a mapping from Links to GroupBoxes for adding new links. - QMap linkToBoxMapping; - // Tie each view to their UAS object so they can be removed easily. - QMap uasViews; - QGCUnconnectedInfoWidget* uWidget; - QTimer* updateTimer; - void changeEvent(QEvent *e); - -private slots: - void _vehicleAdded(Vehicle* vehicle); - void _vehicleRemoved(Vehicle* vehicle); - -private: - Ui::UASList* m_ui; - -private slots: - void updateStatus(); -}; - -#endif // _UASLISTWIDGET_H_ diff --git a/src/ui/uas/UASView.cc b/src/ui/uas/UASView.cc deleted file mode 100644 index 72d82704e..000000000 --- a/src/ui/uas/UASView.cc +++ /dev/null @@ -1,690 +0,0 @@ -/*===================================================================== -PIXHAWK Micro Air Vehicle Flying Robotics Toolkit - -(c) 2009, 2010 PIXHAWK PROJECT - -This file is part of the PIXHAWK project - - PIXHAWK is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - PIXHAWK is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PIXHAWK. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of one airstrip - * - * @author Lorenz Meier - * - */ - -#include -#include -#include -#include -#include - -#include "QGC.h" -#include "MultiVehicleManager.h" -#include "UASView.h" -#include "UASWaypointManager.h" -#include "MainWindow.h" -#include "ui_UASView.h" - -#ifndef __mobile__ -#include -#endif - -UASView::UASView(Vehicle* vehicle, QWidget *parent) : - QWidget(parent), - vehicle(vehicle), - uas(vehicle->uas()), - startTime(0), - timeout(false), - iconIsRed(true), - disconnected(false), - timeRemaining(0), - chargeLevel(0), - load(0), - state("UNKNOWN"), - stateDesc(tr("Unknown state")), - mode("MAV_MODE_UNKNOWN"), - thrust(0), - isActive(false), - x(0), - y(0), - z(0), - totalSpeed(0), - lat(0), - lon(0), - alt(0), - groundDistance(0), - localFrame(false), - globalFrameKnown(false), - removeAction(new QAction(tr("Delete this system"), this)), - renameAction(new QAction(tr("Rename.."), this)), - selectAction(new QAction(tr("Control this system"), this)), - hilAction(new QAction(tr("HIL - Hardware in the Loop"), this)), - selectAirframeAction(new QAction(tr("Choose Airframe"), this)), - setBatterySpecsAction(new QAction(tr("Set Battery Options"), this)), - lowPowerModeEnabled(true), - generalUpdateCount(0), - filterTime(0), - m_ui(new Ui::UASView) -{ - m_ui->setupUi(this); - setToolTip(""); // Make sure the QGroupBox's tooltip doesn't seep through. - - // FIXME XXX - lowPowerModeEnabled = MainWindow::instance()->lowPowerModeEnabled(); - - hilAction->setCheckable(true); - - // Setup communication - //connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), this, SLOT(receiveValue(int,QString,double,quint64))); - connect(uas, SIGNAL(batteryChanged(UASInterface*, double, double, double, int)), this, SLOT(updateBattery(UASInterface*, double, double, double, int))); - connect(uas, SIGNAL(heartbeat(UASInterface*)), this, SLOT(receiveHeartbeat(UASInterface*))); - connect(uas, SIGNAL(thrustChanged(UASInterface*, double)), this, SLOT(updateThrust(UASInterface*, double))); - connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); - connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,double,quint64))); - connect(uas, SIGNAL(velocityChanged_NED(UASInterface*,double,double,double,quint64)), this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64))); - connect(uas, SIGNAL(statusChanged(UASInterface*,QString,QString)), this, SLOT(updateState(UASInterface*,QString,QString))); - connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); - connect(uas, SIGNAL(loadChanged(UASInterface*, double)), this, SLOT(updateLoad(UASInterface*, double))); - connect(uas, SIGNAL(heartbeatTimeout(bool, unsigned int)), this, SLOT(heartbeatTimeout(bool, unsigned int))); - connect(uas, SIGNAL(waypointSelected(int,int)), this, SLOT(selectWaypoint(int,int))); - connect(uas->getWaypointManager(), SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointUpdated(quint16))); - connect(uas, SIGNAL(systemTypeSet(UASInterface*,uint)), this, SLOT(setSystemType(UASInterface*,uint))); - connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(showStatusText(int, int, int, QString))); - connect(uas, SIGNAL(navModeChanged(int, int, QString)), this, SLOT(updateNavMode(int, int, QString))); - - connect(MultiVehicleManager::instance(), &MultiVehicleManager::activeVehicleChanged, this, &UASView::_activeVehicleChanged); - - // Setup user interaction - connect(m_ui->liftoffButton, SIGNAL(clicked()), uas, SLOT(launch())); - connect(m_ui->haltButton, SIGNAL(clicked()), uas, SLOT(halt())); - connect(m_ui->continueButton, SIGNAL(clicked()), uas, SLOT(go())); - connect(m_ui->landButton, SIGNAL(clicked()), uas, SLOT(land())); - connect(m_ui->abortButton, SIGNAL(clicked()), uas, SLOT(emergencySTOP())); - connect(m_ui->killButton, SIGNAL(clicked()), uas, SLOT(emergencyKILL())); - connect(m_ui->shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown())); - - // Allow deleting this widget - connect(renameAction, SIGNAL(triggered()), this, SLOT(rename())); - connect(selectAction, &QAction::triggered, this, &UASView::_activateVehicle); - connect(selectAirframeAction, SIGNAL(triggered()), this, SLOT(selectAirframe())); - connect(setBatterySpecsAction, SIGNAL(triggered()), this, SLOT(setBatterySpecs())); - - // Name changes - connect(uas, SIGNAL(nameChanged(QString)), this, SLOT(updateName(QString))); - - // Set static values - - // Name - if (uas->getUASName() == "") - { - m_ui->nameLabel->setText(tr("UAS") + QString::number(uas->getUASID())); - } - else - { - m_ui->nameLabel->setText(uas->getUASName()); - } - - // Heartbeat fade - refreshTimer = new QTimer(this); - connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); - if (lowPowerModeEnabled) - { - refreshTimer->start(updateInterval*3); - } - else - { - refreshTimer->start(updateInterval); - } - - // Style some elements by default to the UAS' color. - heartbeatColor = uas->getColor(); - QString colorstyle("QLabel { background-color: %1; }"); - m_ui->typeLabel->setStyleSheet(colorstyle.arg(heartbeatColor.name())); - _activeVehicleChanged(vehicle); - - // Hide kill and shutdown buttons by default - m_ui->killButton->hide(); - m_ui->shutdownButton->hide(); - - // Set state and mode - updateMode(uas->getUASID(), uas->getShortMode(), ""); - updateState(uas, uas->getShortState(), ""); - setSystemType(uas, uas->getSystemType()); -} - -UASView::~UASView() -{ - delete m_ui; -} - -void UASView::_activateVehicle(void) -{ - MultiVehicleManager::instance()->setActiveVehicle(vehicle); -} - -void UASView::heartbeatTimeout(bool timeout, unsigned int ms) -{ - Q_UNUSED(ms); - this->timeout = timeout; -} - -void UASView::updateNavMode(int uasid, int mode, const QString& text) -{ - Q_UNUSED(uasid); - Q_UNUSED(mode); - m_ui->navLabel->setText(text); -} - -void UASView::showStatusText(int uasid, int componentid, int severity, QString text) -{ - Q_UNUSED(uasid); - Q_UNUSED(componentid); - Q_UNUSED(severity); - //m_ui->statusTextLabel->setText(text); - stateDesc = text; -} - -void UASView::setUASasActive(bool active) -{ - if (active) - { - MultiVehicleManager::instance()->setActiveVehicle(vehicle); - } -} - -void UASView::_activeVehicleChanged(Vehicle* vehicle) -{ - bool active = false; - - if (vehicle) { - active = vehicle->uas() == this->uas; - } - - this->isActive = active; - if (isActive) - { - setStyleSheet("UASView { border-width: 3px}"); - } - else - { - setStyleSheet(QString("UASView { border-color: %1}").arg(heartbeatColor.name())); - } -} - -void UASView::updateMode(int sysId, QString status, QString description) -{ - Q_UNUSED(description); - - //int aa=this->uas->getUASID(); - if (sysId == this->uas->getUASID()) m_ui->modeLabel->setText(status); - - m_ui->modeLabel->setText(status); -} - -void UASView::mouseDoubleClickEvent (QMouseEvent * event) -{ - Q_UNUSED(event); - MultiVehicleManager::instance()->setActiveVehicle(vehicle); -} - -void UASView::receiveHeartbeat(UASInterface* uas) -{ - heartbeatColor = uas->getColor(); - QString colorstyle("QLabel { background-color: %1; }"); - m_ui->heartBeatLabel->setStyleSheet(colorstyle.arg(heartbeatColor.name())); - - // If we're returning from a disconnection, recolor things properly. - if (disconnected) - { - _activeVehicleChanged(vehicle); - disconnected = false; - } - timeout = false; -} - -void UASView::updateName(const QString& name) -{ - if (uas) m_ui->nameLabel->setText(name); -} - -/** - * The current system type is represented through the system icon. - * - * @param uas Source system, has to be the same as this->uas - * @param systemType type ID, following the MAVLink system type conventions - * @see http://pixhawk.ethz.ch/software/mavlink - */ -void UASView::setSystemType(UASInterface* uas, unsigned int systemType) -{ - if (uas == this->uas) - { - // Set matching icon - switch (systemType) - { - case MAV_TYPE_GENERIC: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Generic")); - break; - case MAV_TYPE_FIXED_WING: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/FixedWing")); - break; - case MAV_TYPE_QUADROTOR: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/QuadRotor")); - break; - case MAV_TYPE_COAXIAL: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Coaxial")); - break; - case MAV_TYPE_HELICOPTER: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Helicopter")); - break; - case MAV_TYPE_ANTENNA_TRACKER: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Unknown")); - break; - case MAV_TYPE_GCS: { - // A groundstation is a special system type, update widget - QString result; - m_ui->nameLabel->setText(tr("GCS ") + result.sprintf("%03d", uas->getUASID())); - m_ui->waypointLabel->setText(""); - m_ui->timeRemainingLabel->setText("Online:"); - m_ui->batteryBar->hide(); - m_ui->thrustBar->hide(); - m_ui->stateLabel->hide(); - m_ui->statusTextLabel->hide(); - m_ui->waypointLabel->hide(); - m_ui->liftoffButton->hide(); - m_ui->haltButton->hide(); - m_ui->landButton->hide(); - m_ui->shutdownButton->hide(); - m_ui->abortButton->hide(); - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Groundstation")); - } - break; - case MAV_TYPE_AIRSHIP: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Airship")); - break; - case MAV_TYPE_FREE_BALLOON: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/FreeBalloon")); - break; - case MAV_TYPE_ROCKET: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Rocket")); - break; - case MAV_TYPE_GROUND_ROVER: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/GroundRover")); - break; - case MAV_TYPE_SURFACE_BOAT: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/SurfaceBoat")); - break; - case MAV_TYPE_SUBMARINE: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Submarine")); - break; - case MAV_TYPE_HEXAROTOR: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/HexaRotor")); - break; - case MAV_TYPE_OCTOROTOR: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/OctoRotor")); - break; - case MAV_TYPE_TRICOPTER: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/TriCopter")); - break; - case MAV_TYPE_FLAPPING_WING: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/FlappingWing")); - break; - case MAV_TYPE_KITE: - m_ui->typeLabel->setPixmap(QPixmap(":/res/mavs/Kite")); - break; - default: - m_ui->typeLabel->setPixmap(QPixmap("://res/mavs/Unknown")); - break; - } - } -} - -void UASView::updateLocalPosition(UASInterface* uas, double x, double y, double z, quint64 usec) -{ - Q_UNUSED(usec); - Q_UNUSED(uas); - this->x = x; - this->y = y; - this->z = z; - localFrame = true; -} - -void UASView::updateGlobalPosition(UASInterface* uas, double lat, double lon, double altAMSL, double altWGS84, quint64 usec) -{ - Q_UNUSED(uas); - Q_UNUSED(usec); - Q_UNUSED(altAMSL); - this->lon = lon; - this->lat = lat; - this->alt = altWGS84; - globalFrameKnown = true; -} - -void UASView::updateSpeed(UASInterface*, double x, double y, double z, quint64 usec) -{ - Q_UNUSED(usec); - totalSpeed = sqrt(x*x + y*y + z*z); -} - -void UASView::currentWaypointUpdated(quint16 waypoint) -{ - m_ui->waypointLabel->setText(tr("WP") + QString::number(waypoint)); -} - -void UASView::setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current) -{ - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(z); - Q_UNUSED(yaw); - Q_UNUSED(autocontinue); - if (uasId == this->uas->getUASID()) - { - if (current) - { - m_ui->waypointLabel->setText(tr("WP") + QString::number(id)); - } - } -} - -void UASView::selectWaypoint(int uasId, int id) -{ - if (uasId == this->uas->getUASID()) - { - m_ui->waypointLabel->setText(tr("WP") + QString::number(id)); - } -} - -void UASView::updateThrust(UASInterface* uas, double thrust) -{ - if (this->uas == uas) - { - this->thrust = thrust; - } -} - -void UASView::updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds) -{ - Q_UNUSED(voltage); - Q_UNUSED(current); - if (this->uas == uas) - { - timeRemaining = seconds; - chargeLevel = percent; - } -} - -void UASView::updateState(UASInterface* uas, QString uasState, QString stateDescription) -{ - if (this->uas == uas) - { - state = uasState; - stateDesc = stateDescription; - } -} - -void UASView::updateLoad(UASInterface* uas, double load) -{ - if (this->uas == uas) - { - this->load = load; - } -} - -/** - * Right-clicking on the view provides a custom menu for interacting - * with the UAS. - */ -void UASView::contextMenuEvent (QContextMenuEvent* event) -{ - QMenu menu(this); - menu.addAction(selectAction); - menu.addSeparator(); - menu.addAction(renameAction); -/* - FIXME: The code below is incorrect. removeAction should only be available when link is - disconnected. fSee Issue #1275 - if (timeout) - { - menu.addAction(removeAction); - } -*/ - menu.addAction(hilAction); - menu.addAction(selectAirframeAction); - menu.addAction(setBatterySpecsAction); - menu.exec(event->globalPos()); -} - -void UASView::setBatterySpecs() -{ - if (uas) - { - bool ok; - QString newName = QInputDialog::getText(this, tr("Set Battery Specifications for %1").arg(uas->getUASName()), - tr("Specs: (empty,warn,full), e.g. (9V,9.5V,12.6V) or just warn level in percent (e.g. 15%) to use estimate from MAV"), QLineEdit::Normal, - uas->getBatterySpecs(), &ok); - - if (ok && !newName.isEmpty()) uas->setBatterySpecs(newName); - } -} - -void UASView::rename() -{ - if (uas) - { - bool ok; - QString newName = QInputDialog::getText(this, tr("Rename System %1").arg(uas->getUASName()), - tr("System Name:"), QLineEdit::Normal, - uas->getUASName(), &ok); - - if (ok && !newName.isEmpty()) uas->setUASName(newName); - } -} - -void UASView::selectAirframe() -{ - if (uas) - { - // Get list of airframes from UAS - QStringList airframes; - airframes << "Generic" - << "Multiplex Easystar" - << "Multiplex Twinstar" - << "Multiplex Merlin" - << "Pixhawk Cheetah" - << "Mikrokopter" - << "Reaper" - << "Predator" - << "Coaxial" - << "Pteryx" - << "Tricopter" - << "Asctec Firefly" - << "X8 Flying Wing" - << "Viper 2.0 Flying Wing" - << "Cam Flyer Q Flying Wing"; - - bool ok; - QString item = QInputDialog::getItem(this, tr("Select Airframe for %1").arg(uas->getUASName()), - tr("Airframe"), airframes, uas->getAirframe(), false, &ok); - if (ok && !item.isEmpty()) - { - // Set this airframe as UAS airframe - uas->setAirframe(airframes.indexOf(item)); - } - } -} - -void UASView::refresh() -{ - if (generalUpdateCount == 4) - { -#if (QGC_EVENTLOOP_DEBUG) - // qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__; -#endif - generalUpdateCount = 0; - //// qDebug() << "UPDATING EVERYTHING"; - // State - m_ui->stateLabel->setText(state); - m_ui->statusTextLabel->setText(stateDesc); - - // Battery - m_ui->batteryBar->setValue(static_cast(this->chargeLevel)); - //m_ui->loadBar->setValue(static_cast(this->load)); - m_ui->thrustBar->setValue(this->thrust); - - // Position - // If global position is known, prefer it over local coordinates - - if (!globalFrameKnown && localFrame) - { - QString position; - position = position.sprintf("%05.1f %05.1f %06.1f m", x, y, z); - m_ui->positionLabel->setText(position); - } - - if (globalFrameKnown) - { - QString globalPosition; - QString latIndicator; - if (lat > 0) - { - latIndicator = "N"; - } - else - { - latIndicator = "S"; - } - QString lonIndicator; - if (lon > 0) - { - lonIndicator = "E"; - } - else - { - lonIndicator = "W"; - } - - globalPosition = globalPosition.sprintf("%6.2f%s %6.2f%s %6.1f m", fabs(lon), lonIndicator.toStdString().c_str(), fabs(lat), latIndicator.toStdString().c_str(), alt); - m_ui->positionLabel->setText(globalPosition); - } - - // Altitude - if (groundDistance == 0 && alt != 0) - { - m_ui->groundDistanceLabel->setText(QString("%1 m").arg(alt, 6, 'f', 1, '0')); - } - else - { - m_ui->groundDistanceLabel->setText(QString("%1 m").arg(groundDistance, 6, 'f', 1, '0')); - } - - // Speed - QString speed("%1 m/s"); - m_ui->speedLabel->setText(speed.arg(totalSpeed, 4, 'f', 1, '0')); - - // Thrust - m_ui->thrustBar->setValue(thrust * 100); - - // Time Elapsed - //QDateTime time = MG::TIME::msecToQDateTime(uas->getUptime()); - - quint64 filterTime = uas->getUptime() / 1000; - int hours = static_cast(filterTime / 3600); - int min = static_cast((filterTime - 3600 * hours) / 60); - int sec = static_cast(filterTime - 60 * min - 3600 * hours); - QString timeText; - timeText = timeText.sprintf("%02d:%02d:%02d", hours, min, sec); - m_ui->timeElapsedLabel->setText(timeText); - - if(this->timeRemaining > 1 && this->timeRemaining < QGC::MAX_FLIGHT_TIME) - { - // Filter output to get a higher stability - filterTime = static_cast(this->timeRemaining); - // filterTime = 0.8 * filterTime + 0.2 * static_cast(this->timeRemaining); - hours = static_cast(filterTime / 3600); - min = static_cast((filterTime - 3600 * hours) / 60); - sec = static_cast(filterTime - 60 * min - 3600 * hours); - - timeText = timeText.sprintf("%02d:%02d:%02d", hours, min, sec); - m_ui->timeRemainingLabel->setText(timeText); - } - else - { - m_ui->timeRemainingLabel->setText(tr("Calc..")); - } - - - } - generalUpdateCount++; - - if (timeout) - { - // CRITICAL CONDITION, NO HEARTBEAT - disconnected = true; - - QColor warnColor; - if (iconIsRed) - { - warnColor = Qt::red; - } - else - { - warnColor = Qt::darkRed; - refreshTimer->setInterval(errorUpdateInterval); - refreshTimer->start(); - } - QString style = QString("UASView {background-color: %1;}").arg(warnColor.name()); - this->setStyleSheet(style); - iconIsRed = !iconIsRed; - } - else - { - // If we're not in low power mode, add the additional visual effect of - // fading out the color of the heartbeat for this UAS. - if (!lowPowerModeEnabled) - { - heartbeatColor = heartbeatColor.darker(110); - QString colorstyle("QLabel {background-color: %1;}"); - m_ui->heartBeatLabel->setStyleSheet(colorstyle.arg(heartbeatColor.name())); - refreshTimer->setInterval(updateInterval); - refreshTimer->start(); - } - } -} - -void UASView::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) - { - case QEvent::LanguageChange: - m_ui->retranslateUi(this); - break; - default: - break; - } -} - -void UASView::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} diff --git a/src/ui/uas/UASView.h b/src/ui/uas/UASView.h deleted file mode 100644 index 579466f80..000000000 --- a/src/ui/uas/UASView.h +++ /dev/null @@ -1,156 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2010 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Definition of class UASView - * - * @author Lorenz Meier - * - */ - -#ifndef UASVIEW_H -#define UASVIEW_H - -#include -#include -#include -#include - -#include "Vehicle.h" -#include "UASInterface.h" - -namespace Ui -{ -class UASView; -} - -class UASView : public QWidget -{ - Q_OBJECT -public: - UASView(Vehicle* vehicle, QWidget *parent = 0); - ~UASView(); - Vehicle* vehicle; - UASInterface* uas; - -public slots: - /** @brief Update the name of the system */ - void updateName(const QString& name); - void receiveHeartbeat(UASInterface* uas); - void updateThrust(UASInterface* uas, double thrust); - void updateBattery(UASInterface* uas, double voltage, double current, double percent, int seconds); - void updateLocalPosition(UASInterface*, double x, double y, double z, quint64 usec); - void updateGlobalPosition(UASInterface*, double lat, double lon, double altAMSL, double altWGS84, quint64 usec); - void updateSpeed(UASInterface*, double x, double y, double z, quint64 usec); - void updateState(UASInterface*, QString uasState, QString stateDescription); - /** @brief Update the MAV mode */ - void updateMode(int sysId, QString status, QString description); - void updateLoad(UASInterface* uas, double load); - //void receiveValue(int uasid, QString id, double value, quint64 time); - void refresh(); - /** @brief Receive new waypoint information */ - void setWaypoint(int uasId, int id, double x, double y, double z, double yaw, bool autocontinue, bool current); - /** @brief Update the current active waypoint */ - void currentWaypointUpdated(quint16 waypoint); - /** @brief Set waypoint as current target */ - void selectWaypoint(int uasId, int id); - /** @brief Set the current system type */ - void setSystemType(UASInterface* uas, unsigned int systemType); - /** @brief Set the current UAS as the globally active system */ - void setUASasActive(bool); - /** @brief Set the widget into critical mode */ - void heartbeatTimeout(bool timeout, unsigned int ms); - /** @brief Bring up the dialog to rename the system */ - void rename(); - /** @brief Select airframe for this vehicle */ - void selectAirframe(); - /** @brief Select the battery type */ - void setBatterySpecs(); - /** @brief Show a status text message */ - void showStatusText(int uasid, int componentid, int severity, QString text); - /** @brief Update the navigation mode state */ - void updateNavMode(int uasid, int mode, const QString& text); - -protected: - void changeEvent(QEvent *e); - QTimer* refreshTimer; - QColor heartbeatColor; - quint64 startTime; - bool timeout; - bool iconIsRed; - bool disconnected; - int timeRemaining; - float chargeLevel; - float load; - QString state; - QString stateDesc; - QString mode; - double thrust; ///< Current vehicle thrust: 0 - 1.0 for 100% thrust - bool isActive; ///< Is this MAV selected by the user? - float x; - float y; - float z; - float totalSpeed; - float lat; - float lon; - float alt; - float groundDistance; - bool localFrame; - bool globalFrameKnown; - QAction* removeAction; - QAction* renameAction; - QAction* selectAction; - QAction* hilAction; - QAction* hilXAction; - QAction* selectAirframeAction; - QAction* setBatterySpecsAction; - static const int updateInterval = 800; - static const int errorUpdateInterval = 200; - bool lowPowerModeEnabled; ///< Low power mode reduces update rates - unsigned int generalUpdateCount; ///< Skip counter for updates - double filterTime; ///< Filter time estimate of battery - /** - * If a user double-clicks on this view, set the active UAS to this one. - */ - void mouseDoubleClickEvent(QMouseEvent *event); - /** - * Right-clicking on the view provides a custom menu for interacting - * with the UAS. - */ - void contextMenuEvent(QContextMenuEvent *event); - -private slots: - void _activeVehicleChanged(Vehicle* vehicle); - void _activateVehicle(void); - -private: - Ui::UASView *m_ui; - - /** - * Implement paintEvent() so that stylesheets work for our custom widget. - */ - virtual void paintEvent(QPaintEvent *event); -}; - -#endif // UASVIEW_H -- 2.22.0