Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Minimum number of lines in cascading line (Read 9787 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Minimum number of lines in cascading line
Nov 17th, 2010 at 6:22am
Print Post  
Hi Stoyo

While drawing the lines between two node, I want to create mimimum number of lines.

For eq. By using any layout alogrithm nodes have given proper postion and diagram looks like something below
http://4nic6g.bay.livefilestore.com/y1p8YORrQ_ppJM6h1PiO6Tdy81ZapXfr_KcoKL_qQajs...

Trying to reposition the nodes, I get following view.
http://4nic6g.bay.livefilestore.com/y1pqyxuspDC4rSvgcCCvckTE0tuyOcpMlRTJsrDp9JIt...

In above image, the line is visible in node area also. In this view, the link is always drawn by considering the center point of node
( by setting Dynamic property to true)

To resolve this issue, I added following code
http://4nic6g.bay.livefilestore.com/y1pqyxuspDC4rSx3EnAT9EolHdTZ0DNx362FB4QQA-Jd...

and the result is as below

http://4nic6g.bay.livefilestore.com/y1pzbfp8Pqs9IAq4-CvYJC6xNxxi0S-znrac3XqiktRj...

Here I expect following output
http://4nic6g.bay.livefilestore.com/y1pzbfp8Pqs9IAnzaHbGknlUuEHWwKux44b0rDV4-MzE...

where the number of line segement drawn between two nodes should be minimum. If you compare last two image, the prior one uses 5 line seqment and the later one uses 3 line segment.

For you info, I made this application using WPF. I need similar behaviour in silverlight. I think whatever i did in above WPF sample is possible but the expected out is not possible in silverlight also.

Update: I see methoud like "RouteAllLinks" which is applicable to diagram. Using this method in node_modifing event also doesn't help.
if it is routing all links in the diagram, i think there should be method to route all links for specific node only.





Regards
Rajesh
« Last Edit: Nov 17th, 2010 at 10:21am by rajesh_patil74 »  
Back to top
WWW  
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #1 - Nov 17th, 2010 at 10:44am
Print Post  
Hi Stoyo,

I also tried by calling the overloaded Arrange method which takes collection of diagram items.
In that parameter, i collected all links which need to rearranged/routed again but still it is not give as expected resulted.

What i need is minimum line segement when possible and in such situation entry/exist of line from node should find the correct edge of line.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #2 - Nov 17th, 2010 at 12:44pm
Print Post  
Hi Rajesh,

Try the following:
Code
Select All
private void OnNodeModified(object sender, NodeEventArgs e)
{
	diagram.RoutingOptions.Anchoring = Anchoring.Reassign;
	diagram.LinkRouter.RouteLinks(e.Node.GetAllLinks());
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #3 - Nov 17th, 2010 at 1:06pm
Print Post  
Hi Stoyo

It is not working as expected.

Please find the attached code and try to reposition the nodes. Anchor points are changing only for the selected node.\
Code
Select All
        private ShapeNode CreateApplication(string appName)
        {
            ShapeNode appNode = new ShapeNode(diagram1);
            appNode.Text = appName;
            appNode.Bounds = new Rect(new Size(200, 70));
            diagram1.Nodes.Add(appNode);
            return appNode;
        }

        void diagram1_NodeModified(object sender, NodeEventArgs e)
        {
            diagram1.RoutingOptions.Anchoring = Anchoring.Reassign;
            diagram1.LinkRouter.RouteLinks(e.Node.GetAllLinks());
        }

        private void LoadCustom(object sender, RoutedEventArgs e)
        {
            diagram1.ClearAll();
            ShapeNode app5 = CreateApplication("Item5");
            ShapeNode app6 = CreateApplication("Item6");
            ShapeNode app7 = CreateApplication("Item7");

            DiagramLink link1 = diagram1.Factory.CreateDiagramLink(app7, app5);
            link1.Dynamic = true;
            link1 = diagram1.Factory.CreateDiagramLink(app7, app6);
            link1.Dynamic = true;

            //new LayeredLayout() { LinkType = LayeredLayoutLinkType.Cascading, KeepGroupLayout = true, MultipleGraphsPlacement = MultipleGraphsPlacement.MinimalArea }.Arrange(diagram1);
            new OrthogonalLayout() { KeepGroupLayout = true, MultipleGraphsPlacement = MultipleGraphsPlacement.MinimalArea }.Arrange(diagram1);

        }
 



With LayeredLayout, Anchor point gets changed only for selected node and since the other node to which selected node is linked, anchor point doen't get changed it results in more segement line than expected ( For eq. when possible with 2 segement , line generated is 5 segement overlapping other lines )

With OrthogonalLayout it doen't change the anchor points at all with added code.

What I would like is with OrthogonalLayout ( I think the complex diagram generated with Orthogonal layout is more nice than LayeredLayout)

Update: What I observed in layered layout is that, if orignial anchor point is top, it always gets changed to top/botton depending on the position and never set to left or right anchor point.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #4 - Nov 17th, 2010 at 1:22pm
Print Post  
Actually I had auto-routing enabled in by test app and it's what moved the anchor points. If you enable AutoRoute, you will get that automatically without having to handle any events:

Code
Select All
DiagramLink link1 = diagram.Factory.CreateDiagramLink(app7, app5);
link1.AutoRoute = true;
link1 = diagram.Factory.CreateDiagramLink(app7, app6);
link1.AutoRoute = true;

diagram.RoutingOptions.Anchoring = Anchoring.Reassign;

// new OrthogonalLayout() ... 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #5 - Nov 17th, 2010 at 1:28pm
Print Post  
Hi Stoyo

Thanks for your quick reply. But my expected out is not still possible. Even with setting autoroute to true for orthogonal layout.

My expected requirement is -

1. What I observed with layed layout is, if orignial anchor point is top, it always gets changed to top/botton depending on the position and never set to left or right anchor point. --> This should be possible.

2. Anchor point of other linked node should also gets changed.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #6 - Nov 17th, 2010 at 1:46pm
Print Post  
Quote:
1. What I observed with layed layout is, if orignial anchor point is top, it always gets changed to top/botton depending on the position and never set to left or right anchor point.  --> This should be possible.


What should be possible? - do you expect the links to always choose only the top and bottom sides of nodes for end points? Have you also set diagram.RoutingOptions.Anchoring = Anchoring.Reassign?
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #7 - Nov 17th, 2010 at 2:02pm
Print Post  
Hi Stoyo

The diagram routing property was not set previously. But after setting it also it doesn't give expected result.

Oringal Image
http://4nic6g.bay.livefilestore.com/y1p5fvR1d38F57QNDScNJyrPGuS0lB359KcDJUnexQVn...


After re-position the nodes i get following one.

http://4nic6g.bay.livefilestore.com/y1phd5kophyKbGO4W2GwMx7W2HIGfvrYPBh0S-OqJ7r_...

If you see the anchor points are not changed. And the code which i have is
Code
Select All
  private ShapeNode CreateApplication(string appName)

  {


ShapeNode appNode = new ShapeNode(diagram1);


appNode.Text = appName;


appNode.Bounds = new Rect(new Size(200, 70));


diagram1.Nodes.Add(appNode);


return appNode;

  }


  void diagram1_NodeModified(object sender, NodeEventArgs e)

  {


//diagram1.RoutingOptions.Anchoring = Anchoring.Reassign;


//diagram1.LinkRouter.RouteLinks(e.Node.GetAllLinks());

  }


  void diagram1_NodeModifying(object sender, NodeValidationEventArgs e)

  {


//diagram1.RoutingOptions.Anchoring = Anchoring.Reassign;


//diagram1.LinkRouter.RouteLinks(e.Node.GetAllLinks());

  }


  private void LoadCustom(object sender, RoutedEventArgs e)

  {


diagram1.ClearAll();


diagram1.RoutingOptions.Anchoring = Anchoring.Reassign;


ShapeNode app5 = CreateApplication("Item5");


ShapeNode app6 = CreateApplication("Item6");


ShapeNode app7 = CreateApplication("Item7");



DiagramLink link1 = diagram1.Factory.CreateDiagramLink(app7, app5);


//link1.Dynamic = true;


link1.AutoRoute = true;


link1 = diagram1.Factory.CreateDiagramLink(app7, app6);


//link1.Dynamic = true;


link1.AutoRoute = true;



//new LayeredLayout() { LinkType = LayeredLayoutLinkType.Cascading, KeepGroupLayout = true, MultipleGraphsPlacement = MultipleGraphsPlacement.MinimalArea }.Arrange(diagram1);


new OrthogonalLayout() { KeepGroupLayout = true, MultipleGraphsPlacement = MultipleGraphsPlacement.MinimalArea }.Arrange(diagram1);


  }
 



What i need is anchor point of both source & destination should be changed ( left , right , top or bottom). In the above modified image, both links should have 2 segements and with that it would be nice diagram again ( User don't need to assing anchor point manually if nodes are re-positioned).


Also see the variations of the same if i arrange like below -
http://cid-2b9bf77533900b84.office.live.com/self.aspx/.Public/9.png

http://cid-2b9bf77533900b84.office.live.com/self.aspx/.Public/10.png

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #8 - Nov 17th, 2010 at 2:19pm
Print Post  
Check this test project of ours, that seems to work as you expect it there:
https://mindfusion.eu/_temp/RouteTest.zip
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #9 - Nov 18th, 2010 at 5:40am
Print Post  
Hi Stoyo

Thanks for the sample.

After taking dlls from your sample application, my application also works as expected.

Now, following issues are occuring to me -

1. When anchor point is changed, it is not always from center of the node.

2. I am not able to change the anchor point.

3. While user is re-positioning the item, link gets autorouted but anchor points are not changed. Once user releases the left mouse button (confirms the position of the node) anchor points gets changed.

Can you help me in those issue.

Also, still with re-positioning node, the link generated is not always optimum i.e when 2 segements with cascading it is possible, it generates 3 segements ( I think , this can be improved later on but above 3 issues needs to be done. )

see the following image http://4nic6g.bay.livefilestore.com/y1pEcGSmpNDe0quUI5I5NkaPW5PBbUlLzy_mEFjzpTFp...

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #10 - Nov 18th, 2010 at 8:15am
Print Post  
Quote:
1. When anchor point is changed, it is not always from center of the node.


You will have to set the nodes' AnchorPattern property if links should always start from the middle points of node borders.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #11 - Nov 18th, 2010 at 8:37am
Print Post  
Quote:
3. While user is re-positioning the item, link gets autorouted but anchor points are not changed. Once user releases the left mouse button (confirms the position of the node) anchor points gets changed.


Actually the routing function runs only after you release the mouse button. Otherwise the links just follow their nodes by offsetting the end segments without trying to find a better route. You could try doing additional routing as you originally did from NodeModifying:

Code
Select All
private void OnNodeModifying(object sender, NodeValidationEventArgs e)
{
	foreach (DiagramLink link in e.Node.GetAllLinks())
		link.ReassignAnchorPoints();
	diagram.LinkRouter.RouteLinks(e.Node.GetAllLinks());
} 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #12 - Nov 18th, 2010 at 8:44am
Print Post  
Quote:
2. I am not able to change the anchor point.


Then you must not use the Reassign value for RoutingOptions.Anchoring, or the auto-routing method will again revert to the anchor point closer to the opposite node. Use Keep instead, and it still seems to work fine in combination with calling ReassignAnchorPoints from NodeModifying. Also set SnapToAnchor as below, otherwise the links won't snap to the points from AnchorPattern when modifying them after creation.

Code
Select All
diagram.RoutingOptions.Anchoring = Anchoring.Keep;
diagram.SnapToAnchor = SnapToAnchor.OnCreateOrModify; 

  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Minimum number of lines in cascading line
Reply #13 - Nov 18th, 2010 at 8:56am
Print Post  
Hi Stoyo

Sorry, it didn't help.
I can set "AnchorPattern" to value like "AnchorPattern.TopInBottomOut" then it always use always top anchor as in and bottom anchor as out.

Update : With createing anchor patten lines are always drawn on anchor patten. The problem with this is that, to assing correct patern one need to know what type of shape is assinged. In my app, I am allowing user for custom shapes creation and use that. With that i need to ask user anchor patten for each shape also ( i think this should not do it that way )

Also, i have one anchor point which is in center. linking to that anchor point line part which overlaps node is also visible.

I need it dynamic ( choose the border dynamically from which link should be shown going in/out ) according to node position.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Minimum number of lines in cascading line
Reply #14 - Nov 18th, 2010 at 9:25am
Print Post  
Quote:
I can set "AnchorPattern" to value like "AnchorPattern.TopInBottomOut" then it always use always top anchor as in and bottom anchor as out.


Well of course - exactly as its name states. You will have to use a custom one with four points at the side centers:

Code
Select All
private AnchorPattern cross = new AnchorPattern(new AnchorPoint[]
{
	new AnchorPoint(50, 0),
	new AnchorPoint(100, 50),
	new AnchorPoint(50, 100),
	new AnchorPoint(0, 50)
});

private ShapeNode CreateApplication(string appName)
{
	ShapeNode appNode = new ShapeNode(diagram);
	appNode.Text = appName;
	appNode.Bounds = new Rect(new Size(200, 70));
	appNode.AnchorPattern = cross;
	diagram.Nodes.Add(appNode);
	return appNode;
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint