API Documentation
Loading...
Searching...
No Matches
DXFAttributes.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: CAD
28File: DXFAttributes
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "Base/Headers/String.h"
35
36namespace NDEVR
37{
38 /**--------------------------------------------------------------------------------------------------
39 \brief DXF Style attributes that can be applied to CAD Entity objects.
40 **/
42 {
43 public:
45 : m_color(Constant<RGBColor>::Invalid)
46 , m_line_type_scale(1.0)
47 , m_width(0)
48 , m_in_paper_space(false)
49 {}
50
51 DXFAttributes(const String& layer, const RGBColor& color, int width, String linetype, double linetypeScale)
52 : m_layer(layer)
53 , m_color(color)
54 , m_line_type(std::move(linetype))
55 , m_line_type_scale(linetypeScale)
56 , m_width(width)
57 , m_in_paper_space(false)
58 {}
59
60 DXFAttributes(String layer, const RGBColor& color, int width, String linetype, uint04 handle)
61 : m_layer(std::move(layer))
62 , m_color(color)
63 , m_line_type(std::move(linetype))
64 , m_line_type_scale(1.0)
65 , m_handle(std::move(handle))
66 , m_width(width)
67 , m_in_paper_space(false)
68 {}
69
70 bool operator==(const DXFAttributes& attributes) const
71 {
72 return m_layer == attributes.m_layer
73 && m_color == attributes.m_color
74 && m_block == attributes.m_block
75 && m_line_type == attributes.m_line_type
76 && m_line_type_scale == attributes.m_line_type_scale
77 && m_handle == attributes.m_handle
78 && m_width == attributes.m_width
79 && m_in_paper_space == attributes.m_in_paper_space;
80 }
81 bool operator!=(const DXFAttributes& attributes) const
82 {
83 return m_layer != attributes.m_layer
84 || m_color != attributes.m_color
85 || m_block != attributes.m_block
86 || m_line_type != attributes.m_line_type
87 || m_line_type_scale != attributes.m_line_type_scale
88 || m_handle != attributes.m_handle
89 || m_width != attributes.m_width
90 || m_in_paper_space != attributes.m_in_paper_space;
91 }
92
93 void setLayer(const String& layer) { m_layer = layer; }
94 [[nodiscard]] const String& getLayer() const { return m_layer; }
95
96 void setBlock(const String& block) { m_block = block; }
97 [[nodiscard]] const String& block() const { return m_block; }
98
99 void setColor(const RGBColor& color) { m_color = color; }
100
101 const RGBColor& getColor() const { return m_color; }
102
103 void setWidth(int width) { m_width = width; }
104
105 int getWidth() const { return m_width; }
106
107 void setLinetype(const String& linetype) { m_line_type = linetype; }
108
109 void setLinetypeScale(double linetypeScale) { m_line_type_scale = linetypeScale; }
110
111 double getLinetypeScale() const { return m_line_type_scale; }
112 const String& getLinetype() const
113 {
114 static const String by_layer("BYLAYER");
115 return m_line_type.size() == 0 ? by_layer : m_line_type;
116 }
117
118 void setHandle(const String& h) { m_handle = h; }
119 [[nodiscard]] const String& handle() const { return m_handle; }
120
121 void setInPaperSpace(bool on) { m_in_paper_space = on; }
122 bool isInPaperSpace() const { return m_in_paper_space; }
123
124 void setSection(const String& h) { m_section = h; }
125 const String& section() const { return m_section; }
126
127 private:
128 String m_section;
129 String m_layer;
130 String m_block;
131 RGBColor m_color;
132 String m_line_type;
133 fltp08 m_line_type_scale;
134 String m_handle;
135 int m_width;
136 // DXF code 67 (true: entity in paper space, false: entity in model space (default):
137 bool m_in_paper_space;
138 };
139
140}
constexpr t_index_type size() const
Definition Buffer.hpp:823
DXF Style attributes that can be applied to CAD Entity objects.
Definition DXFAttributes.h:42
bool isInPaperSpace() const
Definition DXFAttributes.h:122
void setInPaperSpace(bool on)
Definition DXFAttributes.h:121
void setSection(const String &h)
Definition DXFAttributes.h:124
DXFAttributes(String layer, const RGBColor &color, int width, String linetype, uint04 handle)
Definition DXFAttributes.h:60
const String & getLayer() const
Definition DXFAttributes.h:94
void setColor(const RGBColor &color)
Definition DXFAttributes.h:99
const String & section() const
Definition DXFAttributes.h:125
DXFAttributes(const String &layer, const RGBColor &color, int width, String linetype, double linetypeScale)
Definition DXFAttributes.h:51
void setLinetypeScale(double linetypeScale)
Definition DXFAttributes.h:109
DXFAttributes()
Definition DXFAttributes.h:44
void setLayer(const String &layer)
Definition DXFAttributes.h:93
void setLinetype(const String &linetype)
Definition DXFAttributes.h:107
const String & getLinetype() const
Definition DXFAttributes.h:112
void setWidth(int width)
Definition DXFAttributes.h:103
const String & block() const
Definition DXFAttributes.h:97
bool operator==(const DXFAttributes &attributes) const
Definition DXFAttributes.h:70
double getLinetypeScale() const
Definition DXFAttributes.h:111
const RGBColor & getColor() const
Definition DXFAttributes.h:101
int getWidth() const
Definition DXFAttributes.h:105
void setBlock(const String &block)
Definition DXFAttributes.h:96
void setHandle(const String &h)
Definition DXFAttributes.h:118
const String & handle() const
Definition DXFAttributes.h:119
bool operator!=(const DXFAttributes &attributes) const
Definition DXFAttributes.h:81
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Definition File.h:211
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233