This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, We've just bought your controls. After using for some time it seams pretty straightforward how to do most of the customizations we need, but one thing needs clarification. I am building diagram programmatically and I need lay out nodes automatically or at least create basic auto layout algorithm on my own and put connections in it without many collisions. Is there any auto layout capabilities in your control? I saw SimplePathfinder, StraightLinePathfinder classes in API, which I assume can help me do my task, but I don't know how to get them to work. Any explanation or sample would be appreciated. Thanks in advance. Regards, Peter |
|
|
Hello Peter For laying out the nodes, we do not currently provide any layout algorithms for Flow Diagrams, but it is something we plan to implement in the future. Applying your own layout algorithm to the nodes in a diagram is quite simple. Your algorithm will simply need to modify the positions of the nodes. The path finders that you have found are indeed for laying out the connections. These are used to update the path geometry of a connection every time the user moves a node that has connections attached to it etc. It is possible for you to make your own IPathfinder implementation which minimises the number of collisions and then apply it to the diagram. You will see the IDiagramFormatter interface has a Pathfinder property. So you can set a custom path finder instance to the FlowDiagramFormatter in the DiagramSurface. The IPathfinder interface has a single method to implement. Its parameters is a connection element and the diagram surface. You can use the connection element to get the source and destination of the connection, and you can use the diagram surface to find the positions of all the nodes in the diagram. Then you need to return a list of points that the connection will now follow. Like I said, path finders are applied to connections every time the user modifies them, so a more advanced pathfinder for minimising the collisions could start to decrease the performance depending on how you implement it. If you do not think pathfinders will be the best solution to your problem, then the other thing you can do is similar with making a node layout algorithm. Make a connection layout algorithm, and then have it go through all the connections in the diagram and modify them accordingly. Just note that doing it this way means that when a user moves a node, the default pathfinder will automatically be applied. I hope this information gives you a place to start thinking about how to find a solution to this problem. Please let me know if there are parts here that you don't understand, or if you need more information about various things. Regards |
|
|
Hi, Thanks for quick response. PathFinders are used only in UI? Can I execute some build-in pathfinder when I add FlowDiagramConnection to Connections collection of FlowDiagramModel or just before adding? Regards, Peter |
|
|
Yes, pathfinders is only used in the UI. However, when ever you add a connection to the diagram, the default pathfinder is automatically applied to it. Of course this only works if the diagram is being held by a DiagramSurface. If you build a diagram in code first, pathfinders will only get applied once you add the diagram to a DiagramSurface. All the path-finding you can see in Flow Diagrams is done by the SimplePathfinder implementation. Regards |
|
|
How can I customize connection path? I know that there is Segments collection, which contains points around the path. I created instance of DiagramConnectionSegment and added it to Segments collection, but when I assign my custom FlowDiagram to Diagram property of diagram surface Segments collection is overriden.
Regards, Peter |
|
|
DiagramConnectionSegment is indeed what defines the path of a connection, but this is managed by the Pathfinder system. To customize the connection paths you need to implement the IPathfinder interface. This has 1 method for you to implement which is called CreatePath. The parameters for this method is a DiagramConnectionElement and the DiagramSurface. This method needs to create a path for the given connection. This is done by return a list of Point objects, one point for each corner in the path you create including the start and end points. No need to worry about connection segments, this is all done for you internally. Implementing your own pathfinder is one of the hardest customizations you can do. Here is what I suggest: Start by implementing your path finder so that it creates a straight line. It simply need to look at the given connection element and return a list that only contains the start and end position of the connection. To get the starting position you can use this code: connectionElement.FromConnectionPoint.Position To allow the diagram to use your pathfinder, you just need to create an instance of it, and then set it to the Pathfinder property on the diagram formatter like this: DiagramSurface ds Hope this gives you a place to start. Ragards |
|