Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Moving Nodes (Read 6155 times)
Novice
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
Moving Nodes
Apr 27th, 2011 at 11:33am
Print Post  
Hello

AttachTo enables me to specify that when, by user interaction, node 1 moves any AttachedTo node also moves.

Is it possible to program such that a node can have more than one node that it moves with.  For example where there are two root nodes that feed into a third node I would like the third node to move in sync with a movement of either of the root nodes.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #1 - Apr 27th, 2011 at 11:50am
Print Post  
Hi,

There is no built-in support for that. You could try to reattach the dependant nodes to the currently selected node when NodeActivated is raised.

Alternatively, handle NodeModified or NodeModifying for the root nodes and update the dependant nodes' positions from the handlers. If you do that from NodeModifying, you will also have to call the RecreateCacheImage method.

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


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
Re: Moving Nodes
Reply #2 - Apr 27th, 2011 at 2:33pm
Print Post  
Thanks.  The NodeActivated method works for me.
  
Back to top
 
IP Logged
 
Pac
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #3 - Jun 30th, 2011 at 3:49pm
Print Post  
Although the NodeActivated method works well in far as movement of nodes I have found an undesirable knock affect.  This is that a _fcnet_AttachTo command is added into the UndoManager.  Since the attachto is done in order to achieve something invisible to the user it does not make much sense to the user to have this in the History.  Is it possible to prevent this command being added to History or remove afterwards.  I have already  tried to set UndoManager.UndoEnabled to false, perform the attachto, then set UndoEnabled back to true but this has the (also) undesirable affect of clearing out all the commands from the UndoManager.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #4 - Jun 30th, 2011 at 6:19pm
Print Post  
You could call MergeUndoRecords to make it a part of a previous command. Alternatively, handle ActionRecording and set e.Cancel = true to filter the command out.

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


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #5 - Jul 6th, 2011 at 8:36am
Print Post  
Thanks for the reply Stoyo.   Although this works I am sometimes loosing commands for the command history when I move nodes.  This is probably my implementation but I'm thinking that I will look at your alternative to manually move the dependent nodes in NodeModified or NodeModifying.  To do this I will need to know how much the node e.Node has moved.  Is e.Node.Bounds the original node position and MousePosition the new node's position.  Otherwise can you point me in the direction of how I might determine the amount moved.  Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #6 - Jul 6th, 2011 at 9:58am
Print Post  
You could handle Diagram.NodeStartModifying to record the original position of the moved node, or the distance from it to the child nodes. You could also find the distance the mouse was moved from Diagram.Interaction.StartPoint and CurrentPoint.

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


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #7 - Jul 6th, 2011 at 3:03pm
Print Post  
Hi.  Sorry to revert to you yet again.  However I try to achieve this I do at first appear to be able to add the functionality we want.  However after more testing I find unwanted side affects.   So far these side affects appear when ContainerNodes and/or undo/redo functionality is added to the mix.   Is this the reason that the control as supplied behaves as is it and does not behave or have the option of behaving in the way we want it to?   Or am I being a bit dim!  In either case do you have any plans to add this behaviour we need in the future or is this behaviour not at all in demand to make the work worthwhile?  Many thanks again.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #8 - Jul 6th, 2011 at 4:37pm
Print Post  
What behavior are we discussing exactly? Attaching a node to multiple parents as the poster above needed?
  
Back to top
 
IP Logged
 
Pac
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #9 - Jul 8th, 2011 at 5:27pm
Print Post  
Behaviour being that a DiagramNode moves whenever the Origin of an IncomingLink moves no matter how many IncomingLinks with Origin there are.
  
Back to top
 
IP Logged
 
Pac
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #10 - Jul 8th, 2011 at 5:45pm
Print Post  
Apologies.  I believe that when testing I have been confused by the action's recorded when the user moves nodes after these nodes have already been added to a ContainerNode.  When the user moves a selection of nodes it seems that "move shapes" and "Add to container" are recorded then merged with the title of "Add to container".  This possibly is what led me to believe that the NodeActivated resolution resulted in undesirable side affects.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #11 - Jul 8th, 2011 at 5:51pm
Print Post  
The control automatically collects multiple ModifyItemCmd's from the same interactive move operation into a single undo/redo record, so undo should work fine if you trick it into believing that the dependent nodes movement is caused by the user.

One way to do that if you use custom node class is to override the StartModify, UpdateModify and CompleteModify methods and call the same methods of nodes on the other end of this node's outgoing links.

Another method you might try is to automatically select the destination nodes when an origin node is clicked; then the user will be moving all the nodes using the built-in multiple selection feature. The multiple selection handles will show the user that all these nodes will be moved anyway, but you could hide them by temporarily setting their HandlesStyle to Invisible.

I don't know what problems you have with containers. but the effect of dropping the multiple selected nodes into a container should be that they all become its children.
  
Back to top
 
IP Logged
 
Pac
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Aug 16th, 2007
Re: Moving Nodes
Reply #12 - Jul 8th, 2011 at 6:08pm
Print Post  
Thanks for that.  Adding nodes into a container works fine and as you say they become children of the container.  What is strange is that if you subsequently move a selection of these container's children nodes the title of the NextUndo() command becomes "Add to container" when I would expect it to be "moves shapes".  What I'm not sure is whether this is because of something I'm doing.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving Nodes
Reply #13 - Jul 11th, 2011 at 9:32am
Print Post  
You aren't doing anything wrong, but it seems the control assumes it adds children to a container every time you drop nodes over it and creates an AddToContainerCmd instance, even if the dropped items were originally in the same container.
  
Back to top
 
IP Logged
 
Novice
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
Re: Moving Nodes
Reply #14 - Aug 3rd, 2011 at 10:59am
Print Post  
ok thanks.  I've used your suggestion to select the destination nodes when an origin node is clicked.  This is much simpler than using AttachTo which has knock on affects to the UndoManager and use of ContainerNodes that I was finding difficult to resolve.

Regarding the extra AddToContainerCmd it would be excellent if this were removed from a future version if possible.  My application indicates to the user the caption of the last action to undo and giving them the wrong information for the last action to undo will cause confusion.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint