• 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

75.0
/src/ACadSharp/Entities/MText.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Tables;
3
using CSMath;
4
using System;
5
using System.Collections;
6

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

23
                /// <inheritdoc/>
24
                public override string ObjectName => DxfFileToken.EntityMText;
1,336✔
25

26
                /// <inheritdoc/>
27
                public override string SubclassMarker => DxfSubclassMarker.MText;
126,038✔
28

29
                /// <summary>
30
                /// A 3D WCS coordinate representing the insertion or origin point.
31
                /// </summary>
32
                [DxfCodeValue(10, 20, 30)]
33
                public XYZ InsertPoint { get; set; } = XYZ.Zero;
57,289✔
34

35
                /// <summary>
36
                /// Specifies the three-dimensional normal unit vector for the object.
37
                /// </summary>
38
                [DxfCodeValue(210, 220, 230)]
39
                public XYZ Normal { get; set; } = XYZ.AxisZ;
16,544✔
40

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

55
                /// <summary>
56
                /// Reference rectangle width.
57
                /// </summary>
58
                [DxfCodeValue(41)]
59
                public double RectangleWidth { get; set; }
12,109✔
60

61
                /// <summary>
62
                /// Reference rectangle height.
63
                /// </summary>
64
                [DxfCodeValue(46)]
65
                public double RectangleHeight { get; set; }
7,722✔
66

67
                /// <summary>
68
                /// Attachment point
69
                /// </summary>
70
                [DxfCodeValue(71)]
71
                public AttachmentPointType AttachmentPoint { get; set; } = AttachmentPointType.TopLeft;
23,329✔
72

73
                /// <summary>
74
                /// Drawing direction
75
                /// </summary>
76
                [DxfCodeValue(72)]
77
                public DrawingDirectionType DrawingDirection { get; set; }
12,104✔
78

79
                /// <inheritdoc/>
80
                [DxfCodeValue(1)]
81
                public string Value { get; set; } = string.Empty;
35,151✔
82

83
                /// <inheritdoc/>
84
                [DxfCodeValue(DxfReferenceType.Name | DxfReferenceType.Optional, 7)]
85
                public TextStyle Style
86
                {
87
                        get { return this._style; }
36,564✔
88
                        set
89
                        {
4,758✔
90
                                if (value == null)
4,758!
91
                                {
×
UNCOV
92
                                        throw new ArgumentNullException(nameof(value));
×
93
                                }
94

95
                                if (this.Document != null)
4,758✔
96
                                {
4,527✔
97
                                        this._style = this.updateTable(value, this.Document.TextStyles);
4,527✔
98
                                }
4,527✔
99
                                else
100
                                {
231✔
101
                                        this._style = value;
231✔
102
                                }
231✔
103
                        }
4,758✔
104
                }
105

106
                /// <inheritdoc/>
107
                [DxfCodeValue(11, 21, 31)]
108
                public XYZ AlignmentPoint { get; set; }
13,047✔
109

110
                /// <summary>
111
                /// Horizontal width of the characters that make up the mtext entity.
112
                /// This value will always be equal to or less than the value of group code 41 
113
                /// </summary>
114
                /// <remarks>
115
                /// read-only, ignored if supplied
116
                /// </remarks>
117
                [DxfCodeValue(DxfReferenceType.Ignored, 42)]
118
                public double HorizontalWidth { get; set; } = 0.9;
11,366✔
119

120
                /// <summary>
121
                /// Vertical height of the mtext entity
122
                /// </summary>
123
                /// <remarks>
124
                /// read-only, ignored if supplied
125
                /// </remarks>
126
                [DxfCodeValue(DxfReferenceType.Ignored, 43)]
127
                public double VerticalHeight { get; set; } = 0.2;
11,366✔
128

129
                /// <summary>
130
                /// Specifies the rotation angle for the object.
131
                /// </summary>
132
                /// <value>
133
                /// The rotation angle in radians.
134
                /// </value>
135
                [DxfCodeValue(DxfReferenceType.IsAngle, 50)]
136
                public double Rotation { get; set; } = 0.0;
11,230✔
137

138
                /// <summary>
139
                /// Mtext line spacing style.
140
                /// </summary>
141
                [DxfCodeValue(73)]
142
                public LineSpacingStyleType LineSpacingStyle { get; set; }
11,458✔
143

144
                /// <summary>
145
                /// Mtext line spacing factor.
146
                /// </summary>
147
                /// <remarks>
148
                /// Percentage of default (3-on-5) line spacing to be applied.Valid values range from 0.25 to 4.00
149
                /// </remarks>
150
                [DxfCodeValue(44)]
151
                public double LineSpacing { get; set; } = 1.0;
22,688✔
152

153
                /// <summary>
154
                /// Background fill setting
155
                /// </summary>
156
                [DxfCodeValue(90)]
157
                public BackgroundFillFlags BackgroundFillFlags { get; set; } = BackgroundFillFlags.None;
18,601✔
158

159
                /// <summary>
160
                /// Determines how much border there is around the text.
161
                /// </summary>
162
                [DxfCodeValue(45)]
163
                public double BackgroundScale { get; set; } = 1.5;
11,621✔
164

165
                /// <summary>
166
                /// Background fill color 
167
                /// </summary>
168
                /// <remarks>
169
                /// Color to use for background fill when group code 90 is 1.
170
                /// </remarks>
171
                [DxfCodeValue(63, 420, 430)]
172
                public Color BackgroundColor { get; set; }
260✔
173

174
                /// <summary>
175
                /// Transparency of background fill color
176
                /// </summary>
177
                [DxfCodeValue(441)]
178
                public Transparency BackgroundTransparency { get; set; }
260✔
179

180
                public TextColumn Column { get; set; } = new TextColumn();
13,416✔
181

182
                public bool IsAnnotative { get; set; } = false;
12,608✔
183

184
                private double _height = 1.0;
11,225✔
185

186
                private TextStyle _style = TextStyle.Default;
11,225✔
187

188
                /// <inheritdoc/>
189
                public MText() : base() { }
33,675✔
190

191
                /// <inheritdoc/>
192
                public override BoundingBox GetBoundingBox()
193
                {
5✔
194
                        return new BoundingBox(this.InsertPoint);
5✔
195
                }
5✔
196

197
                /// <summary>
198
                /// Get the text value separated in lines.
199
                /// </summary>
200
                /// <returns></returns>
201
                public string[] GetTextLines()
UNCOV
202
                {
×
UNCOV
203
                        return this.Value.Split(
×
UNCOV
204
                                new string[] { "\r\n", "\r", "\n" },
×
UNCOV
205
                                StringSplitOptions.None
×
UNCOV
206
                        );
×
UNCOV
207
                }
×
208

209
                /// <inheritdoc/>
210
                public override CadObject Clone()
211
                {
123✔
212
                        MText clone = (MText)base.Clone();
123✔
213

214
                        clone.Style = (TextStyle)(this.Style?.Clone());
123!
215
                        clone.Column = this.Column?.Clone();
123!
216

217
                        return clone;
123✔
218
                }
123✔
219

220
                internal override void AssignDocument(CadDocument doc)
221
                {
11,246✔
222
                        base.AssignDocument(doc);
11,246✔
223

224
                        this._style = this.updateTable(this.Style, doc.TextStyles);
11,246✔
225

226
                        doc.DimensionStyles.OnRemove += this.tableOnRemove;
11,246✔
227
                }
11,246✔
228

229
                internal override void UnassignDocument()
230
                {
70✔
231
                        this.Document.DimensionStyles.OnRemove -= this.tableOnRemove;
70✔
232

233
                        base.UnassignDocument();
70✔
234

235
                        this.Style = (TextStyle)this.Style.Clone();
70✔
236
                }
70✔
237

238
                protected override void tableOnRemove(object sender, CollectionChangedEventArgs e)
UNCOV
239
                {
×
UNCOV
240
                        base.tableOnRemove(sender, e);
×
241

UNCOV
242
                        if (e.Item.Equals(this.Style))
×
UNCOV
243
                        {
×
UNCOV
244
                                this.Style = this.Document.TextStyles[TextStyle.DefaultName];
×
UNCOV
245
                        }
×
UNCOV
246
                }
×
247
        }
248
}
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