diff --git a/src/ui/map/QGCMapToolBar.cc b/src/ui/map/QGCMapToolBar.cc index 1d332c6..97c972a 100644 --- a/src/ui/map/QGCMapToolBar.cc +++ b/src/ui/map/QGCMapToolBar.cc @@ -28,6 +28,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) connect(ui->goHomeButton, SIGNAL(clicked()), map, SLOT(goHome())); connect(ui->lastPosButton, SIGNAL(clicked()), map, SLOT(loadSettings())); connect(ui->clearTrailsButton, SIGNAL(clicked()), map, SLOT(deleteTrails())); + connect(ui->lockCheckBox, SIGNAL(clicked(bool)), map, SLOT(setZoomBlocked(bool))); connect(map, SIGNAL(OnTileLoadStart()), this, SLOT(tileLoadStart())); connect(map, SIGNAL(OnTileLoadComplete()), this, SLOT(tileLoadEnd())); connect(map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(tileLoadProgress(int))); diff --git a/src/ui/map/QGCMapToolBar.ui b/src/ui/map/QGCMapToolBar.ui index 91840d4..6ad334a 100644 --- a/src/ui/map/QGCMapToolBar.ui +++ b/src/ui/map/QGCMapToolBar.ui @@ -13,11 +13,20 @@ Form - + 2 - + + 4 + + + 4 + + + 4 + + 4 @@ -63,6 +72,13 @@ + + + Lock + + + + Follow diff --git a/src/ui/map/QGCMapWidget.cc b/src/ui/map/QGCMapWidget.cc index 6e47c7f..b13849d 100644 --- a/src/ui/map/QGCMapWidget.cc +++ b/src/ui/map/QGCMapWidget.cc @@ -18,6 +18,7 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) : mapInitialized(false), mapPositionInitialized(false), homeAltitude(0), + zoomBlocked(false), uas(NULL) { currWPManager = UASManager::instance()->getActiveUASWaypointManager(); @@ -249,6 +250,13 @@ void QGCMapWidget::hideEvent(QHideEvent* event) OPMapWidget::hideEvent(event); } +void QGCMapWidget::wheelEvent ( QWheelEvent * event ) +{ + if (!zoomBlocked) { + OPMapWidget::wheelEvent(event); + } +} + /** * @param changePosition Load also the last position from settings and update the map position. */ @@ -328,14 +336,10 @@ void QGCMapWidget::mouseDoubleClickEvent(QMouseEvent* event) // Create new waypoint internals::PointLatLng pos = map->FromLocalToLatLng(event->pos().x(), event->pos().y()); Waypoint* wp = currWPManager->createWaypoint(); - // wp->blockSignals(true); - // wp->setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT); wp->setLatitude(pos.Lat()); wp->setLongitude(pos.Lng()); wp->setFrame((MAV_FRAME)currWPManager->getFrameRecommendation()); wp->setAltitude(currWPManager->getAltitudeRecommendation()); - // wp->blockSignals(false); - // currWPManager->notifyOfChangeEditable(wp); } OPMapWidget::mouseDoubleClickEvent(event); diff --git a/src/ui/map/QGCMapWidget.h b/src/ui/map/QGCMapWidget.h index 8b41d84..0f6e285 100644 --- a/src/ui/map/QGCMapWidget.h +++ b/src/ui/map/QGCMapWidget.h @@ -124,6 +124,11 @@ public slots: } } + void setZoomBlocked(bool blocked) + { + zoomBlocked = blocked; + } + /** @brief Load the settings for this widget from disk */ void loadSettings(bool changePosition=true); /** @brief Store the settings for this widget to disk */ @@ -139,6 +144,7 @@ protected: /** @brief Initialize */ void showEvent(QShowEvent* event); void hideEvent(QHideEvent* event); + void wheelEvent(QWheelEvent* event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent* event); @@ -172,6 +178,7 @@ protected: QPoint mousePressPos; ///< Mouse position when the button is released. QPoint contextMousePressPos; ///< Mouse position when context menu activated. int defaultGuidedAlt; ///< Default altitude for guided mode + bool zoomBlocked; ///< Wether zooming is blocked UASInterface *uas; ///< Currently selected UAS. };