From 297d2ac5ba0997a73d7b81964c954d4977950033 Mon Sep 17 00:00:00 2001 From: lm Date: Mon, 10 Jan 2011 17:15:40 +0100 Subject: [PATCH 1/4] Cleaned up Unmanned systems list widget, reduced size requirements of the widget --- src/uas/UAS.cc | 16 ++++++++-------- src/ui/DebugConsole.ui | 43 +++++++++++++++++++++++++++++++++++++++---- src/ui/UASView.ui | 29 ++++++++++++++++------------- src/ui/uas/UASListWidget.cc | 4 +++- src/ui/uas/UASView.cc | 45 +++++++++++++++++++++++++++++++-------------- src/ui/uas/UASView.h | 1 + 6 files changed, 98 insertions(+), 40 deletions(-) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index c0510db..1dfb068 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -956,27 +956,27 @@ void UAS::getStatusForCode(int statusCode, QString& uasState, QString& stateDesc { case MAV_STATE_UNINIT: uasState = tr("UNINIT"); - stateDescription = tr("Not initialized"); + stateDescription = tr("Waiting.."); break; case MAV_STATE_BOOT: uasState = tr("BOOT"); - stateDescription = tr("Booting system, please wait.."); + stateDescription = tr("Booting.."); break; case MAV_STATE_CALIBRATING: uasState = tr("CALIBRATING"); - stateDescription = tr("Calibrating sensors.."); + stateDescription = tr("Calibrating.."); break; case MAV_STATE_ACTIVE: uasState = tr("ACTIVE"); - stateDescription = tr("Normal operation mode"); + stateDescription = tr("Normal"); break; case MAV_STATE_STANDBY: uasState = tr("STANDBY"); - stateDescription = tr("Standby, operational"); + stateDescription = tr("Standby, OK"); break; case MAV_STATE_CRITICAL: uasState = tr("CRITICAL"); - stateDescription = tr("Failure occured!"); + stateDescription = tr("FAILURE: Continue"); break; case MAV_STATE_EMERGENCY: uasState = tr("EMERGENCY"); @@ -984,11 +984,11 @@ void UAS::getStatusForCode(int statusCode, QString& uasState, QString& stateDesc break; case MAV_STATE_POWEROFF: uasState = tr("SHUTDOWN"); - stateDescription = tr("Powering off system"); + stateDescription = tr("Powering off"); break; default: uasState = tr("UNKNOWN"); - stateDescription = tr("FAILURE: Unknown system state"); + stateDescription = tr("Unknown state"); break; } } diff --git a/src/ui/DebugConsole.ui b/src/ui/DebugConsole.ui index e22d2f2..8a8fe50 100644 --- a/src/ui/DebugConsole.ui +++ b/src/ui/DebugConsole.ui @@ -6,8 +6,8 @@ 0 0 - 447 - 181 + 469 + 190 @@ -24,7 +24,7 @@ 6 - + @@ -81,6 +81,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -107,12 +120,18 @@ - + 5 + + + 100 + 16777215 + + 10 @@ -189,6 +208,22 @@ + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 5 + 20 + + + + + Hold diff --git a/src/ui/UASView.ui b/src/ui/UASView.ui index ceadfa1..1b0cdea 100644 --- a/src/ui/UASView.ui +++ b/src/ui/UASView.ui @@ -6,8 +6,8 @@ 0 0 - 335 - 121 + 310 + 111 @@ -18,7 +18,7 @@ - 335 + 260 0 @@ -73,12 +73,12 @@ QLabel#timeRemainingLabel { } QLabel#waypointLabel { - font: 24px; + font: 22px; } QGroupBox { border: 1px solid #4A4A4F; - border-radius: 5px; + border-radius: 10px; padding: 0px 0px 0px 0px; margin: 0px; } @@ -98,7 +98,7 @@ QGroupBox#heartbeatIcon { QToolButton#typeButton { font-weight: bold; font-size: 12px; - border: 2px solid #999999; + border: 0px solid #999999; border-radius: 5px; min-width:44px; max-width: 44px; @@ -184,8 +184,11 @@ QProgressBar::chunk#thrustBar { } + + 2 + - 6 + 2 @@ -206,26 +209,26 @@ QProgressBar::chunk#thrustBar { - 6 + 4 2 - 6 + 4 - 48 - 48 + 44 + 44 - 48 - 48 + 44 + 44 diff --git a/src/ui/uas/UASListWidget.cc b/src/ui/uas/UASListWidget.cc index e8a4f4e..b505d4f 100644 --- a/src/ui/uas/UASListWidget.cc +++ b/src/ui/uas/UASListWidget.cc @@ -50,6 +50,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA m_ui->setupUi(this); listLayout = new QVBoxLayout(this); + listLayout->setMargin(0); + listLayout->setSpacing(3); listLayout->setAlignment(Qt::AlignTop); this->setLayout(listLayout); setObjectName("UNMANNED_SYSTEMS_LIST"); @@ -58,7 +60,7 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA uWidget = new QGCUnconnectedInfoWidget(this); listLayout->addWidget(uWidget); - this->setMinimumWidth(250); + this->setMinimumWidth(262); uasViews = QMap(); diff --git a/src/ui/uas/UASView.cc b/src/ui/uas/UASView.cc index 01bd37d..afb1fb0 100644 --- a/src/ui/uas/UASView.cc +++ b/src/ui/uas/UASView.cc @@ -59,6 +59,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : lon(0), alt(0), groundDistance(0), + localFrame(false), m_ui(new Ui::UASView) { m_ui->setupUi(this); @@ -109,6 +110,19 @@ UASView::UASView(UASInterface* uas, QWidget *parent) : // Heartbeat fade refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); + + // Hide kill and shutdown buttons per default + m_ui->killButton->hide(); + m_ui->shutdownButton->hide(); + + if (localFrame) + { + m_ui->gpsLabel->hide(); + } + else + { + m_ui->positionLabel->hide(); + } } UASView::~UASView() @@ -135,7 +149,7 @@ void UASView::setBackgroundColor() { uasColor = uasColor.darker(675); } - colorstyle = colorstyle.sprintf("QGroupBox { border-radius: 5px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X; border: 2px solid %s; }", + colorstyle = colorstyle.sprintf("QGroupBox { border-radius: 12px; 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); } @@ -286,11 +300,15 @@ void UASView::setSystemType(UASInterface* uas, unsigned int systemType) void UASView::updateLocalPosition(UASInterface* uas, double x, double y, double z, quint64 usec) { Q_UNUSED(usec); - if (uas == this->uas) + Q_UNUSED(uas); + this->x = x; + this->y = y; + this->z = z; + if (!localFrame) { - this->x = x; - this->y = y; - this->z = z; + localFrame = true; + m_ui->gpsLabel->hide(); + m_ui->positionLabel->show(); } } @@ -404,7 +422,7 @@ void UASView::refresh() // Position QString position; - position = position.sprintf("%02.2f %02.2f %02.2f m", x, y, z); + position = position.sprintf("%05.1f %05.1f %05.1f m", x, y, z); m_ui->positionLabel->setText(position); QString globalPosition; QString latIndicator; @@ -425,23 +443,22 @@ void UASView::refresh() { lonIndicator = "W"; } - globalPosition = globalPosition.sprintf("%02.2f%s %02.2f%s %02.2f m", lon, lonIndicator.toStdString().c_str(), lat, latIndicator.toStdString().c_str(), alt); + globalPosition = globalPosition.sprintf("%05.1f%s %05.1f%s %05.1f m", lon, lonIndicator.toStdString().c_str(), lat, latIndicator.toStdString().c_str(), alt); m_ui->gpsLabel->setText(globalPosition); // Altitude if (groundDistance == 0 && alt != 0) { - m_ui->groundDistanceLabel->setText(QString("%1 m").arg(alt)); + m_ui->groundDistanceLabel->setText(QString("%1 m").arg(alt, 5, 'f', 1, '0')); } else { - m_ui->groundDistanceLabel->setText(QString("%1 m").arg(groundDistance)); + m_ui->groundDistanceLabel->setText(QString("%1 m").arg(groundDistance, 5, 'f', 1, '0')); } // Speed - QString speed; - speed = speed.sprintf("%02.2f m/s", totalSpeed); - m_ui->speedLabel->setText(speed); + QString speed("%1 m/s"); + m_ui->speedLabel->setText(speed.arg(totalSpeed, 4, 'f', 1, '0')); // Thrust m_ui->thrustBar->setValue(thrust * 100); @@ -461,7 +478,7 @@ void UASView::refresh() } else { - m_ui->timeRemainingLabel->setText(tr("Calculating")); + m_ui->timeRemainingLabel->setText(tr("Calc..")); } // Time Elapsed @@ -482,7 +499,7 @@ void UASView::refresh() heartbeatColor = heartbeatColor.darker(150); QString colorstyle; - colorstyle = colorstyle.sprintf("QGroupBox { border: 1px solid #EEEEEE; border-radius: 4px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X;}", + colorstyle = colorstyle.sprintf("QGroupBox { border: 1px solid #EEEEEE; border-radius: 8px; padding: 0px; margin: 0px; background-color: #%02X%02X%02X;}", heartbeatColor.red(), heartbeatColor.green(), heartbeatColor.blue()); m_ui->heartbeatIcon->setStyleSheet(colorstyle); m_ui->heartbeatIcon->setAutoFillBackground(true); diff --git a/src/ui/uas/UASView.h b/src/ui/uas/UASView.h index 74dcc3c..b96103d 100644 --- a/src/ui/uas/UASView.h +++ b/src/ui/uas/UASView.h @@ -99,6 +99,7 @@ protected: float lon; float alt; float groundDistance; + bool localFrame; static const int updateInterval = 300; From 50a34caed891989e9e4f571a4429615ddb195386 Mon Sep 17 00:00:00 2001 From: lm Date: Mon, 10 Jan 2011 19:09:12 +0100 Subject: [PATCH 2/4] Adjusted to small screens --- src/ui/Linechart.ui | 30 ++++++++++++++++++------------ src/ui/MainWindow.cc | 13 +++++++++++++ src/ui/MainWindow.h | 2 ++ src/ui/linechart/LinechartWidget.cc | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/ui/Linechart.ui b/src/ui/Linechart.ui index bad25b0..b6e1df3 100644 --- a/src/ui/Linechart.ui +++ b/src/ui/Linechart.ui @@ -25,7 +25,7 @@ Form - + 3 @@ -51,8 +51,14 @@ - 250 - 300 + 90 + 200 + + + + + 370 + 16777215 @@ -71,21 +77,21 @@ - + 0 0 - 240 - 250 + 60 + 150 - 150 - 200 + 60 + 150 @@ -108,7 +114,7 @@ 0 0 - 242 + 210 361 @@ -122,14 +128,14 @@ - 9 + 0 0 - 400 - 300 + 200 + 200 diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 5d8a867..363e2f4 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -216,6 +216,19 @@ MainWindow::~MainWindow() } +void MainWindow::resizeEvent(QResizeEvent * event) +{ + Q_UNUSED(event); + if (height() < 800) + { + ui.statusBar->setVisible(false); + } + else + { + ui.statusBar->setVisible(true); + } +} + QString MainWindow::getWindowStateKey() { return QString::number(currentView)+"/windowstate"; diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 04e29f0..df1cfb0 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -297,6 +297,8 @@ protected: */ void showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view); + /** @brief Catch window resize events */ + void resizeEvent(QResizeEvent * event); /** @brief Keeps track of the current view */ VIEW_SECTIONS currentView; diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 704b83b..94790b6 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -199,7 +199,7 @@ void LinechartWidget::createLayout() layout->addWidget(activePlot, 0, 0, 1, 6); layout->setRowStretch(0, 10); - layout->setRowStretch(1, 0); + layout->setRowStretch(1, 1); // Linear scaling button scalingLinearButton = createButton(this); From de439a7c1986ba6a6b7387df0f6aa17b59e17fc3 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Tue, 11 Jan 2011 07:59:59 +0100 Subject: [PATCH 3/4] Working on param slider --- src/ui/designer/QGCParamSlider.cc | 103 +++++++++++++++++++++++++++++--------- src/ui/designer/QGCParamSlider.h | 10 ++++ src/ui/designer/QGCParamSlider.ui | 97 +++++++++++++++-------------------- 3 files changed, 128 insertions(+), 82 deletions(-) diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index f5290b0..5af21c8 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -16,8 +16,22 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ui(new Ui::QGCParamSlider) { ui->setupUi(this); - endEditMode(); - connect(ui->doneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); + + scaledInt = ui->valueSlider->maximum() - ui->valueSlider->minimum(); + + ui->editDoneButton->show(); + ui->editMaxLabel->show(); + ui->editMinLabel->show(); + ui->editNameLineEdit->show(); + ui->editInstructionsLabel->show(); + ui->editRefreshParamsButton->show(); + ui->editSelectParamComboBox->show(); + ui->editSelectComponentComboBox->show(); + ui->editStatusLabel->show(); + ui->editMinSpinBox->show(); + ui->editMaxSpinBox->show(); + ui->editTypeComboBox->show(); + connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); } QGCParamSlider::~QGCParamSlider() @@ -27,31 +41,34 @@ QGCParamSlider::~QGCParamSlider() void QGCParamSlider::startEditMode() { - ui->doneButton->show(); - ui->maxLabel->show(); - ui->minLabel->show(); - ui->nameLineEdit->show(); - ui->instructionsLabel->show(); - ui->refreshParamsButton->show(); - ui->selectParamComboBox->show(); - ui->minSpinBox->show(); - ui->maxSpinBox->show(); - ui->typeComboBox->show(); + ui->editDoneButton->show(); + ui->editMaxLabel->show(); + ui->editMinLabel->show(); + ui->editNameLineEdit->show(); + ui->editInstructionsLabel->show(); + ui->editRefreshParamsButton->show(); + ui->editSelectParamComboBox->show(); + ui->editSelectComponentComboBox->show(); + ui->editStatusLabel->show(); + ui->editMinSpinBox->show(); + ui->editMaxSpinBox->show(); isInEditMode = true; } void QGCParamSlider::endEditMode() { - ui->doneButton->hide(); - ui->maxLabel->hide(); - ui->minLabel->hide(); - ui->nameLineEdit->hide(); - ui->instructionsLabel->hide(); - ui->refreshParamsButton->hide(); - ui->selectParamComboBox->hide(); - ui->minSpinBox->hide(); - ui->maxSpinBox->hide(); - ui->typeComboBox->hide(); + ui->editDoneButton->hide(); + ui->editMaxLabel->hide(); + ui->editMinLabel->hide(); + ui->editNameLineEdit->hide(); + ui->editInstructionsLabel->hide(); + ui->editRefreshParamsButton->hide(); + ui->editSelectParamComboBox->hide(); + ui->editSelectComponentComboBox->hide(); + ui->editStatusLabel->hide(); + ui->editMinSpinBox->hide(); + ui->editMaxSpinBox->hide(); + ui->editTypeComboBox->hide(); isInEditMode = false; emit editingFinished(); } @@ -68,6 +85,21 @@ void QGCParamSlider::sendParameter() } } +void QGCParamSlider::setSliderValue(int sliderValue) +{ + parameterValue = scaledIntToFloat(sliderValue); + QString unit(""); + ui->valueLabel->setText(QString("%1 %2").arg(parameterValue, 0, 'f', 3).arg(unit)); +} + +void QGCParamSlider::setParameterValue(int uas, int component, QString parameterName, float value) +{ + parameterValue = value; + QString unit(""); + ui->valueLabel->setText(QString("%1 %2").arg(value, 0, 'f', 3).arg(unit)); + ui->valueSlider->setValue(floatToScaledInt(value)); +} + void QGCParamSlider::changeEvent(QEvent *e) { QWidget::changeEvent(e); @@ -80,12 +112,35 @@ void QGCParamSlider::changeEvent(QEvent *e) } } -void QGCParamSlider::writeSettings(QSettings& settings) +float QGCParamSlider::scaledIntToFloat(int sliderValue) { + return (((double)sliderValue)/scaledInt)*(parameterMax - parameterMin); +} +int QGCParamSlider::floatToScaledInt(float value) +{ + return ((value - parameterMin)/(parameterMax - parameterMin))*scaledInt; } -void QGCParamSlider::readSettings(const QSettings& settings) +void QGCParamSlider::writeSettings(QSettings& settings) { + settings.setValue("TYPE", "SLIDER"); + settings.setValue("QGC_PARAM_SLIDER_DESCRIPTION", ui->nameLabel->text()); + //settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text()); + settings.setValue("QGC_PARAM_SLIDER_PARAMID", ui->editSelectParamComboBox->currentText()); + settings.setValue("QGC_PARAM_SLIDER_COMPONENTID", ui->editSelectComponentComboBox->currentText()); + settings.setValue("QGC_PARAM_SLIDER_MIN", ui->editMinSpinBox->value()); + settings.setValue("QGC_PARAM_SLIDER_MAX", ui->editMaxSpinBox->value()); + settings.sync(); +} +void QGCParamSlider::readSettings(const QSettings& settings) +{ + ui->nameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString()); + //settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text()); + ui->editSelectParamComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); + ui->editSelectComponentsComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); + ui->editMinSpinBox(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); + ui->editMaxSpinBox(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); + qDebug() << "DONE READING SETTINGS"; } diff --git a/src/ui/designer/QGCParamSlider.h b/src/ui/designer/QGCParamSlider.h index 51bd73b..07b9cde 100644 --- a/src/ui/designer/QGCParamSlider.h +++ b/src/ui/designer/QGCParamSlider.h @@ -24,6 +24,10 @@ public slots: void endEditMode(); /** @brief Send the parameter to the MAV */ void sendParameter(); + /** @brief Set the slider value as parameter value */ + void setSliderValue(int sliderValue); + /** @brief Update the UI with the new parameter value */ + void setParameterValue(int uas, int component, QString parameterName, float value); void writeSettings(QSettings& settings); void readSettings(const QSettings& settings); @@ -34,8 +38,14 @@ protected: float parameterMin; float parameterMax; int component; ///< ID of the MAV component to address + double scaledInt; void changeEvent(QEvent *e); + /** @brief Convert scaled int to float */ + + float scaledIntToFloat(int sliderValue); + int floatToScaledInt(float value); + private: Ui::QGCParamSlider *ui; }; diff --git a/src/ui/designer/QGCParamSlider.ui b/src/ui/designer/QGCParamSlider.ui index c702252..7f195cb 100644 --- a/src/ui/designer/QGCParamSlider.ui +++ b/src/ui/designer/QGCParamSlider.ui @@ -6,8 +6,8 @@ 0 0 - 436 - 136 + 499 + 173 @@ -15,50 +15,21 @@ - + Informal Name.. - - - - - Float - - - - - Integer - - - - - Double - - - - - Short - - - - - Byte/Char - - - - - - + + Min - - + + Max @@ -78,37 +49,45 @@ - - + + - + Qt::Horizontal - - + + - - + + - Done + Please configure the parameter slider now: - - - - - Select Parameter.. - - + + + + TextLabel + - - + + + + + + + Done + + + + + true @@ -117,11 +96,13 @@ - - - - Please configure the parameter slider now: - + + + + + Select Parameter.. + + From 5f49774345f81281ffa15e68688d1efe5c8ad433 Mon Sep 17 00:00:00 2001 From: lm Date: Tue, 11 Jan 2011 09:15:18 +0100 Subject: [PATCH 4/4] Fixed low-altitude google maps support, reconfigured map widget to maximize map visibility --- lib/QMapControl/src/googlesatmapadapter.cpp | 2 +- lib/QMapControl/src/mapcontrol.cpp | 17 +++++-- lib/QMapControl/src/mapcontrol.h | 8 ++++ lib/QMapControl/src/mapnetwork.cpp | 2 + src/ui/HUD.cc | 2 +- src/ui/MainWindow.ui | 23 +++++++--- src/ui/MapWidget.cc | 70 ++++++++++++++++++++++++----- src/ui/MapWidget.h | 2 + src/ui/designer/QGCParamSlider.cc | 16 +++---- 9 files changed, 111 insertions(+), 31 deletions(-) diff --git a/lib/QMapControl/src/googlesatmapadapter.cpp b/lib/QMapControl/src/googlesatmapadapter.cpp index a2e3ede..5692b29 100644 --- a/lib/QMapControl/src/googlesatmapadapter.cpp +++ b/lib/QMapControl/src/googlesatmapadapter.cpp @@ -29,7 +29,7 @@ namespace qmapcontrol { GoogleSatMapAdapter::GoogleSatMapAdapter() - : TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 0, 18) + : TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 9, 21) { // // name = "googlesat"; // diff --git a/lib/QMapControl/src/mapcontrol.cpp b/lib/QMapControl/src/mapcontrol.cpp index 2872765..c01a95e 100644 --- a/lib/QMapControl/src/mapcontrol.cpp +++ b/lib/QMapControl/src/mapcontrol.cpp @@ -27,7 +27,7 @@ namespace qmapcontrol { MapControl::MapControl(QSize size, MouseMode mousemode) - : size(size), mymousemode(mousemode), scaleVisible(false), cursorPosVisible(false) + : size(size), mymousemode(mousemode), scaleVisible(false), cursorPosVisible(false), mapPen(Qt::black) { layermanager = new LayerManager(this, size); screen_middle = QPoint(size.width()/2, size.height()/2); @@ -126,6 +126,11 @@ namespace qmapcontrol } } + void MapControl::setPen(QPen pen) + { + this->mapPen = pen; + } + void MapControl::paintEvent(QPaintEvent* evnt) { QWidget::paintEvent(evnt); @@ -160,7 +165,7 @@ namespace qmapcontrol line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164; // draw the scale - painter.setPen(Qt::black); + painter.setPen(mapPen); QPoint p1(10,size.height()-20); QPoint p2((int)line,size.height()-20); painter.drawLine(p1,p2); @@ -209,7 +214,10 @@ namespace qmapcontrol // Draw the Lat and Lon if needed - if (cursorPosVisible) { + + // FIXME Mariano + if (cursorPosVisible && currentZoom() < 19) + { line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164; QString str; @@ -336,6 +344,9 @@ namespace qmapcontrol void MapControl::setZoom(int zoomlevel) { layermanager->setZoom(zoomlevel); + + qDebug() << "MAPCONTROL: Set zoomlevel to:" << zoomlevel << "at " << __FILE__ << __LINE__; + update(); } int MapControl::currentZoom() const diff --git a/lib/QMapControl/src/mapcontrol.h b/lib/QMapControl/src/mapcontrol.h index d0d434e..db790f4 100644 --- a/lib/QMapControl/src/mapcontrol.h +++ b/lib/QMapControl/src/mapcontrol.h @@ -222,6 +222,13 @@ namespace qmapcontrol */ void showCoord ( bool show ); + //! Set the pen for overlay text + /*! + * + * @param pen The new QPen + */ + void setPen(QPen pen); + private: LayerManager* layermanager; QPoint screen_middle; // middle of the widget (half size) @@ -239,6 +246,7 @@ namespace qmapcontrol MouseMode mymousemode; bool scaleVisible; bool cursorPosVisible; + QPen mapPen; bool m_loadingFlag; diff --git a/lib/QMapControl/src/mapnetwork.cpp b/lib/QMapControl/src/mapnetwork.cpp index 155d920..7fba8ae 100644 --- a/lib/QMapControl/src/mapnetwork.cpp +++ b/lib/QMapControl/src/mapnetwork.cpp @@ -98,6 +98,8 @@ namespace qmapcontrol // QGC FIXME Error is currently undetected // TODO Error is currently undetected //qDebug() << "NETWORK_PIXMAP_ERROR: " << ax; + qDebug() << "QMapControl external library: ERROR loading map:" << "width:" << pm.width() << "heigh:" << pm.height() << "at " << __FILE__ << __LINE__; + qDebug() << "HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__; } } diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 90c22ae..1fb7c7e 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -194,7 +194,7 @@ HUD::~HUD() QSize HUD::sizeHint() const { - return QSize(800, 600); + return QSize(width(), (width()*3.0f)/4); } void HUD::showEvent(QShowEvent* event) diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index c8165ae..ebd6609 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -6,8 +6,8 @@ 0 0 - 1000 - 800 + 800 + 500 @@ -31,14 +31,27 @@ - + + + + 0 + 0 + + + + + 200 + 150 + + + 0 0 - 1000 - 22 + 800 + 25 diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index cda58c6..443ee5f 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -14,6 +14,7 @@ #include #include +#include "QGC.h" #include "MapWidget.h" #include "ui_MapWidget.h" #include "UASInterface.h" @@ -34,6 +35,19 @@ MapWidget::MapWidget(QWidget *parent) : m_ui(new Ui::MapWidget) { m_ui->setupUi(this); + mc = new qmapcontrol::MapControl(QSize(320, 240)); + + // VISUAL MAP STYLE + QString buttonStyle("QAbstractButton { background-color: rgba(20, 20, 20, 45%); border-color: rgba(10, 10, 10, 50%)}"); + mc->setPen(QGC::colorCyan.darker(400)); + + + + + + + + waypointIsDrag = false; @@ -41,7 +55,7 @@ MapWidget::MapWidget(QWidget *parent) : this->setFocusPolicy(Qt::StrongFocus); // create MapControl - mc = new qmapcontrol::MapControl(QSize(320, 240)); + mc->showScale(true); mc->showCoord(true); mc->enablePersistentCache(); @@ -126,32 +140,35 @@ MapWidget::MapWidget(QWidget *parent) : mapButton = new QPushButton(this); mapButton->setText("Map Source"); mapButton->setMenu(mapMenu); + mapButton->setStyleSheet(buttonStyle); // display the MapControl in the application QGridLayout* layout = new QGridLayout(this); layout->setMargin(0); - layout->setSpacing(2); - layout->addWidget(mc, 0, 0, 1, 2); - layout->addWidget(mapButton, 1, 0); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 1, 1); - layout->setRowStretch(0, 100); - layout->setRowStretch(1, 1); - layout->setColumnStretch(0, 1); - layout->setColumnStretch(1, 50); + layout->setSpacing(0); + layout->addWidget(mc, 0, 0); setLayout(layout); // create buttons to control the map (zoom, GPS tracking and WP capture) QPushButton* zoomin = new QPushButton(QIcon(":/images/actions/list-add.svg"), "", this); + zoomin->setStyleSheet(buttonStyle); QPushButton* zoomout = new QPushButton(QIcon(":/images/actions/list-remove.svg"), "", this); + zoomout->setStyleSheet(buttonStyle); createPath = new QPushButton(QIcon(":/images/actions/go-bottom.svg"), "", this); + createPath->setStyleSheet(buttonStyle); clearTracking = new QPushButton(QIcon(""), "", this); + clearTracking->setStyleSheet(buttonStyle); followgps = new QPushButton(QIcon(":/images/actions/system-lock-screen.svg"), "", this); + followgps->setStyleSheet(buttonStyle); + QPushButton* goToButton = new QPushButton(QIcon(""), "T", this); + goToButton->setStyleSheet(buttonStyle); zoomin->setMaximumWidth(30); zoomout->setMaximumWidth(30); createPath->setMaximumWidth(30); clearTracking->setMaximumWidth(30); followgps->setMaximumWidth(30); + goToButton->setMaximumWidth(30); // Set checkable buttons // TODO: Currently checked buttons are are very difficult to distinguish when checked. @@ -161,8 +178,8 @@ MapWidget::MapWidget(QWidget *parent) : // add buttons to control the map (zoom, GPS tracking and WP capture) QGridLayout* innerlayout = new QGridLayout(mc); - innerlayout->setMargin(5); - innerlayout->setSpacing(5); + innerlayout->setMargin(3); + innerlayout->setSpacing(3); innerlayout->addWidget(zoomin, 0, 0); innerlayout->addWidget(zoomout, 1, 0); innerlayout->addWidget(followgps, 2, 0); @@ -170,7 +187,9 @@ MapWidget::MapWidget(QWidget *parent) : innerlayout->addWidget(clearTracking, 4, 0); // Add spacers to compress buttons on the top left innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 5, 0); - innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 0, 1, 0, 6); + innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 0, 1, 0, 7); + innerlayout->addWidget(mapButton, 0, 6); + innerlayout->addWidget(goToButton, 0, 7); innerlayout->setRowStretch(0, 1); innerlayout->setRowStretch(1, 100); mc->setLayout(innerlayout); @@ -183,6 +202,8 @@ MapWidget::MapWidget(QWidget *parent) : connect(zoomout, SIGNAL(clicked(bool)), mc, SLOT(zoomOut())); + connect(goToButton, SIGNAL(clicked()), this, SLOT(goTo())); + QList systems = UASManager::instance()->getUASList(); foreach(UASInterface* system, systems) { @@ -229,6 +250,31 @@ MapWidget::MapWidget(QWidget *parent) : radioCamera = 10; } +void MapWidget::goTo() +{ + bool ok; + QString text = QInputDialog::getText(this, tr("Please enter coordinates"), + tr("Coordinates (Lat,Lon):"), QLineEdit::Normal, + QString("%1,%2").arg(mc->currentCoordinate().x()).arg(mc->currentCoordinate().y()), &ok); + if (ok && !text.isEmpty()) + { + QStringList split = text.split(","); + if (split.length() == 2) + { + bool convert; + double latitude = split.first().toDouble(&convert); + ok &= convert; + double longitude = split.last().toDouble(&convert); + ok &= convert; + + if (ok) + { + mc->setView(QPointF(latitude, longitude)); + } + } + } +} + void MapWidget::mapproviderSelected(QAction* action) { diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index 5365433..d8474cb 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -77,6 +77,8 @@ public slots: void clearPath(); void changeGlobalWaypointPositionBySpinBox(int index, float lat, float lon); void drawBorderCamAtMap(bool status); + /** @brief Bring up dialog to go to a specific location */ + void goTo(); protected: void changeEvent(QEvent* e); diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index 5af21c8..6164cfc 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -22,7 +22,7 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ui->editDoneButton->show(); ui->editMaxLabel->show(); ui->editMinLabel->show(); - ui->editNameLineEdit->show(); + ui->editNameLabel->show(); ui->editInstructionsLabel->show(); ui->editRefreshParamsButton->show(); ui->editSelectParamComboBox->show(); @@ -30,7 +30,6 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ui->editStatusLabel->show(); ui->editMinSpinBox->show(); ui->editMaxSpinBox->show(); - ui->editTypeComboBox->show(); connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); } @@ -44,7 +43,7 @@ void QGCParamSlider::startEditMode() ui->editDoneButton->show(); ui->editMaxLabel->show(); ui->editMinLabel->show(); - ui->editNameLineEdit->show(); + ui->editNameLabel->show(); ui->editInstructionsLabel->show(); ui->editRefreshParamsButton->show(); ui->editSelectParamComboBox->show(); @@ -60,7 +59,7 @@ void QGCParamSlider::endEditMode() ui->editDoneButton->hide(); ui->editMaxLabel->hide(); ui->editMinLabel->hide(); - ui->editNameLineEdit->hide(); + ui->editNameLabel->hide(); ui->editInstructionsLabel->hide(); ui->editRefreshParamsButton->hide(); ui->editSelectParamComboBox->hide(); @@ -68,7 +67,6 @@ void QGCParamSlider::endEditMode() ui->editStatusLabel->hide(); ui->editMinSpinBox->hide(); ui->editMaxSpinBox->hide(); - ui->editTypeComboBox->hide(); isInEditMode = false; emit editingFinished(); } @@ -138,9 +136,9 @@ void QGCParamSlider::readSettings(const QSettings& settings) { ui->nameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString()); //settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text()); - ui->editSelectParamComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); - ui->editSelectComponentsComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); - ui->editMinSpinBox(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); - ui->editMaxSpinBox(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); + ui->editSelectParamComboBox->setEditText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); + ui->editSelectComponentComboBox->setEditText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); + ui->editMinSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); + ui->editMaxSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); qDebug() << "DONE READING SETTINGS"; }