Feature request #15755

Make it simpler to use QgsGeometryRubberBand

Added by Casper Børgesen 7 months ago. Updated 30 days ago.

Status:Open
Priority:Normal
Assignee:-
Category:-
Pull Request or Patch supplied:No Resolution:
Easy fix?:No

Description

Having previously used the QgsRubberBand to draw temporary lines in QGIS I needed to draw polygons too. I found the QgsGeometryRubberBand which seems to handle polygons much better. After struggeling with the setGeometry(...) method I finally understood how to use it.

QgsRubberBand.setToGeometry method takes a QgsGeometry and extracts all the points into its own container.

QgsGeometryRubberBand.setGeometry method takes an QgsAbstractGeometryV2 and just make a reference to it (takes ownership???).

In use:

geometry = QgsGeometry.fromWkt('SOME GEOMETRY HERE.')
rb = QgsRubberBand(canvas)
rb.setToGeometry(geometry, None)

grb = QgsGeometryRubberBand(canvas)
grb.setGeometry(geomtry.geometry().clone())

I had to clone the abstract geometry since I don't keep my geometry object alive.

There two methods have their cousins, the QgsVertexMarker and the QgsHighlight.

Wouldn't it be better to make them all a bit more homogeneous if they are to remain as 4 different classes?

History

#1 Updated by Giovanni Manghi 30 days ago

  • Easy fix? set to No

Also available in: Atom PDF