Feature request #15755

Make it simpler to use QgsGeometryRubberBand

Added by Casper Børgesen over 7 years ago. Updated over 6 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Unknown
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:23677

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 almost 7 years ago

  • Easy fix? set to No

#2 Updated by Jürgen Fischer over 6 years ago

  • Category set to Unknown

Also available in: Atom PDF