Feature request #15755

Make it simpler to use QgsGeometryRubberBand

Added by Casper Børgesen 6 months ago.

Status:Open Start Date:10/26/2016
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:-
Target version:Future Release - Nice to have
Platform: Resolution:
Platform version: Pull Request or Patch supplied:No
Status info: Tag:

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?

Also available in: Atom