// 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; } }
protected override SymDef CreateSymDef(Map map, SymColor symColor) { PointKind[] kinds = { PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, }; PointF[] coords = ScaleCoords((PointF[])outlineCoordsRight.Clone()); SymPath pathRight = new SymPath(coords, kinds); coords = ScaleCoords((PointF[])outlineCoordsLeft.Clone()); SymPath pathLeft = new SymPath(coords, kinds); Glyph glyph = new Glyph(); glyph.AddArea(symColor, new SymPathWithHoles(pathLeft, null)); glyph.AddArea(symColor, new SymPathWithHoles(pathRight, null)); glyph.ConstructionComplete(); PointSymDef symdef = new PointSymDef("Move control target", "781", glyph, false); map.AddSymdef(symdef); // should not be visible, we only use the highlight part in actual usages. // the map part is very useful for testing, though. map.SetSymdefVisible(symdef, false); return symdef; }
protected override SymDef CreateSymDef(Map map, SymColor symColor) { PointKind[] kinds = { PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal, PointKind.Normal }; PointF[] coords = ScaleCoords((PointF[]) outlineCoords.Clone()); SymPath path = new SymPath(coords, kinds); Glyph glyph = new Glyph(); glyph.AddArea(symColor, new SymPathWithHoles(path, null)); glyph.ConstructionComplete(); PointSymDef symdef = new PointSymDef("First aid post", "712", glyph, false); symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.FirstAid_OcadToolbox); map.AddSymdef(symdef); return symdef; }