From c498611c60a3d0ef362a6bef5e4a325744fcddfa Mon Sep 17 00:00:00 2001 From: pip Date: Thu, 24 Jun 2010 06:58:25 +0000 Subject: [PATCH] UAV location added to lower statusbar on the new map plug-in. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@881 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/opmap/opmap_widget.ui | 162 +++++++++++------- .../src/plugins/opmap/opmapgadgetwidget.cpp | 31 ++-- ground/src/plugins/opmap/opmapgadgetwidget.h | 2 - 3 files changed, 116 insertions(+), 79 deletions(-) diff --git a/ground/src/plugins/opmap/opmap_widget.ui b/ground/src/plugins/opmap/opmap_widget.ui index 72a9224a8..cd7da844e 100644 --- a/ground/src/plugins/opmap/opmap_widget.ui +++ b/ground/src/plugins/opmap/opmap_widget.ui @@ -85,7 +85,7 @@ - 8 + 5 8 @@ -121,20 +121,14 @@ color: rgb(255, 255, 255); - + + + QFrame::Plain + - Qt::Horizontal + Qt::Vertical - - QSizePolicy::Fixed - - - - 20 - 20 - - - + @@ -168,20 +162,14 @@ color: rgb(255, 255, 255); - + + + QFrame::Plain + - Qt::Horizontal + Qt::Vertical - - QSizePolicy::Fixed - - - - 20 - 20 - - - + @@ -247,20 +235,14 @@ color: rgb(255, 255, 255); - + + + QFrame::Plain + - Qt::Horizontal + Qt::Vertical - - QSizePolicy::Fixed - - - - 20 - 20 - - - + @@ -293,20 +275,14 @@ color: rgb(255, 255, 255); - + + + QFrame::Plain + - Qt::Horizontal + Qt::Vertical - - QSizePolicy::Fixed - - - - 20 - 20 - - - + @@ -386,6 +362,9 @@ color: rgb(255, 255, 255); 16777215 + + Zoom level + background-color: rgba(255, 255, 255, 0); color: rgb(255, 255, 255); @@ -404,6 +383,16 @@ color: rgb(255, 255, 255); + + + + QFrame::Plain + + + Qt::Vertical + + + @@ -417,6 +406,16 @@ color: rgb(255, 255, 255); + + + + QFrame::Plain + + + Qt::Vertical + + + @@ -488,7 +487,16 @@ color: rgb(255, 255, 255); background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(120, 120, 120, 255), stop:1 rgba(68, 68, 68, 255)); - + + 5 + + + 0 + + + 5 + + 0 @@ -524,6 +532,16 @@ color: rgb(255, 255, 255); + + + + QFrame::Plain + + + Qt::Horizontal + + + @@ -551,6 +569,16 @@ color: rgb(255, 255, 255); + + + + QFrame::Plain + + + Qt::Horizontal + + + @@ -644,7 +672,7 @@ color: rgb(255, 255, 255); 0 - 0 + 5 0 @@ -655,10 +683,10 @@ color: rgb(255, 255, 255); - 8 + 12 - 8 + 12 8 @@ -696,20 +724,14 @@ background-color: rgba(255, 255, 255, 0); - + + + QFrame::Plain + - Qt::Horizontal + Qt::Vertical - - QSizePolicy::Fixed - - - - 20 - 20 - - - + @@ -743,6 +765,16 @@ background-color: rgba(255, 255, 255, 0); + + + + QFrame::Plain + + + Qt::Vertical + + + diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/src/plugins/opmap/opmapgadgetwidget.cpp index 009e5ab0e..7d60f1d8f 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/src/plugins/opmap/opmapgadgetwidget.cpp @@ -133,12 +133,12 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) // create the desired timers m_updateTimer = new QTimer(); - m_updateTimer->setInterval(250); + m_updateTimer->setInterval(200); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition())); m_updateTimer->start(); m_statusUpdateTimer = new QTimer(); - m_statusUpdateTimer->setInterval(100); + m_statusUpdateTimer->setInterval(200); connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos())); m_statusUpdateTimer->start(); @@ -305,15 +305,24 @@ void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) void OPMapGadgetWidget::updatePosition() { - PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data + PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data + internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position + double uav_heading = data.Heading; // current UAV heading + double uav_height_feet = data.Altitude * 3.2808399; // current UAV height + double uav_ground_speed = data.Groundspeed; // current UAV ground speed + + // display the UAV lat/lon position + QString str = " lat:" + QString::number(uav_pos.Lat(), 'f', 6) + + " lon:" + QString::number(uav_pos.Lng(), 'f', 6) + + " " + QString::number(uav_heading, 'f', 1) + "deg" + + " " + QString::number(uav_height_feet, 'f', 1) + "feet" + + " " + QString::number(uav_ground_speed, 'f', 1) + "mph"; + if (m_widget) m_widget->labelMapPos->setText(str); if (m_map && followUAVpositionAct && followUAVheadingAct) { if (followUAVpositionAct->isChecked()) { - internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position - double uav_heading = data.Heading; - internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position double map_heading = m_map->Rotate(); @@ -339,10 +348,8 @@ void OPMapGadgetWidget::updateMousePos() { // the mouse has moved mouse_lat_lon = lat_lon; - QString coord_str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 6) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 6); - - statusLabel.setText(coord_str); - if (m_widget) m_widget->labelMousePos->setText(coord_str); + QString str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 6) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 6); + if (m_widget) m_widget->labelMousePos->setText(str); } } @@ -392,7 +399,7 @@ void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point) if (m_widget) { QString coord_str = " " + QString::number(point.Lat(), 'f', 6) + " " + QString::number(point.Lng(), 'f', 6) + " "; - m_widget->labelMapPos->setText(coord_str); +// m_widget->labelMapPos->setText(coord_str); } } @@ -671,7 +678,7 @@ void OPMapGadgetWidget::createMapOverlayUserControls() overlay_layout_h2->setMargin(0); overlay_layout_h2->setSpacing(4); overlay_layout_h2->addStretch(0); - overlay_layout_h2->addWidget(&statusLabel); +// overlay_layout_h2->addWidget(&statusLabel); overlay_layout_h2->addStretch(0); overlay_layout_v1->addSpacing(10); diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.h b/ground/src/plugins/opmap/opmapgadgetwidget.h index 4013ad403..66292f5a5 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.h +++ b/ground/src/plugins/opmap/opmapgadgetwidget.h @@ -139,8 +139,6 @@ private: internals::PointLatLng mouse_lat_lon; - QLabel statusLabel; - QTimer *m_updateTimer; QTimer *m_statusUpdateTimer;