Example #1
0
        void WritePointSymDef(PointSymDef symdef)
        {
            OcadPointSymbol symbol = new OcadPointSymbol();
            FillInCommonSymdef(symbol, symdef);

            symbol.Otp = 1;
            symbol.SymTp = 0;
            symbol.Extent = (short) ToOcadDimensions(symdef.Radius);
            symbol.symbolElts = SymbolEltsFromGlyph(symdef.Glyph, out symbol.DataSize);

            if (symdef.AllowRotation)
                symbol.Flags |= 1;

            symbol.Write(writer, version);
        }
Example #2
0
 SymDef CreatePointSymdef(string name, int ocadID, OcadPointSymbol ocadSym)
 {
     bool allowRotation = ((ocadSym.Flags & 1) != 0);
     Glyph glyph = CreateGlyph(ocadSym.symbolElts);
     return new PointSymDef(name, ocadID, glyph, allowRotation);
 }
Example #3
0
		static public OcadSymbol Read(BinaryReader reader, int version) {

			int Size;
            int Sym = 0;
            short Otp;
            byte SymTp = 0;
            if (version <= 8) {
                Size = reader.ReadInt16();
                Sym = reader.ReadInt16();
                Otp = reader.ReadInt16();
                SymTp = reader.ReadByte();
            }
            else {
                Size = reader.ReadInt32();
                Sym = reader.ReadInt32();
                Otp = reader.ReadByte();
            }

			byte Flags = reader.ReadByte();
			OcadSymbol sym;

            if (Otp == 1) {
                sym = new OcadPointSymbol();
            }
            else if (Otp == 2 && SymTp == 0)
                sym = new OcadLineSymbol();
            else if (Otp == 2 && SymTp == 1)
                sym = new OcadLineTextSymbol();
            else if (Otp == 3)
                sym = new OcadAreaSymbol();
            else if (Otp == 4)
                sym = new OcadTextSymbol();
            else if (Otp == 5 || Otp == 7)
                sym = new OcadRectSymbol();
            else if (Otp == 6)
                sym = new OcadLineTextSymbol();
            else {
                Debug.Assert(false);
                return null;
            }

			sym.Size = Size;
			sym.Sym = Sym;
			sym.Otp = Otp;
			sym.SymTp = SymTp;
			sym.Flags = Flags;
            if (version <= 8)
			    sym.Extent = reader.ReadInt16();
			sym.Selected = (reader.ReadByte() != 0) ? true : false;
			sym.Status = reader.ReadByte();

            if (version <= 8) {
                sym.Tool = reader.ReadInt16();
                sym.FrWidth = reader.ReadInt16();
            }
            else {
                sym.Tool = reader.ReadByte();
                sym.CsMode = reader.ReadByte();
                sym.CsObjType = reader.ReadByte();
                sym.CsCdFlags = reader.ReadByte();
                sym.Extent = reader.ReadInt32();
            }

			sym.FilePos = reader.ReadInt32();

            if (version <= 8) {
                sym.ColorSet = Util.ReadByteArray(reader, 32);
            }
            else {
                sym.Group = reader.ReadInt16();
                sym.nColors = reader.ReadInt16();
                sym.ColorsUsed = new short[sym.nColors];
                for (int i = 0; i < 14; ++i) {
                    short colorId = reader.ReadInt16();
                    if (i < sym.nColors)
                        sym.ColorsUsed[i] = colorId;
                }
            }

			sym.Description = Util.ReadDelphiString(reader, 31);
			sym.IconBits = Util.ReadByteArray(reader, (version <= 8) ? 264 : 484);

			sym.ReadExtra(reader, version);

			return sym;
		}