Exemplo n.º 1
0
Arquivo: SymDef.cs Projeto: jonc/carto
 // A dependent symdef is removed
 internal void RemoveDependentSymdef(SymDef symdef)
 {
     Debug.Assert(symdef.DependsOnSymdef == this);
     dependentSymdefs.Remove(symdef);
 }
Exemplo n.º 2
0
Arquivo: Map.cs Projeto: jonc/carto
        // Set if a symdef is visible.
        public void SetSymdefVisible(SymDef symdef, bool isVisible)
        {
            CheckWritable();
            Debug.Assert(symdefs.Contains(symdef));

            hiddenSymbols[symdef] = isVisible;
        }
Exemplo n.º 3
0
Arquivo: SymDef.cs Projeto: jonc/carto
        // A new dependent symdef is added.
        internal void AddDependentSymdef(SymDef symdef)
        {
            Debug.Assert(symdef.DependsOnSymdef == this);

            dependentSymdefs.Add(symdef);
        }
Exemplo n.º 4
0
Arquivo: Map.cs Projeto: jonc/carto
        // Decide if a symdef is visible.
        public bool IsSymdefVisible(SymDef symdef)
        {
            bool isVisible;

            CheckReadable();
            Debug.Assert(symdefs.Contains(symdef));

            // Not present in the hiddenSymbols dictionary means it is visible.
            if (hiddenSymbols.TryGetValue(symdef, out isVisible) && !isVisible)
                return false;
            else
                return true;
        }
Exemplo n.º 5
0
Arquivo: Map.cs Projeto: jonc/carto
        // Remove a symdef from the map. The symdef must not be in use by any symbol.
        public void RemoveSymdef(SymDef symdef)
        {
            CheckWritable();
            Debug.Assert(symdef.symbols.Count == 0); // No symbols may be used this symdef.
            Debug.Assert(symdef.dependentSymdefs.Count == 0); // No symdefs may be dependent on this symdef.

            if (symdef.DependsOnSymdef != null)
                symdef.DependsOnSymdef.RemoveDependentSymdef(symdef);

            symdefs.Remove(symdef);
            symdefsDirty = true;
        }
Exemplo n.º 6
0
Arquivo: Map.cs Projeto: jonc/carto
        public void AddSymdef(SymDef symdef)
        {
            CheckWritable();
            symdefs.Add(symdef);
            symdef.SetMap(this);

            if (symdef.DependsOnSymdef != null) {
                Debug.Assert(symdef.DependsOnSymdef.ContainingMap == this);
                symdef.DependsOnSymdef.AddDependentSymdef(symdef);
            }

            symdefsDirty = true;
        }
Exemplo n.º 7
0
        // Mark a symdef as non-renderable. This won't necessarily cause the user to be notified, only if the symbols that use
        // that symdef actually occur.
        void SymdefIsNotRenderable(SymDef symdef, string reason)
        {
            if (!nonRenderableSymdefs.ContainsKey(symdef))
                nonRenderableSymdefs[symdef] = new List<string>();

            nonRenderableSymdefs[symdef].Add(reason);
        }
Exemplo n.º 8
0
        // An object of a specific symdef is not renderable for an object-specific reason. Use SymdefIsNotRenderable if all
        // objects of this symdef are not renderable. If no symdef, use null.
        private void SymbolNotRenderable(string reason, SymDef symdef)
        {
            string s;
            if (symdef == null) {
                s = reason + " (";
            }
            else if (map.IsSymdefVisible(symdef)) {
                s = String.Format("{0} ({1}.{2}:{3}, ", reason, symdef.OcadID / 1000, symdef.OcadID % 1000, symdef.Name);
            }
            else {
                return;     // invisible symbol, this is renderable.
            }

            if (nonRenderableObjects.ContainsKey(s))
                nonRenderableObjects[s] += 1;
            else
                nonRenderableObjects[s] = 1;
        }
Exemplo n.º 9
0
        // Fill in common parts of the OcadSymbol class: except Size, Otp, SymTp, Extent
        void FillInCommonSymdef(OcadSymbol symbol, SymDef symdef)
        {
            symbol.Sym = ConvertSymdefId(symdef.OcadID);
            symbol.Selected = false;
            symbol.Status = 0;
            symbol.FilePos = 0;

            List<short> colorsUsed = new List<short>(2);

            foreach (SymColor symcolor in map.AllColors) {
                if (symdef.HasColor(symcolor)) {
                    int colorid = NumberOfColor(symcolor);
                    symbol.ColorSet[colorid / 8] |= (byte) (1 << (colorid % 8));

                    if (version >= 9)
                        colorsUsed.Add((short) colorid);
                }
            }

            if (version >= 9) {
                symbol.nColors = (short) colorsUsed.Count;
                symbol.ColorsUsed = colorsUsed.ToArray();
                mapSymdefToSingleColor[symdef] = (colorsUsed.Count) == 1 ? colorsUsed[0] : (short) -1;     // if this symdef is single-color, save that away for use in writing the objects.
            }

            symbol.Description = symdef.Name;
            #if false
            symbol.IconBits = new byte[version <= 8 ? 264 : 22 * 22];
            #else
            symbol.IconBits = ImageToOcadIcon(symdef.ToolboxImage, version);
            #endif
            if (version == 8)
                symbol.Flags |= 2;

            if (!map.IsSymdefVisible(symdef)) {
                // Symbol is hidden.
                symbol.Status = 2;
            }
        }
Exemplo n.º 10
0
 void WriteSymbolDef(SymDef symdef)
 {
     if (symdef is LineSymDef) {
         WriteLineSymDef(symdef as LineSymDef);
     }
     else if (symdef is PointSymDef) {
         WritePointSymDef(symdef as PointSymDef);
     }
     else if (symdef is AreaSymDef) {
         WriteAreaSymDef(symdef as AreaSymDef);
     }
     else if (symdef is TextSymDef) {
         WriteTextSymDef(symdef as TextSymDef);
     }
     else {
         Debug.Fail("Unknownsymdef kind");
     }
 }