Beispiel #1
0
        SymDef CreateLineSymdef(string name, int ocadID, OcadLineSymbol ocadSym)
        {
            float width = ToWorldDimensions(ocadSym.LineWidth);

            SymColor color = null;
            if (width > 0)
                color = GetColor(ocadSym.LineColor);

            LineStyle lineStyle = ImportLineStyle((short) ocadSym.LineEnds);

            LineSymDef symdef = new LineSymDef(name, ocadID, color, width, lineStyle);

            if (ocadSym.DistFromStart != 0 || ocadSym.DistToEnd != 0) {
                LineSymDef.ShortenInfo shortenInfo;
                shortenInfo.shortenBeginning = ToWorldDimensions(ocadSym.DistFromStart);
                shortenInfo.shortenEnd = ToWorldDimensions(ocadSym.DistToEnd);
                shortenInfo.pointyEnds = ((ocadSym.LineEnds & 2) != 0);

                symdef.SetShortening(shortenInfo);
            }

            if (ocadSym.FrWidth > 0) {
                SymColor secondColor = GetColor(ocadSym.FrColor);
                float secondWidth = ToWorldDimensions(ocadSym.FrWidth);
                LineStyle secondLineStyle = ImportLineStyle(ocadSym.FrStyle);

                symdef.SetSecondLine(secondColor, secondWidth, secondLineStyle);
            }

            if (ocadSym.DblMode > 0) {
                LineSymDef.DoubleLineInfo doubleLines;
                if ((ocadSym.DblFlags & 1) != 0) {
                    doubleLines.doubleFillColor = GetColor(ocadSym.DblFillColor);
                }
                else {
                    doubleLines.doubleFillColor = null;
                }

                doubleLines.doubleLeftColor = GetColor(ocadSym.DblLeftColor);
                doubleLines.doubleRightColor = GetColor(ocadSym.DblRightColor);
                doubleLines.doubleThick = ToWorldDimensions(ocadSym.DblWidth);
                doubleLines.doubleLeftWidth = ToWorldDimensions(ocadSym.DblLeftWidth);
                doubleLines.doubleRightWidth = ToWorldDimensions(ocadSym.DblRightWidth);

                if (ocadSym.DblMode > 1) {
                    if (ocadSym.DblMode == 2) {
                        doubleLines.doubleLeftDashed = true;
                        doubleLines.doubleFillDashed = doubleLines.doubleRightDashed = false;
                    }
                    else if (ocadSym.DblMode == 3) {
                        doubleLines.doubleLeftDashed = doubleLines.doubleRightDashed = true;
                        doubleLines.doubleFillDashed = false;
                    }
                    else {
                        doubleLines.doubleFillDashed = doubleLines.doubleLeftDashed = doubleLines.doubleRightDashed = true;
                    }

                    doubleLines.doubleDashes.dashLength = doubleLines.doubleDashes.firstDashLength = doubleLines.doubleDashes.lastDashLength = ToWorldDimensions(ocadSym.DblLength);
                    doubleLines.doubleDashes.gapLength = ToWorldDimensions(ocadSym.DblGap);
                    doubleLines.doubleDashes.minGaps = 1;
                    doubleLines.doubleDashes.secondaryEndGaps = 0;
                    doubleLines.doubleDashes.secondaryEndLength = 0;
                    doubleLines.doubleDashes.secondaryMiddleGaps = 0;
                    doubleLines.doubleDashes.secondaryMiddleLength = 0;
                }
                else {
                    doubleLines.doubleFillDashed = doubleLines.doubleLeftDashed = doubleLines.doubleRightDashed = false;
                    doubleLines.doubleDashes = new LineSymDef.DashInfo();
                }
                symdef.SetDoubleLines(doubleLines);
            }

            if (ocadSym.MainGap > 0 || ocadSym.SecGap > 0) {
                LineSymDef.DashInfo dashInfo = new LineSymDef.DashInfo();

                dashInfo.dashLength = ToWorldDimensions(ocadSym.MainLength);
                dashInfo.firstDashLength = dashInfo.lastDashLength = ToWorldDimensions(ocadSym.EndLength);
                dashInfo.gapLength = ToWorldDimensions(ocadSym.MainGap);
                dashInfo.minGaps = ocadSym.MinSym + 1;

                if (ocadSym.SecGap > 0) {
                    dashInfo.secondaryMiddleGaps = 1;
                    dashInfo.secondaryMiddleLength = ToWorldDimensions(ocadSym.SecGap);
                }
                if (ocadSym.EndGap > 0) {
                    dashInfo.secondaryEndGaps = 1;
                    dashInfo.secondaryEndLength = ToWorldDimensions(ocadSym.EndGap);
                }

                symdef.SetDashInfo(dashInfo);
            }

            int numGlyphs = 0, iGlyph = 0;
            LineSymDef.GlyphInfo[] glyphs = null;

            if (ocadSym.PrimDElts != null && ocadSym.PrimDElts.Length > 0)			++numGlyphs;
            if (ocadSym.SecDElts != null && ocadSym.SecDElts.Length > 0)			++numGlyphs;
            if (ocadSym.CornerDElts != null && ocadSym.CornerDElts.Length > 0)		++numGlyphs;
            if (ocadSym.StartDElts != null && ocadSym.StartDElts.Length > 0)		++numGlyphs;
            if (ocadSym.EndDElts != null && ocadSym.EndDElts.Length > 0)			++numGlyphs;

            if (numGlyphs > 0) {
                glyphs = new LineSymDef.GlyphInfo[numGlyphs];

                if (ocadSym.PrimDElts != null && ocadSym.PrimDElts.Length > 0) {
                    LineSymDef.GlyphInfo glyphInfo = new LineSymDef.GlyphInfo();

                    glyphInfo.glyph = CreateGlyph(ocadSym.PrimDElts);
                    glyphInfo.number = ocadSym.nPrimSym;
                    glyphInfo.spacing = ToWorldDimensions(ocadSym.PrimSymDist);

                    if (ocadSym.DecMode > 0) {
                        glyphInfo.location = LineSymDef.GlyphLocation.SpacedDecrease;
                        glyphInfo.distance = ToWorldDimensions(ocadSym.MainLength + ocadSym.MainGap);
                        glyphInfo.firstDistance = glyphInfo.lastDistance = ToWorldDimensions(ocadSym.EndLength) + (ToWorldDimensions(ocadSym.MainGap) / 2);
                        glyphInfo.minimum = Math.Max(1, ocadSym.MinSym + 1);   // OCAD always does at least one symbol, even if you say zero!
                        glyphInfo.decreaseLimit = (float) ocadSym.DecLast / 100F;
                        glyphInfo.decreaseBothEnds = (ocadSym.DecMode == 2);
                    }
                    else if (width > 0 && ocadSym.MainGap > 0 || ocadSym.SecGap > 0) {
                        glyphInfo.location = LineSymDef.GlyphLocation.GapCenters;
                        glyphInfo.minimum = 1; // OCAD always does at least one symbol, even if you say zero!
                    }
                    else {
                        glyphInfo.location = LineSymDef.GlyphLocation.Spaced;
                        glyphInfo.distance = ToWorldDimensions(ocadSym.MainLength + ocadSym.MainGap);
                        glyphInfo.firstDistance = glyphInfo.lastDistance = ToWorldDimensions(ocadSym.EndLength) + (ToWorldDimensions(ocadSym.MainGap) / 2);
                        glyphInfo.minimum = Math.Max(1, ocadSym.MinSym + 1);   // OCAD always does at least one symbol, even if you say zero!
                    }

                    glyphs[iGlyph++] = glyphInfo;
                }

                if (ocadSym.SecDElts != null && ocadSym.SecDElts.Length > 0) {
                    LineSymDef.GlyphInfo glyphInfo = new LineSymDef.GlyphInfo();
                    glyphInfo.glyph = CreateGlyph(ocadSym.SecDElts);
                    glyphInfo.number = 1;
                    glyphInfo.location = LineSymDef.GlyphLocation.SpacedOffset;
                    glyphInfo.offset = ToWorldDimensions(ocadSym.MainLength) / 2;
                    glyphInfo.distance = ToWorldDimensions(ocadSym.MainLength + ocadSym.MainGap);
                    glyphInfo.firstDistance = glyphInfo.lastDistance = ToWorldDimensions(ocadSym.EndLength) + (ToWorldDimensions(ocadSym.MainGap) / 2);
                    glyphInfo.minimum = Math.Max(1, ocadSym.MinSym + 1);   // OCAD always does at least one symbol, even if you say zero!

                    glyphs[iGlyph++] = glyphInfo;
                }

                if (ocadSym.CornerDElts != null && ocadSym.CornerDElts.Length > 0) {
                    LineSymDef.GlyphInfo glyphInfo = new LineSymDef.GlyphInfo();
                    glyphInfo.glyph = CreateGlyph(ocadSym.CornerDElts);
                    glyphInfo.number = 1;
                    glyphInfo.location = LineSymDef.GlyphLocation.Corners;

                    glyphs[iGlyph++] = glyphInfo;
                }

                if (ocadSym.StartDElts != null && ocadSym.StartDElts.Length > 0) {
                    LineSymDef.GlyphInfo glyphInfo = new LineSymDef.GlyphInfo();
                    glyphInfo.glyph = CreateGlyph(ocadSym.StartDElts);
                    glyphInfo.number = 1;
                    glyphInfo.location = LineSymDef.GlyphLocation.Start;

                    glyphs[iGlyph++] = glyphInfo;
                }

                if (ocadSym.EndDElts != null && ocadSym.EndDElts.Length > 0) {
                    LineSymDef.GlyphInfo glyphInfo = new LineSymDef.GlyphInfo();
                    glyphInfo.glyph = CreateGlyph(ocadSym.EndDElts);
                    glyphInfo.number = 1;
                    glyphInfo.location = LineSymDef.GlyphLocation.End;

                    glyphs[iGlyph++] = glyphInfo;
                }

                symdef.SetGlyphs(glyphs);
            }

            return symdef;
        }
Beispiel #2
0
        float pixelSizeCached; // pixel size in mm that the patternBrushes are created for. (WPF brushes are resolution independent).

        #endif

        #region Constructors

        public AreaSymDef(string name, int ocadID, SymColor color, LineSymDef borderSymdef)
            : base(name, ocadID)
        {
            fillColor = color;
            this.borderSymdef = borderSymdef;
        }
Beispiel #3
0
        // Create the grid lines for a rectangle of the given size with given cellwidth/height and using the
        // line symdef. Transform the points by the given matrix before creating.
        void CreateGridLines(SizeF size, Matrix matrix, int cxCells, int cyCells, float width, float height, LineSymDef symdef, List<Symbol> symlist)
        {
            PointKind[] kinds = { PointKind.Normal, PointKind.Normal };
            PointF[] pts = new PointF[2];

            for (int x = 1; x < cxCells; ++x) {
                pts[0] = new PointF(x * width, 0);
                pts[1] = new PointF(x * width, size.Height);
                pts = GraphicsUtil.TransformPoints(pts, matrix);
                SymPath path = new SymPath(pts, kinds);
                symlist.Add(new LineSymbol(symdef, path));
            }

            for (int y = 1; y < cyCells; ++y) {
                pts[0] = new PointF(0, y * height);
                pts[1] = new PointF(size.Width, y * height);
                pts = GraphicsUtil.TransformPoints(pts, matrix);
                SymPath path = new SymPath(pts, kinds);
                symlist.Add(new LineSymbol(symdef, path));
            }
        }
Beispiel #4
0
        LineSymbol CreateLineSymbol(OcadObject obj, LineSymDef symdef)
        {
            if (symdef == null)
                throw new OcadFileFormatException("Object has unknown or inconsistent symbol type {0}", obj.Sym);

            if (obj.coords == null || obj.coords.Length < 2)
                return null;

            SymPath path = CreateSymPath(obj.coords);

            return new LineSymbol(symdef, path);
        }
Beispiel #5
0
        // 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;
        }
Beispiel #6
0
        // Rectangle symbols may be translated into multiple symbols (if there is a grid).
        Symbol[] CreateRectangleSymbol(OcadObject obj, LineSymDef symdef, RectangleInfo rectinfo)
        {
            List<Symbol> symlist = new List<Symbol>();  // list of symbols we're creating.

            if (symdef == null)
                throw new OcadFileFormatException("Object has unknown or inconsistent symbol type {0}", obj.Sym);

            if (obj.coords == null || obj.coords.Length < 2)
                return null;

            // Create the main rectangle symbol.
            // Determine size of the rectangle, and matrix needed to transform points to their correct location.
            PointF[] pts = {PointFromOcadCoord(obj.coords[0]), PointFromOcadCoord(obj.coords[1]), PointFromOcadCoord(obj.coords[2]), PointFromOcadCoord(obj.coords[3])};
            SizeF size = new SizeF(Util.DistanceF(pts[0], pts[1]), Util.DistanceF(pts[0], pts[3]));
            float angle = Util.Angle(pts[0], pts[1]);
            Matrix matrix = new Matrix();
            matrix.Translate(pts[0].X, pts[0].Y);
            matrix.Rotate(angle);

            SymPath path;
            PointKind[] kinds;
            PointF[] pathpts;
            if (rectinfo.cornerRadius == 0) {
                kinds = new PointKind[] {PointKind.Corner, PointKind.Corner, PointKind.Corner, PointKind.Corner, PointKind.Corner};
                pathpts = new PointF[] { new PointF(0,0), new PointF(0, size.Height), new PointF(size.Width, size.Height),
                                           new PointF(size.Width, 0), new PointF(0,0)};
            }
            else {
                kinds = new PointKind[] {PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl,
                                            PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl,
                                            PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl,
                                            PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl,
                                            PointKind.Normal};
                pathpts = new PointF[] { new PointF(rectinfo.cornerRadius, 0),
                                           new PointF(size.Width - rectinfo.cornerRadius, 0),
                                           new PointF(size.Width - (1-Util.kappa) * rectinfo.cornerRadius, 0),
                                           new PointF(size.Width, (1-Util.kappa) * rectinfo.cornerRadius),
                                           new PointF(size.Width, rectinfo.cornerRadius),
                                           new PointF(size.Width, size.Height - rectinfo.cornerRadius),
                                           new PointF(size.Width, size.Height - (1-Util.kappa) * rectinfo.cornerRadius),
                                           new PointF(size.Width - (1-Util.kappa) * rectinfo.cornerRadius, size.Height),
                                           new PointF(size.Width - rectinfo.cornerRadius, size.Height),
                                           new PointF(rectinfo.cornerRadius, size.Height),
                                           new PointF((1-Util.kappa) * rectinfo.cornerRadius, size.Height),
                                           new PointF(0, size.Height - (1-Util.kappa) * rectinfo.cornerRadius),
                                           new PointF(0, size.Height - rectinfo.cornerRadius),
                                           new PointF(0, rectinfo.cornerRadius),
                                           new PointF(0, (1-Util.kappa) * rectinfo.cornerRadius),
                                           new PointF((1-Util.kappa) * rectinfo.cornerRadius, 0),
                                           new PointF(rectinfo.cornerRadius, 0)};
            }

            pathpts = GraphicsUtil.TransformPoints(pathpts, matrix);
            for (int i = 0; i < pathpts.Length; ++i)
                pathpts[i] = new PointF((float) Math.Round(pathpts[i].X, 2), (float) Math.Round(pathpts[i].Y, 2));   // round to 2 decimals, so round trip to OCAD without change.
            path = new SymPath(pathpts, kinds);
            symlist.Add(new LineSymbol(symdef, path));

            if (rectinfo.grid) {
                if (size.Width > 0 && size.Height > 0) {
                    int cxCells = (int) Math.Round(size.Width / rectinfo.cellWidth);
                    if (cxCells < 1)
                        cxCells = 1;
                    int cyCells = (int) Math.Round(size.Height / rectinfo.cellHeight);
                    if (cyCells < 1)
                        cyCells = 1;

                    float width = size.Width / cxCells;
                    float height = size.Height / cyCells;

                    CreateGridLines(size, matrix, cxCells, cyCells, width, height, rectinfo.gridLines, symlist);
                    CreateGridText(size, matrix, angle, cxCells, cyCells, width, height, rectinfo, symlist);
                }
            }

            return symlist.ToArray();
        }
Beispiel #7
0
 // If a rectangle symbol include a grid, then we create extra line and text symbols
 // to handle the grid and numbers in the grid.
 void CreateRectangleGridSymdefs(string name, SymColor color, out LineSymDef lineSymdef, out TextSymDef textSymdef)
 {
     // UNDONE: Really should check that a real
     // UNDONE: symbol isn't using these ids, or that there aren't already synthetic symbols that match.
     lineSymdef = new LineSymDef(name + " grid lines", ocadIdNext++, color, 0.15F, LineStyle.Beveled);
     textSymdef = new TextSymDef(name + " grid text", ocadIdNext++);
     textSymdef.SetFont("Arial", 15F / 72F * 25.4F, true, false, color, 0, 0, 0, 0, null, 0, 1F, TextSymDefAlignment.Left);
     map.AddSymdef(lineSymdef);
     map.AddSymdef(textSymdef);
 }
Beispiel #8
0
        void WriteLineSymDef(LineSymDef symdef)
        {
            OcadLineSymbol symbol = new OcadLineSymbol();
            FillInCommonSymdef(symbol, symdef);

            symbol.Otp = 2;
            symbol.SymTp = 0;
            symbol.Extent = (short) ToOcadDimensions(symdef.MaxThickness / 2);
            symbol.LineColor = symdef.LineColor != null ? (short) NumberOfColor(symdef.LineColor) : (short)0;
            symbol.LineWidth = (short) ToOcadDimensions(symdef.LineThickness);
            symbol.DistFromStart = 0;
            symbol.DistToEnd = 0;
            symbol.LineEnds = (ushort) OcadLineStyle(symdef.MainLineStyle);

            LineSymDef.GlyphInfo[] glyphs = symdef.Glyphs;
            int startGlyphIndex = -1, endGlyphIndex = -1, cornerGlyphIndex = -1;
            int dashCenteredGlyphIndex = -1, gapCenteredGlyphIndex = -1, spacedGlyphIndex = -1, spacedOffsetGlyphIndex = -1;
            int primGlyphIndex = -1, secondaryGlyphIndex = -1;

            if (glyphs != null) {
                for (int i = 0; i < glyphs.Length; ++i) {
                    // UNDONE: give warning if more than one glyph of a certain type
                    switch (glyphs[i].location) {
                    case LineSymDef.GlyphLocation.Corners:			cornerGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.DashCenters:		dashCenteredGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.MiddleDashCenters:		secondaryGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.End:				endGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.GapCenters:		gapCenteredGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.Spaced: spacedGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.SpacedDecrease: spacedGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.SpacedOffset: spacedOffsetGlyphIndex = i; break;
                    case LineSymDef.GlyphLocation.Start: startGlyphIndex = i; break;
                    }
                }
            }

            LineSymDef.DashInfo dashInfo = new LineSymDef.DashInfo();
            if (symdef.IsDashed) {
                dashInfo = symdef.Dashes;
                symbol.MainLength = (short) ToOcadDimensions(dashInfo.dashLength);
                symbol.EndLength = (short) ToOcadDimensions(dashInfo.firstDashLength);
                symbol.MainGap = (short) ToOcadDimensions(dashInfo.gapLength);
                symbol.MinSym = (short)(dashInfo.minGaps - 1);
                symbol.SecGap = (short) (dashInfo.secondaryMiddleGaps > 0 ? ToOcadDimensions(dashInfo.secondaryMiddleLength) : 0);
                symbol.EndGap = (short) (dashInfo.secondaryEndGaps > 0 ? ToOcadDimensions(dashInfo.secondaryEndLength) : 0);
            }
            else {
                symbol.MainLength = symbol.EndLength = 0;
                symbol.MainGap = symbol.SecGap = 0;
                symbol.MinSym = 0;
            }

            // The primary glyph is the one centered on gaps.
            primGlyphIndex = gapCenteredGlyphIndex;

            if (spacedGlyphIndex >= 0 && glyphs[spacedGlyphIndex].location == LineSymDef.GlyphLocation.SpacedDecrease) {
                // decreasing symbol.
                symbol.MainLength = (short) ToOcadDimensions(glyphs[spacedGlyphIndex].distance);
                symbol.EndLength = (short) ToOcadDimensions(glyphs[spacedGlyphIndex].firstDistance);
                symbol.MinSym = (short) (glyphs[spacedGlyphIndex].minimum - 1);
                symbol.DecMode = glyphs[spacedGlyphIndex].decreaseBothEnds ? (ushort)2 : (ushort)1;
                symbol.DecLast = (short) Math.Round(glyphs[spacedGlyphIndex].decreaseLimit * 100);
                primGlyphIndex = spacedGlyphIndex;
            }
            else if (spacedGlyphIndex >= 0 && (!symdef.IsDashed || symdef.LineThickness == 0)) {
                // the spaced glyph is actually the primary one, since there is no dashes.
                symbol.MainLength = (short) ToOcadDimensions(glyphs[spacedGlyphIndex].distance);
                symbol.EndLength = (short) ToOcadDimensions(glyphs[spacedGlyphIndex].firstDistance);
                symbol.MainGap = 0;
                symbol.SecGap = 0;
                symbol.MinSym = (short) (glyphs[spacedGlyphIndex].minimum - 1);
                primGlyphIndex = spacedGlyphIndex;
            }
            else if (spacedOffsetGlyphIndex >= 0 && (!symdef.IsDashed || symdef.LineThickness == 0)) {
                // the spaced offset glyph is actually the primary one, since there is no dashes.
                symbol.MainLength = (short) ToOcadDimensions(glyphs[spacedOffsetGlyphIndex].distance);
                symbol.EndLength = (short) ToOcadDimensions(glyphs[spacedOffsetGlyphIndex].firstDistance);
                symbol.MainGap = 0;
                symbol.SecGap = 0;
                symbol.MinSym = (short) (glyphs[spacedOffsetGlyphIndex].minimum - 1);
            }
            else if (dashCenteredGlyphIndex >= 0 && gapCenteredGlyphIndex == -1 && symdef.IsDashed && dashInfo.secondaryMiddleGaps == 0 && dashInfo.secondaryEndGaps == 0) {
                // Use the secondary gaps to represent the primary gaps.
                symbol.MinSym += 1;
                symbol.MainLength += symbol.MainGap;
                symbol.SecGap = symbol.MainGap;
                symbol.MainGap = 0;
                symbol.EndLength = (short) ((symbol.MainLength + 1) / 2);
                primGlyphIndex = dashCenteredGlyphIndex;
            }

            if (symdef.HasSecondLine) {
                symbol.FrColor = (short) NumberOfColor(symdef.SecondLineColor);
                symbol.FrWidth = (short) ToOcadDimensions(symdef.SecondThickness);
                symbol.FrStyle =  OcadLineStyle(symdef.SecondLineStyle);
            }

            if (symdef.IsDoubleLine) {
                LineSymDef.DoubleLineInfo doubleInfo = symdef.DoubleLines;

                symbol.DblMode = 1;  // may be changed below.
                symbol.DblWidth = (short) ToOcadDimensions(doubleInfo.doubleThick);

                if (doubleInfo.doubleFillColor != null) {
                    symbol.DblFlags |= 1;
                    symbol.DblFillColor = NumberOfColor(doubleInfo.doubleFillColor);
                }

                if (doubleInfo.doubleLeftColor != null) {
                    symbol.DblLeftColor = NumberOfColor(doubleInfo.doubleLeftColor);
                    symbol.DblLeftWidth = (short) ToOcadDimensions(doubleInfo.doubleLeftWidth);
                }
                if (doubleInfo.doubleRightColor != null) {
                    symbol.DblRightColor = NumberOfColor(doubleInfo.doubleRightColor);
                    symbol.DblRightWidth = (short) ToOcadDimensions(doubleInfo.doubleRightWidth);
                }

                if (doubleInfo.doubleLeftDashed || doubleInfo.doubleRightDashed || doubleInfo.doubleFillDashed) {
                    symbol.DblLength = (short) ToOcadDimensions(doubleInfo.doubleDashes.dashLength);
                    symbol.DblGap = (short) ToOcadDimensions(doubleInfo.doubleDashes.gapLength);

                    if (doubleInfo.doubleFillDashed)
                        symbol.DblMode = 4;
                    else if (doubleInfo.doubleRightDashed)
                        symbol.DblMode = 3;
                    else
                        symbol.DblMode = 2;
                }
            }

            if (symdef.IsShortened) {
                LineSymDef.ShortenInfo shortening = symdef.Shortening;

                symbol.DistFromStart = (short) ToOcadDimensions(shortening.shortenBeginning);
                symbol.DistToEnd = (short) ToOcadDimensions(shortening.shortenEnd);
                if (shortening.pointyEnds)
                    symbol.LineEnds |= 2;
            }

            if (primGlyphIndex >= 0) {
                LineSymDef.GlyphInfo glyph = glyphs[primGlyphIndex];
                symbol.nPrimSym = (short) glyph.number;
                symbol.PrimSymDist = (short) ToOcadDimensions(glyph.spacing);
                symbol.PrimDElts = SymbolEltsFromGlyph(glyph.glyph, out symbol.PrimDSize);
            }
            if (spacedOffsetGlyphIndex >= 0)  // UNDONE: if both secondaryGlyphIndex and spacedOffset, we can only represent one in OCAD.
                symbol.SecDElts = SymbolEltsFromGlyph(glyphs[spacedOffsetGlyphIndex].glyph, out symbol.SecDSize);
            if (secondaryGlyphIndex >= 0)
                symbol.SecDElts = SymbolEltsFromGlyph(glyphs[secondaryGlyphIndex].glyph, out symbol.SecDSize);
            if (startGlyphIndex >= 0)
                symbol.StartDElts = SymbolEltsFromGlyph(glyphs[startGlyphIndex].glyph, out symbol.StartDSize);
            if (endGlyphIndex >= 0)
                symbol.EndDElts = SymbolEltsFromGlyph(glyphs[endGlyphIndex].glyph, out symbol.EndDSize);
            if (cornerGlyphIndex >= 0)
                symbol.CornerDElts = SymbolEltsFromGlyph(glyphs[cornerGlyphIndex].glyph, out symbol.CornerDSize);

            symbol.Write(writer, version);
        }
Beispiel #9
0
 public LineSymbol(LineSymDef def, SymPath path)
 {
     path.CheckConstructed();
     this.def = def; this.path = path;
     boundingBox = def.CalcBounds(path);
 }