Пример #1
0
            // Add the stroke to an OCAD Map glyph with the given box size.
            public void AddToMapGlyph(Glyph glyph, SymColor color, float boxSize)
            {
                float scaleFactor = boxSize / 200.0F; // symbols are designed in box from -100 to 100.

                switch (kind)
                {
                case SymbolStrokes.Disc:
                    glyph.AddFilledCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), radius * 2 * scaleFactor);
                    break;

                case SymbolStrokes.Circle:
                    glyph.AddCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), thickness * scaleFactor, (radius * 2 + thickness) * scaleFactor);
                    break;

                case SymbolStrokes.Polyline: {
                    PointKind[] pathKinds  = new PointKind[points.Length];
                    PointF[]    pathPoints = new PointF[points.Length];
                    for (int i = 0; i < points.Length; ++i)
                    {
                        pathKinds[i]  = PointKind.Normal;
                        pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                    }
                    SymPath path = new SymPath(pathPoints, pathKinds);

                    glyph.AddLine(color, path, thickness * scaleFactor, corners, ends);
                    break;
                }

                case SymbolStrokes.Polygon: {
                    PointKind[] pathKinds  = new PointKind[points.Length + 1];
                    PointF[]    pathPoints = new PointF[points.Length + 1];
                    for (int i = 0; i < points.Length; ++i)
                    {
                        pathKinds[i]  = PointKind.Normal;
                        pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                    }
                    pathKinds[points.Length]  = pathKinds[0];
                    pathPoints[points.Length] = pathPoints[0];
                    SymPath path = new SymPath(pathPoints, pathKinds);

                    glyph.AddLine(color, path, thickness * scaleFactor, corners, corners == LineJoin.Round ? LineCap.Round : LineCap.Flat);
                    break;
                }

                case SymbolStrokes.FilledPolygon: {
                    PointKind[] pathKinds  = new PointKind[points.Length + 1];
                    PointF[]    pathPoints = new PointF[points.Length + 1];
                    for (int i = 0; i < points.Length; ++i)
                    {
                        pathKinds[i]  = PointKind.Normal;
                        pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                    }
                    pathKinds[points.Length]  = pathKinds[0];
                    pathPoints[points.Length] = pathPoints[0];
                    SymPath path = new SymPath(pathPoints, pathKinds);
                    glyph.AddArea(color, new SymPathWithHoles(path, null));
                    break;
                }

                case SymbolStrokes.PolyBezier: {
                    PointKind[] pathKinds  = new PointKind[points.Length];
                    PointF[]    pathPoints = new PointF[points.Length];
                    for (int i = 0; i < points.Length; ++i)
                    {
                        pathKinds[i]  = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl;
                        pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                    }
                    SymPath path = new SymPath(pathPoints, pathKinds);
                    glyph.AddLine(color, path, thickness * scaleFactor, corners, ends);
                    break;
                }

                case SymbolStrokes.FilledPolyBezier: {
                    PointKind[] pathKinds  = new PointKind[points.Length];
                    PointF[]    pathPoints = new PointF[points.Length];
                    for (int i = 0; i < points.Length; ++i)
                    {
                        pathKinds[i]  = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl;
                        pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                    }
                    SymPath path = new SymPath(pathPoints, pathKinds);
                    glyph.AddArea(color, new SymPathWithHoles(path, null));
                    break;
                }

                default:
                    Debug.Fail("Bad SymbolStroke kind");
                    break;
                }
            }
Пример #2
0
            // Add the stroke to an OCAD Map glyph with the given box size.
            public void AddToMapGlyph(Glyph glyph, SymColor color, float boxSize)
            {
                float scaleFactor = boxSize / 200.0F; // symbols are designed in box from -100 to 100.

                switch (kind) {
                case SymbolStrokes.Disc:
                    glyph.AddFilledCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), radius * 2 * scaleFactor);
                    break;

                case SymbolStrokes.Circle:
                    glyph.AddCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), thickness * scaleFactor, (radius * 2 + thickness) * scaleFactor);
                    break;

                case SymbolStrokes.Polyline: {
                        PointKind[] pathKinds = new PointKind[points.Length];
                        PointF[] pathPoints = new PointF[points.Length];
                        for (int i = 0; i < points.Length; ++i) {
                            pathKinds[i] = PointKind.Normal;
                            pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                        }
                        SymPath path = new SymPath(pathPoints, pathKinds);

                        glyph.AddLine(color, path, thickness * scaleFactor, corners, ends);
                        break;
                    }

                case SymbolStrokes.Polygon: {
                        PointKind[] pathKinds = new PointKind[points.Length + 1];
                        PointF[] pathPoints = new PointF[points.Length + 1];
                        for (int i = 0; i < points.Length; ++i) {
                            pathKinds[i] = PointKind.Normal;
                            pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                        }
                        pathKinds[points.Length] = pathKinds[0];
                        pathPoints[points.Length] = pathPoints[0];
                        SymPath path = new SymPath(pathPoints, pathKinds);

                        glyph.AddLine(color, path, thickness * scaleFactor, corners, corners == LineJoin.Round ? LineCap.Round : LineCap.Flat);
                        break;
                    }

                case SymbolStrokes.FilledPolygon: {
                        PointKind[] pathKinds = new PointKind[points.Length + 1];
                        PointF[] pathPoints = new PointF[points.Length + 1];
                        for (int i = 0; i < points.Length; ++i) {
                            pathKinds[i] = PointKind.Normal;
                            pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                        }
                        pathKinds[points.Length] = pathKinds[0];
                        pathPoints[points.Length] = pathPoints[0];
                        SymPath path = new SymPath(pathPoints, pathKinds);
                        glyph.AddArea(color, new SymPathWithHoles(path, null));
                        break;
                    }

                case SymbolStrokes.PolyBezier: {
                        PointKind[] pathKinds = new PointKind[points.Length];
                        PointF[] pathPoints = new PointF[points.Length];
                        for (int i = 0; i < points.Length; ++i) {
                            pathKinds[i] = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl;
                            pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                        }
                        SymPath path = new SymPath(pathPoints, pathKinds);
                        glyph.AddLine(color, path, thickness * scaleFactor, corners, ends);
                        break;
                    }

                case SymbolStrokes.FilledPolyBezier: {
                        PointKind[] pathKinds = new PointKind[points.Length];
                        PointF[] pathPoints = new PointF[points.Length];
                        for (int i = 0; i < points.Length; ++i) {
                            pathKinds[i] = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl;
                            pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor);
                        }
                        SymPath path = new SymPath(pathPoints, pathKinds);
                        glyph.AddArea(color, new SymPathWithHoles(path, null));
                        break;
                    }

                default:
                    Debug.Fail("Bad SymbolStroke kind");
                    break;
                }
            }
Пример #3
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            Glyph glyph = new Glyph();
            SymPath path1, path2;

            GetPaths(out path1, out path2);
            glyph.AddLine(symColor, path1, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Miter, LineCap.Flat);
            glyph.AddLine(symColor, path2, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Miter, LineCap.Flat);

            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Crossing point", "708", glyph, true);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Crossing_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }
Пример #4
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            Glyph glyph = new Glyph();

            SymPath path = new SymPath(ScaleCoords((PointF[]) coords1.Clone()), kinds1);
            glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);

            path = new SymPath(ScaleCoords((PointF[]) coords2.Clone()), kinds2);
            glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);

            path = new SymPath(ScaleCoords((PointF[]) coords3.Clone()), kinds3);
            glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);

            path = new SymPath(ScaleCoords((PointF[]) coords4.Clone()), kinds4);
            glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);

            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Refreshment point", "713", glyph, false);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Water_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }
Пример #5
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            PointKind[] kinds = { PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal };
            PointF[] pts = ScaleCoords((PointF[]) coords.Clone());
            SymPath path = new SymPath(pts, kinds);

            Glyph glyph = new Glyph();
            glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Miter, LineCap.Flat);
            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Start", "701", glyph, true);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Start_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }
Пример #6
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            Glyph glyph = new Glyph();

            SymPath path = new SymPath(ScaleCoords((PointF[]) coords1.Clone()), kinds1);
            glyph.AddLine(symColor, path, lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Miter, LineCap.Flat);

            path = new SymPath(ScaleCoords((PointF[]) coords2.Clone()), kinds2);
            glyph.AddLine(symColor, path, lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Miter, LineCap.Flat);

            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Registration mark", "714", glyph, false);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Registration_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }
Пример #7
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            Glyph glyph = new Glyph();

            // Note: the line thickness of forbidden marks do NOT scale with the Line Thickness in the Course Appearance. This is by design,
            // otherwise it would look kind of weird. The scale with the control circle size instead to maintain the ratio.

            SymPath path = new SymPath(ScaleCoords((PointF[]) coords1.Clone()), kinds1);
            glyph.AddLine(symColor, path, 0.35F * scaleRatio * appearance.controlCircleSize, LineJoin.Miter, LineCap.Flat);

            path = new SymPath(ScaleCoords((PointF[]) coords2.Clone()), kinds2);
            glyph.AddLine(symColor, path, 0.35F * scaleRatio * appearance.controlCircleSize, LineJoin.Miter, LineCap.Flat);

            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Forbidden route", "710", glyph, false);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Forbidden_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }