Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Finding the correct anchor point (Read 11539 times)
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Finding the correct anchor point
Apr 20th, 2009 at 8:36am
Print Post  
Hello,

I've got a need to find the correct anchor point to attach a link to in a given node, I'm programmatically creating a new link thats attached to an origin node, but the link automatically finds the closest anchor to the destination node rather than the closet anchor to the point I've specified as the start point for the link.

As such it would be nice either if links had a behaviour modifyer which allowed them to anchor to the closest anchor point to the start position or if the node has a find anchor point functionality.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Finding the correct anchor point
Reply #1 - Apr 20th, 2009 at 10:44am
Print Post  
This version adds DiagramNode.GetClosestAnchorPoint method:
https://mindfusion.eu/_beta/fcnet_closestanchor.zip

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


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Finding the correct anchor point
Reply #2 - Apr 22nd, 2009 at 9:17am
Print Post  
Whats the best way of programmatically telling a link that it has new anchor points?

I've tried to create a new link specifying the anchor points as parameters but this will only work with shapenodes and not tablenodes.

m_diagram.Factory.CreateDiagramLink(sourceShapeNode, sourceAnchorInt, destShapeNode, destAnchorInt)

it seems like there is not a similar prototype of table nodes?

Anyways I then tried to set the properties on the link directly by modifying the

OriginAnchor and the DestinationAnchor

although this didn't seem to have any affect on where the link connected to. In both cases it assigned it self to the first anchor point.

is this a bug or do you think I'm doing something wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Finding the correct anchor point
Reply #3 - Apr 22nd, 2009 at 1:27pm
Print Post  
Create links to tables without specifying anchor points; first connect them to a specific row, and set the OriginAnchor/DestinationAnchor only after that.

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


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Finding the correct anchor point
Reply #4 - Apr 22nd, 2009 at 3:35pm
Print Post  
yes thats working a treat, and its very easy now with the new function to find the closest anchor point.

This is awesome guys exactly what I needed Cheesy
  
Back to top
 
IP Logged
 
nbg-user
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Jan 14th, 2010
Re: Finding the correct anchor point
Reply #5 - Jan 14th, 2010 at 9:53am
Print Post  
[quote author=Stoyo link=1240216596/0#3 date=1240406869]Create links to tables without specifying anchor points; first connect them to a specific row, and set the OriginAnchor/DestinationAnchor only after that.

I hope that helps,
Stoyan[/quote]
Hi,
I want to add links to anchorpoints in tablenodes programmitacally after creating two tables (also programmatically). I tried different codes but didn't get it working, so I searched for a solution in the forum and found this thread.
I tried to add a link from Table2-Output (row0) to Table1-Input (row0) using your solution but the link still goes from Table2-Output2 (row1).

When I deselect the table, the link is hidden. Is there any solution to show the link always?
When I select one table and delete it by pressing the "Del"-Key the link is still available but should be deleted also.

Do you have any solution for it? Maybe you can provide a sample or correct my code.

Thanks a lot.
[code] Dim rh As Single = diaSystem.TableRowHeight
Dim th As Single = diaSystem.TableCaptionHeight
Dim totalh As Single = th + (1 + 1) * rh
Dim totalh2 As Single = th + (2 + 1) * rh

Dim t1 As TableNode = diaSystem.Factory.CreateTableNode(5, 5, 30 + 2 * rh, totalh)
Dim t2 As TableNode = diaSystem.Factory.CreateTableNode(5, 5, 30 + 2 * rh, totalh2)

' set table properties
t1.RowCount = 1
t1.ColumnCount = 4
t1.Scrollable = False
t1.EnabledHandles = AdjustmentHandles.Move
t1.CellFrameStyle = CellFrameStyle.None
t1.HandlesStyle = HandlesStyle.HatchHandles3
t1.Columns(0).Width = rh
t1.Columns(3).Width = rh
t1.Columns(1).Width = 15
t1.Columns(2).Width = 15
t1.Style = TableStyle.RoundedRectangle
t1.CaptionColor = Color.White

t2.RowCount = 2
t2.ColumnCount = 4
t2.Scrollable = False
t2.EnabledHandles = AdjustmentHandles.Move
t2.CellFrameStyle = CellFrameStyle.None
t2.HandlesStyle = HandlesStyle.HatchHandles3
t2.Columns(0).Width = rh
t2.Columns(3).Width = rh
t2.Columns(1).Width = 15
t2.Columns(2).Width = 15
t2.Style = TableStyle.RoundedRectangle
t2.CaptionColor = Color.White

' set connection points
Dim ptin_t1 As New AnchorPoint(50, 50, True, False, Color.Red, 0)
Dim ptout_t1 As New AnchorPoint(50, 50, False, True, Color.Red, 3)
Dim ptin_t2 As New AnchorPoint(50, 50, True, False, Color.Red, 0)
Dim ptout_t2_1 As New AnchorPoint(50, 50, False, True, Color.Red, 3)
Dim ptout_t2_2 As New AnchorPoint(50, 50, False, True, Color.Red, 3)

Dim al_t1 As New ArrayList
Dim al_t2_row0 As New ArrayList
Dim al_t2_row1 As New ArrayList

'Table with 1 Input and 1 Output
t1.Caption = "Table 1"
'Row 0 - Input
al_t1.Clear()
t1(0, 0).ImageAlign = ImageAlign.Center
t1(0, 0).Image = images.Images(0)
t1(1, 0).Text = "Input"
al_t1.Add(ptin_t1)
t1.Rows(0).AnchorPattern = New AnchorPattern(al_t1.ToArray(GetType(AnchorPoint)))
'Row 0 - Output
t1(3, 0).ImageAlign = ImageAlign.Center
t1(3, 0).Image = images.Images(1)
t1(2, 0).Text = "Output"
t1(2, 0).TextFormat.Alignment = StringAlignment.Far
al_t1.Add(ptout_t1)
t1.Rows(0).AnchorPattern = New AnchorPattern(al_t1.ToArray(GetType(AnchorPoint)))

'Table with 1 Input and 2 Outputs
t2.Caption = "Table 2"
'Row0 - Input
al_t2_row0.Clear()
t2(0, 0).ImageAlign = ImageAlign.Center
t2(0, 0).Image = images.Images(0)
t2(1, 0).Text = "Input"
al_t2_row0.Add(ptin_t2)
t2.Rows(0).AnchorPattern = New AnchorPattern(al_t2_row0.ToArray(GetType(AnchorPoint)))
'Row0 - Output
t2(3, 0).ImageAlign = ImageAlign.Center
t2(3, 0).Image = images.Images(1)
t2(2, 0).Text = "Output"
t2(2, 0).TextFormat.Alignment = StringAlignment.Far
al_t2_row0.Add(ptout_t2_1)
t2.Rows(0).AnchorPattern = New AnchorPattern(al_t2_row0.ToArray(GetType(AnchorPoint)))
'Row1 - Output
al_t2_row1.Clear()
t2(3, 1).Image = images.Images(1)
t2(2, 1).Text = "Output 2"
t2(2, 1).TextFormat.Alignment = StringAlignment.Far
al_t2_row1.Add(ptout_t2_2)
t2.Rows(1).AnchorPattern = New AnchorPattern(al_t2_row1.ToArray(GetType(AnchorPoint)))

'Create DiagramLink and set to specific row of the tables
Dim DL As New DiagramLink(diaSystem, t2, t1)
t1.Rows(0).IncomingLinks.Add(DL)
t2.Rows(0).OutgoingLinks.Add(DL)

DL.OriginAnchor = 0
DL.DestinationAnchor = 0
[/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Finding the correct anchor point
Reply #6 - Jan 14th, 2010 at 12:04pm
Print Post  
You should add the link to diagram.Links, which automatically updates the rows' link collections. Since you have only one incoming and one outgoing anchor point, they will be selected automatically.

Dim DL As New DiagramLink(diaSystem, t2, t1)
DL.OriginIndex = 0
DL.DestinationIndex = 0
diaSystem.Links.Add(DL)

or just call this:

Dim DL As DiagramLink = diaSystem.Factory.CreateDiagramLink(t2, 0, t1, 0)
  
Back to top
 
IP Logged
 
nbg-user
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Jan 14th, 2010
Re: Finding the correct anchor point
Reply #7 - Jan 14th, 2010 at 12:21pm
Print Post  
Hi Stoyo,
thanks a lot for your quick answer.
Now the link is always visible. So this is working.
But when I delete one table, and select the other one, the link is still available and is not deleted. I guess, that I create a second link with the line "diasystem.links.add(dl)", so the one (which is hidden, when I deselect the table) is still alive. Is there any option for that, or must I add code, to get this working?

But the main problem is still open:
The link always starts from Output 2, and not, as I want from Output 1.
I can change the DL.OriginAnchor as I want, but nothing happens.

Please have a short look, again.
Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Finding the correct anchor point
Reply #8 - Jan 14th, 2010 at 12:33pm
Print Post  
Hi,

Are you calling Link.Add() also after Factory.CreateDiagramLink(t2, 0, t1, 0)? The factory method is a shortcut to creating an instance and adding it to the Links collection, so calling both methods might lead to the link not being deleted.

In my test project the link connects to the expected row, and deleting a table also deletes the link:
https://mindfusion.eu/_temp/VbnetTest.zip

If it does not work with your settings, please copy them to the test project so that's reproduced there and email it to support@mindfusion.eu.

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
nbg-user
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Jan 14th, 2010
Re: Finding the correct anchor point
Reply #9 - Jan 14th, 2010 at 12:56pm
Print Post  
Hi,
I tried the first solution

Dim DL As New DiagramLink(diaSystem, t2, t1)

t1.Rows(0).IncomingLinks.Add(DL)

t2.Rows(0).OutgoingLinks.Add(DL)


DL.OriginAnchor = 0

DL.DestinationAnchor = 0

diaSystem.Links.Add(DL)

Now, I changed it to (as you used in the sample)

Dim DL As DiagramLink = diaSystem.Factory.CreateDiagramLink(t2, 0, t1, 0)

and now, everything is working.

Thanks again for your quick help.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint