mapper
mapper copied to clipboard
Concentric shift / parallel line
To draw exactly parallel lines (as a fence following along a winding road) it would be nice to have a parallel shift function ~ moving the points of a line symbol perpendicular to their tangents (?).
The parallel fence then could be drawn by "filling" the road with the fence first and then using that parallel shift...
This sounds similar to this issue https://github.com/OpenOrienteering/mapper/issues/362
It would definitely be useful. I would be interested to hear any clever ways of drawing parallel lines in the mean time.
Another variant of #143.
Please note - this kind of transformation called Concentric Shift or Radial Shift. The Parallel shift already implemented as Duplicate + Move Object.
The new "follow outline" feature opens up for a temporary work-around to this concentric-shift issue... https://youtu.be/0nXfyCYcHjM
There is new open-source lib CavalierContours
(MIT-licensed) that could be useful for Mapper, but as for now it limited only to "processing 2D polylines containing both straight line and constant radius arc segments" (no Bezier curves support yet)
- Lib (core) - https://github.com/jbuckmccready/CavalierContours
- GUI (interactive) - https://github.com/jbuckmccready/CavalierContoursDev
There is new open-source lib
CavalierContours
(MIT-licensed) that could be useful for Mapper, but as for now it limited only to "processing 2D polylines containing both straight line and constant radius arc segments" (no Bezier curves support yet)
There may be more libraries, but we already do have QBezier
for such calculations. Someone has to write the code which uses it.
Someone has to write the code which uses it.
It's on my list and I've already made one (failed) attempt to implement it as a standalone tool. However, I'm more and more sure that it essentially should be a function of the Edit Line tool, which moves one segment in a "concentric" fashion. It's natural to extend the tool to move all path segments in a similar way. I'm wondering how the function should be switched. Any suggestions for modifier keys and/or switch key combinations are welcome.
BTW, I need this function too. :)
Maybe better start with a standalone clone of the edit-line tool: I would prefer to select multiple bezier segments by dragging along the line, before shifting by dragging away from the line.
By my understanding the concentric shift is applied to entire objects in most cases. You have an object you want a second to align to. You draw the second object snapping to the first, then you shift it concentric.
Thus I would prefer that the default is "all segments of the selected objects", with the option to deselect sections by ctrl-clicking on them before draging away.
Thus I would prefer that the default is "all segments of the selected objects", with the option to deselect sections by ctrl-clicking on them before draging away.
One more reason to start with a separate tool ;-)
One more reason to start with a separate tool ;-)
Yeah, this was a good choice. Thanks for the hint, Kai. There is a mostly working implementation is in my repo (see above). The bad thing is that either LineSymbol::shiftCoordinates()
needs a substantial improvement or we need alternate implementation for the radial path shift. The path shape quickly degrades for large shift distances.
Just a little important note about naming of this great future tool: parallel curve or, perhaps better, offset curve seems to be adequate. See https://en.wikipedia.org/wiki/Parallel_curve
@jmacura offset line maybe?
@lpechacek: thank you for providing an implementation for that topic, Libor. I'm not sure how to use it correctly as it crashes Mapper (Debug mode) everytime when I apply it twice on the same line object (I select the tool, move a line, release the mouse button, move it again -> crash (crash on moving the mouse)).
... it crashes Mapper (Debug mode) everytime when I apply it twice on the same line object.
Thanks for the early testing, Matthias. I appreciate your interest in the feature.
I'm aware that the tool crashes under certain condition but your specific case worked in my testing today. Further code cleanup and testing is on my schedule. In any case, you are welcome to analyze the crash. I guess that it will be null pointer dereference on hover_object
in dragMove()
or something similar.
@jmacura offset line maybe?
Mathematicaly, a line is a straight segment of 2D space. But fine, consistent naming should be used across the GUI. If there was a draw line tool, than offset line would make complete sense. But I can see a draw path tool, so probably offset path could be the most suitable?
Just a little important note about naming of this great future tool: ...
While deciding about the name, I've started with Yevhen's comment from July 2016 above. As far as I remember, I also googled a bit about the terminology, and it made sense to me when I took the ticket.
In any case, I prefer an established name ("Move parallel" is the OCAD tool name since immemorial) or a name from the GIS world or cartography, which are areas that relate to o-map making as far as I can tell. Just agree on the name here, and I'll implement the code change. Thanks!
I'm in favour of "Move parallel" as being most intuitive (and thus serving its purpose).
"Move parallel / Parallel shift" is fine. Offset might be logicaly suitable however in the orienteering context it relates more to printing.
On a sidenote, would be possible to use this tool (or a new one?) like this:
- acquired data of buildings for a sprint map
- a lot of these buildings touch each other
- goal: seamlessly merge these buildings, so there are no seams
- my intuitive solution (in Ocad) was to select all buildings
- enlarge lets say by 10 percent
- merge all these buildings
- decrease size by 9,0909... percent
However the resulted vector is not what anticipated. It does not work. I assume a "higher" mathematic is involved. Such a tool would be very much appreciated though.
4. my intuitive solution (in Ocad) was to select all buildings 5. enlarge lets say by 10 percent
In Mapper: Select all buildings, activate Scale tool (Z), press and hold Ctrl to scale selected objects around their centre (see #1211 for a screenshot), enlarge buildings to 110%.
6. merge all these buildings
Activate Unify areas tool (press U).
7. decrease size by 9,0909... percent
Press and hold Ctrl and drag cursor to reduce buildings to 90.9%. HTH
However the resulted vector is not what anticipated. It does not work.
Without knowledge of the expectation, I cannot comment on this part. In any case, I don't think that this use case (merge building areas) requires cooperation from the new tool.
Thank you Libor for the pointer. I tried the approach - very powerful indeed.
However I am not able to get the desired result. (But I can be doing something wrong. Will further explore it.) See the attached picture: Pic 1: situation Pic 2: desired result Pic 3: what I get (green color) when I use Scale tool + Ctrl
I think that I see what you mean. The shape change resulting from the scaling around the new object centre is undesirable. In my opinion, this is a new use case and should be reported as a new enhancement request.
My favourite would be Parallel Shift as I asociate Move with the shear displacement of the object. While Shift would be move & adapt. But nevermind. Looking forward to the Parallel Move...
I noticed that using the pan tool, the offset and distance is shown in the status bar. It would be very nice to find similar information about the parallel move there (the parallel distance).
The distance indication is in:
setStatusBarText(tr("<b>Move distance:</b> %1 mm").arg(QLocale().toString(qFabs(move_distance), 'f', 1)));
I added it the day before yesterday.