QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_layer.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(OPENNURBS_LAYER_INC_)
17#define OPENNURBS_LAYER_INC_
18
20{
22
23public:
24 ON_Layer();
25 ~ON_Layer();
26 // C++ default copy construction and operator= work fine.
27 // Do not add custom versions.
28
30 //
31 // ON_Object overrides
32
33 /*
34 Description:
35 Tests an object to see if its data members are correctly
36 initialized.
37 Parameters:
38 text_log - [in] if the object is not valid and text_log
39 is not NULL, then a brief englis description of the
40 reason the object is not valid is appened to the log.
41 The information appended to text_log is suitable for
42 low-level debugging purposes by programmers and is
43 not intended to be useful as a high level user
44 interface tool.
45 Returns:
46 @untitled table
47 true object is valid
48 false object is invalid, uninitialized, etc.
49 Remarks:
50 Overrides virtual ON_Object::IsValid
51 */
52 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
53
54 void Dump( ON_TextLog& ) const; // for debugging
55
57 ON_BinaryArchive& // serialize definition to binary archive
58 ) const;
59
61 ON_BinaryArchive& // restore definition from binary archive
62 );
63
64 ON::object_type ObjectType() const;
65
66 ON_UUID ModelObjectId() const;
67
69 //
70 // Interface
71
72 void Default();
73
74 bool SetLayerName( const char* );
75 bool SetLayerName( const wchar_t* );
76 const ON_wString& LayerName() const;
77
78 /*
79 Parameters:
80 viewport_id - [in]
81 If viewport_id is not nil, then checks for setting for
82 that specific viewport.
83 If viewport_id is nil, then checks for any viewport settings.
84 Returns:
85 True if the layer has per viewport settings.
86 */
87 bool HasPerViewportSettings(
88 const ON_UUID& viewport_id
89 ) const;
90
91 /*
92 Description:
93 Delete per viewport layer settings.
94 Parameters:
95 viewport_id - [in]
96 If viewport_id is not nil, then the settings for that
97 viewport are deleted. If viewport_id is nil, then all
98 per viewport settings are deleted.
99 */
100 void DeletePerViewportSettings(
101 const ON_UUID& viewport_id
102 ) const;
103
104 /*
105 Description:
106 Cull unused per viewport layer settings.
107 Parameters:
108 viewport_id_count - [in]
109 viewport_id_list - [in]
110 Settings for any viewports NOT in the viewport_id_list[]
111 are culled.
112 */
113 void CullPerViewportSettings(
114 int viewport_id_count,
115 const ON_UUID* viewport_id_list
116 );
117
118 /*
119 Description:
120 The PerViewportSettingsCRC() can be used to determine
121 when layers have different per viewport settings.
122 */
123 ON__UINT32 PerViewportSettingsCRC() const;
124
125
126 /*
127 Description:
128 Set the color used by objects on this layer that do
129 not have a per object color set
130 Parameters:
131 layer_color - [in]
132 Passing ON_UNSET_COLOR will clear the settings.
133 viewport_id - [in]
134 If viewport_id is not nil, then the setting applies only
135 to the viewport with the specified id.
136 */
137 void SetColor( ON_Color layer_color ); // layer display color
138 void SetColor( ON_Color layer_color, const ON_UUID& viewport_id );
139
140 /*
141 Parameters:
142 viewport_id - [in]
143 If viewport_id is not nil, then the setting to use
144 for a specific viewport is returned.
145 Returns:
146 The color used by objects on this layer that do
147 not have a per object color set.
148 */
149 ON_Color Color() const;
150 ON_Color Color( const ON_UUID& viewport_id ) const;
151
152 /*
153 Description:
154 Remove any per viewport layer color setting so the
155 layer's overall setting will be used for all viewports.
156 Parameters:
157 viewport_id - [in]
158 If viewport_id is not nil, then the setting for this
159 viewport will be deleted. If viewport_id is nil,
160 the all per viewport layer color settings will be removed.
161 */
162 void DeletePerViewportColor( const ON_UUID& viewport_id );
163
164 /*
165 Description:
166 Set the plotting color used by objects on this layer that do
167 not have a per object plotting color set
168 Parameters:
169 plot_color - [in]
170 Passing ON_UNSET_COLOR will clear the settings.
171 viewport_id - [in]
172 If viewport_id is not nil, then the setting applies only
173 to the viewport with the specified id.
174 */
175 void SetPlotColor( ON_Color plot_color ); // plotting color
176 void SetPlotColor( ON_Color plot_color, const ON_UUID& viewport_id ); // plotting color
177
178 /*
179 Parameters:
180 viewport_id - [in]
181 If viewport_id is not nil, then the setting to use
182 for a specific viewport is returned.
183 Returns:
184 The plotting color used by objects on this layer that do
185 not have a per object color set.
186 */
187 ON_Color PlotColor() const;
188 ON_Color PlotColor( const ON_UUID& viewport_id ) const;
189
190 /*
191 Description:
192 Remove any per viewport plot color setting so the
193 layer's overall setting will be used for all viewports.
194 Parameters:
195 viewport_id - [in]
196 If viewport_id is not nil, then the setting for this
197 viewport will be deleted. If viewport_id is nil,
198 the all per viewport plot color settings will be removed.
199 */
200 void DeletePerViewportPlotColor( const ON_UUID& viewport_id );
201
202 /*
203 Description:
204 Set the index of the linetype used by objects on this layer that do
205 not have a per object lintypes
206 Parameters:
207 linetype_index - [in]
208 Passing -1 will clear the setting.
209 */
210 bool SetLinetypeIndex( int linetype_index );
211
212 /*
213 Returns:
214 The index of the linetype used by objects on this layer that do
215 not have a per object linetype set.
216 */
217 int LinetypeIndex() const;
218
219 /*
220 Returns:
221 Returns true if objects on layer are visible.
222 Remarks:
223 Does not inspect per viewport settings.
224 See Also:
225 ON_Layer::SetVisible
226 */
227 bool IsVisible() const;
228
229 /*
230 Returns:
231 Returns true if objects on layer are visible.
232 Parameters:
233 viewport_id - [in]
234 If viewport_id is not nil, then the visibility setting
235 for that viewport is returned. If viewport_id
236 is nil, then true is returned if the layer is visible
237 in some viewport.
238 */
239 bool IsVisible( const ON_UUID& viewport_id ) const;
240
241 /*
242 Description:
243 Controls layer visibility
244 Parameters:
245 bVisible - [in] true to make layer visible,
246 false to make layer invisible
247 viewport_id - [in]
248 If viewport_id is not nil, then the setting applies only
249 to the viewport with the specified id.
250 See Also:
251 ON_Layer::IsVisible
252 */
253 void SetVisible( bool bVisible );
254 void SetVisible( bool bVisible, const ON_UUID& viewport_id );
255
256 /*
257 Description:
258 Remove any per viewport visibility setting so the
259 layer's overall setting will be used for all viewports.
260 Parameters:
261 viewport_id - [in]
262 If viewport_id is not nil, then the setting for this
263 viewport will be deleted. If viewport_id is nil,
264 the all per viewport visibility settings will be removed.
265 */
266 void DeletePerViewportVisible( const ON_UUID& viewport_id );
267
268 /*
269 Returns:
270 Returns true if objects on layer are locked.
271 See Also:
272 ON_Layer::SetLocked
273 */
274 bool IsLocked() const;
275
276 /*
277 Description:
278 Controls layer locked
279 Parameters:
280 bLocked - [in] True to lock layer
281 False to unlock layer
282 See Also:
283 ON_Layer::IsLocked
284 */
285 void SetLocked( bool bLocked );
286
287 /*
288 Returns:
289 Value of (IsVisible() && !IsLocked()).
290 */
291 bool IsVisibleAndNotLocked() const;
292
293 /*
294 Returns:
295 Value of (IsVisible() && IsLocked()).
296 */
297 bool IsVisibleAndLocked() const;
298
300 // Index of render material for objects on this layer that have
301 // MaterialSource() == ON::material_from_layer.
302 // A material index of -1 indicates no material has been assigned
303 // and the material created by the default ON_Material constructor
304 // should be used.
305 bool SetRenderMaterialIndex( int ); // index of layer's rendering material
306 int RenderMaterialIndex() const;
307
308 bool SetLayerIndex( int ); // index of this layer;
309 int LayerIndex() const;
310
311 bool SetIgesLevel( int ); // IGES level for this layer
312 int IgesLevel() const;
313
314 /*
315 Description:
316 Get the weight (thickness) of the plotting pen.
317 Returns:
318 Thickness of the plotting pen in millimeters.
319 A thickness of 0.0 indicates the "default" pen weight should be used.
320 A thickness of -1.0 indicates the layer should not be printed.
321 */
322 double PlotWeight() const;
323 double PlotWeight( const ON_UUID& viewport_id ) const;
324
325 /*
326 Description:
327 Get the weight of the plotting pen.
328 Parameters:
329 plot_weight_mm - [in] Set the thickness of the plotting pen in millimeters.
330 0.0 means use the default pen width which is a Rhino app setting.
331 -1.0 means layer does not print (still displays on the screen)
332 */
333 void SetPlotWeight(double plot_weight_mm);
334 void SetPlotWeight(double plot_weight_mm, const ON_UUID& viewport_id );
335
336 /*
337 Description:
338 Remove any per viewport plot weight setting so the
339 layer's overall setting will be used for all viewports.
340 Parameters:
341 viewport_id - [in]
342 If viewport_id is not nil, then the setting for this
343 viewport will be deleted. If viewport_id is nil,
344 the all per viewport plot weight settings will be removed.
345 */
346 void DeletePerViewportPlotWeight( const ON_UUID& viewport_id );
347
348public:
349
350 int m_layer_index; // index of this layer
352 ON_UUID m_parent_layer_id; // Layers are origanized in a hierarchical
353 // structure (like file folders).
354 // If a layer is in a parent layer,
355 // then m_parent_layer_id is the id of
356 // the parent layer.
357
358 int m_iges_level; // IGES level number if this layer was made during IGES import
359
360
361
362 // Rendering material:
363 // If you want something simple and fast, set
364 // m_material_index to the index of your rendering material
365 // and ignore m_rendering_attributes.
366 // If you are developing a fancy plug-in renderer, and a user is
367 // assigning one of your fabulous rendering materials to this
368 // layer, then add rendering material information to the
369 // m_rendering_attributes.m_materials[] array.
370 //
371 // Developers:
372 // As soon as m_rendering_attributes.m_materials[] is not empty,
373 // rendering material queries slow down. Do not populate
374 // m_rendering_attributes.m_materials[] when setting
375 // m_material_index will take care of your needs.
378
379 int m_linetype_index; // index of linetype
380
381 // Layer display attributes.
382 // If m_display_material_id is nil, then m_color is the layer color
383 // and defaults are used for all other display attributes.
384 // If m_display_material_id is not nil, then some complicated
385 // scheme is used to decide what objects on this layer look like.
386 // In all cases, m_color is a good choice if you don't want to
387 // deal with m_display_material_id. In Rhino, m_display_material_id
388 // is used to identify a registry entry that contains user specific
389 // display preferences.
392
393 // Layer printing (plotting) attributes.
394 ON_Color m_plot_color; // printing color
395 // ON_UNSET_COLOR means use layer color
396 double m_plot_weight_mm; // printing pen thickness in mm
397 // 0.0 means use the default width (a Rhino app setting)
398 // -1.0 means layer does not print (still visible on screen)
400
401 bool m_bVisible; // If true, objects on this layer are visible.
402 bool m_bLocked; // If true, objects on this layer cannot be modified.
403 bool m_bExpanded; // If true, when the layer table is displayed in
404 // a tree control then the list of child layers is
405 // shown in the control.
406
407private:
408 // The m__runtime_flags are used to speed queries that require
409 // checking user data. This field is not saved in persistent
410 // archives and its interpretation is subject to change.
411 unsigned char m__runtime_flags;
412};
413
414
415#endif
416
@ Color
Definition RSMetaType.h:26
Definition opennurbs_archive.h:152
Definition opennurbs_color.h:24
Definition opennurbs_layer.h:20
ON_RenderingAttributes m_rendering_attributes
Definition opennurbs_layer.h:377
bool m_bVisible
Definition opennurbs_layer.h:401
ON_Color m_color
Definition opennurbs_layer.h:390
ON_UUID m_parent_layer_id
Definition opennurbs_layer.h:352
bool m_bLocked
Definition opennurbs_layer.h:402
double m_plot_weight_mm
Definition opennurbs_layer.h:396
int m_material_index
Definition opennurbs_layer.h:376
ON_Color m_plot_color
Definition opennurbs_layer.h:394
bool m_bExpanded
Definition opennurbs_layer.h:403
unsigned char m__runtime_flags
Definition opennurbs_layer.h:411
int m_iges_level
Definition opennurbs_layer.h:358
int m_linetype_index
Definition opennurbs_layer.h:379
ON_UUID m_display_material_id
Definition opennurbs_layer.h:391
ON_OBJECT_DECLARE(ON_Layer)
ON_UUID m_layer_id
Definition opennurbs_layer.h:351
int m_layer_index
Definition opennurbs_layer.h:350
ON_wString m_name
Definition opennurbs_layer.h:399
Definition opennurbs_object.h:393
virtual void Dump(ON_TextLog &) const
Definition opennurbs_object.cpp:1695
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_object.cpp:1734
virtual ON_UUID ModelObjectId() const
Definition opennurbs_object.cpp:1622
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
virtual ON::object_type ObjectType() const
Definition opennurbs_object.cpp:1616
Definition opennurbs_rendering.h:21
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_string.h:392
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
unsigned int ON__UINT32
Definition opennurbs_system.h:326