I spent some time designing data structures to hold the compound curves that will be used for enhanced drawing elements and cams in the Linkage software. The data structure is designed with the idea that there is a single Curve type of object that contains nodes and segments to form a chain of drawing elements. In that chain, there can be Bezier curves, lines, and arcs. The arcs are a special item that I have not seen in other drawing programs; These will be circular curves that work like fillets or chamfers, or whatever makes the most sense descriptively. They are essentially the same as the Bezier curves except that they draw with a consistent radius that is calculated automatically based on the distance between the nodes.

image

Multiple Chained Bezier Curves

With the data structures all written, I went on to write some code for drawing the curves objects. Unlike my previous posts and test, this is all C++ code within the Linkage program itself! The drawing code is layered so that the high level view code deals with drawing selection boxes, the little arrows, etc., as well as with the multiple segments in these compound curves. Since there is already low level code for drawing lines, I just added some low level code to draw a Bezier curve.

And after all of that was written, I hard-coded in a single three-segment curve and marked it as selected. The result is what you see in the screen shot.

I was fortunate to have already written code to draw attractive dotted lines as well as arrow heads.

There is still a lot of code to write. The plan is to add the user interface code to drop in a drawing element that is a curve and then make curves a part of, or aspect of, links (because drawing polygons are just links on a drawing layer). By making curves parts of a link, I can later use them to define sliding paths on mechanism links or let the user use the curve as the link shape while hiding the old-style link shape lines. I had considered letting links be their own mechanism element type, which they actually are right now, but then it would be tricky to manage them on their own and also at the same time, as children or parts of a link.

Oh yeah, and when I mentioned above that these will be drawing element, link shapes, and eventually cams, I forgot to mention that they will also be paths that can be used for sliding connections.