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

DomCR / ACadSharp / 14084601072

26 Mar 2025 01:32PM UTC coverage: 76.345% (-3.4%) from 79.72%
14084601072

Pull #211

github

web-flow
Merge 070f025e9 into c902191a1
Pull Request #211: Cad to svg

5536 of 7962 branches covered (69.53%)

Branch coverage included in aggregate %.

259 of 305 new or added lines in 8 files covered. (84.92%)

5 existing lines in 2 files now uncovered.

21926 of 28009 relevant lines covered (78.28%)

74951.67 hits per line

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

85.27
/src/ACadSharp/Entities/Entity.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Objects;
3
using ACadSharp.Tables;
4
using CSMath;
5
using System;
6

7
namespace ACadSharp.Entities
8
{
9
        /// <summary>
10
        /// The standard class for a basic CAD entity or a graphical object.
11
        /// </summary>
12
        [DxfSubClass(DxfSubclassMarker.Entity)]
13
        public abstract class Entity : CadObject, IEntity
14
        {
15
                /// <summary>
16
                /// Book color for this entity.
17
                /// </summary>
18
                [DxfCodeValue(DxfReferenceType.Name, 430)]
19
                public BookColor BookColor
20
                {
21
                        get { return this._bookColor; }
24,600✔
22
                        set
23
                        {
255✔
24
                                if (this.Document != null)
255!
25
                                {
255✔
26
                                        this._bookColor = this.updateCollection(value, this.Document.Colors);
255✔
27
                                }
255✔
28
                                else
NEW
29
                                {
×
NEW
30
                                        this._bookColor = value;
×
NEW
31
                                }
×
32
                        }
255✔
33
                }
34

35
                /// <inheritdoc/>
36
                [DxfCodeValue(62, 420)]
37
                public Color Color { get; set; } = Color.ByLayer;
453,938✔
38

39
                /// <inheritdoc/>
40
                [DxfCodeValue(60)]
41
                public bool IsInvisible { get; set; } = false;
375,135✔
42

43
                /// <inheritdoc/>
44
                [DxfCodeValue(DxfReferenceType.Name, 8)]
45
                public Layer Layer
46
                {
47
                        get { return this._layer; }
425,868✔
48
                        set
49
                        {
235,874✔
50
                                if (value == null)
235,874!
51
                                {
×
52
                                        throw new ArgumentNullException(nameof(value));
×
53
                                }
54

55
                                if (this.Document != null)
235,874✔
56
                                {
121,075✔
57
                                        this._layer = this.updateTable(value, this.Document.Layers);
121,075✔
58
                                }
121,075✔
59
                                else
60
                                {
114,799✔
61
                                        this._layer = value;
114,799✔
62
                                }
114,799✔
63
                        }
235,874✔
64
                }
65

66
                /// <inheritdoc/>
67
                [DxfCodeValue(DxfReferenceType.Name, 6)]
68
                public LineType LineType
69
                {
70
                        get { return this._lineType; }
438,657✔
71
                        set
72
                        {
65,353✔
73
                                if (value == null)
65,353!
74
                                {
×
75
                                        throw new ArgumentNullException(nameof(value));
×
76
                                }
77

78
                                if (this.Document != null)
65,353✔
79
                                {
50,888✔
80
                                        this._lineType = this.updateTable(value, this.Document.LineTypes);
50,888✔
81
                                }
50,888✔
82
                                else
83
                                {
14,465✔
84
                                        this._lineType = value;
14,465✔
85
                                }
14,465✔
86
                        }
65,353✔
87
                }
88

89
                /// <inheritdoc/>
90
                [DxfCodeValue(48)]
91
                public double LinetypeScale { get; set; } = 1.0;
375,454✔
92

93
                /// <inheritdoc/>
94
                [DxfCodeValue(370)]
95
                public LineweightType LineWeight { get; set; } = LineweightType.ByLayer;
380,509✔
96

97
                /// <inheritdoc/>
98
                [DxfCodeValue(DxfReferenceType.Handle, 347)]
99
                public Material Material { get; set; }
1,920✔
100

101
                /// <inheritdoc/>
102
                public override string SubclassMarker => DxfSubclassMarker.Entity;
440,803✔
103

104
                /// <inheritdoc/>
105
                [DxfCodeValue(440)]
106
                public Transparency Transparency { get; set; } = Transparency.ByLayer;
389,243✔
107

108
                private BookColor _bookColor = null;
298,992✔
109

110
                private Layer _layer = Layer.Default;
298,992✔
111

112
                private LineType _lineType = LineType.ByLayer;
298,992✔
113

114
                /// <inheritdoc/>
115
                public Entity() : base() { }
896,976✔
116

117
                /// <inheritdoc/>
118
                public override CadObject Clone()
119
                {
960✔
120
                        Entity clone = (Entity)base.Clone();
960✔
121

122
                        clone.Layer = (Layer)this.Layer.Clone();
960✔
123
                        clone.LineType = (LineType)this.LineType.Clone();
960✔
124
                        clone.Material = (Material)this.Material?.Clone();
960!
125

126
                        return clone;
960✔
127
                }
960✔
128

129
                /// <inheritdoc/>
130
                public Color GetActiveColor()
131
                {
21✔
132
                        Color color;
133
                        if (this.Color.IsByLayer)
21✔
134
                        {
17✔
135
                                color = this.Layer.Color;
17✔
136
                        }
17✔
137
                        else
138
                        {
4✔
139
                                color = this.Color;
4✔
140
                        }
4✔
141

142
                        return color;
21✔
143
                }
21✔
144

145
                /// <inheritdoc/>
146
                public abstract BoundingBox GetBoundingBox();
147

148
                /// <inheritdoc/>
149
                public void MatchProperties(IEntity entity)
150
                {
11✔
151
                        if (entity is null)
11!
152
                        {
×
153
                                throw new ArgumentNullException(nameof(entity));
×
154
                        }
155

156
                        if (entity.Handle == 0)
11!
157
                        {
11✔
158
                                entity.Layer = (Layer)this.Layer.Clone();
11✔
159
                                entity.LineType = (LineType)this.LineType.Clone();
11✔
160
                        }
11✔
161
                        else
162
                        {
×
163
                                entity.Layer = this.Layer;
×
164
                                entity.LineType = this.LineType;
×
165
                        }
×
166

167
                        entity.Color = this.Color;
11✔
168
                        entity.LineWeight = this.LineWeight;
11✔
169
                        entity.LinetypeScale = this.LinetypeScale;
11✔
170
                        entity.IsInvisible = this.IsInvisible;
11✔
171
                        entity.Transparency = this.Transparency;
11✔
172
                }
11✔
173

174
                internal override void AssignDocument(CadDocument doc)
175
                {
125,603✔
176
                        base.AssignDocument(doc);
125,603✔
177

178
                        this._layer = this.updateTable(this.Layer, doc.Layers);
125,603✔
179
                        this._lineType = this.updateTable(this.LineType, doc.LineTypes);
125,603✔
180

181
                        doc.Layers.OnRemove += this.tableOnRemove;
125,603✔
182
                        doc.LineTypes.OnRemove += this.tableOnRemove;
125,603✔
183
                }
125,603✔
184

185
                internal override void UnassignDocument()
186
                {
2,345✔
187
                        this.Document.Layers.OnRemove -= this.tableOnRemove;
2,345✔
188
                        this.Document.LineTypes.OnRemove -= this.tableOnRemove;
2,345✔
189

190
                        base.UnassignDocument();
2,345✔
191

192
                        this.Layer = (Layer)this.Layer.Clone();
2,345✔
193
                        this.LineType = (LineType)this.LineType.Clone();
2,345✔
194
                }
2,345✔
195

196
                protected virtual void tableOnRemove(object sender, CollectionChangedEventArgs e)
197
                {
10✔
198
                        if (e.Item.Equals(this.Layer))
10✔
199
                        {
1✔
200
                                this.Layer = this.Document.Layers[Layer.DefaultName];
1✔
201
                        }
1✔
202

203
                        if (e.Item.Equals(this.LineType))
10✔
204
                        {
1✔
205
                                this.LineType = this.Document.LineTypes[LineType.ByLayerName];
1✔
206
                        }
1✔
207
                }
10✔
208
        }
209
}
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