Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) nonrectangular clip path for DiagramNodeAdapter? (Read 8066 times)
dn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: May 16th, 2008
nonrectangular clip path for DiagramNodeAdapter?
Jun 9th, 2008 at 5:53pm
Print Post  
Hi

I have a set of custom shapes I've defined as WPF UIElements that I want to add as nodes to my diagram, e.g. a circular object with gradient, drop shadow, text label etc.

However, when I add it to the diagram and apply a radial layout, it clearly has a rectangular clip path even though I've tried various things like setting the UIElement.Clip property

I'd prefer to define my shapes as UserControls so that I get the full flexibility of WPF and it's convenient to view/edit them in the VS designer, but I can't figure out how to get the nonrectangular clipping to work

any ideas?

thanks

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #1 - Jun 9th, 2008 at 7:15pm
Print Post  
Hi,

I can't find the DiagramNodeAdapter setting a clip rectangle anywhere in our code. Could you post a screenshot of what result you are getting from the radial layout, or email it to support@mindfusion.eu? If what you see looks like all items sharing the same clip rectangle, try setting a larger Diagram.Bounds, or call ResizeToFitItems after applying the layout.

Stoyan
  
Back to top
 
IP Logged
 
dn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: May 16th, 2008
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #2 - Jun 9th, 2008 at 8:42pm
Print Post  
I have a number of other UIElements that work fine in the same diagram, but they were not UserControls, clip problem only happens on the UserControl I added.

The ones that clip ok are Ellipse and my subclass of Border.

could not see how to post file attachments, I have emailed support. (Clicking the Insert Image button only seems to insert empty img tags if it detects the click at all in a few browsers I tried.)

I'll try to post the answer here if/when there is a good solution

thanks

D.
  
Back to top
 
IP Logged
 
dn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: May 16th, 2008
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #3 - Jun 10th, 2008 at 2:00am
Print Post  
BTW, also noticed that if I don't set an explicit Height/Width on the UIElement attached to the DiagramNodeAdapter, it gets drawn assuming a Size of (0,0).

But I want a template to determine what to draw within my UserControl, so the Height/Width aren't really known in advance and can vary.

for now, I'm hardcoding Height/Width in the XAML just so I see something, tried to hook Loaded event etc but that gets raised too late

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #4 - Jun 10th, 2008 at 8:09am
Print Post  
You can't actually upload images here, but only link to ones hosted on your site, or say on flickr.

The clipping on the first image seems to be done by the 20*20 points UserControl since it is smaller than its content (which is 56*56 points). You could verify that by setting ClipBounds="false". I suppose a possible solution is to omit the content's Width and Height assignments, and instead set the Alignment attributes to Stretch.

If the second image shows 20x20 size assigned from code, perhaps you have assigned that to the NodeAdapter's Bounds and it is measured in millimeters?

In your comments I see you mention millimeters as unsuitable when using WPF controls as nodes. Now we see that most people create their own controls to use as nodes, so in the 1.0.1 version we'll change the default for MeasureUnit to WPFPoint, which should preserve the original appearance of the controls as defined in Xaml, instead of scaling them to millimeters.

I suppose it should not be hard to call Measure for controls whose size is not explicitly set, and then use their DesiredSize as the node's size. We'll try to implement that in the next few days.

Stoyan
  
Back to top
 
IP Logged
 
dn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: May 16th, 2008
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #5 - Jun 10th, 2008 at 4:45pm
Print Post  
images




re 20x20 vs 56x56, forgot to fix some sizes in the control to use diagram's mm units

your suggestion to use stretch alignment works well, thanks (except I still need to figure out how to set overall height/width depending on variable DataTemplate loaded)

I tried your idea of forcing a call to Measure, I think I can now get Height/Width from ActualSize

now using the control:
- the clipping looks like the 2nd screenshot, the first link (at 6 o'clock position) docks to the top left corner
- remaining links are spread around radially almost as expected, except some clip at the edge of the ellipse, some clip at the edge of the bitmap edge, and some in between

3rd image is the correct behaviour, but using my custom EllipseDecorator (subclass of Border) as the outer UIElement.

if I can resolve the remaining clipping problems, UserControls are the most straightforward to use in VS designer

thanks

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #6 - Jun 11th, 2008 at 11:07am
Print Post  
When looking for intersection points of a link with an arbitrary UIElement, the Diagram uses the WPF's VisualTreeHelper class to get an intersection point. From the second image it seems UserControl adds a rectangular shape as outer-most geometry by default, so the lines are drawn around a rectangle. Apparently setting your EllipseDecorator as a border overrides that rectangle, and VisualTreeHelper correctly finds the intersection point with the elliptical border.

If you don't wish to use the EllipseDecorator, can't you set the UserControl.Clip to an ellipse? I can see this commented out in your Xaml, but then the EllipseDecorator calls drawingContext.PushClip(ellipse), which should have the same effect?

Stoyan
  
Back to top
 
IP Logged
 
dn
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: May 16th, 2008
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #7 - Jun 11th, 2008 at 4:59pm
Print Post  
I tried setting the control's Clip property to the same EllipseGeometry as the decorator uses to draw when it is a child element of the same control

I tried both in XAML and in codebehind, but it did not seem to have any effect, so I left it commented out in the XAML

maybe because I have to set the Height/Width explicitly on the control, it implies a rectangular bounds bigger than the Clip geometry, so the clip geometry gets ignored?

in general, the shapes I will be using can be anything defined by a DataTemplate in XAML so in general I don't know what the outermost clip path will be, except here I was experimenting to make a particular case work correctly
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #8 - Jun 12th, 2008 at 8:55am
Print Post  
Ok, the Clip property doesn't help much indeed. You'll have to use the custom decorator for the time being, and we will try to filter out the user-control's rectangular borders when looking for intersection points.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #9 - Jun 20th, 2008 at 7:54am
Print Post  
We couldn't find any reliable way to get automatically the borders for the user-control content. Instead, we'll add a new property to DiagramNodeAdapter that will let you specify the geometry used to align links to the node. Setting the adapter's property should be much easier than creating a decorator class, so hopefully this will be a good compromise.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: nonrectangular clip path for DiagramNodeAdapte
Reply #10 - Jun 25th, 2008 at 10:58am
Print Post  
We've managed to implement that using just the VisualTreeHelper. This version should position the link end points correctly without requiring you to provide a custom decorator object -
https://www.mindfusion.eu/_beta/wpfdiag101pre.zip

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