Esempio n. 1
0
        // Test for rendering into a map.

        // Render one course object to a map.
        internal Map RenderSymbolToMap(Symbol sym, float boxSize)
        {
            Map map = new Map(new GDIPlus_TextMetrics(), null);

            using (map.Write()) {
                //Dictionary<object, SymDef> dict = new Dictionary<object, SymDef>();
                SymColor    symColor = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false);
                PointSymDef symdef   = sym.CreateSymdef(map, symColor, boxSize);
                PointSymbol symbol   = new PointSymbol(symdef, new PointF(0, 0), 0, null);
                map.AddSymbol(symbol);
            }
            return(map);
        }
Esempio n. 2
0
        // Create a point symbol that can be used to put this symbol onto a map inside
        // a box of the given size (in mm).
        public PointSymDef CreateSymdef(Map map, SymColor color, float boxSize)
        {
            Glyph glyph = new Glyph();

            for (int i = 0; i < strokes.Length; ++i)
            {
                strokes[i].AddToMapGlyph(glyph, color, boxSize);
            }
            glyph.ConstructionComplete();

            // Find a free OCAD ID number.
            string symbolId = map.GetFreeSymbolId(800);

            // Create the symdef
            PointSymDef symdef;

            symdef = new PointSymDef("Description: " + this.GetName(Util.CurrentLangName()), symbolId, glyph, false);

            // Create the toolbox image.
            Bitmap bm = new Bitmap(24, 24);

            using (Graphics g = Graphics.FromImage(bm)) {
                g.Clear(Color.White);
                g.SmoothingMode = SmoothingMode.AntiAlias;
                if (kind >= 'T')
                {
                    g.SetClip(new RectangleF(0, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(0, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                    g.SetClip(new RectangleF(bm.Width / 2, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(-bm.Width * 5F / 3F, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                }
                else
                {
                    Draw(g, Color.Black, new RectangleF(0, 0, bm.Width, bm.Height));
                }
            }
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(bm);

            // Add the symdef to the map.
            map.AddSymdef(symdef);

            return(symdef);
        }
Esempio n. 3
0
        // Create a point symbol that can be used to put this symbol onto a map inside
        // a box of the given size (in mm).
        public PointSymDef CreateSymdef(Map map, SymColor color, float boxSize)
        {
            Glyph glyph = new Glyph();
            for (int i = 0; i < strokes.Length; ++i)
                strokes[i].AddToMapGlyph(glyph, color, boxSize);
            glyph.ConstructionComplete();

            // Find a free OCAD ID number.
            string symbolId = map.GetFreeSymbolId(800);

            // Create the symdef
            PointSymDef symdef;
            symdef = new PointSymDef("Description: " + this.GetName(Util.CurrentLangName()), symbolId, glyph, false);

            // Create the toolbox image.
            Bitmap bm = new Bitmap(24, 24);
            using (Graphics g = Graphics.FromImage(bm)) {
                g.Clear(Color.White);
                g.SmoothingMode = SmoothingMode.AntiAlias;
                if (kind >= 'T') {
                    g.SetClip(new RectangleF(0, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(0, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                    g.SetClip(new RectangleF(bm.Width / 2, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(- bm.Width * 5F / 3F, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                }
                else {
                    Draw(g, Color.Black, new RectangleF(0, 0, bm.Width, bm.Height));
                }
            }
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(bm);

            // Add the symdef to the map.
            map.AddSymdef(symdef);

            return symdef;
        }
Esempio n. 4
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;
        }
Esempio n. 5
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;
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }
Esempio n. 9
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;
        }
Esempio n. 10
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;
        }
Esempio n. 11
0
        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;
        }
Esempio n. 12
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, (5.35F * scaleRatio * appearance.controlCircleSize - NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth));
            glyph.AddCircle(symColor, new PointF(0.0F, 0.0F), NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, 7.0F * scaleRatio * appearance.controlCircleSize);
            glyph.ConstructionComplete();

            PointSymDef symdef = new PointSymDef("Finish", "706", glyph, false);
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Finish_OcadToolbox);
            map.AddSymdef(symdef);
            return symdef;
        }