Skip to content
Permalink
Browse files

Merge pull request #5148 from wonder-sk/adv-digitizing-cleanup-2

Advanced digitizing cleanup - part 2
  • Loading branch information
wonder-sk committed Sep 10, 2017
2 parents cea7eb8 + f938b60 commit 1b588c85dfb9d01870658fc469c06d006b4cc810
@@ -474,7 +474,7 @@ QgsAction {#qgis_api_break_3_0_QgsAction}
QgsAdvancedDigitizingDockWidget {#qgis_api_break_3_0_QgsAdvancedDigitizingDockWidget}
-------------------------------

- canvasReleaseEvent takes now QgsAdvancedDigitizingDockWidget::CaptureMode as second argument.
- canvasPressEvent(), canvasReleaseEvent(), canvasMoveEvent() were removed. Handling of events is done in QgsMapToolAdvancedDigitizing.
- snappingMode() was removed. Advanced digitizing now always uses project's snapping configuration.


@@ -1577,7 +1577,8 @@ QgsMapMouseEvent {#qgis_api_break_3_0_QgsMapMouseEvent}
----------------

- SnappingMode enum was removed.
- snapPoint() and snapSegment() do not take SnappingMode argument anymore. Snapping is done according to project's snapping configuration.
- snapPoint() does not take SnappingMode argument anymore. Snapping is done according to project's snapping configuration.
- snapSegment() was removed.


QgsMapOverviewCanvas {#qgis_api_break_3_0_QgsMapOverviewCanvas}
@@ -1624,6 +1625,13 @@ QgsMapTool {#qgis_api_break_3_0_QgsMapTool}
- isTransient() and isEditTool() were removed. Use flags() instead.


QgsMapToolAdvancedDigitizing {#qgis_api_break_3_0_QgsMapToolAdvancedDigitizing}
----------------------------

- setMode() was replaced by setAdvancedDigitizingAllowed() and setAutoSnapEnabled()
- mode() and CaptureMode enum have been moved to QgsMapToolCapture subclass


QgsMapToolCapture {#qgis_api_break_3_0_QgsMapToolCapture}
-----------------

@@ -42,13 +42,6 @@ class QgsAdvancedDigitizingDockWidget : QgsDockWidget
Parallel
};

enum AdvancedDigitizingMode
{
SinglePoint,
TwoPoints,
ManyPoints
};

class CadConstraint
{
%Docstring
@@ -179,47 +172,30 @@ class QgsAdvancedDigitizingDockWidget : QgsDockWidget
Disables the CAD tools when hiding the dock
%End

bool canvasPressEvent( QgsMapMouseEvent *e );
%Docstring
Will react on a canvas press event

\param e A mouse event (may be modified)
:return: If the event is hidden (construction mode hides events from the maptool)
:rtype: bool
%End

bool canvasReleaseEvent( QgsMapMouseEvent *e, AdvancedDigitizingMode mode );
bool canvasKeyPressEventFilter( QKeyEvent *e );
%Docstring
Will react on a canvas release event
Filter key events to e.g. toggle construction mode or adapt constraints

\param e A mouse event (may be modified)
\param mode determines if the dock has to record one, two or many points.
:return: If the event is hidden (construction mode hides events from the maptool)
:rtype: bool
%End

bool canvasMoveEvent( QgsMapMouseEvent *e );
bool applyConstraints( QgsMapMouseEvent *e );
%Docstring
Will react on a canvas move event

\param e A mouse event (may be modified)
:return: If the event is hidden (construction mode hides events from the maptool)
:return: false if no solution was found (invalid constraints)
:rtype: bool
%End

bool canvasKeyPressEventFilter( QKeyEvent *e );
bool alignToSegment( QgsMapMouseEvent *e, QgsAdvancedDigitizingDockWidget::CadConstraint::LockMode lockMode = QgsAdvancedDigitizingDockWidget::CadConstraint::HardLock );
%Docstring
Filter key events to e.g. toggle construction mode or adapt constraints

\param e A mouse event (may be modified)
:return: If the event is hidden (construction mode hides events from the maptool)
.. versionadded:: 3.0
:rtype: bool
%End

virtual bool applyConstraints( QgsMapMouseEvent *e );
void releaseLocks( bool releaseRepeatingLocks = true );
%Docstring
:return: false if no solution was found (invalid constraints)
:rtype: bool
.. versionadded:: 3.0
%End

void clear();
@@ -273,6 +249,27 @@ Constraint on a common angle
:rtype: bool
%End

void clearPoints();
%Docstring
Removes all points from the CAD point list
.. versionadded:: 3.0
%End

void addPoint( const QgsPointXY &point );
%Docstring
Adds point to the CAD point list
.. versionadded:: 3.0
%End

void setPoints( const QList<QgsPointXY> &points );
%Docstring
Configures list of current CAD points

Some map tools may find it useful to override list of CAD points that is otherwise
automatically populated when user clicks with left mouse button on map canvas.
.. versionadded:: 3.0
%End

QgsPointXY currentPoint( bool *exists = 0 ) const;
%Docstring
The last point.
@@ -334,6 +331,11 @@ return the action used to enable/disable the tools
Disable the widget. Normally done automatically from QgsMapToolAdvancedDigitizing.deactivate().
%End

void updateCadPaintItem();
%Docstring
.. versionadded:: 3.0
%End

signals:

void pushWarning( const QString &message );
@@ -61,16 +61,6 @@ class QgsMapMouseEvent : QMouseEvent
:rtype: QgsPointXY
%End

QList<QgsPointXY> snapSegment( bool *snapped = 0, bool allLayers = false ) const;
%Docstring
Returns the first snapped segment. If the cached snapped match is a segment, it will simply return it.
Otherwise it will try to snap a segment according to the event's snapping mode. In this case the cache
will not be overwritten.
\param snapped if given, determines if a segment has been snapped
\param allLayers if true, override snapping mode
:rtype: list of QgsPointXY
%End

bool isSnapped() const;
%Docstring
Returns true if there is a snapped point cached.
@@ -27,14 +27,6 @@ class QgsMapToolAdvancedDigitizing : QgsMapToolEdit
#include "qgsmaptooladvanceddigitizing.h"
%End
public:
enum CaptureMode
{
CaptureNone,
CapturePoint,
CaptureSegment,
CaptureLine,
CapturePolygon
};

explicit QgsMapToolAdvancedDigitizing( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
%Docstring
@@ -56,22 +48,6 @@ Catch the mouse release event, filters it, transforms it to map coordinates and
Catch the mouse move event, filters it, transforms it to map coordinates and send it to virtual method
%End

CaptureMode mode() const;
%Docstring
The capture mode

:return: Capture mode
:rtype: CaptureMode
%End

void setMode( CaptureMode mode );
%Docstring
Set capture mode. This should correspond to the layer on which the digitizing
happens.

\param mode Capture Mode
%End

virtual void activate();
%Docstring
Registers this maptool with the cad dock widget
@@ -87,9 +63,51 @@ Catch the mouse move event, filters it, transforms it to map coordinates and sen
:rtype: QgsAdvancedDigitizingDockWidget
%End

bool isAdvancedDigitizingAllowed() const;
%Docstring
Returns whether functionality of advanced digitizing dock widget is currently allowed.

Tools may decide to switch this support on/off based on the current state of the map tool.
For example, in node tool before user picks a vertex to move, advanced digitizing dock
widget should be disabled and only enabled once a vertex is being moved. Other map tools
may keep advanced digitizing allowed all the time.

If true is returned, that does not mean that advanced digitizing is actually active,
because it is up to the user to enable/disable it when it is allowed.
\sa setAdvancedDigitizingAllowed()
.. versionadded:: 3.0
:rtype: bool
%End

bool isAutoSnapEnabled() const;
%Docstring
Returns whether mouse events (press/move/release) should automatically try to snap mouse position
(according to the snapping configuration of map canvas) before passing the mouse coordinates
to the tool. This may be desirable default behavior for some map tools, but not for other map tools.
It is therefore possible to configure the behavior by the map tool.
\sa isAutoSnapEnabled()
.. versionadded:: 3.0
:rtype: bool
%End

protected:

void setAdvancedDigitizingAllowed( bool allowed );
%Docstring
Sets whether functionality of advanced digitizing dock widget is currently allowed.
This method is protected because it should be a decision of the map tool and not from elsewhere.
\sa isAdvancedDigitizingAllowed()
.. versionadded:: 3.0
%End

void setAutoSnapEnabled( bool enabled );
%Docstring
Sets whether mouse events (press/move/release) should automatically try to snap mouse position
This method is protected because it should be a decision of the map tool and not from elsewhere.
\sa isAutoSnapEnabled()
.. versionadded:: 3.0
%End

virtual void cadCanvasPressEvent( QgsMapMouseEvent *e );
%Docstring
Override this method when subclassing this class.
@@ -122,7 +140,6 @@ Catch the mouse move event, filters it, transforms it to map coordinates and sen
\param e Mouse events prepared by the cad system
%End


};

/************************************************************************
@@ -18,7 +18,16 @@ class QgsMapToolCapture : QgsMapToolAdvancedDigitizing
#include "qgsmaptoolcapture.h"
%End
public:
QgsMapToolCapture( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode = CaptureNone );

enum CaptureMode
{
CaptureNone,
CapturePoint,
CaptureLine,
CapturePolygon
};

QgsMapToolCapture( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode );
%Docstring
constructor
%End
@@ -28,6 +37,14 @@ constructor
virtual void activate();
virtual void deactivate();

CaptureMode mode() const;
%Docstring
The capture mode

:return: Capture mode
:rtype: CaptureMode
%End

int addCurve( QgsCurve *c );
%Docstring
Adds a whole curve (e.g. circularstring) to the captured geometry. Curve must be in map CRS

0 comments on commit 1b588c8

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