Hello,

I'm working on a python plugin that provides a new map tool for drawing 
polygons and I'm hoping someone could give me some pointers. I'm very familiar 
with the pyqgis API when it comes to processing, less so (but learning) when it 
comes to gui.

I have created a new polygon drawing tool that behaves like the default one. 
What I want to do now is modify the drawing widget so that it behaves more like 
a brush tool, so the user can activate the tool, click on the map canvas and 
drag to leave a brush stroke, and when they release the mouse button the brush 
stroke is turned into a polygon.

My impression is that I need to create a subclass of QgsRubberBand and then 
re-implement that class's draw method, but honestly I can't figure out where to 
start with that reimplementation. I've read through the pyqt docs for QPainter, 
and through the pyqgis docs and source code for QgsRubberBand (links below); I 
still couldn't figure out what to do next.

Anyone have any recommendations?

Thanks very much,

Joseph Burkhart



QgsRubberBand:
https://qgis.org/pyqgis/3.28/gui/QgsRubberBand.html
https://github.com/qgis/QGIS/blob/master/src/gui/qgsrubberband.h 
https://github.com/qgis/QGIS/blob/master/src/gui/qgsrubberband.h, 
https://github.com/qgis/QGIS/blob/master/src/gui/qgsgeometryrubberband.cpp

QPainter:
https://doc.qt.io/qtforpython-5/PySide2/QtGui/QPainter.html

_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to