Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Require custom arrangement of links (Read 6385 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Require custom arrangement of links
May 21st, 2010 at 2:15pm
Print Post  
Hi,

We are using ShapeNodes in our diagram. In ShapeNode we have applied a custom positioned anchor point. Code for that custom position anchor point is

aPattern = new AnchorPattern(new AnchorPoint[]

{

new AnchorPoint(93,30,false,false,MarkStyle.Circle,new SolidColorBrush(Colors.Brown))

});

We want some custom arrangement for diagram links. We want All incoming links should be on left and all outgoing links should be on right
We can achieve this using Anchor Point property but we already have our custom anchor point, we don’t want to create another.

Can we achieve this with our custom anchor?

Please suggest.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #1 - May 21st, 2010 at 3:04pm
Print Post  
Hi,

Are you using this point only to display a circle inside the node? You could add two additional points on the left and right that allow respectively incoming and outgoing links, and set MarkStyle = None if you don't want them to be seen. Otherwise you will have to set the links' ControlPoints[0] and ControlPoints[Count - 1] to update the end points positions.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #2 - May 24th, 2010 at 9:22am
Print Post  
Hi Stoyan,

Could you please explain in detail what are ControlPoints[0] and ControlPoints[Count - 1]? How we can use them to get the desired behavior?

Will it make any performance impect to the application?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #3 - May 24th, 2010 at 11:53am
Print Post  
Hi Anshul,

ControlPoints contains the points that define a link's geometry, e.g. each pair of points defines one segment of a polyline link. So link.ControlPoints[0] and link.ControlPoints[link.ControlPoints.Count - 1] define the end points of the link. This lets you set the end point's positions without using anchor points, e.g. the following places the link origin point at the middle-right of a node:

var r = node.Bounds;
var p = new Point(r.Right, r.Top + r.Height/2);
link.ControlPoints[0] = p;
link.UpdateFromPoints();

I hope that helps,
Stoyan
« Last Edit: May 24th, 2010 at 1:41pm by Stoyo »  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #4 - May 27th, 2010 at 2:39pm
Print Post  
Hi Stoyan,

If we add two additional points on the left and right, how we can map that link incoming at one point and outgoing from other point?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #5 - May 27th, 2010 at 3:03pm
Print Post  
Hi,

The AchorPoint constructor takes two boolean arguments - allowIncoming and allowOutgoing. Set them to true,false for the incoming point and false,true for the outgoing one.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #6 - May 29th, 2010 at 2:39pm
Print Post  
Hi Stoyan,

In anchor point approach, we are having some issues like we are already using an anchor point in our ShapeNodes. We don’t want to do anything with that anchor point. In a special case, we want to have two new anchor points in left and right middle of the node, one anchor for incoming link and other is for outgoing link. In this case, link may be straight or may have right link path only. If we can overcome these issues, please let us know.

For 1st approach, we have tried your suggested way. In this way we are facing few issues like, Link is bend initially. When we move any node than only node's associated link gets straight or right angled. We want this behavior of link just after click on "Arrange" button. We are sending a sample application. Please have a look into that and suggest a suitable solution.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #7 - May 30th, 2010 at 9:20am
Print Post  
Hi,

I could not understand what problem exactly do you have with AnchorPoints. So you have already defined an AnchorPattern containing a point that doesn't accept any links, kind of only to display the anchor point mark over a node? Is it that hard to add two additional points to that AnchorPattern where the first accepts incoming links and the second accepts outgoing links?

Regarding setting AnchorPoints, with that approach you take complete responsibility over the link's shape. If it's a cascading-style link and you move one point, you will have to align its neighbor points X or Y positions to make the segments horizontal or vertical again. You could simply call link.Route at the end of your BusLinkStyle method to find a cascading link route between the specified end points, or otherwise use the code below to align the cascading links points after setting their ends' positions:

Code
Select All
private void AlignFirstCascadingSegment()
{
	Real fx = points[1].X;
	Real fy = points[1].Y;
	if (cascadeStartHorizontal)
		fy = points[0].Y;
	else
		fx = points[0].X;
	points[1] = new Point(fx, fy);
}

private void AlignLastCascadingSegment()
{
	int pts = points.Count;
	Real lx = points[pts - 2].X;
	Real ly = points[pts - 2].Y;
	if (pts % 2 != 0)
	{
		if (cascadeStartHorizontal)
			lx = points[pts - 1].X;
		else
			ly = points[pts - 1].Y;
	}
	else
	{
		if (cascadeStartHorizontal)
			ly = points[pts - 1].Y;
		else
			lx = points[pts - 1].X;
	}
	points[pts - 2] = new Point(lx, ly);
} 



This is actual code the control runs when you move cascading link end points with the mouse. To use it from your application, replace points with ControlPoints and Real with double.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #8 - May 31st, 2010 at 3:18pm
Print Post  
Hi Stoyan,

Now we are getting links with right angle only and we do not have to move nodes to do this; but with this approach, we are getting multiple right angle in the link path, also link is not always pointing to the left or right (When we move the node, link also moves accordingly, we want link should always incoming at the left and outgoing from the right).

We have tried with anchor point approach also, but we are not able to attach two anchor points with the node.AnchorPattern property.

We have sent a sample image and a sample project describing problem with anchor point approach. Please have a look and let know your suggestion.

Thanks and Regards,
Anshul
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #9 - Jun 2nd, 2010 at 6:20am
Print Post  
Hi Stoyan,

Have you got a chance to look into the sample?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #10 - Jun 2nd, 2010 at 7:54am
Print Post  
Yes, but for example the node5 -> node6 link in your example cannot be drawn with only one bend without crossing other nodes. If you don't mind that, you can simply loop over the links and process two cases:

- If a link connect nodes that occupy overlapping X or Y ranges, set the link to a single segment polyline that lies at the middle of the overlapping range;

- Set all other links to cascading with SegmentCount = 2;

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #11 - Jun 2nd, 2010 at 8:53am
Print Post  
Hi,

We have tried with SegmentCount = 2, but still we are getting more than 2 bends in the link. Link may cross the node but important point is that link should not bend anywhere (in loading or while moving the node). Currently, in loading time links are appearing with two and more right angles and while we are trying to move the node, link is bending.

Also with this approach, we are not always getting incoming links at left and outgoing links at Right of the node. When we move the node, links also changes its pointing location.

We are seeing some issue with this approach, could you please suggest some pointer for additional two anchor point approach over the node.

We have tried with anchor point approach also, but we are not able to attach two anchor points with the node.AnchorPattern property. 
We have sent a sample image and a sample project describing problem with anchor point approach. Please have a look and let know your suggestion.


Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #12 - Jun 2nd, 2010 at 11:21am
Print Post  
Hi,

Disable AutoRoute / don't call the RouteLinks method and you will get only one bend with SegmentCount = 2. Otherwise the routing function overrides this to avoid crossing nodes.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Require custom arrangement of links
Reply #13 - Jun 2nd, 2010 at 1:41pm
Print Post  
Hi Stoyan,

If I have three custom anchor points and I want all three points in Node, How can I attach them with the node? (If I am not wrong, we can attach only one anchor point with Node.AnchorPattern property)
  • First anchor point I will use to create a link and it will appear when mouse is over the node.
  • Second anchor point will accept incoming links and it will always hide.
  • Third anchor point will allow outgoing links and it will also always hide.

Please let us know your suggestion.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Require custom arrangement of links
Reply #14 - Jun 2nd, 2010 at 2:11pm
Print Post  
Hi Anshul,

Do you mean you need to start drawing links from the first point, but they should connect to the third point once created?

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