• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 14083457468

26 Mar 2025 12:37PM UTC coverage: 76.338% (+0.2%) from 76.127%
14083457468

Pull #211

github

web-flow
Merge 48899a8f3 into c902191a1
Pull Request #211: Cad to svg

5534 of 7958 branches covered (69.54%)

Branch coverage included in aggregate %.

247 of 293 new or added lines in 7 files covered. (84.3%)

22 existing lines in 2 files now uncovered.

21914 of 27998 relevant lines covered (78.27%)

74980.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.75
/src/ACadSharp/Entities/TextEntity.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Tables;
3
using CSMath;
4
using System;
5

6
namespace ACadSharp.Entities
7
{
8
        /// <summary>
9
        /// Represents a <see cref="TextEntity"/>
10
        /// </summary>
11
        /// <remarks>
12
        /// Object name <see cref="DxfFileToken.EntityText"/> <br/>
13
        /// Dxf class name <see cref="DxfSubclassMarker.Text"/>
14
        /// </remarks>
15
        [DxfName(DxfFileToken.EntityText)]
16
        [DxfSubClass(DxfSubclassMarker.Text)]
17
        public class TextEntity : Entity, IText
18
        {
19
                /// <inheritdoc/>
20
                public override ObjectType ObjectType => ObjectType.TEXT;
17✔
21

22
                /// <inheritdoc/>
23
                public override string ObjectName => DxfFileToken.EntityText;
1,027✔
24

25
                /// <inheritdoc/>
26
                public override string SubclassMarker => DxfSubclassMarker.Text;
126,610✔
27

28
                /// <summary>
29
                /// Specifies the distance a 2D object is extruded above or below its elevation.
30
                /// </summary>
31
                [DxfCodeValue(39)]
32
                public double Thickness { get; set; } = 0.0;
25,410✔
33

34
                /// <inheritdoc/>
35
                [DxfCodeValue(10, 20, 30)]
36
                public XYZ InsertPoint { get; set; } = XYZ.Zero;
121,339✔
37

38
                /// <inheritdoc/>
39
                [DxfCodeValue(40)]
40
                public double Height
41
                {
42
                        get => _height;
963✔
43
                        set
44
                        {
20,539✔
45
                                if (value < 0)
20,539!
UNCOV
46
                                        throw new ArgumentOutOfRangeException("Height value cannot be negative.");
×
47
                                else
48
                                        this._height = value;
20,539✔
49
                        }
20,539✔
50
                }
51

52
                /// <inheritdoc/>
53
                /// <value>
54
                /// The maximum length is 256 characters.
55
                /// </value>
56
                [DxfCodeValue(1)]
57
                public string Value
58
                {
59
                        get
60
                        {
963✔
61
                                return _value;
963✔
62
                        }
963✔
63
                        set
64
                        {
20,516✔
65
                                if (value.Length > 256)
20,516!
UNCOV
66
                                        throw new ArgumentException($"Text length cannot be supiror than 256, current: {value.Length}");
×
67
                                else
68
                                        this._value = value;
20,516✔
69
                        }
20,516✔
70
                }
71

72
                /// <summary>
73
                /// Specifies the rotation angle for the object.
74
                /// </summary>
75
                /// <value>
76
                /// The rotation angle in radians.
77
                /// </value>
78
                [DxfCodeValue(DxfReferenceType.IsAngle, 50)]
79
                public double Rotation { get; set; }
2,164✔
80

81
                /// <summary>
82
                /// Relative X scale factor—widt
83
                /// </summary>
84
                /// <remarks>
85
                /// This value is also adjusted when fit-type text is used
86
                /// </remarks>
87
                [DxfCodeValue(DxfReferenceType.Optional, 41)]
88
                public double WidthFactor { get; set; } = 1.0;
22,229✔
89

90
                /// <summary>
91
                /// Specifies the oblique angle of the object.
92
                /// </summary>
93
                /// <value>
94
                /// The angle in radians within the range of -85 to +85 degrees. A positive angle denotes a lean to the right; a negative value will have 2*PI added to it to convert it to its positive equivalent.
95
                /// </value>
96
                [DxfCodeValue(DxfReferenceType.IsAngle, 51)]
97
                public double ObliqueAngle { get; set; } = 0.0;
22,228✔
98

99
                /// <inheritdoc/>
100
                [DxfCodeValue(DxfReferenceType.Name | DxfReferenceType.Optional, 7)]
101
                public TextStyle Style
102
                {
103
                        get { return this._style; }
41,259✔
104
                        set
105
                        {
7,620✔
106
                                if (value == null)
7,620!
UNCOV
107
                                {
×
UNCOV
108
                                        throw new ArgumentNullException(nameof(value));
×
109
                                }
110

111
                                if (this.Document != null)
7,620✔
112
                                {
6,729✔
113
                                        this._style = this.updateTable(value, this.Document.TextStyles);
6,729✔
114
                                }
6,729✔
115
                                else
116
                                {
891✔
117
                                        this._style = value;
891✔
118
                                }
891✔
119
                        }
7,620✔
120
                }
121

122
                /// <summary>
123
                /// Mirror flags.
124
                /// </summary>
125
                [DxfCodeValue(71)]
126
                public TextMirrorFlag Mirror { get; set; } = TextMirrorFlag.None;
22,288✔
127

128
                /// <summary>
129
                /// Horizontal text justification type.
130
                /// </summary>
131
                [DxfCodeValue(72)]
132
                public TextHorizontalAlignment HorizontalAlignment { get; set; } = TextHorizontalAlignment.Left;
22,365✔
133

134
                /// <summary>
135
                /// Second alignment point (in OCS).
136
                /// </summary>
137
                /// <remarks>
138
                /// This value is meaningful only if the value of a 72 or 73 group is nonzero (if the justification is anything other than baseline/left)
139
                /// </remarks>
140
                [DxfCodeValue(DxfReferenceType.Optional, 11, 21, 31)]
141
                public XYZ AlignmentPoint { get; set; }
6,774✔
142

143
                /// <summary>
144
                /// Specifies the three-dimensional normal unit vector for the object.
145
                /// </summary>
146
                [DxfCodeValue(210, 220, 230)]
147
                public XYZ Normal { get; set; } = XYZ.AxisZ;
26,362✔
148

149
                /// <summary>
150
                /// Vertical text justification type.
151
                /// </summary>
152
                [DxfCodeValue(DxfReferenceType.Optional, 73)]
153
                public virtual TextVerticalAlignmentType VerticalAlignment { get; set; } = TextVerticalAlignmentType.Baseline;
21,794✔
154

155
                private string _value = string.Empty;
20,544✔
156

157
                private double _height = 1.0;
20,544✔
158

159
                private TextStyle _style = TextStyle.Default;
20,544✔
160

161
                public TextEntity() : base() { }
61,632✔
162

163
                /// <inheritdoc/>
164
                public override BoundingBox GetBoundingBox()
165
                {
7✔
166
                        return new BoundingBox(this.InsertPoint);
7✔
167
                }
7✔
168

169
                /// <inheritdoc/>
170
                public override CadObject Clone()
171
                {
136✔
172
                        TextEntity clone = (TextEntity)base.Clone();
136✔
173
                        clone.Style = (TextStyle)this.Style.Clone();
136✔
174
                        return clone;
136✔
175
                }
136✔
176

177
                internal override void AssignDocument(CadDocument doc)
178
                {
12,236✔
179
                        base.AssignDocument(doc);
12,236✔
180

181
                        this._style = this.updateTable(this.Style, doc.TextStyles);
12,236✔
182

183
                        doc.DimensionStyles.OnRemove += this.tableOnRemove;
12,236✔
184
                }
12,236✔
185

186
                internal override void UnassignDocument()
187
                {
434✔
188
                        this.Document.DimensionStyles.OnRemove -= this.tableOnRemove;
434✔
189

190
                        base.UnassignDocument();
434✔
191

192
                        this.Style = (TextStyle)this.Style.Clone();
434✔
193
                }
434✔
194

195
                protected override void tableOnRemove(object sender, CollectionChangedEventArgs e)
UNCOV
196
                {
×
UNCOV
197
                        base.tableOnRemove(sender, e);
×
198

199
                        if (e.Item.Equals(this.Style))
×
UNCOV
200
                        {
×
201
                                this.Style = this.Document.TextStyles[TextStyle.DefaultName];
×
202
                        }
×
203
                }
×
204
        }
205
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc