Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) ShapeNode with custom drawn annotation inside a container (Read 7403 times)
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
ShapeNode with custom drawn annotation inside a container
May 1st, 2014 at 3:17pm
Print Post  
We are refactoring some of our code so that annotations on shape nodes are drawn from an overridden Draw() rather than as attached nodes. The problem is that the annotations now are drawn outside of containers, instead of the containers sizing to fit the annotations.

I have tried overriding the GetBounds() method on the container and the shapenodes, but what happens is that when you highlight the container the bounds of the selection are smaller than the bounds of the container drawn...

Do you have any ideas on how to make this work?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeNode with custom drawn annotation inside a container
Reply #1 - May 1st, 2014 at 6:25pm
Print Post  
Try overriding ShapeNode.GetRotatedBounds() instead, to return the union of base result and all annotation bounding rectangles.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #2 - May 5th, 2014 at 3:02pm
Print Post  
That works well. Thank you.
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #3 - May 5th, 2014 at 11:00pm
Print Post  
Actually, I've found an issue with overriding the GetRotatedBounds. It seems like the routing code is now behaving differently around my drawn annotations rather than when they were attached nodes. Is there anyway to avoid this change in the routing code while still having the desire behavior with containers?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeNode with custom drawn annotation inside a container
Reply #4 - May 6th, 2014 at 7:52am
Print Post  
Did you have the Obstacle property enabled for the attached nodes? We'll have to add some method that lets you define custom obstacles for routing, if you need the links routed around individual drawn annotations.
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #5 - May 6th, 2014 at 2:51pm
Print Post  
It's the opposite problem actually... The attached nodes had Obstacle set to false, and Locked set to true. They were for display only. But with the new code, overriding the GetRotatedBounds(), the routing gets strange around the nodes. I'm not exactly sure what is going on here, but look at the attached screenshot. The routing is acting differently now.. this doesn't happen if I don't override GetRotatedBounds() but then the containers have the problem mentioned in the original post.
  

routing_getoratedbounds.png (Attachment deleted)
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #6 - May 6th, 2014 at 3:40pm
Print Post  
I realized we are doing some custom post-routing code in the LinkRouted event, so here is a screenshot of the difference without our post processing code turned on:
  

routing_getoratedbounds2.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeNode with custom drawn annotation inside a container
Reply #7 - May 7th, 2014 at 7:19am
Print Post  
It seems the router treats that link as starting from inside the node according to RotatedBounds result, and chooses the shortest way that will get it out of that bounds - that's the upwards one in this example. So instead of overriding GetRotatedBounds, try setting containers size to the union of all child nodes and annotations from ContainerChildAdded and CotnainerChildRemoved event handlers.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #8 - May 7th, 2014 at 1:40pm
Print Post  
We use AutoShrink = true. Is there something I can override to force the size to be something?
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #9 - May 7th, 2014 at 2:05pm
Print Post  
Oh, I missed the part about ContainerChildAdded and ContainerChildRemoved. I will try that.
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ShapeNode with custom drawn annotation inside a container
Reply #10 - May 7th, 2014 at 6:14pm
Print Post  
Solving this problem through ContainerChildAdded/ContainerChildRemoved is going to require a lot of additional code to make sure container sizes stay up to date, such as after an annotation changes, when a node is moved inside of a container (NodeModified event), when a container is collapsed/uncollapsed, etc..

After glancing at the code, it would be a lot easier if the GetRotatedBounds() had a bool to indicate if this was being called by the routing code or not. OR, if there was a separate method such as GetRoutingBounds() to override..

In the source I changed GetRoutingBounds() to:
RectangleF GetRotatedBounds(bool bRoute = false)
and only passed in true in the four places it gets called in the routing code.

Could a solution like this, or something like GetRoutingBounds(), be added to a future release?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeNode with custom drawn annotation inside a container
Reply #11 - May 8th, 2014 at 4:58pm
Print Post  
We'll have it in mind for next release. Overriding GetRotatedBounds might have other adverse effects such as increased time for hit-testing, so it's probably better to allow overriding the ContainerNode's method that calculates size based on its children. Also if you need to add annotations to more types of nodes, you wouldn't have to override GetRotatedBounds for each of them.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint