Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Getting the best from routing (Read 4216 times)
Stuart
Junior Member
**
Offline


Short, fat and bald, that's
me.

Posts: 64
Location: Lincs, UK
Joined: Sep 5th, 2008
Getting the best from routing
Sep 12th, 2008 at 4:31pm
Print Post  
[img]http://www.yuangchi.com/offtopic/ss4.gif[/img]
The image above shows a simple chart. The 'Start' node was added first, then the numbered in order.

After each node was added the code called
[code]
procedure tFlowChartHelper.layout;
var
t : Treelayout;
begin
t := CreateComObject(CLASS_TreeLayout) as Treelayout;
t.NodeSpacing := CLayoutNodeSpacing;
t.LevelSpacing := CLayoutLevelSpacing;
t.ArrowAnchoring := ancKeep;
t.type_ := tltCentralized;
t.ArrowStyle := tlaPerpendicular3;
fcx.ArrangeDiagram(t);
fcx.RouteAllArrows;
fcx.FitDocToObjects(CLayoutMargin);
end;
[/code]

I've set up the fcx.RoutingOptions with this ...

[code]
const
CLayoutGridSize = 16;
CLayoutLevelSpacing = 60;
CLayoutMargin = 20;
CLayoutNodeSpacing = 48;
CLayoutTurnCost = 255;
ClayoutCrossingCost = 255;
CLayoutNodeVicinityCost = 0;
CLayoutLengthCost = 255;

...

fcx.RoutingOptions.CrossingCost := CLayoutCrossingCost;
fcx.RoutingOptions.TurnCost := CLayoutTurnCost;
fcx.RoutingOptions.LengthCost := CLayoutLengthCost;
fcx.RoutingOptions.NodeVicinityCost := CLayoutNodeVicinityCost;

[/code]

It doesn't seem to matter [i]what[/i] I do to the RoutingOptions values, I just can't get it to do something sensible like move the boxes to the correct side of the decision node.

I'd appreciate any suggestions.

TVM
  

-- &&Stuart
Back to top
YIM  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the best from routing
Reply #1 - Sep 14th, 2008 at 7:38am
Print Post  
Routing only sets the arrow point coordinates, depending on the positions of nodes in the diagram, without moving the nodes. TreeLayout and routing are not related in any way, and TreeLayout will not change the node order based on the values in RoutingOptions. The order in which child nodes are arranged under their parent depend on the order of the OutgoingArrows collection, so to make TreeLayout place the 'no' node on the left of the 'yes' node, you must either create the 'no' link before the 'yes' link, or use the ArrowCollection.ChangeIndex method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stuart
Junior Member
**
Offline


Short, fat and bald, that's
me.

Posts: 64
Location: Lincs, UK
Joined: Sep 5th, 2008
Re: Getting the best from routing
Reply #2 - Sep 15th, 2008 at 8:17am
Print Post  
OK Stoyan, thanks.

I guess that's gust something I'm going to have to document for my users.

That said, I wonder if there's not something I should expect from TreeLayout wrt placing of the nodes, before Routing does it's thing?
  

-- &&Stuart
Back to top
YIM  
IP Logged
 
Stuart
Junior Member
**
Offline


Short, fat and bald, that's
me.

Posts: 64
Location: Lincs, UK
Joined: Sep 5th, 2008
Re: Getting the best from routing
Reply #3 - Sep 16th, 2008 at 10:53am
Print Post  
Stuart wrote on Sep 15th, 2008 at 8:17am:
That said, I wonder if there's not something I should expect from TreeLayout wrt placing of the nodes, before Routing does it's thing?

Any thoughts about this?
  

-- &&Stuart
Back to top
YIM  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the best from routing
Reply #4 - Sep 16th, 2008 at 12:02pm
Print Post  
TreeLayout was designed to arrange trees. It does not know a thing about the logical meaning of the links, and whether you want to place some nodes on the left and other nodes on the right. It just places the nodes in the order in which they an be accessed through the OutgoingArrows of the parent node. So the only way for you to control the order of child nodes is to use the same order for links in the parent's OutgoingArrows collection. You either create the links in that order, or use the OugoingArrows.ChangeIndex method. E.g. to make TreeLayout place the Yes node on the right of the No node, the Yes link should come after the No link in the OugoingArrows collection.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stuart
Junior Member
**
Offline


Short, fat and bald, that's
me.

Posts: 64
Location: Lincs, UK
Joined: Sep 5th, 2008
Re: Getting the best from routing
Reply #5 - Sep 16th, 2008 at 12:12pm
Print Post  
So, am I then using the wrong layout class? Or am I likely to see a similar thing with all of the classes?
  

-- &&Stuart
Back to top
YIM  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the best from routing
Reply #6 - Sep 16th, 2008 at 4:44pm
Print Post  
Actually this is the only layout class that provides you with some control over the order of child nodes 8) It's not that hard though - if you let your users draw links, use the OutgoingArrows.ChangeIndex method to specify in what order you'd like the child nodes to appear before calling ArrangeDiagram. If you create the diagrams entirely from code, just call CreateArrow in the correct order.

Stoyan
  
Back to top
 
IP Logged
 
Stuart
Junior Member
**
Offline


Short, fat and bald, that's
me.

Posts: 64
Location: Lincs, UK
Joined: Sep 5th, 2008
Re: Getting the best from routing
Reply #7 - Sep 16th, 2008 at 4:47pm
Print Post  
Stoyan,

Thanks for that. I'll give some thought to the ChangeIndex idea.
  

-- &&Stuart
Back to top
YIM  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint