Esempio n. 1
0
 public Leader(ToleranceEntry tolerance, IEnumerable <Vector2> vertexes, DimensionStyle style)
     : base(EntityType.Leader, DxfObjectCode.Leader)
 {
     if (vertexes == null)
     {
         throw new ArgumentNullException(nameof(vertexes));
     }
     this.vertexes = new List <Vector2>(vertexes);
     if (this.vertexes.Count < 2)
     {
         throw new ArgumentOutOfRangeException(nameof(vertexes), this.vertexes.Count, "The leader vertexes list requires at least two points.");
     }
     if (style == null)
     {
         throw new ArgumentNullException(nameof(style));
     }
     this.style          = style;
     this.hasHookline    = false;
     this.showArrowhead  = true;
     this.pathType       = LeaderPathType.StraightLineSegements;
     this.lineColor      = AciColor.ByLayer;
     this.elevation      = 0.0;
     this.offset         = Vector2.Zero;
     this.styleOverrides = new DimensionStyleOverrideDictionary();
     this.styleOverrides.BeforeAddItem    += this.StyleOverrides_BeforeAddItem;
     this.styleOverrides.AddItem          += this.StyleOverrides_AddItem;
     this.styleOverrides.BeforeRemoveItem += this.StyleOverrides_BeforeRemoveItem;
     this.styleOverrides.RemoveItem       += this.StyleOverrides_RemoveItem;
     this.annotation = this.BuildAnnotation(tolerance);
     this.annotation.AddReactor(this);
 }
Esempio n. 2
0
 private Tolerance BuildAnnotation(ToleranceEntry tolerance)
 {
     return(new Tolerance(tolerance, this.vertexes[this.vertexes.Count - 1])
     {
         Color = this.style.TextColor.IsByBlock ? AciColor.ByLayer : this.style.TextColor,
         Style = this.style
     });
 }
Esempio n. 3
0
        public Tolerance(ToleranceEntry tolerance, Vector3 position)
            : base(EntityType.Tolerance, DxfObjectCode.Tolerance)
        {
            this.entry1 = tolerance;
            this.entry2 = null;
            this.height = string.Empty;
            this.showProjectedToleranceZoneSymbol = false;
            this.datumIdentifier = string.Empty;

            this.style    = DimensionStyle.Default;
            this.position = position;
            this.rotation = 0.0;
        }
Esempio n. 4
0
 public Tolerance(ToleranceEntry tolerance, Vector2 position)
     : this(tolerance, new Vector3(position.X, position.Y, 0.0))
 {
 }
Esempio n. 5
0
 public Tolerance(ToleranceEntry tolerance)
     : this(tolerance, Vector3.Zero)
 {
 }
Esempio n. 6
0
        private static ToleranceEntry ParseToleranceEntry(string line)
        {
            string[] values = Regex.Split(line, "%%v");

            ToleranceGeometricSymbol geom = ToleranceGeometricSymbol.None;
            ToleranceValue           t1   = null;
            ToleranceValue           t2   = null;
            DatumReferenceValue      d1   = null;
            DatumReferenceValue      d2   = null;
            DatumReferenceValue      d3   = null;

            if (!string.IsNullOrEmpty(values[0]))
            {
                if (values[0].StartsWith("{"))
                {
                    // geometric symbol
                    CharEnumerator chars  = values[0].GetEnumerator();
                    char           symbol = Symbol(chars);
                    geom = ParseGeometricSymbol(symbol);
                }
            }

            for (int i = 1; i < values.Length; i++)
            {
                string value = values[i];

                switch (i)
                {
                case 1:
                    t1 = ParseToleranceValue(value);
                    break;

                case 2:
                    t2 = ParseToleranceValue(value);
                    break;

                case 3:
                    d1 = ParseDatumReferenceValue(value);
                    break;

                case 4:
                    d2 = ParseDatumReferenceValue(value);
                    break;

                case 5:
                    d3 = ParseDatumReferenceValue(value);
                    break;

                default:
                    throw new FormatException("The tolerance string representation is not well formatted");
                }
            }

            ToleranceEntry t = new ToleranceEntry
            {
                GeometricSymbol = geom,
                Tolerance1      = t1,
                Tolerance2      = t2,
                Datum1          = d1,
                Datum2          = d2,
                Datum3          = d3
            };

            return(t);
        }
Esempio n. 7
0
        private static string ToleranceEntryToString(ToleranceEntry entry)
        {
            StringBuilder value = new StringBuilder();

            switch (entry.GeometricSymbol)
            {
            case ToleranceGeometricSymbol.None:
                break;

            case ToleranceGeometricSymbol.Position:
                value.Append("{\\Fgdt;j}");
                break;

            case ToleranceGeometricSymbol.Concentricity:
                value.Append("{\\Fgdt;r}");
                break;

            case ToleranceGeometricSymbol.Symmetry:
                value.Append("{\\Fgdt;i}");
                break;

            case ToleranceGeometricSymbol.Parallelism:
                value.Append("{\\Fgdt;f}");
                break;

            case ToleranceGeometricSymbol.Perpendicularity:
                value.Append("{\\Fgdt;b}");
                break;

            case ToleranceGeometricSymbol.Angularity:
                value.Append("{\\Fgdt;a}");
                break;

            case ToleranceGeometricSymbol.Cylindricity:
                value.Append("{\\Fgdt;g}");
                break;

            case ToleranceGeometricSymbol.Flatness:
                value.Append("{\\Fgdt;c}");
                break;

            case ToleranceGeometricSymbol.Roundness:
                value.Append("{\\Fgdt;e}");
                break;

            case ToleranceGeometricSymbol.Straightness:
                value.Append("{\\Fgdt;u}");
                break;

            case ToleranceGeometricSymbol.ProfileSurface:
                value.Append("{\\Fgdt;d}");
                break;

            case ToleranceGeometricSymbol.ProfileLine:
                value.Append("{\\Fgdt;k}");
                break;

            case ToleranceGeometricSymbol.CircularRunout:
                value.Append("{\\Fgdt;h}");
                break;

            case ToleranceGeometricSymbol.TotalRunOut:
                value.Append("{\\Fgdt;t}");
                break;
            }

            value.Append(ToleranceValueToString(entry.Tolerance1));
            value.Append(ToleranceValueToString(entry.Tolerance2));
            value.Append(DatumValueToString(entry.Datum1));
            value.Append(DatumValueToString(entry.Datum2));
            value.Append(DatumValueToString(entry.Datum3));

            return(value.ToString());
        }
Esempio n. 8
0
        public static Tolerance ParseRepresentation(string s)
        {
            string[] lines = Regex.Split(s, "\\^J");

            ToleranceEntry t1              = null;
            ToleranceEntry t2              = null;
            string         height          = string.Empty;
            bool           showProjSymbol  = false;
            string         datumIdentifier = string.Empty;

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                if (line.StartsWith("{") || line.StartsWith("%%v"))
                {
                    switch (i)
                    {
                    case 0:
                        t1 = ParseToleranceEntry(line);
                        break;

                    case 1:
                        t2 = ParseToleranceEntry(line);
                        break;
                    }
                }
                else
                {
                    if (i == lines.Length - 1)
                    {
                        datumIdentifier = line;
                    }
                    else
                    {
                        StringBuilder value = new StringBuilder();

                        CharEnumerator chars = line.GetEnumerator();
                        while (chars.MoveNext())
                        {
                            char token = chars.Current;
                            if (token == '{')
                            {
                                char symbol = Symbol(chars);
                                if (symbol == 'p')
                                {
                                    showProjSymbol = true;
                                }
                            }
                            else
                            {
                                value.Append(token);
                            }
                        }
                        height = value.ToString();
                    }
                }
            }

            Tolerance tolerance = new Tolerance
            {
                Entry1 = t1,
                Entry2 = t2,
                Height = height,
                ShowProjectedToleranceZoneSymbol = showProjSymbol,
                DatumIdentifier = datumIdentifier
            };

            return(tolerance);
        }
Esempio n. 9
0
 public Leader(ToleranceEntry tolerance, IEnumerable <Vector2> vertexes)
     : this(tolerance, vertexes, DimensionStyle.Default)
 {
 }