private void _3DLink2D(double x, double y, double z) { if (b3To2 || b2To3) { b3To2 = false; b2To3 = false; return; } b3To2 = true; DF2DApplication app2D = DF2DApplication.Application; DF3DApplication app3D = DF3DApplication.Application; if (app2D == null || app3D == null || app2D.Current2DMapControl == null || app3D.Current3DMapControl == null) { return; } ICamera camera3D = app3D.Current3DMapControl.Camera; Gvitech.CityMaker.Math.IEulerAngle angle = new Gvitech.CityMaker.Math.EulerAngle(); Gvitech.CityMaker.Math.IVector3 pos = new Gvitech.CityMaker.Math.Vector3(); camera3D.GetCamera(out pos, out angle); ESRI.ArcGIS.Geometry.IEnvelope env = app2D.Current2DMapControl.Extent; double width = env.XMax - env.XMin; double height = env.YMax - env.YMin; double rate = width / height; double xmin, ymin, xmax, ymax; Link2DAnd3D._3DLink2D(x, y, z, Math.Abs(angle.Tilt * Math.PI / 180), camera3D.VerticalFieldOfView * Math.PI / 180, rate, out xmin, out ymin, out xmax, out ymax); ESRI.ArcGIS.Geometry.IEnvelope env1 = new ESRI.ArcGIS.Geometry.EnvelopeClass(); env1.PutCoords(xmin, ymin, xmax, ymax); app2D.Current2DMapControl.Extent = env1; }
private void _2DLink3D() { if (b3To2 || b2To3) { b3To2 = false; b2To3 = false; return; } b2To3 = true; DF2DApplication app2D = DF2DApplication.Application; DF3DApplication app3D = DF3DApplication.Application; if (app2D == null || app3D == null || app2D.Current2DMapControl == null || app3D.Current3DMapControl == null) { return; } ESRI.ArcGIS.Geometry.IEnvelope env = app2D.Current2DMapControl.Extent; ICamera camera3D = app3D.Current3DMapControl.Camera; Gvitech.CityMaker.Math.IEulerAngle angle = new Gvitech.CityMaker.Math.EulerAngle(); Gvitech.CityMaker.Math.IVector3 pos = new Gvitech.CityMaker.Math.Vector3(); camera3D.GetCamera(out pos, out angle); double ox, oy, oz; Link2DAnd3D._2DLink3D(env.XMin, env.XMax, env.YMin, env.YMax, Math.Abs(angle.Tilt * Math.PI / 180), camera3D.VerticalFieldOfView * Math.PI / 180, out ox, out oy, out oz); pos.Set(ox, oy, oz); camera3D.SetCamera(pos, angle, gviSetCameraFlags.gviSetCameraNoFlags); }