Exemplo n.º 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;
                }
            }
Exemplo n.º 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;
                }
            }
Exemplo n.º 3
0
        protected override SymDef CreateSymDef(Map map, SymColor symColor)
        {
            Glyph glyph = new Glyph();
            glyph.AddCircle(symColor, new PointF(0.0F, 0.0F), NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, diameter * scaleRatio * appearance.controlCircleSize);
            if (appearance.centerDotDiameter > 0.0F) {
                glyph.AddFilledCircle(symColor, new PointF(0.0F, 0.0F), appearance.centerDotDiameter * scaleRatio);
            }
            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Control point", "702", glyph, false);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Control_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }