public BasicLayoutRenderInfo(IViewDescription viewDescription) { double val1 = viewDescription.ViewportWidth / viewDescription.ViewWidth; double val2 = viewDescription.ViewportHeight / viewDescription.ViewHeight; if (DxfUtil.IsSaneNotZero(val1) && DxfUtil.IsSaneNotZero(val2)) { this.ModelToLayoutScaling = System.Math.Min(val1, val2); Vector2D vector2D = val1 > val2 ? new Vector2D(0.5 * val2 / val1 * viewDescription.ViewportWidth, 0.5 * viewDescription.ViewportHeight) : new Vector2D(0.5 * viewDescription.ViewportWidth, 0.5 * val1 / val2 * viewDescription.ViewportHeight); WW.Math.Point2D viewportCenter = (WW.Math.Point2D)viewDescription.ViewportCenter; this.LayoutViewport = new Bounds2D(viewportCenter - vector2D, viewportCenter + vector2D); this.ModelToLayoutTransform = Transformation4D.Translation((WW.Math.Vector3D)viewDescription.ViewportCenter) * Transformation4D.Scaling(this.ModelToLayoutScaling) * ViewUtil.GetBasicModelToViewportTransform(viewDescription) * Transformation4D.Translation(-(WW.Math.Vector3D)viewDescription.ViewportCenter); } else { this.LayoutViewport = new Bounds2D(); this.ModelToLayoutTransform = Matrix4D.Identity; this.ModelToLayoutScaling = 0.0; } }
public DxfLayout.PlotInfo GetPlotInfo( double paperWidth, double paperHeight, Rectangle2D printArea, bool autoRotate, bool invertY) { DxfLayout.BasicLayoutRenderInfo layoutRenderInfo = this.method_8(); if (!layoutRenderInfo.LayoutViewport.Initialized) { return((DxfLayout.PlotInfo)null); } Bounds2D layoutViewport = layoutRenderInfo.LayoutViewport; Matrix4D matrix4D1 = Matrix4D.Identity; double num1 = layoutViewport.Delta.X; double num2 = layoutViewport.Delta.Y; if (autoRotate && (printArea.Width > printArea.Height && num1 < num2 || printArea.Width < printArea.Height && num1 > num2)) { PlotRotation plotRotation1 = PlotRotation.None; PlotRotation plotRotation2; PlotRotation plotRotation3; switch (this.PlotRotation) { case PlotRotation.None: plotRotation2 = PlotRotation.QuarterCounterClockwise; plotRotation3 = PlotRotation.QuarterCounterClockwise; goto label_10; case PlotRotation.QuarterCounterClockwise: plotRotation2 = PlotRotation.QuarterClockwise; plotRotation3 = PlotRotation.QuarterClockwise; break; case PlotRotation.Half: plotRotation2 = PlotRotation.QuarterClockwise; plotRotation3 = PlotRotation.QuarterClockwise; break; case PlotRotation.QuarterClockwise: plotRotation2 = PlotRotation.QuarterCounterClockwise; plotRotation3 = PlotRotation.QuarterCounterClockwise; goto label_10; default: switch (plotRotation1) { case PlotRotation.QuarterCounterClockwise: goto label_10; case PlotRotation.QuarterClockwise: break; default: goto label_11; } } matrix4D1 = Transformation4D.RotateZ(invertY ? System.Math.PI / 2.0 : -1.0 * System.Math.PI / 2.0); goto label_11; label_10: matrix4D1 = Transformation4D.RotateZ(invertY ? -1.0 * System.Math.PI / 2.0 : System.Math.PI / 2.0); label_11: num1 = layoutViewport.Delta.Y; num2 = layoutViewport.Delta.X; } double s = System.Math.Min(printArea.Width / num1, printArea.Height / num2); if (!DxfUtil.IsSaneNotZero(s)) { return((DxfLayout.PlotInfo)null); } Matrix4D matrix4D2 = Transformation4D.Translation(printArea.Center.X, printArea.Center.Y, 0.0) * Transformation4D.Scaling(s) * matrix4D1 * Transformation4D.Translation(-layoutViewport.Center.X, -layoutViewport.Center.Y, 0.0); WW.Math.Point3D point3D1 = matrix4D2.Transform(new WW.Math.Point3D(layoutViewport.Corner1, 0.0)); WW.Math.Point3D point3D2 = matrix4D2.Transform(new WW.Math.Point3D(layoutViewport.Corner2, 0.0)); return(new DxfLayout.PlotInfo(this, new Size2D(paperWidth, paperHeight), new Rectangle2D(System.Math.Min(point3D1.X, point3D2.X), System.Math.Min(point3D1.Y, point3D2.Y), System.Math.Max(point3D1.X, point3D2.X), System.Math.Max(point3D1.Y, point3D2.Y)), matrix4D2 * layoutRenderInfo.ModelToLayoutTransform, s * layoutRenderInfo.ModelToLayoutScaling)); }