1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
/****************************************************************************
**
** Copyright (C) 1993-2009 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#pragma once
//==============================================================================
// Includes
//==============================================================================
#include "RuntimePrefix.h"
#include "Qt3DSIPresentation.h"
#include "Qt3DSPresentationFrameData.h"
#include "Qt3DSAnimationSystem.h"
#include "Qt3DSCircularArray.h"
#include "Qt3DSEventCallbacks.h"
#include "Qt3DSTimePolicy.h"
#include "EASTL/hash_map.h"
#include "foundation/StringTable.h"
#include "Qt3DSComponentManager.h"
#include <QObject>
class QPresentationSignalProxy : public QObject
{
Q_OBJECT
Q_SIGNALS:
void SigSlideEntered(const QString &elementPath, unsigned int index, const QString &name);
void SigSlideExited(const QString &elementPath, unsigned int index, const QString &name);
};
namespace qt3ds {
namespace runtime {
class IApplication;
class IActivityZone;
}
}
namespace qt3ds {
namespace render {
class ILoadedBuffer;
}
}
//==============================================================================
// Namespace
//==============================================================================
namespace Q3DStudio {
//==============================================================================
/**
* Intelligent representation of a Studio presentation.
*/
class CPresentation : public IPresentation
{
//==============================================================================
// Fields
//==============================================================================
protected:
QString m_Name; ///< Name of ths presentation
QString m_FilePath; ///< The full path from which this presentation was loaded
qt3ds::runtime::IApplication *m_Application; ///< Runtime object
IScene *m_Scene; ///< Connection to the associated scene (render) for this presentation
qt3ds::runtime::IActivityZone *m_ActivityZone; ///< Controls element active status.
TElement *m_RootElement;
CPresentationFrameData m_FrameData; ///< Storage of data of the current frame
CCircularArray<SEventCommand> m_EventCommandQueue; ///< The Event/Command integrated queue
bool m_IsProcessingEventCommandQueue;
CEventCallbacks m_EventCallbacks; ///< Handles event callbacks on registered elements
SPresentationSize m_Size; ///< Native width, height and mode exported from Studio
qt3ds::foundation::NVScopedRefCounted<qt3ds::render::ILoadedBuffer>
m_LoadedBuffer; ///< Reference to loaded data when loading from binary.
CComponentManager m_ComponentManager;
qt3ds::foundation::NVScopedRefCounted<ISlideSystem>
m_SlideSystem; ///< Container and factory of all logics
qt3ds::foundation::NVScopedRefCounted<ILogicSystem>
m_LogicSystem; ///< Container and factory of all logics
qt3ds::foundation::NVScopedRefCounted<IAnimationSystem>
m_AnimationSystem; ///< Container and factory of all animation tracks
qt3ds::foundation::NVScopedRefCounted<IParametersSystem>
m_ParametersSystem; ///< Container and factory of all custom actions
TTimeUnit m_Offset;
TTimeUnit m_LocalTime;
TTimeUnit m_PreviousGlobalTime;
bool m_Paused;
bool m_OffsetInvalid;
bool m_Active;
typedef eastl::hash_map<TElement *, qt3ds::foundation::CRegisteredString> TElemStringMap;
TElemStringMap m_ElementPathMap;
//==============================================================================
// Methods
//==============================================================================
public: // Construction
CPresentation(const CHAR *inName, qt3ds::runtime::IApplication *inRuntime);
virtual ~CPresentation();
public: // Execution
void Initialize();
// Clear dirty elements
void ClearDirtyList() override;
// Run events
void PreUpdate(const TTimeUnit inGlobalTime) override;
// update element graph
void BeginUpdate() override;
// end update element graph
void EndUpdate() override;
// Run behaviors.
void PostUpdate(const TTimeUnit inGlobalTime) override;
public: // Bridge Control
IScene *GetScene() const override;
IScriptBridge *GetScriptBridgeQml() override;
void SetScene(IScene *inScene) override;
void SetActivityZone(qt3ds::runtime::IActivityZone *inZone);
qt3ds::runtime::IActivityZone *GetActivityZone() override { return m_ActivityZone; }
void SetActive(bool inValue);
bool GetActive() const;
TElement *GetRoot() override { return m_RootElement; }
void SetRoot(TElement &inRoot) override { m_RootElement = &inRoot; }
public: // Commands and Events
void FireEvent(const SEventCommand &inEvent);
void FireEvent(const TEventCommandHash inEventType, TElement *inTarget,
const UVariant *inArg1 = NULL, const UVariant *inArg2 = NULL,
const EAttributeType inType1 = ATTRIBUTETYPE_NONE,
const EAttributeType inType2 = ATTRIBUTETYPE_NONE) override;
void FireCommand(const TEventCommandHash inCommandType, TElement *inTarget,
const UVariant *inArg1 = NULL, const UVariant *inArg2 = NULL,
const EAttributeType inType1 = ATTRIBUTETYPE_NONE,
const EAttributeType inType2 = ATTRIBUTETYPE_NONE) override;
void FlushEventCommandQueue(void) override;
void ProcessEvent(SEventCommand &inEvent) override;
QPresentationSignalProxy *signalProxy();
public: // Event Callbacks
void RegisterEventCallback(TElement *inElement, const TEventCommandHash inEventHash,
const TEventCallback inCallback, void *inContextData) override;
BOOL UnregisterEventCallback(TElement *inElement, const TEventCommandHash inEventHash,
const TEventCallback inCallback, void *inContextData) override;
protected: // Execution Helper Methods
void ProcessAllCallbacks();
BOOL ProcessEventCommandQueue();
void ProcessEvent(SEventCommand &ioEvent, INT32 &ioEventCount);
void ProcessEventBubbling(SEventCommand &ioEvent, INT32 &ioEventCount);
void ProcessCommand(const SEventCommand &inCommand);
public: // Managers
IComponentManager &GetComponentManager() override;
ISlideSystem &GetSlideSystem() override;
IAnimationSystem &GetAnimationSystem() override;
ILogicSystem &GetLogicSystem() override;
IParametersSystem &GetParametersSystem() override;
qt3ds::foundation::IStringTable &GetStringTable() override;
qt3ds::runtime::IApplication &GetApplication() override
{
QT3DS_ASSERT(m_Application);
return *m_Application;
}
void SetLoadedBuffer(qt3ds::render::ILoadedBuffer &inBuffer);
void SetElementPath(TElement &inElement, const char8_t *inPath) override;
qt3ds::foundation::CRegisteredString GetElementPath(TElement &inElement) override;
public: // Helpers
CPresentationFrameData &GetFrameData() override;
TTimeUnit GetTime() { return m_LocalTime; }
public: // Hooks and callbacks
void OnPresentationLoaded() override;
public: // Configuration access
SPresentationSize GetSize() const override;
BOOL GetPause() const;
const QByteArray GetName() const;
void SetSize(const SPresentationSize &inSize) override;
void SetPause(const BOOL inPause);
void SetHide(const BOOL inHide);
void SetUpdateLock(const BOOL inLockUpdate);
void SetVCAA(const BOOL inVCAA);
public: // Full file path
void SetFilePath(const CHAR *inPath) override;
QString GetFilePath() override;
private: // Disabled Copy Construction
CPresentation(CPresentation &);
CPresentation &operator=(const CPresentation &);
private:
QPresentationSignalProxy m_SignalProxy;
};
} // namespace Q3DStudio
|