<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="Ubuntu">Hi Joseph,<br>
<br>
Like you, rubber bands and drawing/paint stuff are quite obscure
to me and I need to dig into it when I want something specific...<br>
I don't have a direct answer, but you could look into existing
code doing similar things: the plugins "beePen" and "Bezier
Editing" available in QGIS are "freehand" drawing tools.<br>
They might use some of these functions.<br>
<br>
Regards,</font><font face="Ubuntu"><br>
</font>
<pre class="moz-signature" cols="72">--
Jacky Volpes
Ingénieur SIG - Oslandia</pre>
<br>
<font face="Ubuntu"><font face="Ubuntu">beePen:
<a class="moz-txt-link-freetext" href="https://github.com/mauroalberti/beePen">https://github.com/mauroalberti/beePen</a><br>
Bezier Editing: <a class="moz-txt-link-freetext" href="https://github.com/tmizu23/BezierEditing">https://github.com/tmizu23/BezierEditing</a><br>
</font><br>
<br>
</font><br>
<div class="moz-cite-prefix">Le 19/02/2023 à 21:59, Joseph Burkhart
via QGIS-Developer a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:1045528822.1582993.1676840373598@connect.xfinity.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<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"
moz-do-not-send="true" class="moz-txt-link-freetext">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,"
moz-do-not-send="true">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"
moz-do-not-send="true" class="moz-txt-link-freetext">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"
moz-do-not-send="true" class="moz-txt-link-freetext">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>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
<br>
</body>
</html>