[QGIS-Developer] New MapTools for Circle, ellipse, regular polygon
Nyall Dawson
nyall.dawson at gmail.com
Sun May 21 16:09:15 PDT 2017
On 20 May 2017 at 04:16, L.Bartoletti <lbartoletti at tuxfamily.org> wrote:
> Hello,
>
> I would like, if I have time, to add the GUI for the classes I recently
> added (Circle, ellipse, regular polygon).
Great news - I've long wanted a simple way to draw circles (and if I
can add a feature request - rectangles too!). Thanks for all your
recent work implementing the base components of this in the c++
classes.
> Where do you think the buttons
> must go?
>
> - DigitizeToolBar
> - AdvancedDigitizeToolBar
> - A new toolbar (which name?)
+1 ... but no good ideas for names, sorry. "Feature construction toolbar"?
> Do you also have any recommendations or advice regarding this addition?
Yep. I looked into adding an inbuilt "draw rectangle" tool a few
months ago, but never got the chance to actually do the work. Here's
my 2c:
Here's what I'd suggest:
1. QgsMapToolCapture needs refactoring. It's become quite messy and
the interface is tied too heavily to the existing subclasses, making
it difficult to add new capture tools. I think this should be
refactored so that subclasses implement two virtual methods - one for
returning the geometry for the temporary rubber band which is shown
while moving the mouse during digitizing, and one for returning the
actual created QgsGeometry corresponding to the current clicked
points.
2. Create QgsMapToolAddFeature subclasses for each of the new "add
shape" actions. Assuming that the QgsMapToolCapture API is cleaned,
this should be quite simple to do for each shape type. I'd actually go
crazy here - and add multiple tools for each shape type, so you could
have tools for "add ellipse by center and radius", "add ellipse by
bounding box", etc. Same for rectangles - we could have a "add
rectangle by clicking two opposite corners tools", and an ArcGIS style
"add rectangle by clicking one corner, clicking the other end of this
side, and then clicking the opposite side tool" (see
https://www.youtube.com/watch?v=YdeRhpDmf2s). This approach would
automatically play very nicely with the existing advanced digitizing
dock constraints + inbuilt snapping tools.
3. Expose these construction tools via a new toolbar. Group the
similar tools together with the little down arrows to select between
them + remember which was the last tool used and show that one by
default (just like how the select tools are grouped and operate). So
there'd be a group for rectangle construction, ellipse construction,
regular polygon construction.
I'm interested to here Denis' thoughts given that he's the maintainer
of this area of code and whether this approach would fit his vision.
(Incidentally - I really want to see this happen, and I'm happy to
provide mentorship for these changes if you require.)
Nyall
More information about the QGIS-Developer
mailing list