PartSettings.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Geometry
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2013, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeGeometry/Base.h"
16 #include "CeeVisualization/Model.h"
17 #include "CeeCore/RefCountedObject.h"
18 #include "CeeGeometry/Effect.h"
19 
20 namespace cee {
21 namespace geo {
22 
23 
24 //==================================================================================================
25 //
26 //
27 //
28 //==================================================================================================
29 class CEE_GEO_EXPORT PartSettings : public RefCountedObject
30 {
31 public:
32  PartSettings();
33  virtual ~PartSettings();
34 
35  void setVisible(bool visible);
36  bool visible() const;
37 
38  void setIntersectable(bool intersectable);
39  bool intersectable() const;
40 
41  size_t effectCount() const;
42  size_t effectIndex(const Effect* effect) const;
43  Effect* effect(size_t index);
44  const Effect* effect(size_t index) const;
45  void addEffect(Effect* effect);
46  void removeEffect(Effect* effect);
47  void removeAllEffects();
48 
49  template<typename T>
50  const T* activeEffectOfType() const;
51  template<typename T>
52  T* activeEffectOfType();
53 
54  template<typename T>
55  void removeAllEffectsOfType();
56 
57 private:
58  CEE_PRIVATE_IMPL(PartSettings);
59  CEE_PRIVATE_F(GeometryModel);
60  CEE_PRIVATE_F(Part);
61  CEE_DISALLOW_COPY_AND_ASSIGN(PartSettings);
62 };
63 
64 
65 //--------------------------------------------------------------------------------------------------
67 //--------------------------------------------------------------------------------------------------
68 template<typename T>
70 {
71  size_t i = effectCount();
72  while (i > 0)
73  {
74  i--;
75  if (dynamic_cast<const T*>(effect(i)))
76  {
77  removeEffect(effect(i));
78  }
79  }
80 }
81 
82 
83 //--------------------------------------------------------------------------------------------------
86 //--------------------------------------------------------------------------------------------------
87 template<typename T>
89 {
90  size_t i = effectCount();
91  while (i > 0)
92  {
93  i--;
94  if (dynamic_cast<const T*>(effect(i)))
95  {
96  return static_cast<const T*>(effect(i));
97  }
98  }
99 
100  return NULL;
101 }
102 
103 
104 //--------------------------------------------------------------------------------------------------
107 //--------------------------------------------------------------------------------------------------
108 template<typename T>
110 {
111  // Use the const version to avoid code duplication
112  return const_cast<T*>(static_cast<const PartSettings&>(*this).activeEffectOfType<T>());
113 }
114 
115 } // namespace geo
116 } // namespace cee
117 
Part settings represents how to draw a part and it&#39;s associated part data.
Definition: PartSettings.h:29
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
void removeAllEffectsOfType()
Removes all effects of the given type.
Definition: PartSettings.h:69
Base class for all reference counted objects with built-in support for intrusive reference counting...
Definition: RefCountedObject.h:34
GeometryModel is a subclass of Model that can handle a large number of parts efficiently.
Definition: GeometryModel.h:36
const T * activeEffectOfType() const
Returns the active (last inserted/top of stack) effect of the given type T, or NULL if no effect of t...
Definition: PartSettings.h:88
Base class for an effect describing how to draw a part and it&#39;s associated part data.
Definition: Effect.h:28
Geometry part and how it is to be drawn.
Definition: Part.h:32