Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring of QgsMapToolCapture to integrate shape map tools #46687

Merged
merged 66 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
864787e
make QgsMapToolCapture capable of capturing point/line/polygons
3nids Jan 4, 2022
e2a80d9
use a current CaptureTechnique in QgsMapToolCapture
3nids Jan 4, 2022
be56109
add point/line/polygon specific handlers for capture map tool
3nids Jan 5, 2022
6780475
convert add part map tool to use QgsMapToolCapture capabilities
3nids Jan 5, 2022
281a327
fix use of deprecated methods
3nids Jan 5, 2022
c88a63f
also create a virtual handler for QgsMapToolDigitizeFeature::featureD…
3nids Jan 5, 2022
04d79be
more dox
3nids Jan 6, 2022
f577cf9
use const abstract geom in virtual handlers
3nids Jan 7, 2022
83c5e6f
add new class QgsMapToolCaptureLayerGeometry to handle layer specific…
3nids Jan 7, 2022
d434e21
allow to add linear geometries on curved geometry layers
3nids Jan 7, 2022
8ec0dc5
make actions exclusive
3nids Jan 7, 2022
2c13d72
add settings registry to app
3nids Jan 13, 2022
7132431
add a registry for shape map tools
3nids Jan 13, 2022
55e8819
abstract class for shape map tools
3nids Jan 13, 2022
0aed1cc
adapt QgsMapToolCapture to correctly support shape map tools
3nids Jan 13, 2022
f0d9897
clean up of QgisApp
3nids Jan 13, 2022
972f53d
new class QgsMapToolsDigitizingTechniqueManager to handle actions in …
3nids Jan 13, 2022
7c90509
clean up QgisInterface
3nids Jan 13, 2022
e37e985
sipify
3nids Jan 13, 2022
42d86f7
refactoring of existing shape tools
3nids Jan 13, 2022
e2e8a12
refactor add ring to fully support capture map tool
3nids Jan 13, 2022
f879351
add missing folder to Doxygen
3nids Jan 13, 2022
09a4376
fix layout
3nids Jan 13, 2022
6e9a7d5
fix erasing at iterator pos
3nids Jan 13, 2022
d8d824a
fix unused warning
3nids Jan 13, 2022
41ea405
fix more dox
3nids Jan 13, 2022
aef39ea
fix cpp check warning
3nids Jan 13, 2022
71bb4f0
fix unused warning
3nids Jan 13, 2022
2635d42
fix annotation map tool does not support shape + set tool name
3nids Jan 14, 2022
8f74823
correctly handle case when the capture is not done on a vector layer …
3nids Jan 14, 2022
9510498
enable shapes in annotation map tool
3nids Jan 14, 2022
bef73cd
correctly undo and clean
3nids Jan 14, 2022
b31c3fb
adapt existing shape tests
3nids Jan 14, 2022
deca81a
fix warning
3nids Jan 14, 2022
f476685
refactor fill ring to support shape digitizing
3nids Jan 14, 2022
997197c
fix win build
3nids Jan 14, 2022
c01999d
fix more tests
3nids Jan 18, 2022
acca2f1
avoid detach warnings
3nids Jan 18, 2022
2b6195c
fix app test + clean up
3nids Jan 18, 2022
f9ff15f
harmonize new settings with existing ones
3nids Jan 20, 2022
4beb70b
fix categories
3nids Jan 25, 2022
a63af99
support adding multi lines as a part
3nids Jan 25, 2022
11e63e9
fix adding curve part to multi line
3nids Jan 25, 2022
5aacbb8
also handle points
3nids Jan 25, 2022
68ba540
code a bit clearer
3nids Jan 25, 2022
100fc91
cast not always valid
3nids Jan 25, 2022
e83c8a5
allow adding curved polygon to multipolygon
3nids Jan 26, 2022
514739b
add test for QgsGeometry::addPart with curved parts on non-curved geo…
3nids Jan 26, 2022
9af554e
fix with Python < 3.9
3nids Jan 26, 2022
be0fe08
better dox for deprecated interface actions methods
3nids Jan 27, 2022
03a1055
remove files leftover
3nids Jan 27, 2022
cf07276
remove leftover circular string curve point tool
3nids Jan 27, 2022
e88ae90
add default Z/M values when calling QgsGeometry::coerceToType
3nids Jan 28, 2022
7b86867
Apply suggestions from code review
3nids Feb 21, 2022
e9fc54c
fixes from review
3nids Feb 21, 2022
49b5926
move layer specific part to specific tool
3nids Feb 21, 2022
4f87cee
fix typo
3nids Feb 21, 2022
3cccf4f
fix leak
3nids Feb 21, 2022
8fbd474
fix dox
3nids Feb 21, 2022
002fd4b
fix segmentization
3nids Feb 21, 2022
b827f34
call map tool implementation of addCurve when adding trace curve to a…
3nids Feb 21, 2022
d8c6574
call sub-class implementation
3nids Feb 21, 2022
efcf169
fix since 3.24 -> 3.26
3nids Feb 21, 2022
68702f1
fix test
3nids Feb 21, 2022
f7cf0f5
add test to avoid extra curves when using tracing
3nids Feb 21, 2022
4185783
fix headers
3nids Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ if(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/gui/layertree
${CMAKE_SOURCE_DIR}/src/gui/layout
${CMAKE_SOURCE_DIR}/src/gui/locator
${CMAKE_SOURCE_DIR}/src/gui/maptools
${CMAKE_SOURCE_DIR}/src/gui/mesh
${CMAKE_SOURCE_DIR}/src/gui/numericformats
${CMAKE_SOURCE_DIR}/src/gui/ogr
Expand Down
2 changes: 2 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@
<file>themes/default/mActionDeleteTable.svg</file>
<file>themes/default/mActionDeselectAll.svg</file>
<file>themes/default/mActionDeselectActiveLayer.svg</file>
<file>themes/default/mActionDigitizeShape.svg</file>
<file>themes/default/mActionDigitizeWithCurve.svg</file>
<file>themes/default/mActionDigitizeWithSegment.svg</file>
<file>themes/default/mActionDuplicateLayer.svg</file>
<file>themes/default/mActionDuplicateComposer.svg</file>
<file>themes/default/mActionEditCopy.svg</file>
Expand Down
52 changes: 52 additions & 0 deletions images/themes/default/mActionDigitizeShape.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions images/themes/default/mActionDigitizeWithSegment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/gui/auto_additions/qgsmaptoolcapture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The following has been generated automatically from src/gui/qgsmaptoolcapture.h
QgsMapToolCapture.CaptureTechnique.baseClass = QgsMapToolCapture
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/maptools/qgsmaptoolcapturelayergeometry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsMapToolCaptureLayerGeometry : QgsMapToolCapture
{
%Docstring(signature="appended")
:py:class:`QgsMapToolCaptureLayerGeometry` is a base class for map tools digitizing layer geometries
This map tool subclass automatically handles intersection avoidance with other layers in the active project whenever a geometry is digitized by the user.

.. versionadded:: 3.26
%End

%TypeHeaderCode
#include "qgsmaptoolcapturelayergeometry.h"
%End
public:
QgsMapToolCaptureLayerGeometry( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode );
%Docstring
Constructor
%End

private:
virtual void layerGeometryCaptured( const QgsGeometry &geometry );
%Docstring
Called when the geometry is captured
A more specific handler is also called afterwards (layerPointCaptured, layerLineCaptured or layerPolygonCaptured)
%End
virtual void layerPointCaptured( const QgsPoint &point );
%Docstring
Called when a point is captured
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this point-specific signal.
%End
virtual void layerLineCaptured( const QgsCurve *line );
%Docstring
Called when a line is captured
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this line-specific signal.
%End
virtual void layerPolygonCaptured( const QgsCurvePolygon *polygon );
%Docstring
Called when a polygon is captured
The generic :py:func:`~QgsMapToolCaptureLayerGeometry.geometryCaptured` signal will be emitted immediately before this polygon-specific signal.
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/maptools/qgsmaptoolcapturelayergeometry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
96 changes: 80 additions & 16 deletions python/gui/auto_generated/qgisinterface.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -672,69 +672,133 @@ Returns the Hide Deselected Layers action.
virtual QAction *actionCheckQgisVersion() = 0;
virtual QAction *actionAbout() = 0;

virtual QAction *actionCircle2Points() = 0;

virtual QAction *actionCircle2Points() /Deprecated/;
lbartoletti marked this conversation as resolved.
Show resolved Hide resolved
%Docstring
Returns the native add circle from 2 points action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
3nids marked this conversation as resolved.
Show resolved Hide resolved
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionCircle3Points() = 0;

virtual QAction *actionCircle3Points() /Deprecated/;
%Docstring
Returns the native add circle from 3 points action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionCircle3Tangents() = 0;

virtual QAction *actionCircle3Tangents() /Deprecated/;
%Docstring
Returns the native add circle from 3 tangents action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionCircle2TangentsPoint() = 0;

virtual QAction *actionCircle2TangentsPoint() /Deprecated/;
%Docstring
Returns the native add circle from 2 tangents and a point action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionCircleCenterPoint() = 0;

virtual QAction *actionCircleCenterPoint() /Deprecated/;
%Docstring
Returns the native add circle from center action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionEllipseCenter2Points() = 0;

virtual QAction *actionEllipseCenter2Points() /Deprecated/;
%Docstring
Returns the native add ellipse from center and 2 points action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionEllipseCenterPoint() = 0;

virtual QAction *actionEllipseCenterPoint() /Deprecated/;
%Docstring
Returns the native add ellipse from center and a point action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionEllipseExtent() = 0;

virtual QAction *actionEllipseExtent() /Deprecated/;
%Docstring
Returns the native add ellipse from an extent action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionEllipseFoci() = 0;

virtual QAction *actionEllipseFoci() /Deprecated/;
%Docstring
Returns the native add ellipse from foci action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRectangleCenterPoint() = 0;

virtual QAction *actionRectangleCenterPoint() /Deprecated/;
%Docstring
Returns the native add rectangle from center and a point action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRectangleExtent() = 0;

virtual QAction *actionRectangleExtent() /Deprecated/;
%Docstring
Returns the native add rectangle from extent action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRectangle3PointsDistance() = 0;

virtual QAction *actionRectangle3PointsDistance() /Deprecated/;
%Docstring
Returns the native add rectangle from 3 points (distance from 2nd and 3rd points) action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRectangle3PointsProjected() = 0;

virtual QAction *actionRectangle3PointsProjected() /Deprecated/;
%Docstring
Returns the native add rectangle from 3 points (distance from projected 3rd point on segment p1 and p2) action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRegularPolygon2Points() = 0;

virtual QAction *actionRegularPolygon2Points() /Deprecated/;
%Docstring
Returns the native add regular polygon from 2 points action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRegularPolygonCenterPoint() = 0;

virtual QAction *actionRegularPolygonCenterPoint() /Deprecated/;
%Docstring
Returns the native add regular polygon from center and a point action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End
virtual QAction *actionRegularPolygonCenterCorner() = 0;

virtual QAction *actionRegularPolygonCenterCorner() /Deprecated/;
%Docstring
Returns the native add regular polygon from center and a corner action. Call :py:func:`~QgisInterface.trigger` on it to set the map tool.

.. deprecated:: QGIS 3.24
shape digitizing is now part of the add feature tool. To enable the shape tool, use :py:func:`QgsMapToolCapture.setCurrentCaptureTechnique()` and then :py:func:`QgsMapToolCapture.setCurrentShapeMapTool()`.
%End

virtual QgsVectorLayerTools *vectorLayerTools() = 0;
Expand Down
10 changes: 5 additions & 5 deletions python/gui/auto_generated/qgsmaptool.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ The default implementation does nothing and returns false.
is present in :py:func:`~QgsMapTool.flags`.

.. versionadded:: 3.18
%End

QgsPointXY toMapCoordinates( QPoint point );
%Docstring
Transforms a ``point`` from screen coordinates to map coordinates.
%End

signals:
Expand Down Expand Up @@ -289,11 +294,6 @@ signal emitted once the map tool is deactivated
QgsMapTool( QgsMapCanvas *canvas /TransferThis/ );
%Docstring
Constructor takes a map canvas as a parameter.
%End

QgsPointXY toMapCoordinates( QPoint point );
%Docstring
Transforms a ``point`` from screen coordinates to map coordinates.
%End

QgsPoint toLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) /PyName=toLayerCoordinatesV2/;
Expand Down
Loading