Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drawing group around objects (with layouting) (Read 6151 times)
dku
YaBB Newbies
*
Offline



Posts: 41
Joined: Jun 5th, 2008
Drawing group around objects (with layouting)
Jun 13th, 2008 at 8:48am
Print Post  
Hello,

I'm building a layered layout (with 4 levels) and I've to draw groups around the element in the last level.

a -> b1 -> c1 -> d1
                     -> d2
   -> b2 -> c2 -> d3
                     -> d4
                     -> d5

I want to draw a group around d1&d2, around d3, around d4&d5 (a group could be composed of 1 element). The better display will be a shape (ellipse / rounded rectangle) around the others.

Does it give a way using groups ? It should support the layout arrange on the elements.

Anyway to put images in the forum ? (could be simpler to show the problem).

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing group around objects (with layouting)
Reply #1 - Jun 13th, 2008 at 10:56am
Print Post  
Hi,

I suppose you could add a ShapeNode of the appropriate shape, set its Bounds to the union of the grouped nodes' bounding rectangles, and set its Brush to a new SolidColorBrush(Color.Transparent) so that only its outline is visible.

You cannot upload images here, but can link to ones hosted on your server, or say on flickr.

Stoyan
  
Back to top
 
IP Logged
 
dku
YaBB Newbies
*
Offline



Posts: 41
Joined: Jun 5th, 2008
Re: Drawing group around objects (with layouting)
Reply #2 - Jun 13th, 2008 at 1:10pm
Print Post  
Hello,

I've tried, creating the group nodes and set their property IgnoreLayout to true. After the layered layout has been executed, I'm computing the union rect and setting it to the node :

Code
Select All
l_Node.Bounds = new Rect (l_UnionRect.Left - 5, l_UnionRect.Top-5, l_UnionRect.Width+10, l_UnionRect.Height+10);
l_Node.ZBottom(); 



I've set the group at ZBottom, but some of element in the group are drawn behind the group ...

Am I missing something with ZIndex ?

Another question : when performing layered layout, in which order will appear the nodes ? Inserted order ? Any method to sort ? Otherwise my groups could appear in strange way (intersection)

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing group around objects (with layouting)
Reply #3 - Jun 13th, 2008 at 2:32pm
Print Post  
Hi,

Have you added l_Node to the Diagram before calling ZBottom?

Stoyan
  
Back to top
 
IP Logged
 
dku
YaBB Newbies
*
Offline



Posts: 41
Joined: Jun 5th, 2008
Re: Drawing group around objects (with layouting)
Reply #4 - Jun 13th, 2008 at 3:16pm
Print Post  
Hello,

Yes, it is added to diagram.

Question : LayeredLayout is changing the Zindex of elements, so if one of these elements is taking ZIndex 0 and my component is set to Zbottom, is it taking a value below 0 ? (I've seen 0)

It could explain that one of the element is behind. Does it give a way to set the minimal ZIndex used by the layout ?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing group around objects (with layouting)
Reply #5 - Jun 15th, 2008 at 10:17am
Print Post  
Hi,

It seems you have found a bug. The ZIndex setter does not invalidate the Z order of the WPF visual tree. Other properties do that correctly; so as a workaround you could call the SelectionOnTop setter after changing ZIndex of items to update the WPF visuals Z order:

l_Node.ZBottom();
diag.SelectionOnTop = diag.SelectionOnTop; // force Z order refresh

We'll post a fix in a few days.

Z indices always takes the values from 0 to N-1, where N is the number of items in the diagram. If you call node1.ZBottom() followed by node2.ZIndex = 0, node1.Zindex will be shifted to 1, and node2 should appear below node1.

Stoyan
  
Back to top
 
IP Logged
 
dku
YaBB Newbies
*
Offline



Posts: 41
Joined: Jun 5th, 2008
Re: Drawing group around objects (with layouting)
Reply #6 - Jun 16th, 2008 at 6:41am
Print Post  
Hello,

Thanks, with your workaround, it works.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing group around objects (with layouting)
Reply #7 - Jun 25th, 2008 at 11:06am
Print Post  
Hi,

This version correctly invalidates the Z order of the WPF visual tree when you change ZIndex. That seems a very slow operation, so we have implemented the ISupportInitialize interface to avoid the big delay after each ZIndex assignment. Now if you need to set ZIndex for multiple items, do it like this, and the visual tree's Z order will be refreshed just once:

diagram.BeginInit();
for (...)
  item.ZIndex = z;
diagram.EndInit();

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