QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_3dm_attributes.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
17//
18// defines ON_3dmObjectAttributes
19//
21
22#if !defined(OPENNURBS_3DM_ATTRIBUTES_INC_)
23#define OPENNURBS_3DM_ATTRIBUTES_INC_
24
25
26/*
27Description:
28 Top level OpenNURBS objects have geometry and attributes. The
29 geometry is stored in some class derived from ON_Geometry and
30 the attributes are stored in an ON_3dmObjectAttributes class.
31 Examples of attributes are object name, object id, display
32 attributes, group membership, layer membership, and so on.
33
34Remarks:
35 7 January 2003 Dale Lear
36 Derived from ON_Object so ON_UserData can be attached
37 to ON_3dmObjectAttributes.
38*/
39
41{
43
44public:
45 // ON_Object virtual interface. See ON_Object
46 // for details.
47
48 // virtual
49 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
50 // virtual
51 void Dump( ON_TextLog& ) const;
52 // virtual
53 unsigned int SizeOf() const;
54 // virtual
56 // virtual
58
59 /*
60 Returns:
61 True if successful.
62 (xform is invertable or didn't need to be).
63 */
64 bool Transform( const ON_Xform& xform );
65
66 // attributes of geometry and dimension table objects
67public:
70
71 // Default C++ copy constructor and operator= work fine
72 // Do not provide custom versions
73 // NO // ON_3dmObjectAttributes(const ON_3dmObjectAttributes&);
74 // NO // ON_3dmObjectAttributes& operator=(const ON_3dmObjectAttributes&);
75
76 bool operator==(const ON_3dmObjectAttributes&) const;
77 bool operator!=(const ON_3dmObjectAttributes&) const;
78
79 // Initializes all attributes to the default values.
80 void Default();
81
82 // Interface ////////////////////////////////////////////////////////
83
84 // An OpenNURBS object must be in one of three modes: normal, locked
85 // or hidden. If an object is in normal mode, then the object's layer
86 // controls visibility and selectability. If an object is locked, then
87 // the object's layer controls visibility by the object cannot be selected.
88 // If the object is hidden, it is not visible and it cannot be selected.
89 ON::object_mode Mode() const;
90 void SetMode( ON::object_mode ); // See Mode().
91
92 /*
93 Description:
94 Use this query to determine if an object is part of an
95 instance definition.
96 Returns:
97 True if the object is part of an instance definition.
98 */
99 bool IsInstanceDefinitionObject() const;
100
101 /*
102 Returns:
103 Returns true if object is visible.
104 See Also:
105 ON_3dmObjectAttributes::SetVisible
106 */
107 bool IsVisible() const;
108
109 /*
110 Description:
111 Controls object visibility
112 Parameters:
113 bVisible - [in] true to make object visible,
114 false to make object invisible
115 See Also:
116 ON_3dmObjectAttributes::IsVisible
117 */
118 void SetVisible( bool bVisible );
119
120 // The Linetype used to display an OpenNURBS object is specified in one of two ways.
121 // If LinetypeSource() is ON::linetype_from_layer, then the object's layer
122 // ON_Layer::Linetype() is used.
123 // If LinetypeSource() is ON::linetype_from_object, then value of m_linetype is used.
124 ON::object_linetype_source LinetypeSource() const;
125 void SetLinetypeSource( ON::object_linetype_source ); // See LinetypeSource().
126
127 // The color used to display an OpenNURBS object is specified in one of three ways.
128 // If ColorSource() is ON::color_from_layer, then the object's layer
129 // ON_Layer::Color() is used.
130 // If ColorSource() is ON::color_from_object, then value of m_color is used.
131 // If ColorSource() is ON::color_from_material, then the diffuse color of the object's
132 // render material is used. See ON_3dmObjectAttributes::MaterialSource() to
133 // determine where to get the definition of the object's render material.
134 ON::object_color_source ColorSource() const;
135 void SetColorSource( ON::object_color_source ); // See ColorSource().
136
137 // The color used to plot an OpenNURBS object on paper is specified
138 // in one of three ways.
139 // If PlotColorSource() is ON::plot_color_from_layer, then the object's layer
140 // ON_Layer::PlotColor() is used.
141 // If PlotColorSource() is ON::plot_color_from_object, then value of PlotColor() is used.
142 ON::plot_color_source PlotColorSource() const;
143 void SetPlotColorSource( ON::plot_color_source ); // See PlotColorSource().
144
145 ON::plot_weight_source PlotWeightSource() const;
146 void SetPlotWeightSource( ON::plot_weight_source );
147
148
149 // OpenNURBS objects can be displayed in one of three ways: wireframe,
150 // shaded, or render preview. If the display mode is ON::default_display,
151 // then the display mode of the viewport detrmines how the object
152 // is displayed. If the display mode is ON::wireframe_display,
153 // ON::shaded_display, or ON::renderpreview_display, then the object is
154 // forced to display in that mode.
155 ON::display_mode DisplayMode() const;
156 void SetDisplayMode( ON::display_mode ); // See DisplayMode().
157
158 /*
159 Description:
160 If "this" has attributes (color, plot weight, ...) with
161 "by parent" sources, then the values of those attributes
162 on parent_attributes are copied.
163 Parameters:
164 parent_attributes - [in]
165 parent_layer - [in]
166 control_limits - [in]
167 The bits in control_limits determine which attributes may
168 may be copied.
169 1: visibility
170 2: color
171 4: render material
172 8: plot color
173 0x10: plot weight
174 0x20: linetype
175 0x40: display order
176
177 Returns:
178 The bits in the returned integer indicate which attributes were
179 actually modified.
180
181 1: visibility
182 2: color
183 4: render material
184 8: plot color
185 0x10: plot weight
186 0x20: linetype
187 0x40: display order
188 */
189#if defined(ON_COMPILER_MSC)
190 __declspec(deprecated)
191#endif
192 unsigned int ApplyParentalControl(
193 const ON_3dmObjectAttributes& parent_attributes,
194 unsigned int control_limits = 0xFFFFFFFF
195 );
196
197 unsigned int ApplyParentalControl(
198 const ON_3dmObjectAttributes& parent_attributes,
199 const ON_Layer& parent_layer,
200 unsigned int control_limits = 0xFFFFFFFF
201 );
202
203 // Every OpenNURBS object has a UUID (universally unique identifier). The
204 // default value is NULL. When an OpenNURBS object is added to a model, the
205 // value is checked. If the value is NULL, a new UUID is created. If the
206 // value is not NULL but it is already used by another object in the model,
207 // a new UUID is created. If the value is not NULL and it is not used by
208 // another object in the model, then that value persists. When an object
209 // is updated, by a move for example, the value of m_uuid persists.
211
212 // OpenNURBS object have optional text names. More than one object in
213 // a model can have the same name and some objects may have no name.
215
216 // OpenNURBS objects may have an URL. There are no restrictions on what
217 // value this URL may have. As an example, if the object came from a
218 // commercial part library, the URL might point to the definition of that
219 // part.
221
222 // Layer definitions in an OpenNURBS model are stored in a layer table.
223 // The layer table is conceptually an array of ON_Layer classes. Every
224 // OpenNURBS object in a model is on some layer. The object's layer
225 // is specified by zero based indicies into the ON_Layer array.
227
228 // Linetype definitions in an OpenNURBS model are stored in a linetype table.
229 // The linetype table is conceptually an array of ON_Linetype classes. Every
230 // OpenNURBS object in a model references some linetype. The object's linetype
231 // is specified by zero based indicies into the ON_Linetype array.
232 // index 0 is reserved for continuous linetype (no pattern)
234
235 // Rendering material:
236 // If you want something simple and fast, set
237 // m_material_index to the index of the rendering material
238 // and ignore m_rendering_attributes.
239 // If you are developing a high quality plug-in renderer,
240 // and a user is assigning one of your fabulous rendering
241 // materials to this object, then add rendering material
242 // information to the m_rendering_attributes.m_materials[]
243 // array.
244 //
245 // Developers:
246 // As soon as m_rendering_attributes.m_materials[] is not empty,
247 // rendering material queries slow down. Do not populate
248 // m_rendering_attributes.m_materials[] when setting
249 // m_material_index will take care of your needs.
252
253 /*
254 Description:
255 Determine if the simple material should come from
256 the object or from it's layer.
257 High quality rendering plug-ins should use m_rendering_attributes.
258 Returns:
259 Where to get material information if you do are too lazy
260 to look in m_rendering_attributes.m_materials[].
261 */
262 ON::object_material_source MaterialSource() const;
263
264 /*
265 Description:
266 Specifies if the simple material should be the one
267 indicated by the material index or the one indicated
268 by the object's layer.
269 Parameters:
270 ms - [in]
271 */
272 void SetMaterialSource( ON::object_material_source ms );
273
274 // If ON::color_from_object == ColorSource(), then m_color is the object's
275 // display color.
277
278 // If ON::plot_color_from_object == PlotColorSource(), then m_color is the object's
279 // display color.
281
282 // Display order used to force objects to be drawn on top or behind each other
283 // 0 = draw object in standard depth buffered order
284 // <0 = draw object behind "normal" draw order objects
285 // >0 = draw object on top of "noraml" draw order objects
286 // Larger number draws on top of smaller number.
288
289 // Plot weight in millimeters.
290 // =0.0 means use the default width
291 // <0.0 means don't plot (visible for screen display, but does not show on plot)
293
294 // Used to indicate an object has a decoration (like an arrowhead on a curve)
295 ON::object_decoration m_object_decoration;
296
297 // When a surface object is displayed in wireframe, m_wire_density controls
298 // how many isoparametric wires are used.
299 //
300 // @table
301 // value number of isoparametric wires
302 // 0 boundary and knot wires
303 // 1 boundary and knot wires and, if there are no
304 // interior knots, a single interior wire.
305 // N>=2 boundary and knot wires and (N+1) interior wires
307
308
309 // If m_viewport_id is nil, the object is active in
310 // all viewports. If m_viewport_id is not nil, then
311 // this object is only active in a specific view.
312 // This field is primarily used to assign page space
313 // objects to a specific page, but it can also be used
314 // to restrict model space to a specific view.
316
317 // Starting with V4, objects can be in either model space
318 // or page space. If an object is in page space, then
319 // m_viewport_id is not nil and identifies the page it
320 // is on.
321 ON::active_space m_space;
322
323private:
325 unsigned char m_mode; // (m_mode % 16) = ON::object_mode values
326 // (m_mode / 16) = ON::display_mode values
327 unsigned char m_color_source; // ON::object_color_source values
328 unsigned char m_plot_color_source; // ON::plot_color_source values
329 unsigned char m_plot_weight_source; // ON::plot_weight_source values
330 unsigned char m_material_source; // ON::object_material_source values
331 unsigned char m_linetype_source; // ON::object_linetype_source values
332
333 ON_SimpleArray<int> m_group; // array of zero based group indices
334public:
335
336 // group interface
337
338 // returns number of groups object belongs to
339 int GroupCount() const;
340
341 // Returns and array an array of GroupCount() zero based
342 // group indices. If GroupCount() is zero, then GroupList()
343 // returns NULL.
344 const int* GroupList() const;
345
346 // Returns GroupCount() and puts a list of zero based group indices
347 // into the array.
348 int GetGroupList(ON_SimpleArray<int>&) const;
349
350 // Returns the index of the last group in the group list
351 // or -1 if the object is not in any groups
352 int TopGroup() const;
353
354 // Returns true if object is in group with the specified index
355 ON_BOOL32 IsInGroup(
356 int // zero based group index
357 ) const;
358
359 // Returns true if the object is in any of the groups in the list
360 ON_BOOL32 IsInGroups(
361 int, // group_list_count
362 const int* // group_list[] array
363 ) const;
364
365 // Returns true if object is in any of the groups in the list
366 ON_BOOL32 IsInGroups(
367 const ON_SimpleArray<int>& // group_list[] array
368 ) const;
369
370 // Adds object to the group with specified index by appending index to
371 // group list (If the object is already in group, nothing is changed.)
372 void AddToGroup(
373 int // zero based group index
374 );
375
376 // Removes object from the group with specified index. If the
377 // object is not in the group, nothing is changed.
378 void RemoveFromGroup(
379 int // zero based group index
380 );
381
382 // removes the object from the last group in the group list
383 void RemoveFromTopGroup();
384
385 // Removes object from all groups.
386 void RemoveFromAllGroups();
387
388
389 // display material references
390
391 /*
392 Description:
393 Searches for a matching display material. For a given
394 viewport id, there is at most one display material.
395 For a given display material id, there can be multiple
396 viewports. If there is a display reference in the
397 list with a nil viewport id, then the display material
398 will be used in all viewports that are not explictly
399 referenced in other ON_DisplayMaterialRefs.
400
401 Parameters:
402 search_material - [in]
403 found_material - [out]
404
405 If FindDisplayMaterialRef(), the input value of search_material
406 is never changed. If FindDisplayMaterialRef() returns true,
407 the chart shows the output value of display_material. When
408 there are multiple possibilities for a match, the matches
409 at the top of the chart have higher priority.
410
411 search_material found_material
412 input value output value
413
414 (nil,nil) (nil,did) if (nil,did) is in the list.
415 (nil,did) (vid,did) if (vid,did) is in the list.
416 (nil,did) (nil,did) if (nil,did) is in the list.
417 (vid,nil) (vid,did) if (vid,did) is in the list
418 (vid,nil) (vid,did) if (nil,did) is in the list
419 (vid,did) (vid,did) if (vid,did) is in the list.
420
421 Example:
422 ON_UUID display_material_id = ON_nil_uuid;
423 ON_Viewport vp = ...;
424 ON_DisplayMaterialRef search_dm;
425 search_dm.m_viewport_id = vp.ViewportId();
426 ON_DisplayMaterialRef found_dm;
427 if ( attributes.FindDisplayMaterial(search_dm, &found_dm) )
428 {
429 display_material_id = found_dm.m_display_material_id;
430 }
431
432 Returns:
433 True if a matching display material is found.
434 See Also:
435 ON_3dmObjectAttributes::AddDisplayMaterialRef
436 ON_3dmObjectAttributes::RemoveDisplayMaterialRef
437 */
438 bool FindDisplayMaterialRef(
439 const ON_DisplayMaterialRef& search_material,
440 ON_DisplayMaterialRef* found_material = NULL
441 ) const;
442
443 /*
444 Description:
445 Quick way to see if a viewport has a special material.
446 Parameters:
447 viewport_id - [in]
448 display_material_id - [out]
449 Returns:
450 True if a material_id is assigned.
451 */
452 bool FindDisplayMaterialId(
453 const ON_UUID& viewport_id,
454 ON_UUID* display_material_id = NULL
455 ) const;
456
457 /*
458 Description:
459 Add a display material reference to the attributes. If
460 there is an existing entry with a matching viewport id,
461 the existing entry is replaced.
462 Parameters:
463 display_material - [in]
464 Returns:
465 True if input is valid (material id != nil)
466 See Also:
467 ON_3dmObjectAttributes::FindDisplayMaterialRef
468 ON_3dmObjectAttributes::RemoveDisplayMaterialRef
469 */
470 bool AddDisplayMaterialRef(
471 ON_DisplayMaterialRef display_material
472 );
473
474 /*
475 Description:
476 Remove a display material reference from the list.
477 Parameters:
478 viewport_id - [in] Any display material references
479 with this viewport id will be removed. If nil,
480 then viewport_id is ignored.
481 display_material_id - [in]
482 Any display material references that match the
483 viewport_id and have this display_material_id
484 will be removed. If nil, then display_material_id
485 is ignored.
486 Returns:
487 True if a display material reference was removed.
488 See Also:
489 ON_3dmObjectAttributes::FindDisplayMaterialRef
490 ON_3dmObjectAttributes::AddDisplayMaterialRef
491 */
492 bool RemoveDisplayMaterialRef(
493 ON_UUID viewport_id,
494 ON_UUID display_material_id = ON_nil_uuid
495 );
496
497 /*
498 Description:
499 Remove a the entire display material reference list.
500 */
501 void RemoveAllDisplayMaterialRefs();
502
503 /*
504 Returns:
505 Number of diplay material refences.
506 */
507 int DisplayMaterialRefCount() const;
508
510
511private:
512 bool WriteV5Helper( ON_BinaryArchive& file ) const;
513 bool ReadV5Helper( ON_BinaryArchive& file );
514};
515
516#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_3dm_attributes.h:41
int m_linetype_index
Definition opennurbs_3dm_attributes.h:233
ON_wString m_name
Definition opennurbs_3dm_attributes.h:214
int m_display_order
Definition opennurbs_3dm_attributes.h:287
bool m_bVisible
Definition opennurbs_3dm_attributes.h:324
ON_OBJECT_DECLARE(ON_3dmObjectAttributes)
ON_Color m_color
Definition opennurbs_3dm_attributes.h:276
unsigned char m_plot_weight_source
Definition opennurbs_3dm_attributes.h:329
unsigned char m_plot_color_source
Definition opennurbs_3dm_attributes.h:328
ON_UUID m_viewport_id
Definition opennurbs_3dm_attributes.h:315
int m_layer_index
Definition opennurbs_3dm_attributes.h:226
int m_material_index
Definition opennurbs_3dm_attributes.h:250
unsigned char m_color_source
Definition opennurbs_3dm_attributes.h:327
unsigned char m_mode
Definition opennurbs_3dm_attributes.h:325
ON_UUID m_uuid
Definition opennurbs_3dm_attributes.h:210
ON_Color m_plot_color
Definition opennurbs_3dm_attributes.h:280
ON_SimpleArray< int > m_group
Definition opennurbs_3dm_attributes.h:333
ON_wString m_url
Definition opennurbs_3dm_attributes.h:220
ON::object_decoration m_object_decoration
Definition opennurbs_3dm_attributes.h:295
double m_plot_weight_mm
Definition opennurbs_3dm_attributes.h:292
unsigned char m_linetype_source
Definition opennurbs_3dm_attributes.h:331
ON_SimpleArray< ON_DisplayMaterialRef > m_dmref
Definition opennurbs_3dm_attributes.h:509
ON::active_space m_space
Definition opennurbs_3dm_attributes.h:321
unsigned char m_material_source
Definition opennurbs_3dm_attributes.h:330
int m_wire_density
Definition opennurbs_3dm_attributes.h:306
ON_ObjectRenderingAttributes m_rendering_attributes
Definition opennurbs_3dm_attributes.h:251
Definition opennurbs_archive.h:152
Definition opennurbs_color.h:24
Definition opennurbs_linestyle.h:43
Definition opennurbs_layer.h:20
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 unsigned int SizeOf() const
Definition opennurbs_object.cpp:1677
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
Definition opennurbs_rendering.h:38
Definition opennurbs_array.h:46
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_xform.h:28
Definition opennurbs_string.h:392
#define ON_CLASS
Definition opennurbs_defines.h:91
const ON_UUID ON_nil_uuid
Definition opennurbs_object.cpp:132
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362