Skip to content

Commit

Permalink
Fix snapping
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 13, 2015
1 parent e281625 commit 1d90f66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/gui/qgsmaptooladvanceddigitizing.cpp
Expand Up @@ -34,18 +34,21 @@ QgsMapToolAdvancedDigitizing::~QgsMapToolAdvancedDigitizing()

void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent* e )
{
snap( e );
if ( !mCadDockWidget->canvasPressEvent( e ) )
cadCanvasPressEvent( e );
}

void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QgsMapMouseEvent* e )
{
snap( e );
if ( !mCadDockWidget->canvasReleaseEvent( e, mCaptureMode == CaptureLine || mCaptureMode == CapturePolygon ) )
cadCanvasReleaseEvent( e );
}

void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QgsMapMouseEvent* e )
{
snap( e );
if ( !mCadDockWidget->canvasMoveEvent( e ) )
cadCanvasMoveEvent( e );
}
Expand All @@ -70,3 +73,9 @@ void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPoint& point )
fakeEvent.setMapPoint( point );
canvasMoveEvent( &fakeEvent );
}

void QgsMapToolAdvancedDigitizing::snap( QgsMapMouseEvent* e )
{
if ( !mCadDockWidget->cadEnabled() )
e->snapPoint( QgsMapMouseEvent::SnapProjectConfig );
}
4 changes: 3 additions & 1 deletion src/gui/qgsmaptooladvanceddigitizing.h
Expand Up @@ -123,7 +123,7 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit
private slots:
/**
* Is to be called by the cad system whenever a point changes outside of a
* mouse event. E.g. when additional constraints are triggered.
* mouse event. E.g. when additional constraints are toggled.
* The specified point will be used to generate a fake mouse event which will
* be sent as move event to cadCanvasMoveEvent.
*
Expand All @@ -133,6 +133,8 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit

private:
QgsAdvancedDigitizingDockWidget* mCadDockWidget;

void snap( QgsMapMouseEvent* e );
};

#endif // QGSMAPTOOLADVANCEDDIGITIZE_H

0 comments on commit 1d90f66

Please sign in to comment.