3 ms·
Years ago I was making a diagram editor with the intent of doing code generation from diagrams (like simulink, not stateflow). I started with splines for the co
by phkahler 1y ago
Years ago I was making a diagram editor with the intent of doing code generation from diagrams (like simulink, not stateflow). I started with splines for the connections and decided straight lines and junctions would be better for complex diagrams. I realized that a better way to internally define the connecting wires is via a set of lines and their connectivity (vs their endpoint coordinates). Imagine each line segment is defined by a direction (vertical or horizontal) and a position (perpendicular distance from the origin) Like ax+by=d where a and b are either 0 or 1. You also need to define which other lines it connects to. Given the list of connections you can then calculate the intersections at rendering time. By sorting the list of connections you can render the line without features at the start and end, and then draw junctions for any intermediate connections. The beauty of this would be to allow dragging blocks around and having the lines follow with the junctions passing through each other as needed. There is some housekeeping with this data structure (merging colinear segments that connect, breaking segments when needed) but the UI for dragging should be much better than anything out there.
- ttd 1y agoInteresting - do you have a writeup or a demo available somewhere? What types of junctions were you envisioning?
- phkahler 1y agoIn the links you posted (2 comments up) there is a PID controller. Out of the difference block the signal splits 3 ways. In Simulink that junction would just be a round dot where the lines meet. In most diagram editors that junction would probably have 5 lines connected to it. In my scheme there would be one horizontal line right through it and one vertical line. There would also be 2 short horizontal lines connecting the vertical line to the P and D blocks. In my scheme you could drag the D block up to the top above the P (D,P,I) and the junctions would change (because they're locations are computed) even though the topology has not. I never did a full implementation. email me at gmail if you want a better explanation or a quick drawing.