Commit ba883c79 authored by Lorenz Meier's avatar Lorenz Meier

Support blocking zoom on map

parent ae7cb28a
......@@ -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)));
......
......@@ -13,11 +13,20 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1,1,1,5,1,30,1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1,1,0,1,5,1,30,1">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
......@@ -62,6 +71,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lockCheckBox">
<property name="text">
<string>Lock</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="followCheckBox">
<property name="text">
......
......@@ -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);
......
......@@ -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.
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment