diff --git a/src/CAD/IFox.CAD.Shared/ExtensionMethod/EditorEx.cs b/src/CAD/IFox.CAD.Shared/ExtensionMethod/EditorEx.cs index d9a92b06ae9d9a4c298a0f5df2ce461c07e82866..482fd828c684c5eefb42f53698b66aa40d05a149 100644 --- a/src/CAD/IFox.CAD.Shared/ExtensionMethod/EditorEx.cs +++ b/src/CAD/IFox.CAD.Shared/ExtensionMethod/EditorEx.cs @@ -868,8 +868,15 @@ public static void ZoomWindow(this Editor ed, Point3d lpt, Point3d rpt, double o Extents3d extents = new(); extents.AddPoint(lpt); extents.AddPoint(rpt); - rpt = extents.MaxPoint + new Vector3d(offsetDist, offsetDist, 0); - lpt = extents.MinPoint - new Vector3d(offsetDist, offsetDist, 0); + + // 获取世界坐标系到观察坐标系的矩阵变换 + using ViewTableRecord view = ed.GetCurrentView(); + Matrix3d worldToEyeMat = Matrix3d.WorldToPlane(view.ViewDirection) * + Matrix3d.Displacement(view.Target.GetAsVector().Negate()) * + Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target); + + rpt = (extents.MaxPoint + new Vector3d(offsetDist, offsetDist, 0)).TransformBy(worldToEyeMat); + lpt = (extents.MinPoint - new Vector3d(offsetDist, offsetDist, 0)).TransformBy(worldToEyeMat); Vector3d ver = rpt - lpt; ed.Zoom(lpt + ver / 2, ver.X, ver.Y); }