Hi @ all.
I have a little problem of algorithm type. I'm making a vector based (WMF-like) graphic editor. I'll try to explain my problem with an example. Let's assume I have drawn an empty polygon (only the contour) and many other objects. Now I want to edit my polygon. I'm going to click over the contour of it. The program should make a hit test to understand which object has been clicked. And here the problem. I can enumerate the objects. Let's assume my first object is the polygon itself. How could the program understand if the mouse click happened on it? Should I calculate the line equation of each side until I get the click happened on a side? I think it is very time consuming. Think of about having 100 or 1000 objects: it would be quite impossible to manage from a "time" point of view.
How could I so detect which object has been clicked? The problem is simpler for filled polygon (I'm creating a region and then calling the API to see if the point is inside region).
Thanx in advance to anyone.
Sincerely,
Daniel
I have a little problem of algorithm type. I'm making a vector based (WMF-like) graphic editor. I'll try to explain my problem with an example. Let's assume I have drawn an empty polygon (only the contour) and many other objects. Now I want to edit my polygon. I'm going to click over the contour of it. The program should make a hit test to understand which object has been clicked. And here the problem. I can enumerate the objects. Let's assume my first object is the polygon itself. How could the program understand if the mouse click happened on it? Should I calculate the line equation of each side until I get the click happened on a side? I think it is very time consuming. Think of about having 100 or 1000 objects: it would be quite impossible to manage from a "time" point of view.
How could I so detect which object has been clicked? The problem is simpler for filled polygon (I'm creating a region and then calling the API to see if the point is inside region).
Thanx in advance to anyone.
Sincerely,
Daniel
Use rectangles to BOUND each poly (top,left,right,bottom)
first check for rectangles...this sould be very fast and hopefully it will eliminate a lot of work...
Then refine second search stage by changeing the mouse coordonates relative to the "bound hit rectangle" make a region oot of that only and test only here :)
Also if you use Bresenham's line draw algo a few thousands of lines to interpolate will be a piece of cake for ASM :)
first check for rectangles...this sould be very fast and hopefully it will eliminate a lot of work...
Then refine second search stage by changeing the mouse coordonates relative to the "bound hit rectangle" make a region oot of that only and test only here :)
Also if you use Bresenham's line draw algo a few thousands of lines to interpolate will be a piece of cake for ASM :)