Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Several questions about routing (Read 9717 times)
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Several questions about routing
Sep 16th, 2010 at 12:11pm
Print Post  
Hello, I got several questions about routing links - I have about 10 square nodes, each has top input and bottom output anchor and there are links between them.
I need layout with orthogonal connections and links not crossing other nodes and also as few crossing among links as possible.
I tried

diagram.RoutingOptions.CrossingCost = 50;
diagram.RoutingOptions.NodeVicinityCost = 10;
diagram.RoutingOptions.TurnCost = 0;
diagram.LinkStyle = LinkStyle.Cascading;
diagram.RouteLinks = true;
and for links:
AutoRoute = true, Style = LinkStyle.Cascading
I tried also LayeredLayout, FlowchartLayout, OrthogonalLayout, but I wasn't able to make these rules happen - there are still crossing between links and links are crossing nodes. Any idea?

Edit: Solved problem with key down routing - I had focus on another control... stupid mistake Smiley

The third question is, is it possible ot give names to used anchors in Node and show them in diagram? User should know which anchor has which name in case of multiple output/input anchors.
thanks Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #1 - Sep 17th, 2010 at 11:41am
Print Post  
Hi,

If it's a planar graph (allows drawing in the plane without link crossings), OrthogonalLayout will arrange it without link crossings for sure. However only a small subset of all graphs are planar. Also if node's incoming links must always connect to the top and outgoing ones to the bottom, that won't work well with OrthogonalLayout. It places the links after nodes positions are found, and you might get link-node crossings if a link coming from below the destination must connect to the top of the destination.

If the link anchor points and their flow direction are more important, you might be better off using TreeLayout with some additional routing of non-tree links. You might also try LayeredLayout with the EnforceLinkFlow and StraightenLong links options to place the nodes, and then route links orthogonally by calling RouteAllLinks or running OrthogonalRouter. If you send us a sample diagram saved as xml, our developer will try to find some good settings.

The control cannot display AnhorPoint labels at this time. You might set AnchorPoint.Tag to associate a name with it, and display the name temporarily inside the node when the mouse hovers over a point.

Stoyan
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #2 - Sep 20th, 2010 at 2:09pm
Print Post  
Thanks for the hints. I'm currently using TableNode for showing the anchors - two columns, input connectors in the left column, output in the right column. I don't know, how to do this: I need to show input only anchor for each cell in the left column and output only anchors for each cell in the right column.
There is AnchorPattern and RowAnchorPattern property, but I am not sure how to use them, especially how to set different anchors for left and right cells.
Also a question, how to align the text in the right column to the right? I've tried node[1,0].HorizontalAlignment and HorizontalContentAlignment, but none worked.

And another question, when using LayeredLayout, how to keep the position of all nodes within the diagram area? I need the layout to fit all nodes into the 800x600 area. The Layered layout is moving the nodes into positions out of the diagram visible area. The Layout.Margin switch does not work at all, also prohibiting changes in diagram size does not work.
Thanks for help Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #3 - Sep 20th, 2010 at 5:18pm
Print Post  
You should set table.RowAnchorPattern = AnchorPattern.LeftInRightOut in that case.

There's no property available for cell text alignment. For now you can change it by overriding the ControlTemplate for the Cell class; we'll add a property for the 1.8 release.

You can't limit LayeredLayout to a fixed area. Its width and height depend on the NodeDistance and LayerDistance properties. I suppose you could change ZoomFactor to fit the whole diagram, or calculate such NodeDistance and LayerDistance that the result fits the specified area.
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #4 - Sep 20th, 2010 at 6:01pm
Print Post  
I've already calculated manually the anchor patter for table nodes, but I'' try your solution Smiley
Too bad the cell can't be arranged, but that is only a small drawback.

But probably the last question today - how to change size of anchors or how to make them solid, not just outlines? They are hard to hit and not so clear to see imho.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #5 - Sep 21st, 2010 at 9:44am
Print Post  
Set the AnchorPoint.Size property to change their size. Currently you can make them solid only by overriding DiagramNode.CreateAnchorPointVisual and setting the Fill property of the Path returned by the base method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #6 - Sep 21st, 2010 at 11:35am
Print Post  
There is no DiagramNode.CreateAnchorPointVisual method as far as I can see Sad. Also another issue - I got table nodes with two columns, see the picture:



There might be different number of items in left/right column. The unoccupied cells should not be allowed as link targets - how to manage that? Currently when I create link it's possible to snap the end to the empty cells - which is wrong. Also I have found, that upon creating new link in LinkCreated handler the e.Link.DestinationAnchor is always -1 - only the destination index is set. Is this by design or is it a bug?

Update, I tried to add invisible anchor point to empty cell with "allowincoming = false", but new links are still snapped to each table cell. Also if I set RowAnchorPattern to empty pattern, the starting point of the new link is guided from the top left corner of the diagram. This is surely some bug.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #7 - Sep 21st, 2010 at 1:22pm
Print Post  
It is a protected method, you should be able to override it in a derived class. Preventing a link to specific rows can be implemented via the LinkCreating validation event:

Code
Select All
private void OnLinkCreating(object sender, LinkValidationEventArgs e)
{
	var table = e.Node as TableNode;
	if (table != null)
	{
		int row = -1, col = -1;
		if (table.CellFromPoint(e.MousePosition, true, ref row, ref col))
			e.Cancel = row == 2;
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #8 - Sep 21st, 2010 at 3:47pm
Print Post  
DiagramNode.CreateAnchorPointVisual

There's no such method.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #9 - Sep 21st, 2010 at 6:19pm
Print Post  
This is what I see:


What version of the control are you using?
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #10 - Sep 21st, 2010 at 6:37pm
Print Post  
MindFusion.Diagramming.Silverlight 1.7.0.30389
MindFusion.Graphs.Silverlight 1.1.0.30388
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #11 - Sep 21st, 2010 at 7:05pm
Print Post  
Try that with the assemblies from this post then -
http://mindfusion.eu/Forum/YaBB.pl?board=diaglite_disc;action=display;num=127901...

It seems we have added this method a few days after the 1.7 release.
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #12 - Sep 21st, 2010 at 7:22pm
Print Post  
It works, but I have experienced this error when using layered layout - only with 2 MyTableNodes:
Update - it throws exception in 1.7 stable too:
I've created 2 table nodes, both with 2x2 table. then added two links from 1st node to second and 2links from 2nd to 1st node... clicked to layout=>

LayeredLayout ll = new LayeredLayout
{
Orientation = Orientation.Horizontal,
LinkType = LayeredLayoutLinkType.Straight,
IgnoreNodeSize = false,
Anchoring = Anchoring.Keep,
LayerDistance = 15,
NodeDistance = 15,
EnforceLinkFlow = true,
StraightenLongLinks = true,
};

public class MyTableNode : TableNode
{
protected override System.Windows.Shapes.Path CreateAnchorPointVisual(AnchorPoint point)
{
Path x = base.CreateAnchorPointVisual(point);
x.Fill = x.Stroke;
return x;
}

public MyTableNode(Diagram diagram) : base(diagram) {}
}


at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at MindFusion.Layout.x348b8deb5aa85ce7.x210b394f42751fdc()
at MindFusion.Layout.x348b8deb5aa85ce7.xb7874248b0c0bc2d(x5e63d74830b5db57 x8e7bfcccb55aaf8f, xae117168b0e0c39f x8d3f74e5f925679c, x78e3ce9dc43283f0 x22bfd1664c623dc4)
at MindFusion.Diagramming.Silverlight.Layout.LayeredLayout.Arrange(Diagram diagram, DiagramItemCollection items)
at MindFusion.Diagramming.Silverlight.Layout.Layout.Arrange(Diagram diagram)

I've also found that even though I have created 4 links between these nodes, there is no link in Outgoing and incoming links in both nodes. Where's the problem?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Several questions about routing
Reply #13 - Sep 21st, 2010 at 7:38pm
Print Post  
Ok, our developer will check the layout tomorrow. The links should be in the in/out link collections of the table rows they connect.
  
Back to top
 
IP Logged
 
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: Several questions about routing
Reply #14 - Sep 22nd, 2010 at 6:50am
Print Post  
I've narrowed the problem to this setting:
LayeredLayout ll = new LayeredLayout
{
EnforceLinkFlow = true,
StraightenLongLinks = true,
};
using this on two table nodes 2x2cells, both with 2 links to the other nodes crashes the ll.Arrange.

Also I'm facing another problem... link.Locked is good for preventing changes on link, but I want links, with fixed endpoints, but selectable by clicking - user should be able to select the link and delete it ,but not change the endpoint positions. Is there a simple solution, or should I handle link modifying events and cancel them manually?
« Last Edit: Sep 22nd, 2010 at 9:55am by Necroman »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint