Skip to content

Commit

Permalink
add point/line/polygon specific handlers for capture map tool
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 28, 2022
1 parent e2a80d9 commit be56109
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
18 changes: 18 additions & 0 deletions python/gui/auto_generated/qgsmaptoolcapture.sip.in
Expand Up @@ -330,6 +330,24 @@ Stop capturing
%Docstring
Called when the geometry is captured

.. versionadded:: 3.24
%End
virtual void pointCaptured( const QgsPoint &point );
%Docstring
Called when a point is captured

.. versionadded:: 3.24
%End
virtual void lineCaptured( QgsCurve *line );
%Docstring
Called when a line is captured

.. versionadded:: 3.24
%End
virtual void polygonCaptured( QgsCurvePolygon *polygon );
%Docstring
Called when a polygon is captured

.. versionadded:: 3.24
%End
public:
Expand Down
12 changes: 11 additions & 1 deletion src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -1167,6 +1167,7 @@ void QgsMapToolCapture::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
addVertex( e->mapPoint(), e->mapPointMatch() );

geometryCaptured( g );
pointCaptured( savePoint );

stopCapturing();

Expand Down Expand Up @@ -1223,6 +1224,8 @@ void QgsMapToolCapture::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

QList<QgsPointLocator::Match> snappingMatchesList;
QgsCurve *curveToAdd = nullptr;
QgsCurvePolygon *poly = nullptr;

if ( hasCurvedSegments && providerSupportsCurvedSegments )
{
curveToAdd = captureCurve()->clone();
Expand All @@ -1239,7 +1242,6 @@ void QgsMapToolCapture::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else
{
QgsCurvePolygon *poly = nullptr;
if ( hasCurvedSegments && providerSupportsCurvedSegments )
{
poly = new QgsCurvePolygon();
Expand Down Expand Up @@ -1281,6 +1283,14 @@ void QgsMapToolCapture::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}

emit geometryCaptured( g );
if ( mode() == CaptureLine )
{
lineCaptured( curveToAdd );
}
else
{
polygonCaptured( poly );
}

stopCapturing();
}
Expand Down
19 changes: 19 additions & 0 deletions src/gui/qgsmaptoolcapture.h
Expand Up @@ -34,6 +34,7 @@ class QgsVertexMarker;
class QgsMapLayer;
class QgsGeometryValidator;
class QgsMapToolCaptureRubberBand;
class QgsCurvePolygon;


/**
Expand Down Expand Up @@ -340,6 +341,24 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*/
virtual void geometryCaptured( const QgsGeometry &geometry ) {Q_UNUSED( geometry )} SIP_FORCE

/**
* Called when a point is captured
* \since QGIS 3.24
*/
virtual void pointCaptured( const QgsPoint &point ) {Q_UNUSED( point )} SIP_FORCE

/**
* Called when a line is captured
* \since QGIS 3.24
*/
virtual void lineCaptured( QgsCurve *line ) {Q_UNUSED( line )} SIP_FORCE

/**
* Called when a polygon is captured
* \since QGIS 3.24
*/
virtual void polygonCaptured( QgsCurvePolygon *polygon ) {Q_UNUSED( polygon )} SIP_FORCE

//! whether tracing has been requested by the user
bool tracingEnabled();
//! first point that will be used as a start of the trace
Expand Down

0 comments on commit be56109

Please sign in to comment.