Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Shape Node contains point (Read 2350 times)
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Shape Node contains point
Jun 29th, 2010 at 10:38am
Print Post  
Hi there,

I have some shape nodes and for I do not know what reason the method ContainsPoint(diagramPoint) return false for some situations when the mouse is inside the node.
Here are some images displayingthe situations: ContainsPoint method returns false:

ContainsPoint method returns true:


When the ContainsPoint method returns true the mouse cursor is changed.

Can anybody point me to a solution.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape Node contains point
Reply #1 - Jun 29th, 2010 at 1:30pm
Print Post  
Are you actually calling ContainsPoint from the MouseMove handler and changing the cursor?
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: Shape Node contains point
Reply #2 - Jun 29th, 2010 at 2:27pm
Print Post  
I am using custom behavior and in the method SetMouseCursor I am searching for a node at the point using Diagram.GetItemAt(point, exclLocked). If i find a node I set the diagramView.PointerCursor to a custom cursor (the one in the second picture) and return the CursorHint.Pointer.

I must say that this is visible only with a large zoom (500 and more) and on shapes that have some kinds of rounded corners (round rectangles, or ellipse shapes).

I hope this helps.

Dexter
  
Back to top
 
IP Logged
 
Dexter
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 62
Joined: Jun 25th, 2009
Re: Shape Node contains point
Reply #3 - Jul 8th, 2010 at 6:04am
Print Post  
Hi Stoyo,

Do you have any inside on this. Have you reproduced the problem!

Regards,
Dexter
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape Node contains point
Reply #4 - Jul 8th, 2010 at 8:44am
Print Post  
Hi,

I can see a margin of couple of pixels in or out where hit-testing is not correct  at zoom level 500, but not as much as in your image.

Hit-testing for ShapeNodes is implemented by calling GraphicsPath.IsVisible(), and so we can't think of anything to make it better.

If you need better precision at large zoom levels that much, you might try overriding ContainsPoint and use the ellipse's equation to determine if a point is inside. That could still lead to differences with what's shown on screen, because the shapes are rendered as GraphicsPaths, and GDI+ paths are implemented as a series of straight line segments and Bezier splines - there will be no trace of the ellipse there.

For even better precision you might override Draw to call DrawEllipse instead of using GraphicsPaths, but then it's still not clear if there will be much improvement because ellipses are rendered using the Bresenham's algorithm and not through the ellipse equation.

Of course you can draw ellipses point by point using the equation, but then rendering will be very slow. All in all, we would not invest time in this, but you have some options to try if you wish to.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint