Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 MoveObj.FindObj and bounding box
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fsjodin

26 Posts

Posted - 11 Apr 2007 :  15:44:06  Show Profile  Reply with Quote
When I create a ChartShape with a GraphicsPath containing a line that is either straight horizontal or vertical the MoveObj.FindObj seems unable to detect the object.

From the looks of it the bounding box is used for hit detection and I am guessing for a straight line (horizontal or vertical) there is no bounding box? Is there a way to find these through MoveObj.FindObj?

Thanks

quinncurtis

1164 Posts

Posted - 12 Apr 2007 :  09:34:20  Show Profile  Reply with Quote
You are correct.
The MoveObj hit detection requres that the mouse cursor be completely within the bounding box of the object, and the bounding box of a horizontal or vertical line has no "inside". Also, by default, we use a coarse box of abount 5 pixels, at the end of the mouse cursor, and it is this box that must be within the bounding box of the object.

You can use a rectangle shape to draw your horizontal and vertical lines, as long as they don't have to be razor thin. In the example below, a thin rectangle, combined with a line width of 2, give a solid line that the MoveObj mouse listener can grab. The titleLineShape.SetIntersectionTestDistance(0) call is important because it shrinks the test area of the tip of the mouse cursor down to a single pixel.


GraphicsPath titleLine = new GraphicsPath();
titleLine.AddRectangle( new RectangleF(0.1f,0.1f, 0.8f,0.002f));
RectangleF rect = titleLine.GetBounds();

ChartShape titleLineShape = new ChartShape(pTransform1, titleLine,
	ChartObj.NORM_GRAPH_POS, 0.0, 0.0, ChartObj.NORM_GRAPH_POS,0);
titleLineShape.SetLineWidth(2);
titleLineShape.SetIntersectionTestDistance(0);
chartVu.AddChartObject(titleLineShape);
Go to Top of Page

fsjodin

26 Posts

Posted - 12 Apr 2007 :  09:54:50  Show Profile  Reply with Quote
The problem I have is that these are lines drawn by the user wich means they would not always be straight.

Is there a way to say 'find me the closest object of this type' and have the straight lines be found that way?

Go to Top of Page

quinncurtis

1164 Posts

Posted - 12 Apr 2007 :  10:28:01  Show Profile  Reply with Quote
Sorry, we can't think of any way to do what you want to do with line segments using the software as is. The MoveObj class was created to facilitate the moving of rectangular objects within a chart, not as a general pupose drawing utility. Even the bounding box for a diagonal line is not good for what you describe, since it encompasses a much larger area than the actual line, and the bounding box for adjacent diagonal lines can easily overlap, making line selection difficult. It would not be hard for us to write a more specialized MoveLine class that will do what you describe. If you are interested in a quote contact our programming services group at sales@quinn-curtis.com.

Go to Top of Page

fsjodin

26 Posts

Posted - 12 Apr 2007 :  14:59:51  Show Profile  Reply with Quote
On a related topic, I have a question on the 'nthhit' parameter to the FindObj method. I thought it could be used to find objects through the Z-order if they are overlapping, is that correct? In other words, if I have two objects whose bounding box overlap, and I call FindObj passing a point where the bounding boxes overlap, passing a value of '0' for nthhit would return one of the objects while passing a value of '1' for nthhit would return the second object. I am not seeing this behavior, instead the first object is found every time independent of the nthhit value.

My question is, how do I found objects when their bounding boxes overlap?

Thanks
Go to Top of Page

quinncurtis

1164 Posts

Posted - 12 Apr 2007 :  15:46:28  Show Profile  Reply with Quote
The nthhit parameter of the ChartView.FindObj method is supposed to return the nth item in the z-order from the back. Our own tests show this to be the case. If you have some example that you think demonstrates that it is not working properly you will have to send us the complete source to a zipped project that contains simplest possible program that demonstrates the problem. You can send it to support@quinn-curtis.com with a description of how to reproduce the problem.

Go to Top of Page

fsjodin

26 Posts

Posted - 12 Apr 2007 :  18:00:05  Show Profile  Reply with Quote
I was able to create my own hit detection using the IsOutlineVisible on the GraphicsPath and that solved both the problem of hit detection for straight lines and the problem with the bounding boxes for the diagonal lines occupying a lot of space.

Thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07