// helper function transforming parameters from screen to world coordinates void dolly(Teigha.GraphicsSystem.View pView, int x, int y) { Vector3d vec = new Vector3d(-x, -y, 0.0); vec = vec.TransformBy((pView.ScreenMatrix * pView.ProjectionMatrix).Inverse()); pView.Dolly(vec); }
// helper function transforming parameters from screen to world coordinates public static void Transform(this Teigha.GraphicsSystem.View pView, double x, double y) { Vector3d vec = new Vector3d(-x, -y, 0.0); vec = vec.TransformBy((pView.ScreenMatrix * pView.ProjectionMatrix).Inverse()); pView.Dolly(vec); }
private void ZoomWindow(Point3d pt1, Point3d pt2) { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { using (AbstractViewPE pVpPE = new AbstractViewPE(pView)) { pt1 = pt1.TransformBy(pVpPE.WorldToEye); pt2 = pt2.TransformBy(pVpPE.WorldToEye); Vector3d eyeVec = pt2 - pt1; if (((eyeVec.X < -1E-10) || (eyeVec.X > 1E-10)) && ((eyeVec.Y < -1E-10) || (eyeVec.Y > 1E-10))) { Point3d newPos = pt1 + eyeVec / 2.0; pView.Dolly(newPos.GetAsVector()); double wf = pView.FieldWidth / Math.Abs(eyeVec.X); double hf = pView.FieldHeight / Math.Abs(eyeVec.Y); pView.Zoom(wf < hf ? wf : hf); Invalidate(); } } } }