public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit)
        {
            PointF p = cs.Convert(point);

            DrawPoint(p);

            Pen penDot = (Pen)pen.Clone();

            penDot.DashStyle = DashStyle.Dot;

            double pi2 = 2 * Geometry.HalfAngle(unit);
            // draw points on the west
            double x_tmp = point[0] - pi2;

            while (x_tmp >= box.Min[0])
            {
                p.X = cs.ConvertX(x_tmp);
                DrawPoint(p, penDot);
                x_tmp -= pi2;
            }
            // draw points on the east
            x_tmp = point[0] + pi2;
            while (x_tmp <= box.Max[0])
            {
                p.X = cs.ConvertX(x_tmp);
                DrawPoint(p, penDot);
                x_tmp += pi2;
            }
        }
Exemple #2
0
        // For GraphicalWatch
        public static bool Draw(Graphics graphics,
                                IDrawable drawable, Geometry.Traits traits,
                                Settings settings, Colors colors)
        {
            if (drawable == null)
            {
                return(false);
            }

            if (traits != null && traits.CoordinateSystem == Geometry.CoordinateSystem.SphericalPolar)
            {
                throw new Exception("This coordinate system is not yet supported.");
            }

            if (settings.color == Color.Empty)
            {
                settings.color = DefaultColor(drawable, colors);
            }

            Geometry.Box aabb = drawable.Aabb(traits, true);
            if (aabb.IsValid())
            {
                Geometry.Unit unit = (traits != null) ? traits.Unit : Geometry.Unit.None;
                bool          fill = (traits == null);
                Drawer.DrawAxes(graphics, aabb, unit, colors, fill);
                drawable.Draw(aabb, graphics, settings, traits);
            }
            return(true);
        }
Exemple #3
0
            public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope)
            {
                Geometry.Box box = null;

                for (int i = 0; i < this.Count; ++i)
                {
                    Geometry.Box poly_box = AabbPolygon(this[i], traits, calculateEnvelope);

                    if (box == null)
                    {
                        box = poly_box;
                    }
                    else
                    {
                        if (calculateEnvelope)
                        {
                            Geometry.Expand(box, poly_box, traits);
                        }
                        else
                        {
                            Geometry.Expand(box, poly_box);
                        }
                    }
                }

                if (box == null)
                {
                    Geometry.AssignInverse(box);
                }

                return(box);
            }
Exemple #4
0
 public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
 {
     for (int i = 0; i < this.Count; ++i)
     {
         DrawPolygon(this[i], box, graphics, settings, traits);
     }
 }
Exemple #5
0
            void DrawLines(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits, double diffX)
            {
                // NOTE: traits == null
                bool fill = true;

                LocalCS cs = new LocalCS(box, graphics, fill);

                //float dx = cs.ConvertDimensionX(diffX);
                //float s = Math.Min(Math.Max(dx, 1.0f), 2.0f);

                Drawer drawer = new Drawer(graphics, settings.color);

                if (points.Count == 1)
                {
                    float x = cs.ConvertX(points[0][0]);
                    float y = cs.ConvertY(points[0][1]);
                    drawer.DrawLine(x, y - 0.5f, x, y + 0.5f);
                }
                else if (points.Count > 1)
                {
                    float xp = cs.ConvertX(points[0][0]);
                    float yp = cs.ConvertY(points[0][1]);
                    for (int i = 1; i < points.Count; ++i)
                    {
                        float x = cs.ConvertX(points[i][0]);
                        float y = cs.ConvertY(points[i][1]);
                        drawer.DrawLine(xp, yp, x, y);
                        xp = x;
                        yp = y;
                    }
                }
            }
Exemple #6
0
        private static void DrawLinestring(Geometry.Linestring linestring, Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
        {
            LocalCS cs     = new LocalCS(box, graphics);
            Drawer  drawer = new Drawer(graphics, settings.color);

            if (traits.Unit == Geometry.Unit.None)
            {
                for (int i = 1; i < linestring.Count; ++i)
                {
                    PointF p0 = cs.Convert(linestring[i - 1]);
                    PointF p1 = cs.Convert(linestring[i]);
                    drawer.DrawLine(p0, p1);
                    if (settings.showDir)
                    {
                        drawer.DrawDir(p0, p1);
                    }
                }
            }
            else // Radian, Degree
            {
                Drawer.PeriodicDrawableRange pd       = new Drawer.PeriodicDrawableRange(cs, linestring, false, traits.Unit, settings.densify);
                Geometry.Interval            interval = RelativeEnvelopeLon(linestring, false, traits.Unit);
                drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, false, settings.showDir, settings.showDots);
            }
        }
Exemple #7
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                LocalCS cs     = new LocalCS(box, graphics);
                Drawer  drawer = new Drawer(graphics, settings.color);

                if (traits.Unit == Geometry.Unit.None)
                {
                    PointF[] dst_points = cs.Convert(this);

                    if (dst_points != null)
                    {
                        drawer.FillPolygon(dst_points);
                        drawer.DrawPolygon(dst_points);

                        if (settings.showDir)
                        {
                            drawer.DrawDirs(dst_points, true);
                            drawer.DrawPoint(dst_points[0].X, dst_points[0].Y);
                        }
                    }
                }
                else
                {
                    Drawer.PeriodicDrawableRange pd       = new Drawer.PeriodicDrawableRange(cs, this, true, traits.Unit, settings.densify);
                    Geometry.Interval            interval = RelativeEnvelopeLon(this, true, traits.Unit);
                    drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, true, settings.showDir, settings.showDots);

                    if (settings.showDir && this.Count > 0)
                    {
                        drawer.DrawPeriodicPoint(cs, this[0], box, traits.Unit, settings.showDots);
                    }
                }
            }
Exemple #8
0
            public System.Drawing.Point GetDrawingPoint(Geometry.Box box, Graphics graphics)
            {
                LocalCS cs = new LocalCS(box, graphics);
                PointF  pf = cs.Convert(point);

                return(new System.Drawing.Point((int)Math.Round(pf.X), (int)Math.Round(pf.Y)));
            }
        public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit, bool drawDots)
        {
            PointF p = cs.Convert(point);

            DrawPoint(p);

            double pi2 = 2 * Geometry.HalfAngle(unit);
            Pen    pen = drawDots ? this.penDot : this.pen;
            // draw points on the west
            double x_tmp = point[0] - pi2;

            while (x_tmp >= box.Min[0])
            {
                p.X = cs.ConvertX(x_tmp);
                DrawPoint(p, pen);
                x_tmp -= pi2;
            }
            // draw points on the east
            x_tmp = point[0] + pi2;
            while (x_tmp <= box.Max[0])
            {
                p.X = cs.ConvertX(x_tmp);
                DrawPoint(p, pen);
                x_tmp += pi2;
            }
        }
            public PeriodicDrawablePolygon(LocalCS cs,
                                           Geometry.IRandomAccessRange <Geometry.Point> outer,
                                           IEnumerable <Geometry.IRandomAccessRange <Geometry.Point> > inners,
                                           Geometry.Box box,
                                           Geometry.Unit unit)
            {
                this.outer = new PeriodicDrawableRange(cs, outer, box, unit);

                minf     = this.outer.minf;
                maxf     = this.outer.maxf;
                periodf  = this.outer.periodf;
                box_minf = this.outer.box_minf;
                box_maxf = this.outer.box_maxf;

                this.inners = new List <PeriodicDrawableRange>();
                int i = 0;

                foreach (var inner in inners)
                {
                    this.inners.Add(new PeriodicDrawableRange(cs, inner, box, unit));

                    // expand relative box X
                    if (this.inners[i].minf < minf)
                    {
                        minf = this.inners[i].minf;
                    }
                    if (this.inners[i].maxf > maxf)
                    {
                        maxf = this.inners[i].maxf;
                    }
                }
            }
Exemple #11
0
            public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope)
            {
                Geometry.Box box = new Geometry.Box();
                Geometry.AssignInverse(box);

                for (int i = 0; i < turns.Count; ++i)
                {
                    Geometry.Expand(box, turns[i].Point);
                }

                return(box);
            }
Exemple #12
0
            void DrawBars(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                // NOTE: traits == null
                bool fill = true;

                LocalCS cs = new LocalCS(box, graphics, fill);

                float y0        = cs.ConvertY(0);
                float x0        = cs.ConvertX(0);
                float x1        = cs.ConvertX(1);
                float dx        = Math.Abs(x1 - x0);
                bool  drawLines = dx < 4;

                double i = 0;

                if (drawLines)
                {
                    float penWidth = dx < 2 ? 1 : 2;
                    Pen   pen      = new Pen(settings.color, penWidth);
                    foreach (double v in values)
                    {
                        float x = cs.ConvertX(i);
                        float y = cs.ConvertY(v);
                        graphics.DrawLine(pen, x, y0, x, y);
                        i += 1;
                    }
                }
                else
                {
                    Drawer drawer = new Drawer(graphics, settings.color);
                    foreach (double v in values)
                    {
                        float x  = cs.ConvertX(i);
                        float y  = cs.ConvertY(v);
                        float t  = Math.Min(y0, y);
                        float h  = Math.Abs(y - y0);
                        float xl = dx / 3.0f;
                        float xw = dx * 2.0f / 3.0f;
                        if (h >= 2)
                        {
                            drawer.DrawRectangle(x - xl, t, xw, h);
                            drawer.FillRectangle(x - xl, t, xw, h);
                        }
                        else
                        {
                            drawer.DrawLine(x - xl, t, x + xl, t);
                        }
                        i += 1;
                    }
                }
            }
        public void Reset(Geometry.Box src_box, float viewWidth, float viewHeight, bool fill)
        {
            float w = viewWidth;
            float h = viewHeight;

            dst_orig_w = w;
            dst_orig_h = h;
            dst_x0     = w / 2;
            dst_y0     = h / 2;
            float dst_w = w * viewScale;
            float dst_h = h * viewScale;

            double src_w = src_box.Dim(0);
            double src_h = src_box.Dim(1);

            if (src_w < 0 || src_h < 0)
            {
                throw new System.Exception("Invalid box dimensions.");
            }

            src_x0 = src_box.Min[0] + src_w / 2;
            src_y0 = src_box.Min[1] + src_h / 2;

            // point or 1 value
            if (src_w == 0 && src_h == 0)
            {
                scale_x = dst_w / 2;
                scale_y = dst_h / 2;
            }
            // vertical segment or N 1-value plots
            else if (src_w == 0)
            {
                scale_x = dst_w / 2;
                scale_y = dst_h / src_h;
            }
            // horizontal segment or equal values
            else if (src_h == 0)
            {
                scale_x = dst_w / src_w;
                scale_y = dst_h / 2;
            }
            else
            {
                scale_x = dst_w / src_w;
                scale_y = dst_h / src_h;
                if (!fill)
                {
                    scale_x = scale_y = Math.Min(scale_x, scale_y);
                }
            }
        }
Exemple #14
0
        public void DrawPeriodic(LocalCS cs,
                                 Geometry.Box box, Geometry.Interval interval, Geometry.Unit unit,
                                 IPeriodicDrawable drawer,
                                 bool fill, bool drawDirs, bool drawDots)
        {
            double twoPi    = Geometry.FullAngle(unit);
            float  periodf  = cs.ConvertDimensionX(twoPi);
            float  box_minf = cs.ConvertX(box.Min[0]);
            float  box_maxf = cs.ConvertX(box.Max[0]);

            float minf = cs.ConvertX(interval.Min);
            float maxf = cs.ConvertX(interval.Max);

            if (maxf >= box_minf && minf <= box_maxf)
            {
                drawer.DrawOne(this, 0, fill, drawDirs, drawDots);
            }

            // west
            float minf_i       = minf;
            float maxf_i       = maxf;
            float translationf = 0;

            while (maxf_i >= box_minf &&
                   Util.Assign(ref maxf_i, maxf_i - periodf))
            {
                translationf -= periodf;
                minf_i       -= periodf;
                //maxf_i -= periodf; // subtracted above
                if (maxf_i >= box_minf && minf_i <= box_maxf)
                {
                    drawer.DrawOne(this, translationf, fill, drawDirs, drawDots);
                }
            }
            // east
            minf_i       = minf;
            maxf_i       = maxf;
            translationf = 0;
            while (minf_i <= box_maxf &&
                   Util.Assign(ref minf_i, minf_i + periodf))
            {
                translationf += periodf;
                //minf_i += periodf; // added above
                maxf_i += periodf;
                if (maxf_i >= box_minf && minf_i <= box_maxf)
                {
                    drawer.DrawOne(this, translationf, fill, drawDirs, drawDots);
                }
            }
        }
Exemple #15
0
            public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope)
            {
                // NOTE: traits == null
                // so don't return points.Aabb(traits, calculateEnvelope)

                Geometry.Box box = new Geometry.Box();
                Geometry.AssignInverse(box);

                for (int i = 0; i < points.Count; ++i)
                {
                    Geometry.Expand(box, points[i]);
                }

                return(box);
            }
Exemple #16
0
        private static void DrawPoint(Geometry.Point point, Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
        {
            LocalCS cs     = new LocalCS(box, graphics);
            Drawer  drawer = new Drawer(graphics, settings.color);

            if (traits.Unit == Geometry.Unit.None)
            {
                PointF p = cs.Convert(point);
                drawer.DrawPoint(p);
            }
            else // Radian, Degree
            {
                drawer.DrawPeriodicPoint(cs, point, box, traits.Unit, settings.showDots);
            }
        }
            public PeriodicDrawableNSphere(LocalCS cs, Geometry.NSphere nsphere, Geometry.Box box, Geometry.Unit unit)
            {
                double pi = Geometry.HalfAngle(unit);

                periodf = cs.ConvertDimension(2 * pi);

                c_rel = cs.Convert(nsphere.Center);
                r     = cs.ConvertDimension(nsphere.Radius);

                minf = c_rel.X - r;
                maxf = c_rel.X + r;

                box_minf = cs.ConvertX(box.Min[0]);
                box_maxf = cs.ConvertX(box.Max[0]);
            }
        public void DrawPeriodic(LocalCS cs,
                                 Geometry.Box box, Geometry.Interval interval, Geometry.Unit unit,
                                 IPeriodicDrawable drawer,
                                 bool fill, bool drawDirs, bool drawDots)
        {
            double pi       = Geometry.HalfAngle(unit);
            float  periodf  = cs.ConvertDimensionX(2 * pi);
            float  box_minf = cs.ConvertX(box.Min[0]);
            float  box_maxf = cs.ConvertX(box.Max[0]);

            float minf = cs.ConvertX(interval.Min);
            float maxf = cs.ConvertX(interval.Max);

            if (maxf >= box_minf && minf <= box_maxf)
            {
                drawer.DrawOne(this, 0, fill, drawDirs, drawDots);
            }

            // west
            float minf_i       = minf;
            float maxf_i       = maxf;
            float translationf = 0;

            while (maxf_i >= box_minf)
            {
                translationf -= periodf;
                minf_i       -= periodf;
                maxf_i       -= periodf;
                if (maxf_i >= box_minf && minf_i <= box_maxf)
                {
                    drawer.DrawOne(this, translationf, fill, drawDirs, drawDots);
                }
            }
            // east
            minf_i       = minf;
            maxf_i       = maxf;
            translationf = 0;
            while (minf_i <= box_maxf)
            {
                translationf += periodf;
                minf_i       += periodf;
                maxf_i       += periodf;
                if (maxf_i >= box_minf && minf_i <= box_maxf)
                {
                    drawer.DrawOne(this, translationf, fill, drawDirs, drawDots);
                }
            }
        }
Exemple #19
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                DrawPoint(box, graphics, settings, traits);

                if (settings.showLabels)
                {
                    Drawer     drawer     = new Drawer(graphics, settings.color);
                    SolidBrush text_brush = new SolidBrush(Color.Black);
                    Font       font       = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif), 10);

                    string label            = this.GetLabel();
                    System.Drawing.Point pi = GetDrawingPoint(box, graphics);

                    graphics.DrawString(label, font, text_brush, pi);
                }
            }
Exemple #20
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                // Esstimate the distance between samples, uniform distribution, 2 samples per X
                Geometry.Box originalBox = this.Aabb(traits, false);
                int          count       = Math.Max(points.Count, 1);
                double       diffX       = Math.Abs(originalBox.Dim(0)) / count * 2.0;

                if (settings.pointPlot_enableLines)
                {
                    DrawLines(box, graphics, settings, traits, diffX);
                }

                if (settings.pointPlot_enablePoints)
                {
                    DrawPoints(box, graphics, settings, traits, diffX);
                }
            }
Exemple #21
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                if (settings.valuePlot_enableBars)
                {
                    DrawBars(box, graphics, settings, traits);
                }

                if (settings.valuePlot_enableLines)
                {
                    DrawLines(box, graphics, settings, traits);
                }

                if (settings.valuePlot_enablePoints)
                {
                    DrawPoints(box, graphics, settings, traits);
                }
            }
Exemple #22
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                LocalCS cs     = new LocalCS(box, graphics);
                Drawer  drawer = new Drawer(graphics, settings.color);

                float rx = cs.ConvertDimensionX(Radius);
                float ry = cs.ConvertDimensionY(Radius);

                if (rx < 0 || ry < 0)
                {
                    return;
                }

                if (traits.Unit == Geometry.Unit.None)
                {
                    PointF c = cs.Convert(Center);
                    if (rx == 0 || ry == 0)
                    {
                        drawer.DrawPoint(c.X, c.Y);
                    }
                    else
                    {
                        float x = c.X - rx;
                        float y = c.Y - ry;
                        float w = rx * 2;
                        float h = ry * 2;
                        drawer.DrawEllipse(x, y, w, h);
                        drawer.FillEllipse(x, y, w, h);
                    }
                }
                else // Radian, Degree
                {
                    if (rx == 0 || ry == 0)
                    {
                        drawer.DrawPeriodicPoint(cs, Center, box, traits.Unit, settings.showDots);
                    }
                    else
                    {
                        Drawer.PeriodicDrawableNSphere pd = new Drawer.PeriodicDrawableNSphere(cs, this, traits.Unit);
                        Geometry.Interval interval        = RelativeEnvelopeLon(this, traits.Unit);
                        drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, true, false, settings.showDots);
                    }
                }
            }
Exemple #23
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                LocalCS    cs         = new LocalCS(box, graphics);
                Drawer     drawer     = new Drawer(graphics, settings.color);
                SolidBrush text_brush = new SolidBrush(Color.Black);

                Font font = null;

                if (settings.showLabels)
                {
                    font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif), 10);
                }

                Dictionary <System.Drawing.Point, string> labelsMap = new Dictionary <System.Drawing.Point, string>();

                int index = 0;

                foreach (Turn turn in turns)
                {
                    turn.DrawPoint(box, graphics, settings, traits);

                    if (settings.showLabels)
                    {
                        System.Drawing.Point pi = turn.GetDrawingPoint(box, graphics);
                        string str = index.ToString() + ' ' + turn.GetLabel();

                        if (!labelsMap.ContainsKey(pi))
                        {
                            labelsMap.Add(pi, str);
                        }
                        else
                        {
                            labelsMap[pi] = labelsMap[pi] + '\n' + str;
                        }
                    }
                    ++index;
                }

                foreach (var label in labelsMap)
                {
                    graphics.DrawString(label.Value, font, text_brush, label.Key);
                }
            }
Exemple #24
0
        private static Geometry.Box AabbPolygon(Geometry.Polygon poly, Geometry.Traits traits, bool calculateEnvelope)
        {
            Geometry.Box result = AabbRange(poly.Outer, true, traits, calculateEnvelope);

            foreach (Geometry.Ring inner in poly.Inners)
            {
                Geometry.Box aabb = AabbRange(inner, true, traits, calculateEnvelope);
                if (calculateEnvelope)
                {
                    Geometry.Expand(result, aabb, traits);
                }
                else
                {
                    Geometry.Expand(result, aabb);
                }
            }

            return(result);
        }
Exemple #25
0
            public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope)
            {
                // NOTE: traits == null

                Geometry.Box box = new Geometry.Box();
                Geometry.AssignInverse(box);

                if (values.Count > 0)
                {
                    Geometry.Expand(box, new Point(0.0, 0.0));
                }

                for (int i = 0; i < values.Count; ++i)
                {
                    Geometry.Expand(box, new Point(i, values[i]));
                }

                return(box);
            }
Exemple #26
0
        public void DrawPeriodicPoint(LocalCS cs, Geometry.Point point, Geometry.Box box, Geometry.Unit unit, bool drawDots)
        {
            PointF p = cs.Convert(point);

            DrawPoint(p);

            double twoPi = Geometry.FullAngle(unit);
            Pen    pen   = drawDots ? this.penDot : this.pen;

            // NOTE: Use AssignChanged becasue for big coordinates subtracting/adding
            //   twoPi doesn't change the value of x_tmp which causes infinite loop

            float  x            = Math.Min(Math.Max(p.X, 0.0f), cs.Width);
            double nPeriodsWest = (point[0] - box.Min[0]) / twoPi;
            float  pixelsWest   = x;
            double nPeriodsEast = (box.Max[0] - point[0]) / twoPi;
            float  pixelsEast   = cs.Width - x;

            if (nPeriodsWest <= pixelsWest / 5)
            {
                // draw points on the west
                double x_tmp = point[0];
                while (Util.Assign(ref x_tmp, x_tmp - twoPi) &&
                       x_tmp >= box.Min[0])
                {
                    p.X = cs.ConvertX(x_tmp);
                    DrawPoint(p, pen);
                }
            }

            if (nPeriodsEast <= pixelsEast / 5)
            {
                // draw points on the east
                double x_tmp = point[0];
                while (Util.Assign(ref x_tmp, x_tmp + twoPi) &&
                       x_tmp <= box.Max[0])
                {
                    p.X = cs.ConvertX(x_tmp);
                    DrawPoint(p, pen);
                }
            }
        }
Exemple #27
0
            void DrawPoints(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits, double diffX)
            {
                // NOTE: traits == null
                bool fill = true;

                LocalCS cs = new LocalCS(box, graphics, fill);

                float dx      = cs.ConvertDimensionX(diffX);
                float s       = Math.Min(Math.Max(dx * 2.0f, 2.0f), 5.0f);
                bool  drawPts = dx < 1;

                Drawer drawer = new Drawer(graphics, settings.color);

                for (int i = 0; i < points.Count; ++i)
                {
                    float x = cs.ConvertX(points[i][0]);
                    float y = cs.ConvertY(points[i][1]);
                    drawer.DrawPoint(x, y, s);
                }
            }
        public LocalCS(Geometry.Box src_box, Graphics dst_graphics)
        {
            float w = dst_graphics.VisibleClipBounds.Width;
            float h = dst_graphics.VisibleClipBounds.Height;

            dst_x0 = w / 2;
            dst_y0 = h / 2;
            float dst_w = w * 0.9f;
            float dst_h = h * 0.9f;

            double src_w = src_box.Dim(0);
            double src_h = src_box.Dim(1);

            if (src_w < 0 || src_h < 0)
            {
                throw new System.Exception("Invalid box dimensions.");
            }

            src_x0 = src_box.Min[0] + src_w / 2;
            src_y0 = src_box.Min[1] + src_h / 2;

            if (src_w == 0 && src_h == 0)
            {
                scale = 1; // point
            }
            else if (src_w == 0)
            {
                scale = (h * 0.9f) / src_h;
            }
            else if (src_h == 0)
            {
                scale = (w * 0.9f) / src_w;
            }
            else
            {
                double scale_w = (w * 0.9f) / src_w;
                double scale_h = (h * 0.9f) / src_h;
                scale = Math.Min(scale_w, scale_h);
            }
        }
Exemple #29
0
            public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                LocalCS cs     = new LocalCS(box, graphics);
                Drawer  drawer = new Drawer(graphics, settings.color);

                if (traits.Unit == Geometry.Unit.None)
                {
                    PointF p0 = cs.Convert(this[0]);
                    PointF p1 = cs.Convert(this[1]);
                    drawer.DrawLine(p0, p1);
                    if (settings.showDir)
                    {
                        drawer.DrawDir(p0, p1);
                    }
                }
                else // Radian, Degree
                {
                    Drawer.PeriodicDrawableRange pd       = new Drawer.PeriodicDrawableRange(cs, this, false, traits.Unit, settings.densify);
                    Geometry.Interval            interval = RelativeEnvelopeLon(this, false, traits.Unit);
                    drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, false, settings.showDir, settings.showDots);
                }
            }
Exemple #30
0
            void DrawPoints(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
            {
                // NOTE: traits == null
                bool fill = true;

                LocalCS cs = new LocalCS(box, graphics, fill);

                float x0 = cs.ConvertX(0);
                float x1 = cs.ConvertX(1);
                float dx = Math.Abs(x1 - x0);
                float s  = Math.Min(Math.Max(dx * 2.0f, 2.0f), 5.0f);

                double i      = 0;
                Drawer drawer = new Drawer(graphics, settings.color);

                foreach (double v in values)
                {
                    float x = cs.ConvertX(i);
                    float y = cs.ConvertY(v);
                    drawer.DrawPoint(x, y, s);
                    i += 1;
                }
            }