Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) How to size ContainerNode to its content? (Read 6282 times)
thejimster
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
How to size ContainerNode to its content?
Sep 18th, 2015 at 8:44am
Print Post  
I have populated a diagram with a mixture of ShapeNodes, ContainerNodes and DiagramLinks.  Once all nodes/links are added I perform a LayeredLayout on the diagram.  After the layout is complete the ShapeNodes that are inside a ContainerNode are not arranged correctly - they all sit in the same location.

How can I get the contained nodes to arrange properly and the get container to have the correct bounds for its nodes?

Thanks,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to size ContainerNode to its content?
Reply #1 - Sep 18th, 2015 at 8:50am
Print Post  
Layout.Arrange only arranges top-level nodes. Try this method to also arrange containers' contents:
http://mindfusion.eu/Forum/YaBB.pl?num=1273515591/1#1

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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #2 - Sep 18th, 2015 at 1:11pm
Print Post  
Thanks Stoyan.

That is much better now.

I have a couple of other questions regarding link routing. I've attached a picture showing the issues I want to solve.
I am using a LayeredLayout algorithim

1) Can I control the routing so that there is a gap between parallel lines?
2) Can I make the routing a bit less crazy Smiley The bottom middle container has a non-optimal routing.

Thanks for your help.

Jim
  

Routing.png ( 43 KB | 134 Downloads )
Routing.png
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to size ContainerNode to its content?
Reply #3 - Sep 18th, 2015 at 3:43pm
Print Post  
The router should pull links apart automatically if you call RouteAllLinks method, instead of link.Route called from a loop as shown in the linked post. So try replacing the foreach loop in Arrange with a call to diagram.RouteAllLinks().

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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #4 - Sep 18th, 2015 at 3:53pm
Print Post  
OK, thanks Stoyan.

Final question (I hope):
When I put the diagram into a scrollviewer - I don't get any diagram drawn.  Is there something obvious I'm missing?

Thanks,

Jim.
  
Back to top
 
IP Logged
 
thejimster
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #5 - Sep 18th, 2015 at 3:55pm
Print Post  
There is something I'm missing - I'm an idiot Smiley
Please ignore that last question.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to size ContainerNode to its content?
Reply #6 - Sep 18th, 2015 at 4:00pm
Print Post  
Do you keep the diagram.ResizeToFitItems call from sample code? Diagram.MeasureOverride returns Diagram.Bounds value and ScrollViewer will only let you scroll in that range. ResizeToFitItems updates Bounds to exactly fit the diagram elements.

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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #7 - Sep 21st, 2015 at 8:12am
Print Post  
The problem was that the DiagramView doesn't contain a Diagram until it has been activated, so I wasn't hooking up the the Diagram to insert my graph elements.

I have pretty much everything working that I need now, except zooming...

I am trying to use the DiagramView::SetZoomFactor to zoom around the current mouse position.  I am unsure what units the pivot point is in.

I have tried the following in the MouseWheel event:
GetPosition(<view>)
<view>.TransformToDocument(point)
<View>.SetZoomFactor(zoom,transformedPoint);

but that doesn't zoom centred around the mouse.

What do I need to do?

Thanks,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to size ContainerNode to its content?
Reply #8 - Sep 21st, 2015 at 8:38am
Print Post  
Try the code from this post:
http://mindfusion.eu/Forum/YaBB.pl?num=1415805251/1#1

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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #9 - Sep 21st, 2015 at 8:49am
Print Post  
OK, ClientToDoc works better than TransformToDocument, but it still doesn't feel like the zooming is around the mouse position.  It kind of starts off around the mouse but as I zoom in, the section of the diagram I want to look at starts to slide out of view.

Thanks,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to size ContainerNode to its content?
Reply #10 - Sep 21st, 2015 at 11:25am
Print Post  
It works fine for me, see attached test project. Check if you don't have more than one MouseWheel handlers attached by some chance, or post your Xaml for the DiagramView and all its parent elements here.
  

diagview_zoom.zip ( 11 KB | 122 Downloads )
Back to top
 
IP Logged
 
thejimster
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: How to size ContainerNode to its content?
Reply #11 - Sep 21st, 2015 at 2:44pm
Print Post  
Hmmm, yes your example does work.
I am doing the same thing in my code and it doesn't work.

I have found that if I change to using:

e.GetPosition(diagram.DocumentPlane)

and don't do any transform then I can get it to work as expected.

Since I've got zooming to work as I want, then that takes care of all my current issues. Smiley

Thanks for all your help.

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