Skip to content

Commit

Permalink
Don't force a vector layer to be used for QgsRubberBand::addGeometry
Browse files Browse the repository at this point in the history
There's no reason to restrict this call solely to vector layers
-- it's useful to have accessible for adding geometries associated
with other layer types too.
  • Loading branch information
nyalldawson committed Sep 8, 2021
1 parent 84247cb commit d43c575
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions python/gui/auto_generated/qgsrubberband.sip.in
Expand Up @@ -281,7 +281,7 @@ Copies the points from another rubber band.
.. versionadded:: 3.22
%End

void addGeometry( const QgsGeometry &geometry, QgsVectorLayer *layer, bool doUpdate = true );
void addGeometry( const QgsGeometry &geometry, QgsMapLayer *layer, bool doUpdate = true );
%Docstring
Adds the geometry of an existing feature to a rubberband
This is useful for multi feature highlighting.
Expand All @@ -293,8 +293,7 @@ If additional geometries are to be added then set ``doUpdate`` to ``False`` to d
After adding the final geometry :py:func:`~QgsRubberBand.updatePosition` should be called.

:param geometry: the geometry object. Will be treated as a collection of vertices.
:param layer: the layer containing the feature, used for coord transformation to map
crs. If ``layer`` is ``None``, the coordinates are not going to be transformed.
:param layer: the layer associated with the geometry. This is used for transforming the geometry from the layer's CRS to themap crs. If ``layer`` is ``None`` no coordinate transformation will occur.
:param doUpdate: set to ``False`` to defer updates of the rubber band.
%End

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsrubberband.cpp
Expand Up @@ -284,7 +284,7 @@ void QgsRubberBand::setToGeometry( const QgsGeometry &geom, const QgsCoordinateR
addGeometry( geom, crs );
}

void QgsRubberBand::addGeometry( const QgsGeometry &geometry, QgsVectorLayer *layer, bool doUpdate )
void QgsRubberBand::addGeometry( const QgsGeometry &geometry, QgsMapLayer *layer, bool doUpdate )
{
QgsGeometry geom = geometry;
if ( layer )
Expand Down
5 changes: 2 additions & 3 deletions src/gui/qgsrubberband.h
Expand Up @@ -337,11 +337,10 @@ class GUI_EXPORT QgsRubberBand : public QgsMapCanvasItem
* After adding the final geometry updatePosition() should be called.
*
* \param geometry the geometry object. Will be treated as a collection of vertices.
* \param layer the layer containing the feature, used for coord transformation to map
* crs. If \a layer is NULLPTR, the coordinates are not going to be transformed.
* \param layer the layer associated with the geometry. This is used for transforming the geometry from the layer's CRS to themap crs. If \a layer is NULLPTR no coordinate transformation will occur.
* \param doUpdate set to FALSE to defer updates of the rubber band.
*/
void addGeometry( const QgsGeometry &geometry, QgsVectorLayer *layer, bool doUpdate = true );
void addGeometry( const QgsGeometry &geometry, QgsMapLayer *layer, bool doUpdate = true );

/**
* Adds a \a geometry to the rubberband.
Expand Down

0 comments on commit d43c575

Please sign in to comment.