<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">Hello,</span>
<br>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">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.<br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">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. <br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">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.<br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">Anyone have any recommendations?<br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">Thanks very much,<br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">Joseph Burkhart<br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">QgsRubberBand:</span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><a href="https://qgis.org/pyqgis/3.28/gui/QgsRubberBand.html">https://qgis.org/pyqgis/3.28/gui/QgsRubberBand.html</a></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><a href="https://github.com/qgis/QGIS/blob/master/src/gui/qgsrubberband.h,">https://github.com/qgis/QGIS/blob/master/src/gui/qgsrubberband.h</a> <a href="https://github.com/qgis/QGIS/blob/master/src/gui/qgsgeometryrubberband.cpp">https://github.com/qgis/QGIS/blob/master/src/gui/qgsgeometryrubberband.cpp</a><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;">QPainter:</span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><a href="https://doc.qt.io/qtforpython-5/PySide2/QtGui/QPainter.html">https://doc.qt.io/qtforpython-5/PySide2/QtGui/QPainter.html</a><br></span>
</div>
<div style="font-size:12pt;font-family:helvetica,arial,sans-serif;color:#333333;" class="default-style">
<span style="font-family: helvetica; font-size: 12pt;"><br></span>
</div>
</body>
</html>