From af4b8ccea1ad91e6657a56e001f2d0f3a6d08a04 Mon Sep 17 00:00:00 2001 From: David Goodman Date: Thu, 29 Aug 2013 16:22:31 -0700 Subject: [PATCH 1/3] Default map type checked and defined in QGCMapWidget.h. --- src/ui/map/QGCMapToolBar.cc | 11 ++++++++++- src/ui/map/QGCMapWidget.cc | 6 ++++++ src/ui/map/QGCMapWidget.h | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ui/map/QGCMapToolBar.cc b/src/ui/map/QGCMapToolBar.cc index 067544b..c9596ef 100644 --- a/src/ui/map/QGCMapToolBar.cc +++ b/src/ui/map/QGCMapToolBar.cc @@ -60,18 +60,27 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) action = mapTypesMenu.addAction(tr("Bing Hybrid"),this,SLOT(setMapType())); action->setData(MapType::BingHybrid); action->setCheckable(true); +#ifdef MAP_DEFAULT_TYPE_BING + action->setChecked(true); +#endif mapTypesGroup->addAction(action); action = mapTypesMenu.addAction(tr("Google Hybrid"),this,SLOT(setMapType())); action->setData(MapType::GoogleHybrid); action->setCheckable(true); +#ifdef MAP_DEFAULT_TYPE_GOOGLE + action->setChecked(true); +#endif mapTypesGroup->addAction(action); action = mapTypesMenu.addAction(tr("OpenStreetMap"),this,SLOT(setMapType())); action->setData(MapType::OpenStreetMap); action->setCheckable(true); +#ifdef MAP_DEFAULT_TYPE_OSM + action->setChecked(true); +#endif mapTypesGroup->addAction(action); - //TODO check current item + optionsMenu.addMenu(&mapTypesMenu); diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 748d1c2..8e2e821 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -34,7 +34,13 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) : //this->SetShowTileGridLines(true); //default appears to be Google Hybrid, and is broken currently +#if defined MAP_DEFAULT_TYPE_BING this->SetMapType(MapType::BingHybrid); +#elif defined MAP_DEFAULT_TYPE_GOOGLE + this->SetMapType(MapType::GoogleHybrid); +#else + this->SetMapType(MapType::OpenStreetMap); +#endif this->setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/src/ui/map/QGCMapWidget.h b/src/ui/map/QGCMapWidget.h index 8657ede..2f169a9 100644 --- a/src/ui/map/QGCMapWidget.h +++ b/src/ui/map/QGCMapWidget.h @@ -5,6 +5,11 @@ #include #include "../../../libs/opmapcontrol/opmapcontrol.h" +// Choose one default map type +#define MAP_DEFAULT_TYPE_BING +//#define MAP_DEFAULT_TYPE_GOOGLE +//#define MAP_DEFAULT_TYPE_OSM + class UASInterface; class UASWaypointManager; class Waypoint; From d916bfdda446fe47f6bef1baf234336a05320d3b Mon Sep 17 00:00:00 2001 From: David Goodman Date: Thu, 29 Aug 2013 16:24:28 -0700 Subject: [PATCH 2/3] Removed commented out code. --- src/ui/map/QGCMapWidget.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 8e2e821..6fbc618 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -171,15 +171,6 @@ void QGCMapWidget::mouseReleaseEvent(QMouseEvent *event) mapcontrol::OPMapWidget::mouseReleaseEvent(event); } -/* -void QGCMapWidget::contextMenuEvent(QContextMenuEvent *event) -{ - // TODO Remove this method - qDebug() << "Context menu event triggered."; - mapcontrol::OPMapWidget::contextMenuEvent(event); -} -*/ - QGCMapWidget::~QGCMapWidget() { SetShowHome(false); // doing this appears to stop the map lib crashing on exit From 948e9d063bf90ac2fb2baaba6ca69cc9279d4099 Mon Sep 17 00:00:00 2001 From: David Goodman Date: Thu, 29 Aug 2013 16:32:55 -0700 Subject: [PATCH 3/3] Fixed "Go To Here" and "Point Camera Here" map context actions to use correct mouse coordinates. --- src/ui/map/QGCMapWidget.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 6fbc618..db76a20 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -81,7 +81,7 @@ void QGCMapWidget::guidedActionTriggered() } } // Create new waypoint and send it to the WPManager to send out. - internals::PointLatLng pos = map->FromLocalToLatLng(mousePressPos.x(), mousePressPos.y()); + internals::PointLatLng pos = map->FromLocalToLatLng(contextMousePressPos.x(), contextMousePressPos.y()); qDebug() << "Guided action requested. Lat:" << pos.Lat() << "Lon:" << pos.Lng(); Waypoint wp; wp.setLatitude(pos.Lat()); @@ -119,7 +119,7 @@ void QGCMapWidget::cameraActionTriggered() if (newmav) { newmav->setMountConfigure(4,true,true,true); - internals::PointLatLng pos = map->FromLocalToLatLng(mousePressPos.x(), mousePressPos.y()); + internals::PointLatLng pos = map->FromLocalToLatLng(contextMousePressPos.x(), contextMousePressPos.y()); newmav->setMountControl(pos.Lat(),pos.Lng(),100,true); } }