Exemple #1
0
 public DxfLayout.PlotInfo GetPlotInfo(bool invertY)
 {
     DxfLayout.BasicLayoutRenderInfo layoutRenderInfo = this.method_8();
     if (!layoutRenderInfo.LayoutViewport.Initialized)
     {
         return((DxfLayout.PlotInfo)null);
     }
     return(this.GetPlotInfo(invertY, layoutRenderInfo));
 }
Exemple #2
0
        private DxfLayout.PlotInfo GetPlotInfo(
            bool invertY,
            DxfLayout.BasicLayoutRenderInfo layoutRenderInfo)
        {
            Size2D plotPaperSize = this.PlotPaperSize;

            if (plotPaperSize.X == 0.0 || plotPaperSize.Y == 0.0)
            {
                return((DxfLayout.PlotInfo)null);
            }
            double y = invertY ? this.UnprintableMarginBottom : plotPaperSize.Y - this.UnprintableMarginTop;

            WW.Math.Point3D toPoint1         = new WW.Math.Point3D(this.UnprintableMarginLeft, invertY ? plotPaperSize.Y - this.UnprintableMarginTop : this.UnprintableMarginBottom, 0.0);
            WW.Math.Point3D toPoint2         = new WW.Math.Point3D(plotPaperSize.X - this.UnprintableMarginRight, y, 0.0);
            WW.Math.Point3D toReferencePoint = new WW.Math.Point3D(0.5 * (toPoint1.X + toPoint2.X), 0.5 * (toPoint1.Y + toPoint2.Y), 0.0);
            Matrix4D        matrix4D1        = Matrix4D.Identity;

            switch (this.PlotRotation)
            {
            case PlotRotation.QuarterCounterClockwise:
                matrix4D1 = Transformation4D.RotateZ(System.Math.PI / 2.0);
                break;

            case PlotRotation.Half:
                matrix4D1 = Transformation4D.RotateZ(System.Math.PI);
                break;

            case PlotRotation.QuarterClockwise:
                matrix4D1 = Transformation4D.RotateZ(-1.0 * System.Math.PI / 2.0);
                break;
            }
            if (invertY)
            {
                matrix4D1 *= Transformation4D.Scaling(1.0, -1.0, 1.0);
            }
            WW.Math.Point3D point3D1           = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Min, 0.0);
            WW.Math.Point3D point3D2           = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Max, 0.0);
            WW.Math.Point3D fromReferencePoint = new WW.Math.Point3D(layoutRenderInfo.LayoutViewport.Center, 0.0);
            Matrix4D        matrix4D2          = Transformation4D.Translation((WW.Math.Vector3D)fromReferencePoint) * matrix4D1 * Transformation4D.Translation(-(WW.Math.Vector3D)fromReferencePoint);

            WW.Math.Point3D point3D3 = matrix4D2 * point3D1;
            point3D2 = matrix4D2 * point3D2;
            double   scaling;
            Matrix4D toPaperTransform = DxfUtil.GetScaleTransform(new WW.Math.Point3D(System.Math.Min(point3D3.X, point3D2.X), System.Math.Min(point3D3.Y, point3D2.Y), 0.0), new WW.Math.Point3D(System.Math.Max(point3D3.X, point3D2.X), System.Math.Max(point3D3.Y, point3D2.Y), 0.0), fromReferencePoint, toPoint1, toPoint2, toReferencePoint, out scaling) * matrix4D2;

            return(new DxfLayout.PlotInfo(this, plotPaperSize, new Rectangle2D(toPoint1.X, System.Math.Min(toPoint1.Y, toPoint2.Y), toPoint2.X, System.Math.Max(toPoint1.Y, toPoint2.Y)), toPaperTransform, scaling));
        }
Exemple #3
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));
        }