Skip to content

Commit

Permalink
Allow usage of QgsMapToolAdvancedDigitizing from python code
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 22, 2015
1 parent 7b9bcff commit ef2528b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
18 changes: 13 additions & 5 deletions python/gui/qgsmaptooladvanceddigitizing.sip
Expand Up @@ -40,11 +40,11 @@ class QgsMapToolAdvancedDigitizing : QgsMapToolEdit
~QgsMapToolAdvancedDigitizing();

//! catch the mouse press event, filters it, transforms it to map coordinates and send it to virtual method
void canvasPressEvent( QgsMapMouseEvent* e );
virtual void canvasPressEvent( QgsMapMouseEvent* e );
//! catch the mouse release event, filters it, transforms it to map coordinates and send it to virtual method
void canvasReleaseEvent( QgsMapMouseEvent* e );
virtual void canvasReleaseEvent( QgsMapMouseEvent* e );
//! catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method
void canvasMoveEvent( QgsMapMouseEvent* e );
virtual void canvasMoveEvent( QgsMapMouseEvent* e );

/**
* The capture mode
Expand All @@ -53,15 +53,23 @@ class QgsMapToolAdvancedDigitizing : QgsMapToolEdit
*/
CaptureMode mode() const;

/**
* Set capture mode. This should correspond to the layer on which the digitizing
* happens.
*
* @param mode Capture Mode
*/
void setMode( CaptureMode mode );

/**
* Registers this maptool with the cad dock widget
*/
void activate();
virtual void activate();

/**
* Unregisters this maptool from the cad dock widget
*/
void deactivate();
virtual void deactivate();

QgsAdvancedDigitizingDockWidget* cadDockWidget() const;

Expand Down
24 changes: 22 additions & 2 deletions python/gui/qgsmaptoolcapture.sip
Expand Up @@ -31,11 +31,31 @@ class QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
/** Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be in map CRS*/
int addCurve( QgsCurveV2* c );

/**
* Get the capture curve
*
* @return Capture curve
*/
const QgsCompoundCurveV2* captureCurve() const;


/**
* Update the rubberband according to mouse position
*
* @param e The mouse event
*/
virtual void cadCanvasMoveEvent( QgsMapMouseEvent * e );

/**
* Intercept key events like Esc or Del to delete the last point
* @param e key event
*/
virtual void keyPressEvent( QKeyEvent* e );

/**
* Clean a temporary rubberband
*/
void deleteTempRubberBand();
void cadCanvasMoveEvent( QgsMapMouseEvent * e );
void keyPressEvent( QKeyEvent* e );

private slots:
void validationFinished();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolcircularstringcurvepoint.cpp
Expand Up @@ -51,7 +51,7 @@ void QgsMapToolCircularStringCurvePoint::cadCanvasReleaseEvent( QgsMapMouseEvent
{
if ( !mRubberBand )
{
mRubberBand = createGeometryRubberBand(( mCaptureMode == CapturePolygon ) ? QGis::Polygon : QGis::Line );
mRubberBand = createGeometryRubberBand(( mode() == CapturePolygon ) ? QGis::Polygon : QGis::Line );
mRubberBand->show();
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolcircularstringradius.cpp
Expand Up @@ -139,7 +139,7 @@ void QgsMapToolCircularStringRadius::recalculateCircularString()
QgsCircularStringV2* cString = new QgsCircularStringV2();
cString->setPoints( rubberBandPoints );
delete mRubberBand;
mRubberBand = createGeometryRubberBand(( mCaptureMode == CapturePolygon ) ? QGis::Polygon : QGis::Line );
mRubberBand = createGeometryRubberBand(( mode() == CapturePolygon ) ? QGis::Polygon : QGis::Line );
mRubberBand->setGeometry( cString );
mRubberBand->show();
}
Expand Down
18 changes: 13 additions & 5 deletions src/gui/qgsmaptooladvanceddigitizing.h
Expand Up @@ -54,11 +54,11 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit
~QgsMapToolAdvancedDigitizing();

//! catch the mouse press event, filters it, transforms it to map coordinates and send it to virtual method
void canvasPressEvent( QgsMapMouseEvent* e ) override;
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
//! catch the mouse release event, filters it, transforms it to map coordinates and send it to virtual method
void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
//! catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method
void canvasMoveEvent( QgsMapMouseEvent* e ) override;
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;

/**
* The capture mode
Expand All @@ -67,15 +67,23 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit
*/
CaptureMode mode() const { return mCaptureMode; }

/**
* Set capture mode. This should correspond to the layer on which the digitizing
* happens.
*
* @param mode Capture Mode
*/
void setMode( CaptureMode mode ) { mCaptureMode = mode; }

/**
* Registers this maptool with the cad dock widget
*/
void activate() override;
virtual void activate() override;

/**
* Unregisters this maptool from the cad dock widget
*/
void deactivate() override;
virtual void deactivate() override;

QgsAdvancedDigitizingDockWidget* cadDockWidget() const { return mCadDockWidget; }

Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmaptoolcapture.h
Expand Up @@ -61,13 +61,13 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*
* @param e The mouse event
*/
void cadCanvasMoveEvent( QgsMapMouseEvent * e ) override;
virtual void cadCanvasMoveEvent( QgsMapMouseEvent * e ) override;

/**
* Intercept key events like Esc or Del to delete the last point
* @param e key event
*/
void keyPressEvent( QKeyEvent* e ) override;
virtual void keyPressEvent( QKeyEvent* e ) override;

#ifdef Q_OS_WIN
virtual bool eventFilter( QObject *obj, QEvent *e ) override;
Expand Down

0 comments on commit ef2528b

Please sign in to comment.