We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

problems with detecting overlap Nodes

Hi 
I'm Using VS 2022 .Net 6 and syncfusion v : 20.4.0.44

I have problems when I want to detect that Shape Nodes have overlap with each other..
i will be very thankful if anyone can help ...

overlap.png

according to image I've uploaded 
step 1 ) first I drop node A on diagram --> works fine
step 2 ) then I drop node B on diagram near node A -- > overlap detected and make an or statement correctly 
step 3 ) then I drop Node C on diagram near node B --> diagram does NOT detect overlap and the code does not work as expected.


This function wants to detect Overlap using  4 points ( TopLeft and BottomRight) for each Node.
for step 1 and 2 works fine but not for step 3.

public bool OverlapCheck(PointF addedNodeTopLeft, PointF addedNodeBottomRight, PointF existNodeTopLeft, PointF existNodeBottomRight)

        {

            if (addedNodeTopLeft.X == addedNodeBottomRight.X ||

                 addedNodeTopLeft.Y == addedNodeBottomRight.Y ||

                      existNodeTopLeft.X == existNodeBottomRight.X ||

                            existNodeTopLeft.Y == existNodeBottomRight.Y)

                return false;

            if (existNodeTopLeft.X > addedNodeBottomRight.X || addedNodeTopLeft.X > existNodeBottomRight.X)

                return false;

            if (existNodeBottomRight.Y > addedNodeTopLeft.Y || addedNodeBottomRight.Y > existNodeTopLeft.Y)

                return false;

            return true;

        }

is there any Other way to detect overlapping shape Node???

thanks


1 Reply 1 reply marked as answer

KR Karkuvel Rajan Shanmugavel Syncfusion Team April 10, 2023 10:18 AM UTC

Hi Mohammad,


We have validated your requirement of “Need to find two Nodes are overlapped with each other”. We have validated the provided code example and do some changes in that code to find the nodes are overlapped or not. Please find the codes to find the nodes are overlapped or not.


 

            if (existNodeTopLeft.X >= addedNodeBottomRight.X || existNodeTopLeft.Y <= addedNodeBottomRight.Y

            || existNodeBottomRight.X >= addedNodeTopLeft.X || existNodeTopLeft.Y >= addedNodeBottomRight.Y

            || existNodeTopLeft.X <= addedNodeBottomRight.X || existNodeBottomRight.Y >= addedNodeTopLeft.Y

            || existNodeBottomRight.X >= addedNodeTopLeft.X || existNodeBottomRight.Y >= addedNodeTopLeft.Y)

            {

                return true;

            }

 

 

            return false;

 


Regards,

Karkuvel Rajan S


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon