cart: empty [ Login ]

Get the bounds of a ViewControl

1 
Dominik Egger
10/31/2013 9:17 AM
Hello, I an working an a small problem at the moment. I am basically using the "WinFormsExtendedViewExample" that comes with the download of CadLib 3.5. How can i get the coordinates of the bounds of the viewControl? I am not an AutoCAD user, so some things that may seem clear and logical to en experienced user do not apply to me.. Thanks in Advance
rammi
10/31/2013 10:42 AM
I hope you are working with 2D data, as with 3D there is no 1:1 relation between model bounds and bounds of the view control as each of the points of the control is associated with a ray in the 3D model. In 2D things are easy: you are projecting the model to the view control using a transformation of type Matrix4D which is usually called to2dTransform in out examples. To go the other way back just invert that transform and feed it with view points:
C# Code:
Matrix4D inverseTo2dTransform = to2dTransform.GetInverse(); Point3D modelUpperLeft = inverseTo2dTransform.Transform(Point3D.Zero); // upper left screen coordinate is (0,0) Point3D modelLowerRight = inverseTo2dTransform.Transform(new Point3D(width - 1, // width and height of view control height - 1, 0));
- Rammi
Dominik Egger
10/31/2013 10:55 AM
Yes it is 2d data. If i rotate the view, does this give correct values or do I have to handle rotation by myself?
rammi
10/31/2013 10:58 AM
That depends how you rotate. If you use the to2DTransform for that, everything will just work as described. If you do it by other means, you'll have to undo that first before you feed the points into the inverse transform. - Rammi
Dominik Egger
10/31/2013 1:16 PM
Thanks, its working perfectly :)
1