Esempio n. 1
0
File: SymDef.cs Progetto: jonc/carto
 // A symbol with the symdef is removed from the map. Remove from the list of symbosl with this symdef.
 internal void RemoveSymbol(Symbol sym)
 {
     Debug.Assert(sym.Definition == this);
     symbols.Remove(sym);
 }
Esempio n. 2
0
File: SymDef.cs Progetto: jonc/carto
        // A new symbol with this symdef is added to the map. Add to the list of symbols with this SymDef.
        internal void AddSymbol(Symbol sym)
        {
            Debug.Assert(sym.Definition == this);

            symbols.Add(sym);
        }
Esempio n. 3
0
File: Map.cs Progetto: jonc/carto
 public void RemoveSymbol(Symbol sym)
 {
     // TODO: should invalidate smaller region of map.
     CheckWritable();
     Debug.Assert(symbols.Contains(sym));
     symbols.Remove(sym);
     sym.Definition.RemoveSymbol(sym);
     sym.SetMap(null);
     SetDirty();
 }
Esempio n. 4
0
File: Map.cs Progetto: jonc/carto
 public void AddSymbol(Symbol sym)
 {
     // TODO: should invalidate smaller region of map.
     CheckWritable();
     symbols.Add(sym);
     sym.SetMap(this);
     sym.Definition.AddSymbol(sym);
     SetDirty();
 }
Esempio n. 5
0
        // Check if a symbol uses a visible, non-renderable symdef. If so, add to the list of non-renderable objects.
        void CheckSymbolRenderable(Symbol sym)
        {
            SymDef symdef = sym.Definition;

            // The symdef is indeed non-renderable. Create a message for each reason.
            if (symdef != null && nonRenderableSymdefs.ContainsKey(symdef)) {
                foreach (string s in nonRenderableSymdefs[symdef]) {
                    SymbolNotRenderable(s, symdef);
                }
            }
        }
Esempio n. 6
0
        // Write a symbol, return nItem + nText.
        int WriteSymbol(Symbol sym, out OcadObject obj)
        {
            obj = new OcadObject();
            obj.Sym = ConvertSymdefId(sym.Definition.OcadID);

            if (sym is PointSymbol) {
                PointSymbol psym = sym as PointSymbol;

                obj.Otp = 1;
                obj.Ang = AngleToOcad(psym.Rotation);
                OcadCoord pointCoord = OcadCoordFromPoint(psym.Location);
                if (psym.Gaps == null) {
                    obj.coords = new OcadCoord[1] { pointCoord };
                }
                else {
                    // object has circle gaps in it.
                    obj.coords = new OcadCoord[1 + psym.Gaps.Length / 2];
                    obj.coords[0] = pointCoord;
                    for (int i = 0; i < psym.Gaps.Length; i += 2) {
                        obj.coords[i / 2 + 1].x = AngleToOcad(psym.Gaps[i]);
                        obj.coords[i / 2 + 1].y = AngleToOcad(psym.Gaps[i + 1]);
                    }
                }
            }
            else if (sym is LineSymbol) {
                LineSymbol lsym = sym as LineSymbol;

                obj.Otp = 2;
                obj.coords = CoordsFromSymPath(lsym.Path);
            }
            else if (sym is GraphicsLineSymbol) {
                GraphicsLineSymbol glsym = sym as GraphicsLineSymbol;

                obj.Sym = -2;
                obj.Otp = 2;
                obj.coords = CoordsFromSymPath(glsym.Path);
                obj.Col = (uint) NumberOfColor(glsym.LineColor);
                obj.LineWidth = (short) ToOcadDimensions(glsym.Thickness);
                obj.DiamFlags = OcadLineStyle(glsym.LineStyle);
            }
            else if (sym is ImageLineSymbol) {
                ImageLineSymbol ilsym = sym as ImageLineSymbol;

                obj.Sym = -3;
                obj.Otp = 2;
                obj.coords = CoordsFromSymPath(ilsym.Path);
                obj.Col = CompressedCMYKFromColor(ilsym.LineColor);
                obj.LineWidth = (short) ToOcadDimensions(ilsym.Thickness);
                obj.DiamFlags = OcadLineStyle(ilsym.LineStyle);
            }
            else if (sym is AreaSymbol) {
                AreaSymbol asym = sym as AreaSymbol;

                obj.Otp = 3;
                obj.coords = CoordsFromSymPathWithHoles(asym.Path);
                obj.Ang = AngleToOcad(asym.Angle);

                // UNDONE: if this symbol has a border and version <=8, need to create additional objects for the border.
            }
            else if (sym is GraphicsAreaSymbol) {
                GraphicsAreaSymbol gasym = sym as GraphicsAreaSymbol;

                obj.Sym = -2;
                obj.Otp = 3;
                obj.coords = CoordsFromSymPathWithHoles(gasym.Path);
                obj.Col = (uint) NumberOfColor(gasym.FillColor);
            }
            else if (sym is ImageAreaSymbol) {
                ImageAreaSymbol iasym = sym as ImageAreaSymbol;

                obj.Sym = -3;
                obj.Otp = 3;
                obj.coords = CoordsFromSymPathWithHoles(iasym.Path);
                obj.Col = CompressedCMYKFromColor(iasym.FillColor);
            }
            else if (sym is TextSymbol) {
                TextSymbol tsym = sym as TextSymbol;

                obj.Otp = (byte) (tsym.Width > 0 ? 5 : 4);
                obj.text = string.Join("\r\n", tsym.Text);
                obj.Ang = AngleToOcad(tsym.Rotation);
                obj.coords = GetTextObjectCoords(tsym);
            }
            else if (sym is LineTextSymbol) {
                LineTextSymbol ltsym = sym as LineTextSymbol;

                obj.Otp = (byte) ((version <= 8) ? 2 : 6);
                obj.text = ltsym.Text;
                obj.Ang = 0;
                obj.coords = CoordsFromSymPath(ltsym.Path);
            }
            else {
                Debug.Fail("Unexpected symbol type");
            }

            // UNDONE: deal with overflow of a short below.
            if (obj.coords != null)
                obj.nItem = (short) (obj.coords.Length);
            if (obj.text != null) {
                if (version >= 9 || obj.Unicode != 0)
                    obj.nText = (short) ((obj.text.Length / 4) + 1);
                else
                    obj.nText = (short) ((obj.text.Length / 8) + 1);
            }

            obj.Write(writer, version);
            return obj.nItem + obj.nText;
        }