mapper icon indicating copy to clipboard operation
mapper copied to clipboard

Concentric shift / parallel line

Open mlerjen opened this issue 8 years ago • 26 comments

paralell shift 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...

mlerjen avatar Apr 06 '16 08:04 mlerjen

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.

wanacode avatar Apr 07 '16 07:04 wanacode

Another variant of #143.

dg0yt avatar Jun 19 '16 14:06 dg0yt

Please note - this kind of transformation called Concentric Shift or Radial Shift. The Parallel shift already implemented as Duplicate + Move Object. concentric_shift

yevhenmazur avatar Jul 23 '16 17:07 yevhenmazur

The new "follow outline" feature opens up for a temporary work-around to this concentric-shift issue... https://youtu.be/0nXfyCYcHjM

mlerjen avatar Apr 12 '20 15:04 mlerjen

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

pic.1

pic.2

ghost avatar Apr 18 '20 17:04 ghost

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.

dg0yt avatar Apr 22 '20 06:04 dg0yt

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. :)

lpechacek avatar Apr 22 '20 09:04 lpechacek

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.

dg0yt avatar Apr 22 '20 10:04 dg0yt

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. image 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.

mlerjen avatar Apr 22 '20 14:04 mlerjen

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 ;-)

dg0yt avatar Apr 25 '20 04:04 dg0yt

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.

lpechacek avatar Mar 26 '21 15:03 lpechacek

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 avatar Mar 26 '21 16:03 jmacura

@jmacura offset line maybe? image

mlerjen avatar Mar 26 '21 16:03 mlerjen

@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)).

dl3sdo avatar Mar 26 '21 19:03 dl3sdo

... 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.

lpechacek avatar Mar 26 '21 19:03 lpechacek

@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?

jmacura avatar Mar 26 '21 21:03 jmacura

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!

lpechacek avatar Mar 30 '21 10:03 lpechacek

I'm in favour of "Move parallel" as being most intuitive (and thus serving its purpose).

dl3sdo avatar Mar 30 '21 11:03 dl3sdo

"Move parallel / Parallel shift" is fine. Offset might be logicaly suitable however in the orienteering context it relates more to printing.

ollesmaps avatar Mar 30 '21 12:03 ollesmaps

On a sidenote, would be possible to use this tool (or a new one?) like this:

  1. acquired data of buildings for a sprint map
  2. a lot of these buildings touch each other
  3. goal: seamlessly merge these buildings, so there are no seams
  4. my intuitive solution (in Ocad) was to select all buildings
  5. enlarge lets say by 10 percent
  6. merge all these buildings
  7. 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.

ollesmaps avatar Mar 30 '21 12:03 ollesmaps

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.

lpechacek avatar Mar 30 '21 13:03 lpechacek

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

buildings_merge

ollesmaps avatar Mar 30 '21 14:03 ollesmaps

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.

lpechacek avatar Mar 30 '21 14:03 lpechacek

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...

mlerjen avatar Mar 30 '21 19:03 mlerjen

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).

mlerjen avatar Apr 01 '21 08:04 mlerjen

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.

lpechacek avatar Apr 01 '21 11:04 lpechacek