Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem - Retaining child nodes positions inside container node (Relative to container node) (Read 4788 times)
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Problem - Retaining child nodes positions inside container node (Relative to container node)
Aug 21st, 2012 at 1:45pm
Print Post  
Hi,

We have a requirement in our project where we want to retain the position of all nodes drawn in diagram. To do that we have developed the attached sample. Requirement summary is given below:

1. We need one input node to the left side of diagram center and one ouput node to the right side of diagram center
2. Input node and output node both will have an associated container node. Initially the container node is hidden
3. One normal node will be placed in between the input and output node
4. When user double clicks the input node or output node - corresponding container node will get expanded,  clicked normal node will be made hidden and container node will show its child nodes inside container node
5. Upon collapsing the container node associated normal node (input or output node) will be made visible
6. Associated container node should open in a way so that center of container node overlaps associated normal node
7. When used moves around (drags) input node or outpur node, its associated container node should also place itself according to the normal node poistion
8. All the node information to be added in diagram is read from XML file where details of normal node, input node and output node is given along with its text and X, Y position. INitially the X, Y position will be blank (and will be initialized as per code) until user saves the position. Once user saves poistion using "Save Position" button, X/y values shoud get saved in XML and next time on re-launch the nodes should be initialized according to this new value.

Mostly we have written code to satisfy all above points including saving the relative position of ndoes. However while redrawing the nodes container node childs and associated nodes are not retaining proper position. They are getting messed up.

Position requirement (Problem)
1. On saving the position of all nodes except container node is getting saved in XML file). This is fine.
2. Upon moving child nodes inside container node, though positions are being read from XML, it is getting wrongly positioned (when user re-launches application next time) due its association with container node. Child nodes should retain there position w.r.t to container node even though user moves input/output node or even container node around. Upon expand / collapse also this relative position should be saved and retained while redrawing

We have attached the sample along with this ticket for your perusal.

Kindly look at the sample and provide the solution.

Thanking in anticipation!

Regards,
Bala
  

SampleApp_001.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem - Retaining child nodes positions inside container node (Relative to container node)
Reply #1 - Aug 22nd, 2012 at 4:32pm
Print Post  
Hi,

The children's relative positions are lost because your finalRect variable does not include the child nodes rectangles, but their KeepInsideParent constraint is enabled in AddSubordinateGroup and the subsequent ctrnode.SetBounds (...true...) call applies the constraint. There are other problems too, such as SetBounds(...true...) moving the child nodes again. It seems the initialization code itself (when there are no x,y, values present) works only by some happy chance; if you create child nodes at different initial positions, you will see the same problems as when loading.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Re: Problem - Retaining child nodes positions inside container node (Relative to container node)
Reply #2 - Aug 23rd, 2012 at 1:41pm
Print Post  
Hi Stoyan,

Thanks for the inputs. I will try and change as per your suggestion and see if i can get it right.

However, while trying to implement your suggestions, i am facing another issue. When i am trying to set the bounds for container node after initialization, the hieght and width are not getting properly set. The outer rectangle size doesnt remain same as the container node size. Please see attached screenshot.

To see this behavior you can run attached sample and double click on "Input Child".

Kindly let me know how to make sure the outer rectangle gets resized exactly to container node size.

Regards,
Bala
  

SampleApp_002.zip (Attachment deleted)
RectangleSize.JPG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem - Retaining child nodes positions inside container node (Relative to container node)
Reply #3 - Aug 24th, 2012 at 12:02pm
Print Post  
There are several places where you are setting properties such as Width, Height and RenderSize of the container; they override the node's drawing size and it appears smaller than Bounds, which determines the size of the selection frame. You should set only the container's Bounds value.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint