Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Grouping elements (Read 4454 times)
RJ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Grouping elements
Sep 29th, 2015 at 2:25pm
Print Post  
What is the best way to group nodes in the diagram. I need to draw a simple box around nodes and group all those items within the box.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Grouping elements
Reply #1 - Sep 29th, 2015 at 3:28pm
Print Post  
You could use an actual ShapeNode as group box. Once the user draws it, set its Transparent property to hide the node's geometry, and call childNode.attachTo(groupNode) method to attach the nodes you find enclosed within the group's bounding rectangle. Now the child nodes will be drawn behind the group, and if the user tries to select any of them they will actually select the group node. Moving it will also move all attached nodes.

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


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Re: Grouping elements
Reply #2 - Sep 29th, 2015 at 3:40pm
Print Post  
Thanks Stoyan. How can find the elements within the bounding rectangle. Is there any method where i can pass the rectangle and get all the elements on the digram within the rectangle?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Grouping elements
Reply #3 - Sep 29th, 2015 at 4:00pm
Print Post  
There's undocumented method in Diagram class used for lasso selection:
getIntersectingItems: function (rect, intersectingItems, multiple, ifIntersect)

Pass the bounding rectangle as first argument; an empty array that receives the items as second argument; true as third argument; set ifIntersect to true if nodes should be collected when they intersect the specified rectangle, or false if they should be entirely inside it.

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


I Love MindFusion!

Posts: 27
Joined: Sep 4th, 2015
Re: Grouping elements
Reply #4 - Sep 29th, 2015 at 4:42pm
Print Post  
Thanks Stoyan. I am going to try this - but is there a event handling available for specific ShapeNode - I am thinking to call the getIntersectingItems function inside the handler.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Grouping elements
Reply #5 - Sep 29th, 2015 at 5:59pm
Print Post  
There's only the diagram's nodeCreated event raised for all nodes, you'll have to add a case for the group box inside it. You could also replace that node's endDrag() function with your own version and use it as a handler.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint