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
|
Hello, I have a node with about 30 connections, when I'm moving it, I feel it is slow, I use a profiler and find out most time spend on path finding. I'm using AStarPathfinder, so is it possible to make it faster. Thanks |
|
|
Hello Jzhou Improving the performance of this algorithm will not be trivial. We don't have time to look into this right now so I've put this on the backlog for now. I'm not sure when we can look into this, but I'll let you know when we do. Jason Fauchelle |
|
|
Hello, Before your improving, I want to find a temporary solution, so I make the connections of the node invisible when the user start drag the node, and make the connections visible when the user complete the dragging. I refer the sample of NodeGrouping, add the IsVisible property for connection. When I set the IsVisible to false, the connection is hidden, that is good, but I find the path find algorithm is still called. So is it possible to prevent the calling the algorithm when the connection is hidden or collapsed. Another question is I listen the event of MoveThumb.DragStartedEvent, but the sender parameter of this event is diagram surface, is there a fast way to find the node, now I'm using FindMouseOverNodeElement. Thanks |
|
|
Hello Rather than switching the visibility, I'd recommend changing the path finder while the node is being dragged. On your custom connection implementation, override the Pathfinder property to return the appropriate pathfinder. You could have a method that switches the pathfinder which you can call when the node is being dragged. When the pathfinder is changed, you can call the protected ApplyPathfinding method from within the connection implementation so that it takes effect. I'd recommend switching to the ElbowPathfinder. In the MoveThumb.DragStarted event handler, you can get the MoveThumb instance from the OriginalSource property of the event arguments. From this, you can get the DiagramNodeElement from the MoveThumb.Element property. Jason Fauchelle |
|
|
Hello, Thanks for your suggestion, I've implemented as you said, but I find when I'm dragging one node, the AStarPathFinder is still called, and most time is spend for that, do you have some ideas, thanks. Some code: public override IPathfinder Pathfinder { get { if (_usingAStarPathFinder) { return AStarPathfinder.Instance; }
private bool _usingAStarPathFinder = true; public void ApplyElbowPathfinder() { _usingAStarPathFinder = false; ApplyPathfinding(); }
private void NodeDragStarted(object sender, DragStartedEventArgs e) { if (e.OriginalSource is MoveThumb) { var nodeElement = (e.OriginalSource as MoveThumb).Element as DiagramNodeElement; if (nodeElement != null) { var moduleNode = nodeElement.Node as ModuleNode; if (moduleNode != null) { foreach (var connectionPoint in moduleNode.ConnectionPoints) { foreach (var connection in connectionPoint.Connections) { connection.ApplyElbowPathfinder(); } } } } } } private void NodeDragCompleted(object sender, DragCompletedEventArgs e) { if (e.OriginalSource is MoveThumb) { var nodeElement = (e.OriginalSource as MoveThumb).Element as DiagramNodeElement; if (nodeElement != null) { var moduleNode = nodeElement.Node as ModuleNode; if (moduleNode != null) { foreach (var connectionPoint in moduleNode.ConnectionPoints) { foreach (var connection in connectionPoint.Connections) { connection.ApplyAStarPathfinder(); } } } } } } |
|
|
hello, I've implemented it by another way. Thanks |
|
|
Great to hear! |
|