示例#1
0
        private void DrawData(DynamicStatistic.PlotPoints data, Color color, PointFunc func, bool isRect)
        {
            using (var pen = new Pen(color))
                using (var brush = new SolidBrush(color))
                {
                    for (int n = 0; n < data.Count; ++n)
                    {
                        var f = data.First();
                        var l = data.Last();

                        var d = l.Item2.Subtract(f.Item2).Ticks;

                        var prev = f;
                        foreach (var p in data)
                        {
                            var pp = func(data, p, d);
                            G.DrawLine(pen, func(data, prev, d), pp);

                            if (isRect)
                            {
                                G.FillRectangle(brush, pp.X - 6 / 2, pp.Y - 6 / 2, 6, 6);
                            }
                            else
                            {
                                G.FillEllipse(brush, pp.X - 7 / 2, pp.Y - 7 / 2, 7, 7);
                            }

                            prev = p;
                        }
                    }
                }
        }
        /// Set the pixel shader.
        public void SetPixelShader <T>(T shader) where T : struct, IPixelShader
        {
            var impl = new RasterizerImpl <T>(shader, this);

            m_triangleFunc = impl.DrawTriangleModeTemplate;
            m_lineFunc     = impl.DrawLineTemplate;
            m_pointFunc    = impl.DrawPointTemplate;
        }
示例#3
0
 private void MakeLines()
 {
     lines = new Line2D[VertCount - 1];
     for (int i = 0; i < lines.Length; i++)
     {
         lines[i]   = new Line2D(vertexes[i], vertexes[i + 1]);
         transfs[i] = new PointFunc(new Cut(vertexes[i], vertexes[i + 1]).Transfer);
     }
 }
        private void Vanish(DynamicStatistics.PlotPoints data, PointFunc func)
        {
            const int vanishArea     = 14;
            const int minPointsCount = 10;

            while (true)
            {
                if (data.Count <= minPointsCount)
                {
                    return;
                }

                var pointsToRemove = new List <DynamicStatistics.PlotPoint>();

                for (int i = 0; i < data.Count - minPointsCount /*minPointsCount*/; ++i)
                {
                    var ticks = data.Last().Item2 - data[0].Item2;
                    var p0    = func(data, data[i], ticks);
                    var p1    = func(data, data[i + 1], ticks);
                    var p2    = func(data, data[i + 2], ticks);

                    if (Math.Abs(Angle(p0, p1) - Angle(p1, p2)) < Math.PI / 720D) // 90
                    {
                        pointsToRemove.Add(data[i + 1]);

                        if (data.Count - pointsToRemove.Count < minPointsCount)
                        {
                            break;
                        }

                        i += 2;
                    }
                    else
                    {
                        if (Math.Abs(p0.X - p1.X) < vanishArea && Math.Abs(p0.Y - p1.Y) < vanishArea)
                        {
                            pointsToRemove.Add(data[i + 1]);

                            if (data.Count - pointsToRemove.Count < minPointsCount)
                            {
                                break;
                            }

                            i += 2;
                        }
                    }
                }

                if (!pointsToRemove.Any())
                {
                    return;
                }

                pointsToRemove.ForEach(p => data.Remove(p));
            }
        }
        private void DrawData(DynamicStatistics.PlotPoints data, Color color, PointFunc func, bool isRect)
        {
            if (data == null || data.FirstOrDefault() == null)
            {
                return;
            }

            var pen = Tools.Draw.GetPen(color);

            var firstData = data[0];
            var lastData  = data.Last();

            var ticks = lastData.Item2 - firstData.Item2;

            Point prevPoint = new Point(-1000, -1000);
            var   prevData  = firstData;

            foreach (var d in data)
            {
                var point = func(data, d, ticks);
                if ((point.X - prevPoint.X) > 10 || Math.Abs(point.Y - prevPoint.Y) > 10 || d == lastData) // opt
                {
                    CtlPresenter.DrawLine(pen, func(data, prevData, ticks), point);

                    if (isRect)
                    {
                        CtlPresenter.DrawRectangle(pen.Brush, pen, Rects.Get(point.X - 6 / 2, point.Y - 6 / 2, 6, 6));
                    }
                    else
                    {
                        CtlPresenter.DrawEllipse(pen.Brush, pen, Points.Get(point.X, point.Y), 7 / 2, 7 / 2);
                    }

                    prevData  = d;
                    prevPoint = point;
                }
            }
        }
示例#6
0
        private void Vanish(DynamicStatistic.PlotPoints data, PointFunc func)
        {
            int vanishArea = 16;

            if (data.Count > 10)
            {
                var pointsToRemove = new List <DynamicStatistic.PlotPoint>();
                var time           = data.Last().Item2.Subtract(data.First().Item2);

                for (int i = 0; i < data.Count * 0.8; ++i)
                {
                    var d  = data.Last().Item2.Subtract(data.First().Item2).Ticks;
                    var p0 = func(data, data[i], d);
                    var p2 = func(data, data[i + 2], d);

                    if ((Math.Abs(p0.X - p2.X) < vanishArea && Math.Abs(p0.Y - p2.Y) < vanishArea))
                    {
                        pointsToRemove.Add(data[i + 1]);
                        //i += 2;
                    }
                    else
                    {
                        var p1 = func(data, data[i + 1], d);
                        if ((p0.X == p1.X && p1.X == p2.X) || (p0.Y == p1.Y && p1.Y == p2.Y))
                        {
                            pointsToRemove.Add(data[i + 1]);
                            //i += 2;
                        }
                    }
                }

                foreach (var p in pointsToRemove)
                {
                    data.Remove(p);
                }
            }
        }