What is the best method to modify an existing path?
Lets say, I have a path with different segments ( lines and curves) and want to move
the endpoint of a specific line segment.
The path iterator gives me a copy of the segment points, but
how would I change a path point without rebuilding the complete path?
The path class isn’t designed to be dynamically edited - it’s designed to be quickly constructed and accessed.
Unless you’re doing something extremely unusual, you shouldn’t have any problem whatsoever in just rebuilding your path from scratch when you need to.
Unless you’re doing something extremely unusual, you shouldn’t have any problem whatsoever in just rebuilding your path from scratch when you need to.[/quote]
Nothing extreme, just a PathComponent with HandleComponents to modify the path. Would be nice to have direct access to the actual end- and control points.
But i think I can just build a model with the different segment types ( move, line, curve etc) and then rebuild the path whenever the user edits a point.
Thank you, Jules, your code is always nice to read. Interesting idea to use float type identifiers , so elements are of same type as the parameters.
Hmm, I certainly wouldn’t use a path as a container to store the thing that you’re manipulating. When I do the vector path editor for the new jucer I’ll probably store the paths as ValueTrees and just use a Path to display them.
Yes, using ValueTrees would be fine.
I’m now using a container called NamedDoubleArray which is a STL pair of a name
and a vector of doubles. The segment name is ‘m’,‘l’,‘q’,‘b’ or 'c for
move, line, quadric, cubic and close as seen in your code.
A vector of those containers allows me to access the points per index.
Actually I think a small segment node class with polymorphic behaviour would fit better. A path would be a node holding segments and a segment could also be another (sub)path to build a hierarchy.
A node hierarchy would provide the ability to replace a subpath with a line segment or vice versa.
What are your plans with this ‘vector path editor’ ?
A linked-list data structure would be the most efficient way to store it, but a ValueTree means that your editor gets undo/redo for free, which would be very, very laborious to write if you’re using custom data structures.
I was talking about the Drawables/LookAndFeel editor I’m doing for the new jucer - still in early stages.