Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Snapping links to node/table (Read 4874 times)
MUDO
Junior Member
**
Offline



Posts: 90
Joined: Nov 29th, 2008
Snapping links to node/table
Jan 17th, 2009 at 7:17pm
Print Post  
Hi.

I would like to arrange created links to node/tables bounds. Check my picture. First step (picture1) is creating 5 links from table1 to table2. They arrange it like it is shown on picture2. I would like it to have like it is shown on picture3. Is it possible?

http://i39.tinypic.com/28gz8fs.jpg

I dont have anchorpoints defined on shapes or tables.
In case of table I dont want to use TableConnectionStyle.Rows (or Both) because of some internal restrictions from my side Sad

How is it possible to get acces to control points of links and how to change x&y coordination (for case of developing my own alghoritm Smiley )? Because link.ControlPoints is readonly
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Snapping links to node/table
Reply #1 - Jan 18th, 2009 at 9:57am
Print Post  
Hi,

Try the OrthogonalLayout class (called OrthogonalRouter is you are using v5.2 preview).

To set your own points coordinates, first set SegmentCount, and then assign PointF objects to the ControlPoints elements.

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



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #2 - Jan 18th, 2009 at 11:56am
Print Post  
Thanx!

But...
I have created two tables, link between these tables and
MindFusion.Diagramming.Layout.OrthogonalLayout instance:

MoOrto.Anchoring = MindFusion.Diagramming.Anchoring.Reassign (or keep)
MoOrto.BaseLayout = MindFusion.Layout.BaseLayout.Cascading


After the moving tables (one table below the second one) I want to route links depended on tables position without moving tables. It means not to keep endpoints of links on the same postion (--> picture4) - it is so logical I think Smiley
How is it possible to do this?

Autorouting is keeping endpoints (--> picture2) and OrthogonalLayout is "shaking" my tables (--> picture3).

http://i42.tinypic.com/zvdlbn.jpg


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Snapping links to node/table
Reply #3 - Jan 19th, 2009 at 5:20am
Print Post  
You could enable both AutoRoute and Dynamic; this should make the routing algorithm choose new end points after you move a table. What do you mean by OrthogonalLayout shaking your tables?

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



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #4 - Jan 19th, 2009 at 1:41pm
Print Post  
Hi!

Shaking - I mean shapes are rearrange and I want only rearrange links Smiley Sry for vague.

Now my situation about links is:
- Dynamic = True
- SnapToNodeBorder = True
- AutoRoute = True

- Im handling node modification and there I call route for all adjacent link:

Code
Select All
    Private Sub Diagram_NodeModifying(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeValidationEventArgs) Handles Diagram.NodeModifying
        For Each LoLink As MindFusion.Diagramming.DiagramLink In e.Node.IncomingLinks
            Call LoLink.Route()
        Next

        For Each LoLink As MindFusion.Diagramming.DiagramLink In e.Node.OutgoingLinks
            Call LoLink.Route()
        Next
    End Sub  



After this diagram with two nodes and two links looks like --> picture1. I want it looks like --> picture2

http://i42.tinypic.com/2w5lhk7.jpg


Quote:
To set your own points coordinates, first set SegmentCount, and then assign PointF objects to the ControlPoints elements.


Can you please explain it on my piece of code? Can I do it in LinkRouted event with parameter e? Am I allowed to change existing (starting/ending) control point of every link?

I have checked this forum and help file. What about:
- penalties in RoutingOptions? Some penalty for the same control point for more links?
- minimal distance between all ending points of all links on the same node
- as I read there is a problem with OrthogonalLayout in case of partial diagram layouting Sad

So, now it works great except for arranging of (starting/ending) points on the same edge of shape. This is what Im trying to fix now.

Thanx for your advice.


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Snapping links to node/table
Reply #5 - Jan 19th, 2009 at 2:32pm
Print Post  
Hi,

If you set OrthogonalLayout.BaseLayout = Custom, it should not move the tables, and it should result in something like picture2. Dynamic + AutoRoute doesn't consider the positions of other links but only those of the nodes, so when there are more links between the same nodes, they will get the same start and end points. In that case you could set link.ControlPoints[0] and link.ControlPoints[link.ControlPoints.Count - 1] to pull the link ends apart, and then call Route().

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



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #6 - Jan 19th, 2009 at 9:04pm
Print Post  
Hi!
Dynamic + Autoroute + call link.route in NodeModifying event works great. Thank you!

Another and I hope last issue is on a picture. As you can see links are not overlapped but my point marks are overlapped.

http://i42.tinypic.com/2n8sltf.jpg

I think there is any property whose intent is to set minimal distance between end points of links. Some kind of untouchable/secret area around point. Am I right? Or another your idea?

Thanx.


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Snapping links to node/table
Reply #7 - Jan 20th, 2009 at 9:43am
Print Post  
Hi,

There's no such property unfortunately. What you could do is define an AnchorPattern with say 5 points at each side of the table, and handle the ValidateAnchorPoint event to allow only one link to be connected to a point.

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



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #8 - Jan 20th, 2009 at 4:45pm
Print Post  
Hi!

The solution with anchorpoints is the best way for me, thank you Stoyo!

I checked this threads

http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=116410063...
and
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=119507436...
1) Links are blinking while moving a shape when link.dynamic=true Sad
Can you pls help me with this? I want to keep dynamic behavior.

2) How can I do the same control (only one link for one anchorpoint) for the origin shape? There is not raised event ValidateAnchorPoint for this shape?


...MUDO...
  
Back to top
 
IP Logged
 
MUDO
Junior Member
**
Offline



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #9 - Jan 20th, 2009 at 6:13pm
Print Post  
OK, blinking is solved - I dont count the link for which ValidateAnchorPoint is calling.

Code
Select All
 Private Function NumberOfLinks(ByVal IoNode As MindFusion.Diagramming.TableNode, ByVal IoLink As MindFusion.Diagramming.DiagramLink, ByVal IoAnchorIndex As Integer) As Integer

  Dim LiTotal As Integer = 0

  For Each LoLink As MindFusion.Diagramming.DiagramLink In IoNode.IncomingLinks


If Not IoLink Is Nothing Then


    Debug.Print(IoLink.DestinationAnchor.Equals(LoLink.DestinationAnchor))


    If Not IoLink.DestinationAnchor.Equals(LoLink.DestinationAnchor) Then



  If LoLink.DestinationAnchor = IoAnchorIndex Then LiTotal += 1


    End If


End If

  Next


  For Each LoLink As MindFusion.Diagramming.DiagramLink In IoNode.OutgoingLinks


If LoLink.DestinationAnchor = IoAnchorIndex Then LiTotal += 1

  Next


  Return LiTotal
    End Function
 



1) But why sometimes is e.link=nothing? Its not logical for me. When there is a request for assigning endpoint to anchorpoint, there must be link as well, right?
2) Problem about ValidateAnchorPoint event for the origin shape stands Smiley

Sry for too many questions.

...MUDO...
  
Back to top
 
IP Logged
 
MUDO
Junior Member
**
Offline



Posts: 90
Joined: Nov 29th, 2008
Re: Snapping links to node/table
Reply #10 - Jan 20th, 2009 at 6:52pm
Print Post  
Oooh, sry for my mad-brained solution Sad

This code fix both my questions!

Code
Select All
Private Function NumberOfLinks(ByVal IoNode As MindFusion.Diagramming.TableNode, ByVal IoLink As MindFusion.Diagramming.DiagramLink, ByVal IoAnchorIndex As Integer) As Integer
	  Dim LiTotal As Integer = 0

	  For Each LoLink As MindFusion.Diagramming.DiagramLink In IoNode.IncomingLinks
		If Not IoLink Is Nothing Then
		    Debug.Print(IoLink.DestinationAnchor.Equals(LoLink.DestinationAnchor))
		    If Not IoLink.DestinationAnchor.Equals(LoLink.DestinationAnchor) Then
			  If LoLink.DestinationAnchor = IoAnchorIndex Then LiTotal += 1
		    End If
		End If
	  Next

	  For Each LoLink As MindFusion.Diagramming.DiagramLink In IoNode.OutgoingLinks
		If Not IoLink Is Nothing Then
		    Debug.Print(IoLink.OriginAnchor.Equals(LoLink.OriginAnchor))
		    If Not IoLink.OriginAnchor.Equals(LoLink.OriginAnchor) Then
			  If LoLink.OriginAnchor = IoAnchorIndex Then LiTotal += 1
		    End If
		End If
	  Next

	  Return LiTotal
    End Function
 



It works great!

Maybe you can give some advice for speed improvement.

...to have a collection of assigned anchorpoints and checking this collection instead of IncomingLinks & OutgoingLinks collections because there is a presumption in my application that number of assigned anchorpoints is less than number of free anchorpoints.

Any idea?
Thank you again Smiley


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Snapping links to node/table
Reply #11 - Jan 21st, 2009 at 5:55am
Print Post  
The validation event could be raised before a link is created, so you get a null argument in that case. You could keep them in a System.Collections.Generic.Dictionary object for a constant-time access, though if you have just a few links per node, you'll just waste your efforts Wink

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