]> Shamusworld >> Repos - architektonas/blob - dxflib/src/dl_attributes.h
Fixed problem with MDI activation.
[architektonas] / dxflib / src / dl_attributes.h
1 /****************************************************************************
2 ** $Id: dl_attributes.h 2334 2005-03-27 23:37:52Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the dxflib project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid dxflib Professional Edition licenses may use 
14 ** this file in accordance with the dxflib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #ifndef DL_ATTRIBUTES_H
28 #define DL_ATTRIBUTES_H
29
30 #include <string>
31 using std::string;
32
33 #include "dl_codes.h"
34
35 /**
36  * Storing and passing around attributes. Attributes
37  * are the layer name, color, width and line type.
38  *
39  * @author Andrew Mustun
40  */
41 class DL_Attributes {
42
43 public:
44
45     /**
46      * Default constructor.
47      */
48     DL_Attributes() {
49         setLayer("");
50         setColor(0);
51         setWidth(0);
52         setLineType("BYLAYER");
53     }
54
55
56
57     /**
58      * Constructor for DXF attributes.
59      *
60      * @param layer Layer name for this entity or NULL for no layer
61      *              (every entity should be on a named layer!).
62      * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
63      * @param width Line thickness. Defaults to zero. -1 = BYLAYER, 
64      *               -2 = BYBLOCK, -3 = default width
65      * @param lineType Line type name or "BYLAYER" or "BYBLOCK". Defaults
66      *              to "BYLAYER"
67      */
68     DL_Attributes(const string& layer,
69                   int color, int width,
70                   const string& lineType) {
71         setLayer(layer);
72         setColor(color);
73         setWidth(width);
74         setLineType(lineType);
75     }
76
77
78
79     /**
80      * Sets the layer. If the given pointer points to NULL, the
81      *  new layer name will be an empty but valid string.
82      */
83     void setLayer(const string& layer) {
84         this->layer = layer;
85     }
86
87
88
89     /**
90      * @return Layer name.
91      */
92     string getLayer() const {
93         return layer;
94     }
95
96
97
98     /**
99      * Sets the color.
100      *
101      * @see DL_Codes, dxfColors
102      */
103     void setColor(int color) {
104         this->color = color;
105     }
106
107
108
109     /**
110      * @return Color.
111      *
112      * @see DL_Codes, dxfColors
113      */
114     int getColor() const {
115         return color;
116     }
117
118
119
120     /**
121      * Sets the width.
122      */
123     void setWidth(int width) {
124         this->width = width;
125     }
126
127
128
129     /**
130      * @return Width.
131      */
132     int getWidth() const {
133         return width;
134     }
135
136
137
138     /**
139      * Sets the line type. This can be any string and is not
140      *  checked to be a valid line type. 
141      */
142     void setLineType(const string& lineType) {
143         this->lineType = lineType;
144     }
145
146
147
148     /**
149      * @return Line type.
150      */
151     string getLineType() const {
152         if (lineType.length()==0) {
153             return "BYLAYER";
154         } else {
155             return lineType;
156         }
157     }
158
159
160
161     /**
162      * Copies attributes (deep copies) from another attribute object.
163      */
164     DL_Attributes operator = (const DL_Attributes& attrib) {
165         setLayer(attrib.layer);
166         setColor(attrib.color);
167         setWidth(attrib.width);
168         setLineType(attrib.lineType);
169
170         return *this;
171     }
172
173 private:
174     string layer;
175     int color;
176     int width;
177     string lineType;
178 };
179
180 #endif
181
182 // EOF