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

DomCR / ACadSharp / 12008475829

25 Nov 2024 10:52AM UTC coverage: 75.339% (-0.3%) from 75.668%
12008475829

push

github

web-flow
Merge pull request #494 from DomCR/Issue-487_DBCOLOR

Issue 487 dbcolor

4956 of 7275 branches covered (68.12%)

Branch coverage included in aggregate %.

116 of 206 new or added lines in 21 files covered. (56.31%)

91 existing lines in 11 files now uncovered.

19811 of 25599 relevant lines covered (77.39%)

36312.43 hits per line

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

83.76
/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
                /// <inheritdoc/>
16
                public override string SubclassMarker => DxfSubclassMarker.Entity;
230,773✔
17

18
                /// <inheritdoc/>
19
                [DxfCodeValue(DxfReferenceType.Name, 8)]
20
                public Layer Layer
21
                {
22
                        get { return this._layer; }
278,007✔
23
                        set
24
                        {
91,980✔
25
                                if (value == null)
91,980!
26
                                {
×
27
                                        throw new ArgumentNullException(nameof(value));
×
28
                                }
29

30
                                if (this.Document != null)
91,980✔
31
                                {
77,783✔
32
                                        this._layer = this.updateTable(value, this.Document.Layers);
77,783✔
33
                                }
77,783✔
34
                                else
35
                                {
14,197✔
36
                                        this._layer = value;
14,197✔
37
                                }
14,197✔
38
                        }
91,980✔
39
                }
40

41
                /// <inheritdoc/>
42
                [DxfCodeValue(62, 420)]
43
                public Color Color { get; set; } = Color.ByLayer;
172,936✔
44

45
                /// <inheritdoc/>
46
                [DxfCodeValue(370)]
47
                public LineweightType LineWeight { get; set; } = LineweightType.ByLayer;
160,027✔
48

49
                /// <inheritdoc/>
50
                [DxfCodeValue(48)]
51
                public double LinetypeScale { get; set; } = 1.0;
158,205✔
52

53
                /// <inheritdoc/>
54
                [DxfCodeValue(60)]
55
                public bool IsInvisible { get; set; } = false;
157,680✔
56

57
                /// <inheritdoc/>
58
                [DxfCodeValue(440)]
59
                public Transparency Transparency { get; set; } = Transparency.ByLayer;
160,071✔
60

61
                /// <inheritdoc/>
62
                [DxfCodeValue(DxfReferenceType.Name, 6)]
63
                public LineType LineType
64
                {
65
                        get { return this._lineType; }
288,843✔
66
                        set
67
                        {
29,128✔
68
                                if (value == null)
29,128!
69
                                {
×
70
                                        throw new ArgumentNullException(nameof(value));
×
71
                                }
72

73
                                if (this.Document != null)
29,128✔
74
                                {
26,537✔
75
                                        this._lineType = this.updateTable(value, this.Document.LineTypes);
26,537✔
76
                                }
26,537✔
77
                                else
78
                                {
2,591✔
79
                                        this._lineType = value;
2,591✔
80
                                }
2,591✔
81
                        }
29,128✔
82
                }
83

84
                /// <inheritdoc/>
85
                [DxfCodeValue(DxfReferenceType.Handle, 347)]
86
                public Material Material { get; set; }
796✔
87

88
                /// <summary>
89
                /// Book color for this entity.
90
                /// </summary> 
91
                [DxfCodeValue(DxfReferenceType.Name, 430)]
92
                public BookColor BookColor
93
                {
94
                        get { return this._bookColor; }
17,310✔
95
                        set
96
                        {
12✔
97
                                if (this.Document != null)
12!
98
                                {
12✔
99
                                        this._bookColor = this.updateCollection(value, this.Document.Colors);
12✔
100
                                }
12✔
101
                                else
NEW
102
                                {
×
NEW
103
                                        this._bookColor = value;
×
NEW
104
                                }
×
105
                        }
12✔
106
                }
107

108
                private Layer _layer = Layer.Default;
118,733✔
109

110
                private LineType _lineType = LineType.ByLayer;
118,733✔
111

112
                private BookColor _bookColor = null;
118,733✔
113

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

117
                /// <inheritdoc/>
118
                public abstract BoundingBox GetBoundingBox();
119

120
                /// <inheritdoc/>
121
                public void MatchProperties(IEntity entity)
122
                {
11✔
123
                        if (entity is null)
11!
124
                        {
×
125
                                throw new ArgumentNullException(nameof(entity));
×
126
                        }
127

128
                        if (entity.Handle == 0)
11!
129
                        {
11✔
130
                                entity.Layer = (Layer)this.Layer.Clone();
11✔
131
                                entity.LineType = (LineType)this.LineType.Clone();
11✔
132
                        }
11✔
133
                        else
134
                        {
×
135
                                entity.Layer = this.Layer;
×
136
                                entity.LineType = this.LineType;
×
137
                        }
×
138

139
                        entity.Color = this.Color;
11✔
140
                        entity.LineWeight = this.LineWeight;
11✔
141
                        entity.LinetypeScale = this.LinetypeScale;
11✔
142
                        entity.IsInvisible = this.IsInvisible;
11✔
143
                        entity.Transparency = this.Transparency;
11✔
144
                }
11✔
145

146
                /// <inheritdoc/>
147
                public override CadObject Clone()
148
                {
398✔
149
                        Entity clone = (Entity)base.Clone();
398✔
150

151
                        clone.Layer = (Layer)this.Layer.Clone();
398✔
152
                        clone.LineType = (LineType)this.LineType.Clone();
398✔
153
                        clone.Material = (Material)this.Material?.Clone();
398!
154

155
                        return clone;
398✔
156
                }
398✔
157

158
                internal override void AssignDocument(CadDocument doc)
159
                {
80,853✔
160
                        base.AssignDocument(doc);
80,853✔
161

162
                        this._layer = this.updateTable(this.Layer, doc.Layers);
80,853✔
163
                        this._lineType = this.updateTable(this.LineType, doc.LineTypes);
80,853✔
164

165
                        doc.Layers.OnRemove += this.tableOnRemove;
80,853✔
166
                        doc.LineTypes.OnRemove += this.tableOnRemove;
80,853✔
167
                }
80,853✔
168

169
                internal override void UnassignDocument()
170
                {
1,589✔
171
                        this.Document.Layers.OnRemove -= this.tableOnRemove;
1,589✔
172
                        this.Document.LineTypes.OnRemove -= this.tableOnRemove;
1,589✔
173

174
                        base.UnassignDocument();
1,589✔
175

176
                        this.Layer = (Layer)this.Layer.Clone();
1,589✔
177
                        this.LineType = (LineType)this.LineType.Clone();
1,589✔
178
                }
1,589✔
179

180
                protected virtual void tableOnRemove(object sender, CollectionChangedEventArgs e)
181
                {
10✔
182
                        if (e.Item.Equals(this.Layer))
10✔
183
                        {
1✔
184
                                this.Layer = this.Document.Layers[Layer.DefaultName];
1✔
185
                        }
1✔
186

187
                        if (e.Item.Equals(this.LineType))
10✔
188
                        {
1✔
189
                                this.LineType = this.Document.LineTypes[LineType.ByLayerName];
1✔
190
                        }
1✔
191
                }
10✔
192
        }
193
}
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

© 2025 Coveralls, Inc