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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

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

0.0
/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;
×
21

22
                /// <inheritdoc/>
23
                public override string ObjectName => DxfFileToken.EntityText;
×
24

25
                /// <inheritdoc/>
26
                public override string SubclassMarker => DxfSubclassMarker.Text;
×
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;
×
33

34
                /// <summary>
35
                /// First alignment point(in OCS)
36
                /// </summary>
37
                [DxfCodeValue(10, 20, 30)]
38
                public XYZ InsertPoint { get; set; } = XYZ.Zero;
×
39

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

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

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

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

92
                /// <summary>
93
                /// Specifies the oblique angle of the object.
94
                /// </summary>
95
                /// <value>
96
                /// 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.
97
                /// </value>
98
                [DxfCodeValue(DxfReferenceType.IsAngle, 51)]
99
                public double ObliqueAngle { get; set; } = 0.0;
×
100

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

113
                                if (this.Document != null)
×
114
                                {
×
115
                                        this._style = this.updateTable(value, this.Document.TextStyles);
×
116
                                }
×
117
                                else
118
                                {
×
119
                                        this._style = value;
×
120
                                }
×
121
                        }
×
122
                }
123

124
                /// <summary>
125
                /// Mirror flags.
126
                /// </summary>
127
                [DxfCodeValue(71)]
128
                public TextMirrorFlag Mirror { get; set; } = TextMirrorFlag.None;
×
129

130
                /// <summary>
131
                /// Horizontal text justification type.
132
                /// </summary>
133
                [DxfCodeValue(72)]
134
                public TextHorizontalAlignment HorizontalAlignment { get; set; } = TextHorizontalAlignment.Left;
×
135

136
                /// <summary>
137
                /// Second alignment point (in OCS) 
138
                /// </summary>
139
                /// <remarks>
140
                /// 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)
141
                /// </remarks>
142
                [DxfCodeValue(DxfReferenceType.Optional, 11, 21, 31)]
143
                public XYZ AlignmentPoint { get; set; }
×
144

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

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

157
                private string _value = string.Empty;
×
158

159
                private double _height = 0.0;
×
160

161
                private TextStyle _style = TextStyle.Default;
×
162

163
                public TextEntity() : base() { }
×
164

165
                /// <inheritdoc/>
166
                public override BoundingBox GetBoundingBox()
167
                {
×
168
                        return new BoundingBox(this.InsertPoint);
×
169
                }
×
170

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

179
                internal override void AssignDocument(CadDocument doc)
180
                {
×
181
                        base.AssignDocument(doc);
×
182

183
                        this._style = this.updateTable(this.Style, doc.TextStyles);
×
184

185
                        doc.DimensionStyles.OnRemove += this.tableOnRemove;
×
186
                }
×
187

188
                internal override void UnassignDocument()
189
                {
×
190
                        this.Document.DimensionStyles.OnRemove -= this.tableOnRemove;
×
191

192
                        base.UnassignDocument();
×
193

194
                        this.Style = (TextStyle)this.Style.Clone();
×
195
                }
×
196

197
                protected override void tableOnRemove(object sender, CollectionChangedEventArgs e)
198
                {
×
199
                        base.tableOnRemove(sender, e);
×
200

201
                        if (e.Item.Equals(this.Style))
×
202
                        {
×
203
                                this.Style = this.Document.TextStyles[TextStyle.DefaultName];
×
204
                        }
×
205
                }
×
206
        }
207
}
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