Skip to content

Commit

Permalink
Support blocking zoom on map
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzMeier committed Jun 3, 2014
1 parent ae7cb28 commit ba883c7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/ui/map/QGCMapToolBar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
20 changes: 18 additions & 2 deletions src/ui/map/QGCMapToolBar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down
12 changes: 8 additions & 4 deletions src/ui/map/QGCMapWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
mapInitialized(false),
mapPositionInitialized(false),
homeAltitude(0),
zoomBlocked(false),
uas(NULL)
{
currWPManager = UASManager::instance()->getActiveUASWaypointManager();
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/ui/map/QGCMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -139,6 +144,7 @@ protected slots:
/** @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);
Expand Down Expand Up @@ -172,6 +178,7 @@ protected slots:
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.

};
Expand Down

0 comments on commit ba883c7

Please sign in to comment.