-
Notifications
You must be signed in to change notification settings - Fork 2
Straighten edges #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Straighten edges #30
Conversation
This pull request makes edges that span multiple layers prettier. Before, edges always changed direction when they crossed a layer, see the figure below: With this PR, we can produce this: The algorithm reduces the number of direction changes for edges that span multiple layers. To do this, the algorithm needs to group the intermediate edges by original edge. I took the chance to do a big refactoring of the code. The coordinates of the nodes and the edges are calculated in file graphics/layout.ts that is part of the library. The datastructures needed for this calculation are in model/layout-model.ts. That file introduces class Connector that stands for one endpoint of an intermediate edge. The sequence of the Connector objects that belong to a node can be calculated without knowing coordinates. While developing, I discovered a bug that showed when you omitted nodes in the playground. Each row of the sequence editor has a x-control that allows you to hide the node. But then the intermediate edges that belong to an original edge are not necessarily shown and the shown intermediate edges may be disconnected. Before calculating coordinates of edges, groups of connected intermediate edges are established. File graphics/horizontal-conflict.ts also needs a hack because there can be nodes without "predecessors". When the algorithm determines x-coordinates, it uses the x-coordinates of the nodes on an adjacent layer (the predecessors). Reducing the number of direction changes is done as follows. First, initial line segments are calculated. For each traversed intermediate node, a vertical line segment is created. For each intermediate edge, a line segment is drawn from the endpoint of the previous vertical segment to the start point of the next vertical segment. If an original edge goes from Start to Int_1 to End, then we have the following segments:
After establishing the line initial line segments, the algorithm tries to join them again. One constraint is that joined lines should not cross nodes. Another constraint is that modified line segments should pass layers reasonably close the point originally calculated. Extra dimensions have been introduced in the dimension editor to tweak this behavior. This calculation uses function objects to allow testing. The mechanics of traversing intermediate edges and considering options to join segments is in function |
No description provided.