// A rectange symdef is just a line symdef, but additional information is cached away. SymDef CreateRectangleSymdef(string name, int ocadID, OcadRectSymbol ocadSym) { // A rectangle symdef is just a line symbol with an additional RectangleInfo. SymColor color = GetColor(ocadSym.LineColor); float width = ToWorldDimensions(ocadSym.LineWidth); LineSymDef symdef = new LineSymDef(name, ocadID, color, width, ocadSym.Radius > 0 ? LineStyle.Rounded : LineStyle.Mitered); RectangleInfo rectinfo = new RectangleInfo(); rectinfo.cornerRadius = ToWorldDimensions(ocadSym.Radius); if ((ocadSym.GridFlags & 1) != 0) { // we have a grid. rectinfo.grid = true; CreateRectangleGridSymdefs(name, color, out rectinfo.gridLines, out rectinfo.gridText); rectinfo.numberFromBottom = ((ocadSym.GridFlags & 4) != 0) ? true: false; rectinfo.cellWidth = ToWorldDimensions(ocadSym.CellWidth); rectinfo.cellHeight = ToWorldDimensions(ocadSym.CellHeight); rectinfo.unnumberedCells = ocadSym.UnnumCells; rectinfo.unnumberedText = ocadSym.UnnumText; } // remember the rectangle info for later use in creating the symbol. rectangleInfos[ocadID] = rectinfo; return symdef; }
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; }