Skip to content
Permalink
Browse files

Allow usage of QgsMapToolAdvancedDigitizing from python code

  • Loading branch information
m-kuhn committed Oct 22, 2015
1 parent 7b9bcff commit ef2528bf02c66f00019690297ea31a182e6b9bac
@@ -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
@@ -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;

@@ -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();
@@ -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();
}

@@ -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();
}
@@ -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
@@ -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; }

@@ -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;

0 comments on commit ef2528b

Please sign in to comment.
You can’t perform that action at this time.