From f56866c45bc9f7b2dbf88acc4722b1ec59cb5dab Mon Sep 17 00:00:00 2001 From: pip Date: Tue, 13 Jul 2010 15:45:40 +0000 Subject: [PATCH] UAV overlay control added to the OPMap plug-in git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1085 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/opmap/images/uav_heading.png | Bin 3509 -> 3901 bytes ground/src/plugins/opmap/images/uav_trail.png | Bin 0 -> 4102 bytes .../plugins/opmap/images/uav_trail_clear.png | Bin 0 -> 4034 bytes ground/src/plugins/opmap/opmap.qrc | 2 + ground/src/plugins/opmap/opmap_widget.ui | 90 +++++++++++- .../src/plugins/opmap/opmapgadgetwidget.cpp | 137 +++++++++++++----- ground/src/plugins/opmap/opmapgadgetwidget.h | 12 +- 7 files changed, 203 insertions(+), 38 deletions(-) create mode 100644 ground/src/plugins/opmap/images/uav_trail.png create mode 100644 ground/src/plugins/opmap/images/uav_trail_clear.png diff --git a/ground/src/plugins/opmap/images/uav_heading.png b/ground/src/plugins/opmap/images/uav_heading.png index b4cd8598f9bc2e093a23dfacb56553dab3721add..c8b701fad92f5e37394c52282b97b1c492e210ea 100644 GIT binary patch delta 1150 zcmV-^1cCdt8@(Q|&kBD8SV=@dRCwCNmv3lOR~W{ho7-Njlx7OSNu?kZgnkkVf*_j| zGUf!KW6n`GPzD2GpM-&5_sJm$gTY2&U}ZWst6;^nsb#UNwac8^wKYxCmac8uCf430 zHED8h?mg$(2dAdh=3hI!@P0YTeV^Ys-19!~tB}N-d@4$QgHV3~>;6= z1F`=HfN+C20pPG{nwnu4qqc3QR8@^>npUT2T5Ux|#oLhR0dNCA8yrX#&P(PG$wmtH z8fhajJ~n>dKj3$-_uo)3w0k~0f5tMcVG8P&X`L#RzmWJ>6if$30_VM5-t7fpbK+^@ z>F3gx5oyb=*iwJ2x-Dh-3v&y#r2w2;j4n=e zdOGXM6@L+e8U-(}Bv*z*!BACU0Ld21v=UvNT@4!+Uk!05G9PKr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7JYMl#(zE1JCoER;#t>`~HFu!ivY^PCA{QjmP8mT54d`as2jMZwuSD70>es zf`Bj#ky8G79Rz_CLP%9r(KL+%PaRnEav`qw@A)4C03!v8y9Z{(>i_@%07*qoM6N<$ Ef~R}S(EtDd literal 0 HcmV?d00001 diff --git a/ground/src/plugins/opmap/images/uav_trail_clear.png b/ground/src/plugins/opmap/images/uav_trail_clear.png new file mode 100644 index 0000000000000000000000000000000000000000..de985699a37491daad1d67967dd2a14fdf6f46de GIT binary patch literal 4034 zcmV;z4?XaSP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xM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j${FZ2`>3S_m60P6w z7k%H)fTXe1xZ?=?r5T<0@kC*Jyj@Mx)HMvlvMaV}+qPbg=aVoD)o3)z zM&2kNkH<2O<6PHu&v6|8>1UpvEdl_KKk;~a{M+MOqtVC@!?2j=xd{|>T^E|Bp_Ecm z$}~xmJc=TjrfDXG$W7Cfj^kveY3?Zpc5TO>e)6dZfimages/waypoint_marker2.png images/waypoint_marker1.png images/uav_heading.png + images/uav_trail.png + images/uav_trail_clear.png diff --git a/ground/src/plugins/opmap/opmap_widget.ui b/ground/src/plugins/opmap/opmap_widget.ui index 5bcb9a396..6430130e6 100644 --- a/ground/src/plugins/opmap/opmap_widget.ui +++ b/ground/src/plugins/opmap/opmap_widget.ui @@ -6,8 +6,8 @@ 0 0 - 713 - 363 + 548 + 416 @@ -874,6 +874,15 @@ border-radius: 3px; 20 + + true + + + 500 + + + 500 + false @@ -955,6 +964,15 @@ border-radius: 3px; 20 + + true + + + 500 + + + 500 + false @@ -998,7 +1016,7 @@ border-radius: 3px; - true + false false @@ -1030,7 +1048,7 @@ border-radius: 3px; true - true + false false @@ -1062,8 +1080,72 @@ border-radius: 3px; true + false + + + false + + + + + + + Show/Hide the UAV trail + + + + + + + + + + :/opmap/images/uav_trail.png:/opmap/images/uav_trail.png + + + + 20 + 20 + + + true + + false + + + false + + + + + + + Clear the UAV trail + + + + + + + + + + :/opmap/images/uav_trail_clear.png:/opmap/images/uav_trail_clear.png + + + + 20 + 20 + + + + false + + + false + false diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/src/plugins/opmap/opmapgadgetwidget.cpp index 8616ab1b0..9db961940 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/src/plugins/opmap/opmapgadgetwidget.cpp @@ -92,6 +92,13 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_map->SetMaxZoom(19); m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions m_map->SetFollowMouse(true); // we want a contiuous mouse position reading + m_map->SetShowUAV(true); // display the UAV position on the map + +// m_map->UAV->SetTrailTime(1); // seconds +// m_map->UAV->SetTrailDistance(0.1); // kilometers + + m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed); +// m_map->UAV->SetTrailType(UAVTrailType::ByDistance); // ************** @@ -145,6 +152,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_widget->progressBarMap->setMaximum(1); + m_widget->toolButtonShowUAVtrail->setChecked(true); + /* #if defined(Q_OS_MAC) #elif defined(Q_OS_WIN) @@ -419,8 +428,10 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) menu.addAction(goHomeAct); menu.addAction(goUAVAct); - menu.addSeparator()->setText(tr("Follow")); + menu.addSeparator()->setText(tr("UAV")); + menu.addAction(showUAVAct); + menu.addAction(showUAVtrailAct); menu.addAction(followUAVpositionAct); menu.addAction(followUAVheadingAct); @@ -501,36 +512,26 @@ void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) void OPMapGadgetWidget::updatePosition() { 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_meters = data.Altitude; // current UAV height - double uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed + float uav_heading = data.Heading; // current UAV heading + float uav_altitude_meters = data.Altitude; // current UAV height + float uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed // display the UAV lat/lon position QString str = " lat: " + QString::number(uav_pos.Lat(), 'f', 7) + " lon: " + QString::number(uav_pos.Lng(), 'f', 7) + " " + QString::number(uav_heading, 'f', 1) + "deg" + - " " + QString::number(uav_height_meters, 'f', 1) + "m" + + " " + QString::number(uav_altitude_meters, 'f', 1) + "m" + " " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s"; if (m_widget) m_widget->labelUAVPos->setText(str); - if (m_map && followUAVpositionAct && followUAVheadingAct) + if (m_map) { - if (followUAVpositionAct->isChecked()) +// if (m_map->ShowUAV()) { - internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position - double map_heading = m_map->Rotate(); - - if (map_pos != uav_pos || map_heading != uav_heading) - { - m_map->SetCurrentPosition(uav_pos); // keep the map centered on the UAV - - if (followUAVheadingAct->isChecked()) - m_map->SetRotate(-uav_heading); // rotate the map to match the uav heading - else - if (m_map->Rotate() != 0) - m_map->SetRotate(0); // reset the rotation to '0' - } + m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position + m_map->UAV->SetUAVHeading(uav_heading); // set the maps UAV heading } } } @@ -713,6 +714,16 @@ void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked() followUAVheadingAct->toggle(); } +void OPMapGadgetWidget::on_toolButtonShowUAVtrail_clicked() +{ + showUAVtrailAct->toggle(); +} + +void OPMapGadgetWidget::on_toolButtonClearUAVtrail_clicked() +{ + clearUAVtrailAct->trigger(); +} + void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position) { setZoom(position); @@ -894,12 +905,18 @@ void OPMapGadgetWidget::createActions() connect(findPlaceAct, SIGNAL(triggered()), this, SLOT(onFindPlaceAct_triggered())); showCompassAct = new QAction(tr("Show compass"), this); -// showCompassAct->setShortcut(tr("Ctrl+M")); - showCompassAct->setStatusTip(tr("Show/Hide the map compass")); + showCompassAct->setStatusTip(tr("Show/Hide the compass")); showCompassAct->setCheckable(true); showCompassAct->setChecked(true); connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool))); + showUAVAct = new QAction(tr("Show UAV"), this); + showUAVAct->setStatusTip(tr("Show/Hide the UAV")); + showUAVAct->setCheckable(true); + showUAVAct->setChecked(m_map->ShowUAV()); + showUAVAct->setEnabled(false); // temporary + connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool))); + zoomInAct = new QAction(tr("Zoom &In"), this); zoomInAct->setShortcut(Qt::Key_PageUp); zoomInAct->setStatusTip(tr("Zoom the map in")); @@ -938,6 +955,16 @@ void OPMapGadgetWidget::createActions() followUAVheadingAct->setChecked(false); connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool))); + showUAVtrailAct = new QAction(tr("Show UAV trail"), this); + showUAVtrailAct->setStatusTip(tr("Show/Hide the UAV trail")); + showUAVtrailAct->setCheckable(true); + showUAVtrailAct->setChecked(true); + connect(showUAVtrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVtrailAct_toggled(bool))); + + clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this); + clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail")); + connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered())); + wayPointEditorAct = new QAction(tr("&Waypoint editor"), this); wayPointEditorAct->setShortcut(tr("Ctrl+W")); wayPointEditorAct->setStatusTip(tr("Open the waypoint editor")); @@ -1035,10 +1062,16 @@ void OPMapGadgetWidget::onFindPlaceAct_triggered() */ } -void OPMapGadgetWidget::onShowCompassAct_toggled(bool show_compass) +void OPMapGadgetWidget::onShowCompassAct_toggled(bool show) { if (m_map) - m_map->SetShowCompass(show_compass); + m_map->SetShowCompass(show); +} + +void OPMapGadgetWidget::onShowUAVAct_toggled(bool show) +{ + if (m_map) + m_map->SetShowUAV(show); // this can cause a rather big crash } void OPMapGadgetWidget::onGoZoomInAct_triggered() @@ -1093,11 +1126,7 @@ void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked) if (m_widget->toolButtonMapUAV->isChecked() != checked) m_widget->toolButtonMapUAV->setChecked(checked); - if (m_map) - { -// m_map->SetCanDragMap(!checked); // allow/disallow manual map dragging - if (!checked) m_map->SetRotate(0); // reset map rotation to 0deg - } + setMapFollowingmode(); } } @@ -1108,13 +1137,28 @@ void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked) if (m_widget->toolButtonMapUAVheading->isChecked() != checked) m_widget->toolButtonMapUAVheading->setChecked(checked); - if (m_map) - { - if (!checked) m_map->SetRotate(0); // reset map rotation to 0deg - } + setMapFollowingmode(); } } +void OPMapGadgetWidget::onShowUAVtrailAct_toggled(bool checked) +{ + if (m_widget) + { + if (m_widget->toolButtonShowUAVtrail->isChecked() != checked) + m_widget->toolButtonShowUAVtrail->setChecked(checked); + + if (m_map) + m_map->UAV->SetShowTrail(checked); + } +} + +void OPMapGadgetWidget::onClearUAVtrailAct_triggered() +{ + if (m_map) + m_map->UAV->DeleteTrail(); +} + void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered() { waypoint_editor_dialog.show(); @@ -1242,3 +1286,30 @@ void OPMapGadgetWidget::saveComboBoxLines(QComboBox *comboBox, QString filename) } // ************************************************************************************* + +void OPMapGadgetWidget::setMapFollowingmode() +{ + if (!m_map) return; + + if (!followUAVpositionAct->isChecked()) + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::None); + m_map->SetRotate(0); // reset map rotation to 0deg + } + else + if (!followUAVheadingAct->isChecked()) + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); + m_map->SetRotate(0); // reset map rotation to 0deg + } + else + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode + +// if (m_map->ShowUAV()) + m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap); + } +} + +// ************************************************************************************* diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.h b/ground/src/plugins/opmap/opmapgadgetwidget.h index 7c6e693a8..83ec91fb7 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.h +++ b/ground/src/plugins/opmap/opmapgadgetwidget.h @@ -116,6 +116,8 @@ private slots: void on_toolButtonMapHome_clicked(); void on_toolButtonMapUAV_clicked(); void on_toolButtonMapUAVheading_clicked(); + void on_toolButtonShowUAVtrail_clicked(); + void on_toolButtonClearUAVtrail_clicked(); void on_horizontalSliderZoom_sliderMoved(int position); void on_toolButtonAddWaypoint_clicked(); void on_treeViewWaypoints_clicked(QModelIndex index); @@ -154,7 +156,8 @@ private slots: void onCopyMouseLatToClipAct_triggered(); void onCopyMouseLonToClipAct_triggered(); void onFindPlaceAct_triggered(); - void onShowCompassAct_toggled(bool show_compass); + void onShowCompassAct_toggled(bool show); + void onShowUAVAct_toggled(bool show); void onGoZoomInAct_triggered(); void onGoZoomOutAct_triggered(); void onGoMouseClickAct_triggered(); @@ -162,6 +165,8 @@ private slots: void onGoUAVAct_triggered(); void onFollowUAVpositionAct_toggled(bool checked); void onFollowUAVheadingAct_toggled(bool checked); + void onShowUAVtrailAct_toggled(bool checked); + void onClearUAVtrailAct_triggered(); void onOpenWayPointEditorAct_triggered(); void onAddWayPointAct_triggered(); void onEditWayPointAct_triggered(); @@ -218,6 +223,7 @@ private: QAction *copyMouseLonToClipAct; QAction *findPlaceAct; QAction *showCompassAct; + QAction *showUAVAct; QAction *zoomInAct; QAction *zoomOutAct; QAction *goMouseClickAct; @@ -225,6 +231,8 @@ private: QAction *goUAVAct; QAction *followUAVpositionAct; QAction *followUAVheadingAct; + QAction *showUAVtrailAct; + QAction *clearUAVtrailAct; QAction *wayPointEditorAct; QAction *addWayPointAct; QAction *editWayPointAct; @@ -237,6 +245,8 @@ private: void loadComboBoxLines(QComboBox *comboBox, QString filename); void saveComboBoxLines(QComboBox *comboBox, QString filename); + + void setMapFollowingmode(); }; #endif /* OPMAP_GADGETWIDGET_H_ */