Skip to content

Commit

Permalink
Move QgsMapToolCapture::layer to parent class (QgsMapToolAdvancedDigi…
Browse files Browse the repository at this point in the history
…tizing)
  • Loading branch information
nyalldawson committed Sep 24, 2021
1 parent 7ff1d7e commit f9def2d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
9 changes: 9 additions & 0 deletions python/gui/auto_generated/qgsmaptooladvanceddigitizing.sip.in
Expand Up @@ -70,6 +70,15 @@ Unregisters this maptool from the cad dock widget

QgsAdvancedDigitizingDockWidget *cadDockWidget() const;

virtual QgsMapLayer *layer() const;
%Docstring
Returns the layer associated with the map tool.

By default this returns the map canvas' :py:func:`QgsMapCanvas.currentLayer()`.

.. versionadded:: 3.22
%End

bool isAdvancedDigitizingAllowed() const;
%Docstring
Returns whether functionality of advanced digitizing dock widget is currently allowed.
Expand Down
10 changes: 0 additions & 10 deletions python/gui/auto_generated/qgsmaptoolcapture.sip.in
Expand Up @@ -302,16 +302,6 @@ Set the points on which to work
void closePolygon();
%Docstring
Close an open polygon
%End

virtual QgsMapLayer *layer() const;
%Docstring
Returns the map layer associated with the geometry being captured.

The base class implementation always returns the current map canvas layer, but
subclasses can override this if they need to be associated with a specific layer.

.. versionadded:: 3.22
%End

protected slots:
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmaptooladvanceddigitizing.cpp
Expand Up @@ -142,6 +142,11 @@ void QgsMapToolAdvancedDigitizing::deactivate()
mSnapToGridCanvasItem = nullptr;
}

QgsMapLayer *QgsMapToolAdvancedDigitizing::layer() const
{
return canvas()->currentLayer();
}

void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPointXY &point )
{
Q_UNUSED( point )
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsmaptooladvanceddigitizing.h
Expand Up @@ -64,6 +64,15 @@ class GUI_EXPORT QgsMapToolAdvancedDigitizing : public QgsMapToolEdit

QgsAdvancedDigitizingDockWidget *cadDockWidget() const { return mCadDockWidget; }

/**
* Returns the layer associated with the map tool.
*
* By default this returns the map canvas' QgsMapCanvas::currentLayer().
*
* \since QGIS 3.22
*/
virtual QgsMapLayer *layer() const;

/**
* Returns whether functionality of advanced digitizing dock widget is currently allowed.
*
Expand Down
5 changes: 0 additions & 5 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -873,11 +873,6 @@ void QgsMapToolCapture::closePolygon()
updateExtraSnapLayer();
}

QgsMapLayer *QgsMapToolCapture::layer() const
{
return canvas()->currentLayer();
}

void QgsMapToolCapture::validateGeometry()
{
if ( QgsSettingsRegistryCore::settingsDigitizingValidateGeometries.value() == 0
Expand Down
10 changes: 0 additions & 10 deletions src/gui/qgsmaptoolcapture.h
Expand Up @@ -391,16 +391,6 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*/
void closePolygon();

/**
* Returns the map layer associated with the geometry being captured.
*
* The base class implementation always returns the current map canvas layer, but
* subclasses can override this if they need to be associated with a specific layer.
*
* \since QGIS 3.22
*/
virtual QgsMapLayer *layer() const;

protected slots:

/**
Expand Down

0 comments on commit f9def2d

Please sign in to comment.