Point Cloud Library (PCL)  1.14.1-dev
opennurbs_layer.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_LAYER_INC_)
18 #define OPENNURBS_LAYER_INC_
19 
20 class ON_CLASS ON_Layer : public ON_Object
21 {
22  ON_OBJECT_DECLARE(ON_Layer);
23 
24 public:
25 
28  // C++ default copy construction and operator= work fine.
29  // Do not add custom versions.
30 
31  //////////////////////////////////////////////////////////////////////
32  //
33  // ON_Object overrides
34 
35  /*
36  Description:
37  Tests an object to see if its data members are correctly
38  initialized.
39  Parameters:
40  text_log - [in] if the object is not valid and text_log
41  is not NULL, then a brief englis description of the
42  reason the object is not valid is appened to the log.
43  The information appended to text_log is suitable for
44  low-level debugging purposes by programmers and is
45  not intended to be useful as a high level user
46  interface tool.
47  Returns:
48  @untitled table
49  true object is valid
50  false object is invalid, uninitialized, etc.
51  Remarks:
52  Overrides virtual ON_Object::IsValid
53  */
54  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
55 
56  void Dump( ON_TextLog& ) const; // for debugging
57 
58  ON_BOOL32 Write(
59  ON_BinaryArchive& // serialize definition to binary archive
60  ) const;
61 
62  ON_BOOL32 Read(
63  ON_BinaryArchive& // restore definition from binary archive
64  );
65 
66  ON::object_type ObjectType() const;
67 
69 
70  //////////////////////////////////////////////////////////////////////
71  //
72  // Interface
73 
74  void Default();
75 
76  bool SetLayerName( const char* );
77  bool SetLayerName( const wchar_t* );
78  const ON_wString& LayerName() const;
79 
80  /*
81  Description:
82  The string returned by ON_Layer::LayerNameReferenceDelimiter()
83  is used to separate the name of a reference file from the name of
84  the layer in the file.
85  Example:
86  If a layer named "electrical" is in a file named "house plan.3dm"
87  and "house plan.3dm" is a reference file in a Rhino worksession,
88  then Rhino's user interface will use the string
89  "house plan : electrical" to identify the layer.
90  Returns:
91  " : " (null terminated string space,colon,space)
92  Remarks:
93  Rhino does not save the names of reference files in 3dm archives.
94  Reference file names are used as runtime decorations.
95  */
96  static const wchar_t* LayerNameReferenceDelimiter();
97 
98  /*
99  Description:
100  The string "::" (colon,colon) returned by LayerNamePathDelimiter()
101  is used to separate parent and child layer names.
102  Example:
103  If a model of a building has "level 1" and "level 2" as top level
104  layers, an architect might choose to have a "fixtures" sublayer
105  on each level. The complete layer names would be
106  "level 1::fixtures" and "level 2::fixtures".
107  Returns:
108  "::" (null terminated string colon,colon)
109  */
110  static const wchar_t* LayerNamePathDelimiter();
111 
112  /*
113  Description:
114  Get a layer name's "leaf" level name.
115  Example:
116  If a layer name is "refernce file : alpha::beta::gamma",
117  then ON_Layer::GetLeafName() returns "gamma"
118  Returns:
119  True if the layer has a valid non-empty leaf name.
120  */
121  static bool GetLeafName( const wchar_t* layer_name, ON_wString& leaf_name);
122 
123  /*
124  Description:
125  Get the layer's "parent" path name.
126  Example:
127  If a layer name is "refenence file : alpha::beta::gamma", then
128  ON_Layer::GetParentPathName() returns "alpha::beta"
129  Returns:
130  True if the layer has a valid non-empty parent path name.
131  */
132  static bool GetParentName( const wchar_t* layer_name, ON_wString& parent_path_name );
133 
134  /*
135  Description:
136  Remove any "reference : " prefix from a layer's name.
137  Parameters:
138  layer_name - [in]
139  layer_path_name - [out]
140  layer_name with any reference prefix removed.
141  Example:
142  If a layer name is "refenence file : alpha::beta::gamma", then
143  ON_Layer::RemoveReferenceName() returns "alpha::beta::gamma"
144  Returns:
145  True if layer_path_name is non-empty. If no reference prefix was present,
146  then the returned layer_path_name is identical to the input layer_name.
147  */
148  static bool RemoveReferenceName( const wchar_t* layer_name, ON_wString& layer_path_name );
149 
150  /*
151  Description:
152  Get the layer's reference name.
153  Example:
154  If a layer name is "refenence file : alpha::beta::gamma", then
155  ON_Layer::GetReferenceFileName() returns "refenence file"
156  Returns:
157  True if the layer has a valid non-empty reference file name.
158  */
159  static bool GetReferenceName( const wchar_t* layer_name, ON_wString& reference_name );
160 
161  // The PER_VIEWPORT_SETTINGS enum defines
162  // the bits used to set masks in functions used
163  // to specify and query per viewport layer settings.
165  {
166  per_viewport_none = 0,
167 
168  per_viewport_id = 1,
169  per_viewport_color = 2,
170  per_viewport_plot_color = 4,
171  per_viewport_plot_weight = 8,
172  per_viewport_visible = 16,
173  per_viewport_persistent_visibility = 32,
174 
175  per_viewport_all_settings = 0xFFFFFFFF
176  // (Developers: these values are used in file IO and must not be changed.)
177  };
178 
179  /*
180  Parameters:
181  viewport_id - [in]
182  If viewport_id is not nil, then checks for per viewport
183  settings for that specific viewport.
184  If viewport_id is nil, then checks for per viewport settings
185  in any viewport.
186  settings_mask - [in]
187  settings_mask is a bitfield that specifies which settings
188  to check for. The bits are defined in the
189  ON_Layer::PER_VIEWPORT_PROPERTIES enum. If you want to
190  determine if the layer has any per viewport settings,
191  then pass 0xFFFFFFFF.
192  Returns:
193  True if the layer has per viewport override for the specified
194  settings.
195  */
197  ON_UUID viewport_id,
198  unsigned int settings_mask
199  ) const;
200 
201  /*
202  Parameters:
203  viewport_id - [in]
204  If viewport_id is not nil, then checks for setting for
205  that specific viewport.
206  If viewport_id is nil, then checks for any viewport settings.
207  Returns:
208  True if the layer has per viewport settings.
209  */
211  const ON_UUID& viewport_id
212  ) const;
213 
214 
215  /*
216  Description:
217  Copies all per viewport settings for the source_viewport_id
218  Parameters:
219  source_viewport_id - [in]
220  viewport id to copy all per viewport settings from
221  destination_viewport_id - [in]
222  viewport od to copy all per viewport settings to
223  Returns:
224  True if the settings could be copied, False if no per-viewport
225  settings exist for the source viewport id
226  */
228  ON_UUID source_viewport_id,
229  ON_UUID destination_viewport_id
230  );
231 
232 
233  /*
234  Description:
235  Copies specified per viewport settings from a source layer to this
236  layer.
237  Parameters:
238  source_layer - [in]
239  layer to copy settings from
240  viewport_id - [in]
241  viewport id to copy all per viewport settings from.
242  If viewport_id is nil, then the per viewport settings
243  for all viewports will be copied.
244  settings_mask - [in]
245  bits indicate which settings to copy
246  Use the ON_Layer PER_VIEWPORT_SETTINGS enum to
247  set the bits.
248  Returns:
249  True if the settings were copied, False if no per-viewport
250  settings exist for the specified viewport_id.
251  */
253  const ON_Layer& source_layer,
254  ON_UUID viewport_id,
255  unsigned int settings_mask
256  );
257 
258  /*
259  Description:
260  Delete per viewport layer settings.
261  Parameters:
262  viewport_id - [in]
263  If viewport_id is not nil, then the settings for that
264  viewport are deleted. If viewport_id is nil, then all
265  per viewport settings are deleted.
266  */
268  const ON_UUID& viewport_id
269  ) const;
270 
271  /*
272  Description:
273  Cull unused per viewport layer settings.
274  Parameters:
275  viewport_id_count - [in]
276  viewport_id_list - [in]
277  Settings for any viewports NOT in the viewport_id_list[]
278  are culled.
279  */
281  int viewport_id_count,
282  const ON_UUID* viewport_id_list
283  );
284 
285  /*
286  Description:
287  The PerViewportSettingsCRC() can be used to determine
288  when layers have different per viewport settings.
289  */
290  ON__UINT32 PerViewportSettingsCRC() const;
291 
292  /*
293  Description:
294  Set the color used by objects on this layer that do
295  not have a per object color set
296  Parameters:
297  layer_color - [in]
298  Passing ON_UNSET_COLOR will clear the settings.
299  viewport_id - [in]
300  If viewport_id is not nil, then the setting applies only
301  to the viewport with the specified id.
302  */
303  void SetColor( ON_Color layer_color ); // layer display color
304 
305  /*
306  Description:
307  Set the color used by objects on this layer that do
308  not have a per object color set
309  Parameters:
310  viewport_id - [in]
311  If viewport_id is not nil, then the setting applies only
312  to the viewport with the specified id.
313  layer_color - [in]
314  Passing ON_UNSET_COLOR will clear the settings.
315  */
316  void SetPerViewportColor( ON_UUID viewport_id, ON_Color layer_color );
317 
318  /* use ON_Layer::SetPerViewportColor */
319  ON_DEPRECATED void SetColor( ON_Color, const ON_UUID& );
320 
321  /*
322  Parameters:
323  viewport_id - [in]
324  If viewport_id is not nil, then the setting to use
325  for a specific viewport is returned.
326  Returns:
327  The color used by objects on this layer that do
328  not have a per object color set.
329  */
330  ON_Color Color() const;
331 
332  /*
333  Parameters:
334  viewport_id - [in]
335  If viewport_id is not nil, then the setting to use
336  for a specific viewport is returned.
337  Returns:
338  The color used by objects in the specified viewport and
339  on this layer that do not have a per object color set.
340  */
341  ON_Color PerViewportColor( ON_UUID viewport_id ) const;
342 
343  /* use ON_Layer::PerViewportColor */
344  ON_DEPRECATED ON_Color Color( const ON_UUID& ) const;
345 
346  /*
347  Description:
348  Remove any per viewport layer color setting so the
349  layer's overall setting will be used for all viewports.
350  Parameters:
351  viewport_id - [in]
352  If viewport_id is not nil, then the setting for this
353  viewport will be deleted. If viewport_id is nil,
354  the all per viewport layer color settings will be removed.
355  */
356  void DeletePerViewportColor( const ON_UUID& viewport_id );
357 
358  /*
359  Description:
360  Set the plotting color used by objects on this layer that do
361  not have a per object plotting color set
362  Parameters:
363  plot_color - [in]
364  Passing ON_UNSET_COLOR will clear the settings.
365  viewport_id - [in]
366  If viewport_id is not nil, then the setting applies only
367  to the viewport with the specified id.
368  */
369  void SetPlotColor( ON_Color plot_color ); // plotting color
370 
371  void SetPerViewportPlotColor( ON_UUID viewport_id, ON_Color plot_color );
372 
373  /* use ON_Layer::SetPerViewportPlotColor */
374  ON_DEPRECATED void SetPlotColor( ON_Color, const ON_UUID& );
375 
376  /*
377  Returns:
378  The plotting color used by objects on this layer that do
379  not have a per object color set.
380  */
382 
383  /*
384  Parameters:
385  viewport_id - [in]
386  If viewport_id is not nil, then the setting to use
387  for a specific viewport is returned.
388  Returns:
389  The plotting color used by objects on this layer that do
390  not have a per object color set.
391  */
392  ON_Color PerViewportPlotColor( ON_UUID viewport_id ) const;
393 
394  /* use ON_Layer::PerViewportPlotColor */
395  ON_DEPRECATED ON_Color PlotColor( const ON_UUID& ) const;
396 
397  /*
398  Description:
399  Remove any per viewport plot color setting so the
400  layer's overall setting will be used for all viewports.
401  Parameters:
402  viewport_id - [in]
403  If viewport_id is not nil, then the setting for this
404  viewport will be deleted. If viewport_id is nil,
405  the all per viewport plot color settings will be removed.
406  */
407  void DeletePerViewportPlotColor( const ON_UUID& viewport_id );
408 
409  /*
410  Description:
411  Set the index of the linetype used by objects on this layer that do
412  not have a per object lintypes
413  Parameters:
414  linetype_index - [in]
415  Passing -1 will clear the setting.
416  */
417  bool SetLinetypeIndex( int linetype_index );
418 
419  /*
420  Returns:
421  The index of the linetype used by objects on this layer that do
422  not have a per object linetype set.
423  */
424  int LinetypeIndex() const;
425 
426  /*
427  Returns:
428  Returns true if objects on layer are visible.
429  Remarks:
430  Does not inspect per viewport settings.
431  See Also:
432  ON_Layer::SetVisible
433  */
434  bool IsVisible() const;
435 
436  /*
437  Description:
438  Controls layer visibility
439  Parameters:
440  bVisible - [in] true to make layer visible,
441  false to make layer invisible
442  viewport_id - [in]
443  If viewport_id is not nil, then the setting applies only
444  to the viewport with the specified id.
445  See Also:
446  ON_Layer::IsVisible
447  */
448  void SetVisible( bool bVisible );
449 
450  /*
451  Description:
452  The persistent visbility setting is used for layers whose
453  visibilty can be changed by a "parent" object. A common case
454  is when a layer is a child layer (ON_Layer.m_parent_id is
455  not nil). In this case, when a parent layer is turned off,
456  then child layers are also turned off. The persistent
457  visibility setting determines what happens when the parent
458  is turned on again.
459  Returns:
460  true:
461  If this layer's visibility is controlled by a parent object
462  and the parent is turned on (after being off), then this
463  layer will also be turned on.
464  false:
465  If this layer's visibility is controlled by a parent object
466  and the parent layer is turned on (after being off), then
467  this layer will continue to be off.
468  Remarks:
469  When the persistent visbility is not explicitly set, this
470  function returns the current value of IsVisible().
471  See Also:
472  ON_Layer::SetPersistentVisibility
473  ON_Layer::UnsetPersistentVisibility
474  */
475  bool PersistentVisibility() const;
476 
477  /*
478  Description:
479  Set the persistent visibility setting for this layer.
480  Parameters:
481  bPersistentVisibility - [in]
482  persistent visibility setting for this layer.
483  Remarks:
484  See ON_Layer::PersistentVisibility for a detailed description
485  of persistent visibility.
486  See Also:
487  ON_Layer::PersistentVisibility
488  ON_Layer::UnsetPersistentVisibility
489  */
490  void SetPersistentVisibility( bool bPersistentVisibility );
491 
492  /*
493  Description:
494  Remove any explicit persistent visibility setting from this
495  layer. When persistent visibility is not explictly set,
496  the value of ON_Layer::IsVisible() is used.
497  Remarks:
498  See ON_Layer::PersistentVisibility for a detailed description
499  of persistent visibility.
500  See Also:
501  ON_Layer::PersistentVisibility
502  ON_Layer::SetPersistentVisibility
503  */
505 
506  /*
507  Parameters:
508  viewport_id - [in]
509  If viewport_id is not nil, then the visibility setting
510  for that viewport is returned. If viewport_id
511  is nil, then true is returned if the layer is visible
512  in some viewport.
513  Returns:
514  Returns true if objects on layer are visible.
515  */
516  bool PerViewportIsVisible( ON_UUID viewport_id ) const;
517 
518  /* use ON_Layer::PerViewportIsVisible */
519  ON_DEPRECATED bool IsVisible( const ON_UUID& ) const;
520 
521  /*
522  Description:
523  Controls layer visibility in specific viewports.
524  Parameters:
525  viewport_id - [in]
526  If viewport_id is not nil, then the setting applies only
527  to the viewport with the specified id. If viewport_id
528  is nil, then the setting applies to all viewports with
529  per viewport layer settings.
530  bVisible - [in] true to make layer visible,
531  false to make layer invisible
532  See Also:
533  ON_Layer::IsVisibleInViewport()
534  */
535  void SetPerViewportVisible( ON_UUID viewport_id, bool bVisible );
536 
537  /* use ON_Layer::SetPerViewportVisible */
538  ON_DEPRECATED void SetVisible( bool, const ON_UUID& );
539 
540  /*
541  Parameters:
542  viewport_id - [in]
543  id of a viewport. If viewport_id is nil, then
544  ON_Layer::PersistentVisibility() is returned.
545  Returns:
546  true:
547  If this layer's visibility in the specified viewport is
548  controlled by a parent object and the parent is turned on
549  (after being off), then this layer will also be turned on
550  in the specified viewport.
551  false:
552  If this layer's visibility in the specified viewport is
553  controlled by a parent object and the parent layer is
554  turned on (after being off), then this layer will continue
555  to be off in the specified viewport.
556  Remarks:
557  See ON_Layer::SetPersistentVisibility
558  for a description of persistent visibility.
559  See Also:
560  ON_Layer::SetPerViewportPersistentVisibility
561  */
562  bool PerViewportPersistentVisibility( ON_UUID viewport_id ) const;
563 
564  /*
565  Description:
566  This function allows per viewport setting the
567  child visibility property.
568  Parameters
569  viewport_id - [in]
570  bPersistentVisibility - [in]
571  Remarks:
572  See ON_Layer::SetPersistentVisibility
573  for a description of the child visibility property.
574  See Also:
575  ON_Layer::SetPersistentVisibility
576  */
577  void SetPerViewportPersistentVisibility( ON_UUID viewport_id, bool bPersistentVisibility );
578 
580 
581  /*
582  Description:
583  Remove any per viewport visibility setting so the
584  layer's overall setting will be used for all viewports.
585  Parameters:
586  viewport_id - [in]
587  If viewport_id is not nil, then the setting for this
588  viewport will be deleted. If viewport_id is nil,
589  the all per viewport visibility settings will be removed.
590  */
591  void DeletePerViewportVisible( const ON_UUID& viewport_id );
592 
593  /*
594  Description:
595  Get a list of the viewport ids of viewports that
596  that have per viewport visibility settings that
597  override the default layer visibility setting
598  ON_Layer::m_bVisible.
599  Parameters:
600  viewport_id_list - [out]
601  List of viewport id's that have a per viewport visibility
602  setting. If the returned list is empty, then there
603  are no per viewport visibility settings.
604  Returns:
605  Number of ids added to the list.
606  */
608  ON_SimpleArray<ON_UUID>& viewport_id_list
609  ) const;
610 
611  /*
612  Returns:
613  Returns true if objects on layer are locked.
614  See Also:
615  ON_Layer::SetLocked
616  */
617  bool IsLocked() const;
618 
619  /*
620  Description:
621  Controls layer locked
622  Parameters:
623  bLocked - [in] True to lock layer
624  False to unlock layer
625  See Also:
626  ON_Layer::IsLocked
627  */
628  void SetLocked( bool bLocked );
629 
630  /*
631  Description:
632  The persistent locking setting is used for layers that can
633  be locked by a "parent" object. A common case is when a layer
634  is a child layer (ON_Layer.m_parent_id is not nil). In this
635  case, when a parent layer is locked, then child layers are
636  also locked. The persistent locking setting determines what
637  happens when the parent is unlocked again.
638  Returns:
639  true:
640  If this layer's locking is controlled by a parent object
641  and the parent is unlocked (after being locked), then this
642  layer will also be unlocked.
643  false:
644  If this layer's locking is controlled by a parent object
645  and the parent layer is unlocked (after being locked), then
646  this layer will continue to be locked.
647  Remarks:
648  When the persistent locking is not explicitly set, this
649  function returns the current value of IsLocked().
650  See Also:
651  ON_Layer::SetPersistentLocking
652  ON_Layer::UnsetPersistentLocking
653  */
654  bool PersistentLocking() const;
655 
656  /*
657  Description:
658  Set the persistent locking setting for this layer.
659  Parameters:
660  bPersistentLocking - [in]
661  persistent locking for this layer.
662  Remarks:
663  See ON_Layer::PersistentLocking for a detailed description of
664  persistent locking.
665  See Also:
666  ON_Layer::PersistentLocking
667  ON_Layer::UnsetPersistentLocking
668  */
669  void SetPersistentLocking(bool bPersistentLocking);
670 
671  /*
672  Description:
673  Remove any explicity persistent locking settings from this
674  layer.
675  Remarks:
676  See ON_Layer::PersistentLocking for a detailed description of
677  persistent locking.
678  See Also:
679  ON_Layer::PersistentLocking
680  ON_Layer::SetPersistentLocking
681  */
683 
684  /*
685  Returns:
686  Value of (IsVisible() && !IsLocked()).
687  */
688  bool IsVisibleAndNotLocked() const;
689 
690  /*
691  Returns:
692  Value of (IsVisible() && IsLocked()).
693  */
694  bool IsVisibleAndLocked() const;
695 
696  //////////
697  // Index of render material for objects on this layer that have
698  // MaterialSource() == ON::material_from_layer.
699  // A material index of -1 indicates no material has been assigned
700  // and the material created by the default ON_Material constructor
701  // should be used.
702  bool SetRenderMaterialIndex( int ); // index of layer's rendering material
703  int RenderMaterialIndex() const;
704 
705  bool SetLayerIndex( int ); // index of this layer;
706  int LayerIndex() const;
707 
708  bool SetIgesLevel( int ); // IGES level for this layer
709  int IgesLevel() const;
710 
711  /*
712  Description:
713  Get the weight (thickness) of the plotting pen.
714  Returns:
715  Thickness of the plotting pen in millimeters.
716  A thickness of 0.0 indicates the "default" pen weight should be used.
717  A thickness of -1.0 indicates the layer should not be printed.
718  */
719  double PlotWeight() const;
720 
721  double PerViewportPlotWeight( ON_UUID viewport_id ) const;
722 
723  /* use ON_Layer::PerViewportPlotWeight */
724  ON_DEPRECATED double PlotWeight( const ON_UUID& ) const;
725 
726  /*
727  Description:
728  Set the weight of the plotting pen.
729  Parameters:
730  plot_weight_mm - [in] Set the thickness of the plotting pen in millimeters.
731  0.0 means use the default pen width which is a Rhino app setting.
732  -1.0 means layer does not print (still displays on the screen)
733  */
734  void SetPlotWeight(double plot_weight_mm);
735 
736  /*
737  Description:
738  Set the weight of the plotting pen.
739  Parameters:
740  plot_weight_mm - [in] Set the thickness of the plotting pen in millimeters.
741  0.0 means use the default pen width which is a Rhino app setting.
742  -1.0 means layer does not print (still displays on the screen)
743  */
744  void SetPerViewportPlotWeight(ON_UUID viewport_id, double plot_weight_mm);
745 
746  /* use ON_Layer::SetPerViewportPlotWeight */
747  ON_DEPRECATED void SetPlotWeight(double, const ON_UUID& );
748 
749  /*
750  Description:
751  Remove any per viewport plot weight setting so the
752  layer's overall setting will be used for all viewports.
753  Parameters:
754  viewport_id - [in]
755  If viewport_id is not nil, then the setting for this
756  viewport will be deleted. If viewport_id is nil,
757  the all per viewport plot weight settings will be removed.
758  */
759  void DeletePerViewportPlotWeight( const ON_UUID& viewport_id );
760 
761  /*
762  Description:
763  Use UpdateViewportIds() to change viewport ids in situations
764  like merging when a viewport id conflict requires the viewport
765  ids in a file to be changed.
766  Returns:
767  Number of viewport ids that were updated.
768  */
770  const ON_UuidPairList& viewport_id_map
771  );
772 
773 public:
774 
775  int m_layer_index; // index of this layer
777  ON_UUID m_parent_layer_id; // Layers are origanized in a hierarchical
778  // structure (like file folders).
779  // If a layer is in a parent layer,
780  // then m_parent_layer_id is the id of
781  // the parent layer.
782 
783  int m_iges_level; // IGES level number if this layer was made during IGES import
784 
785 
786 
787  // Rendering material:
788  // If you want something simple and fast, set
789  // m_material_index to the index of your rendering material
790  // and ignore m_rendering_attributes.
791  // If you are developing a fancy plug-in renderer, and a user is
792  // assigning one of your fabulous rendering materials to this
793  // layer, then add rendering material information to the
794  // m_rendering_attributes.m_materials[] array.
795  //
796  // Developers:
797  // As soon as m_rendering_attributes.m_materials[] is not empty,
798  // rendering material queries slow down. Do not populate
799  // m_rendering_attributes.m_materials[] when setting
800  // m_material_index will take care of your needs.
803 
804  int m_linetype_index; // index of linetype
805 
806  // Layer display attributes.
807  // If m_display_material_id is nil, then m_color is the layer color
808  // and defaults are used for all other display attributes.
809  // If m_display_material_id is not nil, then some complicated
810  // scheme is used to decide what objects on this layer look like.
811  // In all cases, m_color is a good choice if you don't want to
812  // deal with m_display_material_id. In Rhino, m_display_material_id
813  // is used to identify a registry entry that contains user specific
814  // display preferences.
817 
818  // Layer printing (plotting) attributes.
819  ON_Color m_plot_color; // printing color
820  // ON_UNSET_COLOR means use layer color
821  double m_plot_weight_mm; // printing pen thickness in mm
822  // 0.0 means use the default width (a Rhino app setting)
823  // -1.0 means layer does not print (still visible on screen)
825 
826  bool m_bVisible; // If true, objects on this layer are visible.
827  bool m_bLocked; // If true, objects on this layer cannot be modified.
828  bool m_bExpanded; // If true, when the layer table is displayed in
829  // a tree control then the list of child layers is
830  // shown in the control.
831 
832 
833  //////////////////////////////////////////////////////////////
834  //
835  // Tools for saving layer settings.
836  //
838  {
839  no_layer_settings = 0,
840  userdata_settings = 1,
841  color_settings = 2,
842  plot_color_settings = 4,
843  plot_weight_settings = 8,
844  visible_settings = 16,
845  locked_settings = 32,
846  all_layer_settings = 0xFFFFFFFF
847  };
848 
849  /*
850  Returns:
851  Bits in the returned value indicate if there are differences
852  between layer0 and layer1. For example, if the layers have
853  difference color, then the returned value would have the
854  "color" bit set.
855  */
856  static unsigned int Differences( const ON_Layer& layer0, const ON_Layer& layer1 );
857 
858  /*
859  Description:
860  Use settings_values and settings to set the specified values
861  on this layer.
862  Parameters:
863  settings_values - [in]
864  settings - [in]
865  LAYER_SETTINGS bits specify which values of this
866  should be set from settings_values.
867  */
868  void Set( unsigned int settings, const ON_Layer& settings_values );
869 
870  /*
871  Description:
872  Saves current values of the specified settings so
873  they can be retrieved by GetSettings().
874  Parameters:
875  settings - [in]
876  LAYER_SETTINGS bits specify which values to save.
877  if 0 == settings, then all saved settings are deleted.
878  bUpdate - [in]
879  If true, then previously saved settings for properties
880  not identified by the settings paramter are left intact.
881  If false, all previously saved settings are removed.
882  */
883  void SaveSettings( unsigned int settings, bool bUpdate );
884 
885  /*
886  Returns:
887  0 if the layer does not have saved settings.
888  Nonzero value with LAYER_SETTINGS bits specifying which settings
889  are saved. The saved that can be retrieved by calling
890  GetSavedSettings().
891  */
892  unsigned int SavedSettings() const;
893 
894  /*
895  Description:
896  Gets values of the saved settings.
897  Parameters:
898  layer - [in/out]
899  values of saved settings are set and all other values are
900  left unchanged.
901  settings - [out]
902  LAYER_SETTINGS bits specify which layer values were set
903  by this call.
904  Returns:
905  True if there were saved settings.
906  */
907  bool GetSavedSettings( ON_Layer& layer, unsigned int& settings ) const;
908 
909 private:
910  // The following information may not be accurate and is subject
911  // to change at any time.
912  //
913  // m_extension_bits & 0x01:
914  // The value of ( m_extension_bits & 0x01) is used to speed
915  // common per viewport visiblity and color queries.
916  // 0x00 = there may be per viewport settings on this layer.
917  // 0x01 = there are no per viewport settings on this layer.
918  //
919  // m_extension_bits & 0x06:
920  // The value of ( m_extension_bits & 0x06) is the persistent
921  // visibility setting for this layer.
922  // 0x00 = no persistent visibility setting
923  // 0x02 = persistent visibility = true
924  // 0x04 = persistent visibility = false
925  // 0x06 = invalid value - treated as 0x00
926  //
927  // m_extension_bits & 0x18:
928  // The value of ( m_extension_bits & 0x18) is the persistent
929  // locking setting for this layer.
930  // 0x00 = no persistent locking setting
931  // 0x08 = persistent locking = true
932  // 0x10 = persistent locking = false
933  // 0x18 = invalid value - treated as 0x00
934  unsigned char m_extension_bits;
935 };
936 
937 
938 #endif
939 
bool IsVisible() const
void SetPerViewportVisible(ON_UUID viewport_id, bool bVisible)
bool CopyPerViewportSettings(ON_UUID source_viewport_id, ON_UUID destination_viewport_id)
unsigned int SavedSettings() const
static const wchar_t * LayerNamePathDelimiter()
ON_RenderingAttributes m_rendering_attributes
void UnsetPerViewportPersistentVisibility(ON_UUID viewport_id)
void SetPerViewportColor(ON_UUID viewport_id, ON_Color layer_color)
ON_Color m_color
void SetPerViewportPersistentVisibility(ON_UUID viewport_id, bool bPersistentVisibility)
ON_Color Color() const
void DeletePerViewportSettings(const ON_UUID &viewport_id) const
bool SetRenderMaterialIndex(int)
static unsigned int Differences(const ON_Layer &layer0, const ON_Layer &layer1)
int UpdateViewportIds(const ON_UuidPairList &viewport_id_map)
bool HasPerViewportSettings(ON_UUID viewport_id, unsigned int settings_mask) const
ON_UUID m_parent_layer_id
static const wchar_t * LayerNameReferenceDelimiter()
void SetColor(ON_Color layer_color)
void SetPlotColor(ON_Color plot_color)
void DeletePerViewportColor(const ON_UUID &viewport_id)
ON_DEPRECATED void SetColor(ON_Color, const ON_UUID &)
ON_DEPRECATED ON_Color Color(const ON_UUID &) const
bool SetIgesLevel(int)
bool PersistentLocking() const
void DeletePerViewportPlotWeight(const ON_UUID &viewport_id)
ON_DEPRECATED void SetPlotWeight(double, const ON_UUID &)
bool HasPerViewportSettings(const ON_UUID &viewport_id) const
void DeletePerViewportPlotColor(const ON_UUID &viewport_id)
bool SetLinetypeIndex(int linetype_index)
void Set(unsigned int settings, const ON_Layer &settings_values)
void SetPersistentVisibility(bool bPersistentVisibility)
int RenderMaterialIndex() const
static bool RemoveReferenceName(const wchar_t *layer_name, ON_wString &layer_path_name)
bool IsLocked() const
bool IsVisibleAndNotLocked() const
void SetPersistentLocking(bool bPersistentLocking)
ON_DEPRECATED void SetPlotColor(ON_Color, const ON_UUID &)
double m_plot_weight_mm
int m_material_index
void DeletePerViewportVisible(const ON_UUID &viewport_id)
void Dump(ON_TextLog &) const
void UnsetPersistentVisibility()
ON_Color m_plot_color
void SetPerViewportPlotColor(ON_UUID viewport_id, ON_Color plot_color)
bool m_bExpanded
ON_DEPRECATED bool IsVisible(const ON_UUID &) const
bool SetLayerName(const char *)
ON_DEPRECATED double PlotWeight(const ON_UUID &) const
ON_DEPRECATED ON_Color PlotColor(const ON_UUID &) const
void CullPerViewportSettings(int viewport_id_count, const ON_UUID *viewport_id_list)
void SetLocked(bool bLocked)
ON_BOOL32 Read(ON_BinaryArchive &)
static bool GetParentName(const wchar_t *layer_name, ON_wString &parent_path_name)
void SetPlotWeight(double plot_weight_mm)
ON_DEPRECATED void SetVisible(bool, const ON_UUID &)
void SetPerViewportPlotWeight(ON_UUID viewport_id, double plot_weight_mm)
int IgesLevel() const
ON_Color PerViewportPlotColor(ON_UUID viewport_id) const
static bool GetReferenceName(const wchar_t *layer_name, ON_wString &reference_name)
void SetVisible(bool bVisible)
int m_linetype_index
bool GetSavedSettings(ON_Layer &layer, unsigned int &settings) const
ON_BOOL32 Write(ON_BinaryArchive &) const
ON_UUID m_display_material_id
void GetPerViewportVisibilityViewportIds(ON_SimpleArray< ON_UUID > &viewport_id_list) const
bool SetLayerName(const wchar_t *)
static bool GetLeafName(const wchar_t *layer_name, ON_wString &leaf_name)
bool CopyPerViewportSettings(const ON_Layer &source_layer, ON_UUID viewport_id, unsigned int settings_mask)
ON_UUID ModelObjectId() const
double PerViewportPlotWeight(ON_UUID viewport_id) const
ON_UUID m_layer_id
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
bool PerViewportIsVisible(ON_UUID viewport_id) const
ON_Color PlotColor() const
double PlotWeight() const
ON_Color PerViewportColor(ON_UUID viewport_id) const
bool PerViewportPersistentVisibility(ON_UUID viewport_id) const
bool IsVisibleAndLocked() const
ON__UINT32 PerViewportSettingsCRC() const
ON_wString m_name
void Default()
int LinetypeIndex() const
bool SetLayerIndex(int)
bool PersistentVisibility() const
int LayerIndex() const
ON::object_type ObjectType() const
void UnsetPersistentLocking()
const ON_wString & LayerName() const
void SaveSettings(unsigned int settings, bool bUpdate)