Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Multiple Links and Container (Read 6242 times)
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Multiple Links and Container
Apr 7th, 2009 at 3:38pm
Print Post  
Hello,
I'm new to WpfDiagram control. I'm developing an application which evolve around visualizing networks as diagrams. I'm currently using GoDiagram WinForms control and I would like to advance to MindFusion WpfDiagram control. I need to know if WpfDiagram has the following capabilities:

1. In my diagrams I have multiple links from the same two nodes. It can get up-to 20-30 links between two nodes. Can WpfDiagram arrange the links in such way that it will be relatively easy to select each individual link?

2. I'm modeling an organization in which a person can belong to zero or more departments. For example I have Jim which belong to both Accounting and Finance. The way I model it today it that I have Accounting node, Finance node and they both contain Jim node in such way that when I mode Jim Accounting and Finance both rearrange themselves to include Jim and also when I move Accounting it move Jim (which rearrange Finance in turn).
This one might look strange but I need it. I'm willing to have an custom drawn node - I don't need to have actual object model here because I have my model that know the relation between the nodes.


Thank you very much,
Ido.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple Links and Container
Reply #1 - Apr 7th, 2009 at 6:29pm
Print Post  
Hi,

1. For example, the following result is produced by the code below:

Code
Select All
DiagramItemCollection items = new DiagramItemCollection();

ShapeNode node1 = diagram.Factory.CreateShapeNode(50, 150, 80, 80);
ShapeNode node2 = diagram.Factory.CreateShapeNode(350, 150, 80, 80);
for (int i = 0; i < 30; ++i)
{
	DiagramLink link = diagram.Factory.CreateDiagramLink(node1, node2);
	items.Add(link);
}
items.Add(node1);
items.Add(node2);

OrthogonalRouter router = new OrthogonalRouter();
router.SplitGraph = false;
router.Arrange(diagram, items);

diagram.ResizeToFitItems(10);
 



You also have direct control over the point positions, and could set whatever other link shapes you'd like, for example check this code:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=122711142...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple Links and Container
Reply #2 - Apr 7th, 2009 at 6:40pm
Print Post  
2. There is no built-in support for such scenario, but it shouldn't be hard to recalculate the new node positions in response to the NodeModified event raised when any of the person or department nodes are moved.

E.g. moving a person would set the Bounds of the department nodes to the union of the Bounds of all persons in the department, and moving a department would move the person nodes with the same offset.

The department could be a background node (set its ZIndex = 0), and you would probably also want to set SelectionOnTop = false so that selecting a department does not hide the related person nodes.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Re: Multiple Links and Container
Reply #3 - Apr 7th, 2009 at 7:02pm
Print Post  
Hi,
Thanks for the quick response. It sure important the great support you have.
I've try your code but I've got different result, not the one I'm looking for.
First, I didn't find the class OrthogonalRouter, I only found OrthogonalLayout in the namespace the documentation say OrthogonalRouter should be. I've used it, maybe that's why I got different result.

About the second question I figure it should be something like that, the trick is to figure how not to cause infinite loops where each node effect the other.

Thank you,
Ido.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple Links and Container
Reply #4 - Apr 7th, 2009 at 7:13pm
Print Post  
Hi,

Perhaps you are using older version, try this with V2.1.1:
https://mindfusion.eu/WpfDiagTrial.zip

To prevent infinite loops in the second case, add processed nodes to a Dictionary<DiagramNode, bool>, and before updating a node, check if it's not already marked as processed in the hashtable.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Re: Multiple Links and Container
Reply #5 - Apr 7th, 2009 at 7:24pm
Print Post  
Many thanks.
I'm downloading the new version and I'll give it another try.

Ido.
  
Back to top
 
IP Logged
 
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Re: Multiple Links and Container
Reply #6 - Apr 20th, 2009 at 10:05pm
Print Post  
Hi, I'm back.
I did had the right version, it's just that the samples of .NET 3.5 have the old version of the diagram.

Anyway, I have the sample up and running and it works just like you say.
Now, the next question is how to cause the links to reroute when a node is moved.
I've did it using NodeModified event of Diagram object but when the diagram is medium-size (5 nodes each with 30 links) using OrthogonalRouter when ever node changes is very slow. Is there way to make it faster?

Thank you,
Ido.

  
Back to top
 
IP Logged
 
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Re: Multiple Links and Container
Reply #7 - Apr 21st, 2009 at 8:29am
Print Post  
Hi,
I've used your sample code to create a more interesting diagram. I have a central node which connected to 5 other nodes. I've made the link to each node with different color so it will be easy to understand which link goes to which node.
The problem is that the routing is not clear. The links go one of the other instead of go as directly to the node.



As you can see, I've expected each link group (by color) to stat from different side of the main node.

Thank you,
Ido.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple Links and Container
Reply #8 - Apr 21st, 2009 at 1:13pm
Print Post  
I think the router tries to distribute the links further from each other, and thus it could choose sides that would make the links longer. The same happens in my screenshot from the post above, where the 30 links are distributed along three sides of each node. We could add some option that chooses sides so that the links are shorter, or perhaps add some callback you could implement to choose the end points yourself.

Stoyan
  
Back to top
 
IP Logged
 
ido.ran
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 7th, 2009
Re: Multiple Links and Container
Reply #9 - Apr 21st, 2009 at 1:22pm
Print Post  
What is the difference between Layout and Router?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple Links and Container
Reply #10 - Apr 22nd, 2009 at 8:49am
Print Post  
OrthogonalLayout arranges the nodes, placing them at positions where their links could make just one or two bends to avoid crossing other nodes. That's usually possible if the nodes don't have more than four links. OrthogonalRouter keeps the node positions and only bends the links to make them avoid obstacles.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint