Page Index Toggle Pages: 1 [2] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa (Read 1032 times)
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #15 - Aug 18th, 2020 at 2:50pm
Print Post  
Container's bounds is set to this value when you move its child -

Code
Select All
var crect = container.getContentBounds(true);
crect = crect.inflate(container.margin);
crect.y -= container.captionHeight;
crect.height += container.captionHeight;
 



So, you could add a check for any other node intersecting container's expected rect from nodeModifying handler raised for the child.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #16 - Aug 26th, 2020 at 11:06am
Print Post  
1) on resizetofitchildern this above your code is already present and i am checking intersect on nodemodifying.it is not working .

2)if remove this above your code from resizetofitchildren and checking intersect on nodemodifying still it is not working

i have attached image at certain point parent node is going inside other node and after that it shows intersect to other node after that it will not allow to go inside for now this behavior is on my side can you please suggest or any example if i am moving node and it's parent not to go inside other node before it shows it intersect to other node.
  

Overlapping_Container_node.png ( 8 KB | 9 Downloads )
Overlapping_Container_node.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #17 - Aug 31st, 2020 at 2:05pm
Print Post  
Code
Select All
function onNodeModifying(diagram, args)
{
	var container = args.node.container;
	if (container)
	{
		var crect = container.getContentBounds(true);
		crect = crect.inflate(container.margin);
		crect.y -= container.captionHeight;
		crect.height += container.captionHeight;

		var nodes = diagram.getNodes();
		for (var i = 0; i < nodes.length; i++)
		{
			if (nodes[i] == container || nodes[i] == args.node)
				continue;
			var b2 = nodes[i].getBounds();
			if (b2.intersectsWith(crect))
				args.setCancel(true);
		}
	}
 



works in my test.
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #18 - Sep 21st, 2020 at 11:17am
Print Post  
var crect = container.getContentBounds(true);
crect = crect.inflate(container.margin);
crect.y -= container.captionHeight;
crect.height += container.captionHeight;
this code is work for if i have only one parent but if i have parent of parent i am trying to chnage the posiiton of internal node it is not working .

In below image s4 is child s4-parent is s3 and s3 -parent is s2
if i am trying to move s4 to the side of other node s1 that time s2(parent of parent) is already some intersect with s1 after that it will not allowed to intersect.
In the above example case is like i have child and that child having parent of parent this is one case but may be child have parent and that parent also one parent and so on
(it's chain of parent ) In this case how to find

above your answer code i  have applied same to parent of parent it's going and overlap some part.
Please give me some idea to do this as soon as.
« Last Edit: Oct 12th, 2020 at 4:25am by reshma »  

Boundary_Child-Parent-Parent.png ( 25 KB | 5 Downloads )
Boundary_Child-Parent-Parent.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #19 - Oct 13th, 2020 at 10:04am
Print Post  
You can find what the updated position of node.container.container will be like this -

Code
Select All
var temp = node.container.bounds;
node.container.bounds = crect;
var crectParent = node.container.container.getContentBounds();
node.container.bounds = temp;
// crectParent.inflate etc - same as for crect but with container.container
 



and then compare crectParent with boundaries of nodes in same container ('click to change' one).

I guess if you need that for arbitrarily deep nesting levels, you could do that recursively starting from modified node, calling recursively with container, until you reach diagram's level (i.e. recursionArgument.container becomes null).

All that's quite pointless, and if you are not careful you might deadlock user interaction in more dense diagrams preventing users from rearranging nodes the way they want to.
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #20 - Oct 19th, 2020 at 8:32am
Print Post  
this below code,
var crect = container.getContentBounds(true);
           crect = crect.inflate(container.margin);
           crect.y -= container.captionHeight;
           crect.height += container.captionHeight;
is not working below case,
if i have one Maincontainer  having children child1 and child2 and child2 having one more child which is child 3 .
increase height of chiild2 and put child1 below child 2 or in the bottom and try to change the position of child3 and increase parent width that time it is showing overlapped.
  

B_diagram_Overlapping_scenario.png ( 22 KB | 4 Downloads )
B_diagram_Overlapping_scenario.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #21 - Oct 19th, 2020 at 9:18am
Print Post  
add this to crect calculations -

Code
Select All
if (!container.allowShrink)
	crect = crect.union(container.bounds); 

  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #22 - Oct 20th, 2020 at 6:07am
Print Post  
With all above solution showing overlapping before some points but after overlap find i am trying to move inside node still it is showing it is overlapped with out element in this case if i change just small position then of overlap node it is allowed to move inside element.

i am using setcancel(true) when ovelap find
Please give some suggestion to if overlapped happen with above cases, i can move inside element
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #23 - Oct 20th, 2020 at 6:54am
Print Post  
Not sure if I understand, if you mean it's preventing you from moving child node anywhere in outer containers, you'll have to adapt this part for deeper container hierarchies -

Code
Select All
if (nodes[i] == container || nodes[i] == args.node)
	continue; 



e.g. write a recursive function that checks if node is nested at any level inside container, and skip the intersection checking part if it does -

Code
Select All
if (nestedInside(args.node, nodes[i]) || nodes[i] == args.node)
	continue; 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #24 - Oct 20th, 2020 at 9:50am
Print Post  
let crect = container.getContentBounds(true);
crect = crect.inflate(container.margin);
crect.y -= (container.captionHeight);
crect.height += container.captionHeight
with above solution overlapping is showing with top element but not for bottom element but i am able to move node in the container.
but below code i added and it is not allowing me to move node in the container

if (!container.allowShrink)
     crect = crect.union(container.bounds);


for eg. if i have MainContainer and that containe 2 child child1 and child2 if i am moving child2 to towards coutElement and also increasing size of mainContianer at one point it's showing it is overlapped after that i am trying to move to child2 to towards child1 it is not allowing me to move
  

Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #25 - Oct 20th, 2020 at 4:28pm
Print Post  
You'll also need to skip all other child nodes of the container here -

Code
Select All
if (nodes[i] == container || nodes[i] == args.node)
    continue; 



should become

Code
Select All
if (nodes[i] == container || nodes[i] == args.node || nodes[i].container == container)
    continue; 



or otherwise crect will always intersect with its children currently not being moved (like child1), and you'd cancel the modification from intersectsWith check.
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #26 - Oct 21st, 2020 at 5:58am
Print Post  
i am little confused about code can you please explain me in detail
In my case on nodemodifying i am checking first for selected node that is s3 is overlapped with any one if it is not then i am checking it has parent then i am checking with crect solution.

what is node[i] and container(i think your checking in all diagram nodes but in my case i am checking directly in containerprent)
in below example please explain for s1,s2 and s3

i am checking directly in parent 'click to change title' if s2===s2 not getting or continue and now s2 checking for the s1. s2 is intersect with s1 it is showing true always on modifying
« Last Edit: Oct 21st, 2020 at 7:02am by reshma »  

Boundary-child-parent.png ( 20 KB | 2 Downloads )
Boundary-child-parent.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #27 - Oct 21st, 2020 at 7:00am
Print Post  
nodes[i] and container as from code in post #17 in this thread. So if you need to prevent any nodes in the diagram intersecting with new position of the container of moved node, you will need to check crect's intersection with all diagram nodes - except the moved node itself, the container, and any other child nodes in the container (they intersect it from the start). That only shows how you could check a single container nesting level. If you support deeper nesting, you will have to run some recursion to calculate containers rectangles and check these conditions for the whole hierarchy.
  
Back to top
 
IP Logged
 
reshma
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 48
Joined: Jan 16th, 2018
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #28 - Oct 21st, 2020 at 7:15am
Print Post  
i added my scenario case in above only i am not chekcing in diagram items i am check first for selected node is intersect with node int the same parent if it is not then i am checking selected node has parent then i am checking for parent is intersect with parentofparent child.

with this working for me,but if node is in the bottom then i have issue with below code
let crect = container.getContentBounds(true);      
        crect = crect.inflate(container.margin);
        crect.y -= (container.captionHeight);      
        crect.height += container.captionHeight

and with below code it is working for bottom node also but not working for inside element.
let crect = container.getContentBounds(true);
        if (!container.allowShrink) {
            crect = crect.union(container.bounds);
        }
        crect = crect.inflate(container.margin);
        crect.y -= (container.captionHeight);      
        crect.height += container.captionHeight
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2278
Joined: Oct 19th, 2005
Re: i want to restrict to move outside node inside scope and can not intersect with scope and vis-versa
Reply #29 - Oct 21st, 2020 at 2:39pm
Print Post  
crect.union is called last in my test handler, after expanding the content rect. Other than that, add a breakpoint to the setCancel line and examine the variable values - you should see easy enough why it gives you unexpected results.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint