From 49c711374a1dd5cc155e16bec2e5d7e9a1219e94 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Tue, 13 Apr 2010 08:55:31 +0200 Subject: [PATCH] Minor improvements in UAS display --- mavlink.pri | 28 ---------------------------- src/Core.cc | 12 ++---------- src/Core.h | 4 +--- src/ui/UASView.ui | 4 ++-- src/ui/uas/UASView.cc | 46 ++++++++++++++++++++++++++++++---------------- src/ui/uas/UASView.h | 5 ++++- 6 files changed, 39 insertions(+), 60 deletions(-) delete mode 100644 mavlink.pri diff --git a/mavlink.pri b/mavlink.pri deleted file mode 100644 index 8592ebe..0000000 --- a/mavlink.pri +++ /dev/null @@ -1,28 +0,0 @@ -# ------------------------------------------------- -# MAVGround - Micro Air Vehicle Groundstation -# Please see our website at -# Original Author: -# Lorenz Meier -# Contributing Authors (in alphabetical order): -# (c) 2009 PIXHAWK Team -# This file is part of the mav groundstation project -# MAVGround 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. -# MAVGround 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 MAVGround. If not, see . -# ABOUT THIS FILE: -# This file includes the MAVLink protocol from outside the groundstation directory -# Change the MAVLINKDIR to whereever the MAVLink .c and .h files are located. -# DO NOT USE A TRAILING SLASH! -# ------------------------------------------------------------------------------ -MAVLINKDIR = ../embedded/src/comm/mavlink -INCLUDEPATH += $$MAVLINKDIR -HEADERS += \ - $$MAVLINKDIR/mavlink.h -SOURCES += $$MAVLINKDIR/protocol.c diff --git a/src/Core.cc b/src/Core.cc index 7ffa5c8..6c8d81a 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -94,12 +94,12 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) // Start the user interface splashScreen->showMessage(tr("Starting User Interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); - startUI(); + // Start UI + mainWindow = new MainWindow(); // Remove splash screen splashScreen->finish(mainWindow); - } /** @@ -133,12 +133,4 @@ void Core::startUASManager() UASManager::instance(); } -/** - * @brief Start and show the user interface. - **/ -void Core::startUI() -{ - // Start UI - mainWindow = new MainWindow(); -} diff --git a/src/Core.h b/src/Core.h index 857cb03..2277a30 100644 --- a/src/Core.h +++ b/src/Core.h @@ -23,7 +23,7 @@ This file is part of the PIXHAWK project /** * @file - * @brief Main class + * @brief Definition of main class * * @author Lorenz Meier * @@ -65,8 +65,6 @@ protected: **/ void startUASManager(); - void startUI(); - private: MainWindow* mainWindow; //ViconTarsusProtocol* tarsus; diff --git a/src/ui/UASView.ui b/src/ui/UASView.ui index 8b1b253..92a715d 100644 --- a/src/ui/UASView.ui +++ b/src/ui/UASView.ui @@ -7,7 +7,7 @@ 0 0 362 - 116 + 120 @@ -201,7 +201,7 @@ QProgressBar::chunk#thrustBar { 6 - + 0 diff --git a/src/ui/uas/UASView.cc b/src/ui/uas/UASView.cc index 5d2e580..2a6728a 100644 --- a/src/ui/uas/UASView.cc +++ b/src/ui/uas/UASView.cc @@ -45,6 +45,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : stateDesc(tr("Unknown system state")), mode("MAV_MODE_UNKNOWN"), thrust(0), + isActive(false), m_ui(new Ui::UASView) { this->uas = uas; @@ -67,7 +68,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : connect(uas, SIGNAL(systemTypeSet(UASInterface*,uint)), this, SLOT(setSystemType(UASInterface*,uint))); // Setup UAS selection - connect(m_ui->groupBox, SIGNAL(clicked(bool)), this, SLOT(setUASasActive(bool))); + connect(m_ui->uasViewFrame, SIGNAL(clicked(bool)), this, SLOT(setUASasActive(bool))); // Setup user interaction connect(m_ui->liftoffButton, SIGNAL(clicked()), uas, SLOT(launch())); @@ -90,20 +91,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : m_ui->nameLabel->setText(uas->getUASName()); } - // Get min/max values from UAS - // TODO get these values from UAS - //m_ui->speedBar->setMinimum(0); - //m_ui->speedBar->setMaximum(15); - - // UAS color - QColor uasColor = uas->getColor(); - uasColor = uasColor.darker(475); - QString colorstyle; - colorstyle = colorstyle.sprintf("QGroupBox { border: 2px solid #4A4A4F; border-radius: 5px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X;}", - uasColor.red(), uasColor.green(), uasColor.blue()); - m_ui->groupBox->setStyleSheet(colorstyle); - //m_ui->groupBox->setAutoFillBackground(true); - + setBackgroundColor(); // Heartbeat fade refreshTimer = new QTimer(this); @@ -116,9 +104,35 @@ UASView::~UASView() delete m_ui; } -void UASView::setUASasActive(bool) +/** + * 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 UASView::setBackgroundColor() +{ + // UAS color + QColor uasColor = uas->getColor(); + QString colorstyle; + QString borderColor = "#4A4A4F"; + if (isActive) + { + borderColor = "#FA4A4F"; + uasColor = uasColor.darker(475); + } + else + { + uasColor = uasColor.darker(675); + } + colorstyle = colorstyle.sprintf("QGroupBox { border-radius: 5px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X; border: 2px solid %s; }", + uasColor.red(), uasColor.green(), uasColor.blue(), borderColor.toStdString().c_str()); + m_ui->uasViewFrame->setStyleSheet(colorstyle); +} + +void UASView::setUASasActive(bool active) { UASManager::instance()->setActiveUAS(this->uas); + this->isActive = active; + setBackgroundColor(); } void UASView::updateMode(int sysId, QString status, QString description) diff --git a/src/ui/uas/UASView.h b/src/ui/uas/UASView.h index 8a4954e..dd6c3d4 100644 --- a/src/ui/uas/UASView.h +++ b/src/ui/uas/UASView.h @@ -69,6 +69,8 @@ public slots: void setSystemType(UASInterface* uas, unsigned int systemType); /** @brief Set the current UAS as the globally active system */ void setUASasActive(bool); + /** @brief Set the background color for the widget */ + void setBackgroundColor(); protected: void changeEvent(QEvent *e); @@ -82,7 +84,8 @@ protected: QString state; QString stateDesc; QString mode; - double thrust; + double thrust; ///< Current vehicle thrust: 0 - 1.0 for 100% thrust + bool isActive; ///< Is this MAV selected by the user? void mouseDoubleClickEvent (QMouseEvent * event); /** @brief Mouse enters the widget */