Ejemplo n.º 1
0
Archivo: Area.cs Proyecto: Daoting/dt
        protected PathFigure RenderNonStacked(Point[] pts, double origin, bool inverted, double optRadius, Rect cr)
        {
            PointCollection points = null;
            int             length = pts.Length;

            if (base.Smoothed && (length > 3))
            {
                points = new SplineNew(pts).CalculateCollection();
                length = pts.Length;
            }
            else if (!double.IsNaN(optRadius))
            {
                points = base.DecimateAsCollection(pts, optRadius);
                length = pts.Length;
            }
            else
            {
                points = new PointCollection();
                for (int i = 0; i < length; i++)
                {
                    points.Add(pts[i]);
                }
            }
            if (inverted)
            {
                points.Add(new Point(origin, pts[length - 1].Y));
                points.Add(new Point(origin, pts[0].Y));
            }
            else
            {
                points.Add(new Point(pts[length - 1].X, origin));
                points.Add(new Point(pts[0].X, origin));
            }
            points.Add(points[0]);
            if (!cr.IsEmptyRect())
            {
                Point[] inArray = new Point[points.Count];
                for (int j = 0; j < points.Count; j++)
                {
                    inArray[j] = points[j];
                }
                inArray = PolygonClipping.sClipPolygonByRect(inArray, cr);
                if (inArray == null)
                {
                    return(null);
                }
                points = Utils.ToCollection(inArray);
            }
            return(RenderSegment(points));
        }
Ejemplo n.º 2
0
Archivo: Area.cs Proyecto: Daoting/dt
        protected override bool Render(RenderContext rc)
        {
            Point[] points = rc.Points;
            if ((points == null) || (points.Length < 2))
            {
                return(false);
            }
            BaseRenderer renderer = rc.Renderer as BaseRenderer;

            if (renderer == null)
            {
                return(false);
            }
            bool   inverted = renderer.Inverted;
            double naN      = double.NaN;

            if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Lines) > ((OptimizationRadiusScope)0))
            {
                naN = rc.OptimizationRadius;
            }
            double[] previousValues = rc.PreviousValues;
            Point[]  pts            = null;

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();

            if (renderer.IsStacked && previousValues != null)
            {
                int length = points.Length;
                if ((previousValues != null) && (previousValues.Length == length))
                {
                    if (base.Smoothed && (length > 3))
                    {
                        Point[] pointArray3 = InitPrevious(rc, inverted, points, previousValues);
                        points      = new SplineNew(points).Calculate();
                        pointArray3 = new SplineNew(pointArray3).Calculate();
                        length      = points.Length;
                        pts         = new Point[2 * length];
                        for (int i = 0; i < length; i++)
                        {
                            pts[i]          = points[i];
                            pts[length + i] = pointArray3[(length - i) - 1];
                        }
                    }
                    else
                    {
                        pts = new Point[2 * length];
                        for (int j = 0; j < length; j++)
                        {
                            pts[j] = points[j];
                            if (inverted)
                            {
                                pts[length + j] = new Point(rc.ConvertX(previousValues[(length - j) - 1]), points[(length - j) - 1].Y);
                            }
                            else
                            {
                                pts[length + j] = new Point(points[(length - j) - 1].X, rc.ConvertY(previousValues[(length - j) - 1]));
                            }
                        }
                    }
                }
                if (pts != null)
                {
                    PathFigure figure = RenderSegment(pts);
                    geometry.Figures.Add(figure);
                }
            }
            else
            {
                double num5 = inverted ? rc.ConvertX(0.0) : rc.ConvertY(0.0);
                if (double.IsNaN(num5))
                {
                    num5 = inverted ? (rc.XReversed ? (rc.Bounds.X + rc.Bounds.Width) : rc.Bounds.X) : (rc.YReversed ? rc.Bounds.Y : (rc.Bounds.Y + rc.Bounds.Height));
                }
                List <Point[]> list = base.SplitPointsWithHoles(points);
                Rect           cr   = rc.IsCustomClipping ? new Rect(rc.Bounds2D.X - 2.0, rc.Bounds2D.Y - 2.0, rc.Bounds2D.Width + 4.0, rc.Bounds2D.Height + 4.0) : Extensions.EmptyRect;
                if (list != null)
                {
                    for (int k = 0; k < list.Count; k++)
                    {
                        Point[]    pointArray4 = list[k];
                        PathFigure figure;
                        if (renderer is RadarRenderer)
                        {
                            figure = RenderSegment(pointArray4);
                        }
                        else
                        {
                            figure = RenderNonStacked(pointArray4, num5, inverted, naN, cr);
                        }
                        if (figure != null)
                        {
                            geometry.Figures.Add(figure);
                        }
                    }
                }
            }
            Data = geometry;

            RectangleGeometry geometry2 = new RectangleGeometry();

            geometry2.Rect = new Rect(rc.Bounds.X, rc.Bounds.Y, rc.Bounds.Width, rc.Bounds.Height);
            base.Clip      = geometry2;
            return(true);
        }
Ejemplo n.º 3
0
        protected PathFigure[] RenderSegment(Point[] pts, double optRadius, Rect clip)
        {
            if ((pts == null) || (pts.Length == 0))
            {
                return(null);
            }
            if (Smoothed && (pts.Length > 3))
            {
                pts = new SplineNew(pts).Calculate();
            }
            else if (!double.IsNaN(optRadius))
            {
                pts = Decimate(pts, optRadius);
            }
            if (clip.IsEmptyRect())
            {
                PathFigure figure = new PathFigure();
                figure.StartPoint = pts[0];
                figure.IsClosed   = IsClosed;
                figure.IsFilled   = IsFilled;
                PolyLineSegment segment = new PolyLineSegment();
                segment.Points = pts.ToCollection();
                figure.Segments.Add(segment);
                return(new PathFigure[] { figure });
            }
            if (!IsClosed)
            {
                return(ClippingEngine.CreateClippedLines(pts, clip));
            }
            pts = PolygonClipping.sClipPolygonByRect(pts, clip);
            if ((pts == null) || (pts.Length <= 0))
            {
                return(null);
            }
            PathFigure figure2 = new PathFigure();

            figure2.StartPoint = pts[0];
            figure2.IsClosed   = IsClosed;
            figure2.IsFilled   = IsFilled;
            figure2.Segments   = new PathSegmentCollection();
            if (!IsFilled)
            {
                PathFigure[] figureArray = new PathFigure[pts.Length];
                PathFigure   figure4     = new PathFigure();
                figure4.StartPoint = pts[pts.Length - 1];
                figureArray[0]     = figure4;
                LineSegment segment3 = new LineSegment();
                segment3.Point = pts[0];
                figureArray[0].Segments.Add(segment3);
                for (int i = 1; i < figureArray.Length; i++)
                {
                    PathFigure figure3 = new PathFigure();
                    figure3.StartPoint = pts[i - 1];
                    figureArray[i]     = figure3;
                    LineSegment segment2 = new LineSegment();
                    segment2.Point = pts[i];
                    figureArray[i].Segments.Add(segment2);
                }
                return(figureArray);
            }
            PolyLineSegment segment4 = new PolyLineSegment();

            segment4.Points = pts.ToCollection();
            figure2.Segments.Add(segment4);
            return(new PathFigure[] { figure2 });
        }