Emergency 20 Dokumentation  4.2.0
OverlayComponent.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
15 
18 
19 #include <glm/glm.hpp>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace qsf
26 {
27  class MeshComponent;
28 }
29 namespace Rocket
30 {
31  namespace Core
32  {
33  class ElementDocument;
34  }
35 }
36 
37 
38 //[-------------------------------------------------------]
39 //[ Namespace ]
40 //[-------------------------------------------------------]
41 namespace em5
42 {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Classes ]
47  //[-------------------------------------------------------]
53  {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Friends ]
58  //[-------------------------------------------------------]
59  friend class OverlayManager;
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public definitions ]
64  //[-------------------------------------------------------]
65  public:
66  static const uint32 COMPONENT_ID;
67 
68 
69  //[-------------------------------------------------------]
70  //[ Public methods ]
71  //[-------------------------------------------------------]
72  public:
77  virtual ~OverlayComponent();
78 
79 
80  //[-------------------------------------------------------]
81  //[ Protected methods ]
82  //[-------------------------------------------------------]
83  protected:
93  explicit OverlayComponent(qsf::Prototype* prototype, OverlayWindowManager& overlayWindowManager);
94 
95  void checkEmptyStateChanged();
96  void makeDirty();
97 
98  void avoidDelayedDestruction();
99  void triggerDelayedDestruction();
100 
101  void onPreCompositorWorkspaceUpdate(const Ogre::Camera& ogreCamera);
102 
103 
104  //[-------------------------------------------------------]
105  //[ Protected virtual em5::OverlayComponent methods ]
106  //[-------------------------------------------------------]
107  protected:
112  inline virtual bool isContentEmpty() const;
113 
114  inline virtual void updateContent(Rocket::Core::ElementDocument& document);
115 
116  virtual const glm::vec3& getContentWorldSpaceOffset() const = 0;
117  virtual const glm::vec2& getContentWindowSize() const = 0;
118  virtual const glm::vec2& getContentWindowOffset() const = 0;
119 
120  inline virtual void updateAnimation(const qsf::JobArguments& jobArguments);
121 
122 
123  //[-------------------------------------------------------]
124  //[ Protected virtual qsf::Component methods ]
125  //[-------------------------------------------------------]
126  protected:
127  virtual void onSetSimulating(bool simulating) override;
128 
129 
130  //[-------------------------------------------------------]
131  //[ Protected virtual qsf::MovableObjectRenderingListener methods ]
132  //[-------------------------------------------------------]
133  protected:
134  virtual qsf::Component* getMovableObjectRenderingListenerComponent() override;
135  virtual void onObjectRenderingStartup() override;
136  virtual void onObjectRendering(const qsf::Component& component, const Ogre::Camera& ogreCamera) override;
137  virtual void onObjectRenderingShutdown() override;
138 
139 
140  //[-------------------------------------------------------]
141  //[ Protected data ]
142  //[-------------------------------------------------------]
143  protected:
145 
146 
147  //[-------------------------------------------------------]
148  //[ Private methods ]
149  //[-------------------------------------------------------]
150  private:
151  bool calculateScreenPosition(const qsf::MeshComponent& meshComponent, const Ogre::Camera& ogreCamera, glm::vec2& screenPosition) const;
152  void onDelayedDestruction(const qsf::JobArguments& jobArguments);
153 
154 
155  //[-------------------------------------------------------]
156  //[ Private definitions ]
157  //[-------------------------------------------------------]
158  private:
159  struct DoubleLinkedListEntry
160  {
161  bool mIsRegistered;
162  OverlayComponent* mPrevious;
163  OverlayComponent* mNext;
164  DoubleLinkedListEntry() : mIsRegistered(false), mPrevious(nullptr), mNext(nullptr) {}
165  };
166 
167 
168  //[-------------------------------------------------------]
169  //[ Private data ]
170  //[-------------------------------------------------------]
171  private:
172  bool mLastIsContentEmptyState;
173  qsf::JobProxy mJobProxy;
174  qsf::JobProxy mDestructionJobProxy;
175  bool mScreenRendered;
176  glm::vec2 mScreenPosition;
177 
178  // Registration in manager
179  qsf::WeakPtr<qsf::MeshComponent> mVisibleMeshComponent;
180  DoubleLinkedListEntry mVisibleOverlayComponentsEntry;
181 
182 
183  //[-------------------------------------------------------]
184  //[ CAMP reflection system ]
185  //[-------------------------------------------------------]
186  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
187 
188 
189  };
190 
191 
192 //[-------------------------------------------------------]
193 //[ Namespace ]
194 //[-------------------------------------------------------]
195 } // em5
196 
197 
198 //[-------------------------------------------------------]
199 //[ Implementation ]
200 //[-------------------------------------------------------]
202 
203 
204 //[-------------------------------------------------------]
205 //[ CAMP reflection system ]
206 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 overlay manager class.
Definition: OverlayManager.h:45
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Job proxy based OGRE movable object rendering listener.
Definition: JobProxyMovableObjectRenderingListener.h:31
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
static const uint32 COMPONENT_ID
"em5::OverlayComponent" unique component ID
Definition: OverlayComponent.h:66
EMERGENCY 5 overlay component base class.
Definition: OverlayComponent.h:52
Definition: OverlayComponent.h:29
Lightweight weak pointer implementation.
Definition: WeakPtr.h:133
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Mesh component class.
Definition: MeshComponent.h:51
qsf::WeakPtr< OverlayWindowManager > mOverlayWindowManager
Definition: OverlayComponent.h:144
Prototype class.
Definition: Prototype.h:100
EMERGENCY 5 overlay window manager base class.
Definition: OverlayWindowManager.h:43