Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Is it possible to do this? (Read 2267 times)
asloan
YaBB Newbies
*
Offline



Posts: 35
Joined: Mar 6th, 2006
Is it possible to do this?
Sep 5th, 2007 at 6:43pm
Print Post  
Often times when we create a diagram from a BOM, we will have a few very long branches that run vertically.

What we would like to do is provide a right-click menu for the user that when clicked will split these long vertical branches into two or more shorter vertical branches.

The way we create these trees is that we lay the diagram out centralized to a specified level, then nodes below that level are laid out bordered.

The best way to illustrate what I'm looking to do is with pictures.

Here's the Before Diagram(Notice the long vertical branch):


Here's what I'd like the diagram to look like after the user splits the long branch:


The use of "Dummy" nodes (the white ones) is acceptable and I would more than likely shrink the size of these and make them invisible to the user.

The parent to the node that has been split is bordered, the node that is split is centralized, and the dummy nodes are again bordered.

Is this possible to do programatically?

Thanks,
Alan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is it possible to do this?
Reply #1 - Sep 6th, 2007 at 6:19am
Print Post  
This code splits the tree at the specified box by inserting two dummy parent nodes. The box you pass as parameter should be a child in the long column, and it will become the last box in the first branch. The boxes that follow it in the column are moved to the second branch:

Code
Select All
Private Sub splitAt(child As box)
    Dim parent As box
    Set parent = child.IncomingArrows(0).OriginBox

    Dim dummy1 As box
    Set dummy1 = fcx.CreateBox(0, 0, 100, 60)

    Dim dummy2 As box
    Set dummy2 = fcx.CreateBox(0, 0, 100, 60)

    Dim newParent As box
    Set newParent = dummy1

    Dim i As Integer
    For i = 0 To parent.OutgoingArrows.Count - 1
	  Dim a As arrow
	  Set a = parent.OutgoingArrows(i)

	  Dim dest As box
	  Set dest = a.DestinationBox
	  fcx.CreateArrow newParent, dest

	  If dest Is child Then Set newParent = dummy2
    Next i

    Do
	  fcx.DeleteItem parent.OutgoingArrows(0)
    Loop While parent.OutgoingArrows.Count > 0

    fcx.CreateArrow parent, dummy1
    fcx.CreateArrow parent, dummy2

    Dim tl As New TreeLayout
    tl.Type = tltBorderAligned
    tl.ArrowStyle = tlaPerpendicular2
    tl.Direction = tldLeftToRight
    fcx.ArrangeDiagram tl

    fcx.FitDocToObjects 10
End Sub
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
asloan
YaBB Newbies
*
Offline



Posts: 35
Joined: Mar 6th, 2006
Re: Is it possible to do this?
Reply #2 - Sep 6th, 2007 at 3:05pm
Print Post  
Thanks Stoyan, however splitting the branch and creating the dummy nodes isn't what I'm having trouble with.

The trouble I'm having is in laying out the diagram after splitting the long branch. I'm not sure that it's possible to lay this out the way that it's structured.

The parent node that is split is part of a bordered layout. It's two direct children (the dummy nodes) are centralized, and the dummy nodes are bordered. It's basically 3 different layout styles in one branch.

I DO have it working as I want it to, but when the branch is split, it collides with adjacent branches. See below:


The circled node is the one that is split. As you can see, it collides with the branch of it's parent, and if it's children had children as well, it would also collide with the branch to the right of it.

I COULD programatically move the split node to the right, so that it didn't collide with it's parent branch, but then I would also need to programatically move all of the other branches(the ones the arrows are pointing to in the graphic) to the right as well. I'd rather not go down that route as this is a very simple diagram. Many diagrams that we generate have thousands of nodes.

I'd rather go through the diagram and re-apply a layout to all of the nodes, but I think the split branch is going to give me problems.

Any ideas?

Note: All nodes are grouped to their parent.

Is there a way, in code, to determine if a node is laid out bordered or centralized?

Thanks Again,
Alan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Is it possible to do this?
Reply #3 - Sep 6th, 2007 at 5:37pm
Print Post  
Apparently you are already using some combination of multiple TreeLayouts, so that seems a matter of adding a few additional layouts to take care for the split branch. I imagine you could associate a different tree layout style with each parent box of a branch, and apply a series of layouts, first arranging the smaller branches and next their containing branches until reaching the top. At each step you would have to regroup the branch boxes to the second-level boxes in the branch, and using the KeepGroupLayout option to preserve the arrangement of the child branches.

E.g. try this after splitting a column:

1) Apply a Bordered layout once for each dummy node as root, to arrange the columns below them. Do not use the KeepGroupLayout in this case.

2) Attach the child nodes to their dummy parents. Run a centered layout starting from the original parent box, using the KeepGroupLayout option.

3) Apply this recursively until you reach the box from the second tree level. What type of layout to apply will depend on which level you are currently processing.

4) When you reach the topmost box, the main branches should be laid out, but will probably overlap. By attaching the children in each branch to the branch' root and applying a layout from the top-most node you should get a nice overall arrangement.

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