summaryrefslogtreecommitdiffstats
path: root/src/dm/systems/Qt3DSDMMetaDataTypes.h
blob: 5532e0a56dfb88562bee03b0b96e814d4c513d7f (plain)
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/****************************************************************************
**
** Copyright (C) 2008 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-EXCEPT$
** 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 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** 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
#include "Qt3DSDMMetaDataValue.h"

namespace qt3ds {
namespace render {
    namespace dynamic {
        struct SCommand;
        struct SPropertyDeclaration;
        struct SPropertyDefinition;
    }
}
}

namespace qt3dsdm {

struct HandlerArgumentType {

  enum Value {
    None,
    Property, // Property reference. Load the Properties of the Target Object.
    Dependent, // Property type depends on another property.
    Slide, // Slide reference. Load the list of slides of the Target Object if
    // applicable.
    Event, // Event reference. Load the applicable Events of the Target Object.
    Object, // Object reference. Used for dynamic actions with object referenced
    // property.
    Signal, // Signal reference. Used for emiting signals fired from the trigger
    // object.
  };

  Q_ENUM(Value)
  Q_GADGET
};

struct CompleteMetaDataType
{
    enum Enum {
        Unknown = 0,
        StringList,
        FloatRange,
        LongRange,
        Float,
        Long,
        Float2,
        Vector,
        Scale,
        Rotation,
        Color,
        Boolean,
        Slide,
        Font,
        FontSize,
        String,
        MultiLineString,
        ObjectRef,
        Image,
        Mesh,
        Import,
        Texture,
        Guid,
        StringListOrInt,
        Renderable,
        Image2D,
        Buffer,
        PathBuffer,
        ShadowMapResolution,
    };

    // Functions defined in UICDMMetaData.cpp
    static DataModelDataType::Value ToDataType(Enum inCompleteType);
    static AdditionalMetaDataType::Value ToAdditionalType(Enum inCompleteType);
    static CompleteMetaDataType::Enum ToCompleteType(DataModelDataType::Value inDataType,
                                                     AdditionalMetaDataType::Value inAdditionalType);
    Q_ENUM(Enum)
    Q_GADGET
};

typedef std::pair<DataModelDataType::Value, AdditionalMetaDataType::Value> TDataTypePair;

inline bool Equals(const TMetaDataData &lhs, const TMetaDataData &rhs)
{
    return rhs == lhs;
}

inline AdditionalMetaDataType::Value GetMetaDataValueType(const TMetaDataData &inValue)
{
    return inValue.getType();
}

// Base class shared between property info
// and handler arguments.
struct SMetaPropertyBase
{
    TCharStr m_Name;
    TCharStr m_FormalName;
    TCharStr m_Usage;
    TCharStr m_Description;
    CompleteMetaDataType::Enum m_CompleteType;
    TMetaDataData m_MetaDataData;
    SValue m_DefaultValue;

    SMetaPropertyBase()
        : m_CompleteType(CompleteMetaDataType::Float)
    {
    }
    bool operator==(const SMetaPropertyBase &inOther) const
    {
        return m_Name == inOther.m_Name && m_FormalName == inOther.m_FormalName
            && m_Usage == inOther.m_Usage && m_Description == inOther.m_Description
            && m_CompleteType == inOther.m_CompleteType
            && Equals(m_DefaultValue.toOldSkool(), inOther.m_DefaultValue.toOldSkool())
            && Equals(m_MetaDataData, inOther.m_MetaDataData);
    }
    DataModelDataType::Value GetDataType() const
    {
        return CompleteMetaDataType::ToDataType(m_CompleteType);
    }
    AdditionalMetaDataType::Value GetAdditionalType() const
    {
        return CompleteMetaDataType::ToAdditionalType(m_CompleteType);
    }
};

struct SMetaDataPropertyInfo : SMetaPropertyBase
{
    Qt3DSDMInstanceHandle m_Instance;
    Qt3DSDMPropertyHandle m_Property;
    bool m_Controllable = false; // Can this property be controlled via data input (default no)
    bool m_IsHidden = false;     // Is this property hidden in the inspector (default no)
    bool m_Animatable = true;    // Is this property animatable (default yes)
    // Note: all animatables are controllable

    TCharStr m_GroupName; // Name of the group this property belongs to or "default"

    SMetaDataPropertyInfo(Qt3DSDMInstanceHandle inInstance)
        : m_Instance(inInstance)
    {
    }
    SMetaDataPropertyInfo() {}

    bool operator==(const SMetaDataPropertyInfo &inOther) const
    {
        return m_Instance == inOther.m_Instance && m_Property == inOther.m_Property
            && m_IsHidden == inOther.m_IsHidden && m_Animatable == inOther.m_Animatable
            && m_GroupName == inOther.m_GroupName
            && m_Controllable == inOther.m_Controllable
            && SMetaPropertyBase::operator==(inOther);
    }

    bool operator!=(const SMetaDataPropertyInfo &inOther) const { return !(*this == inOther); }
};

struct SMetaDataHandlerArgumentInfo : SMetaPropertyBase
{
    Qt3DSDMHandlerHandle m_Handler;
    HandlerArgumentType::Value m_ArgType;
    SMetaDataHandlerArgumentInfo(Qt3DSDMHandlerHandle inHandler = Qt3DSDMHandlerHandle())
        : m_Handler(inHandler)
        , m_ArgType(HandlerArgumentType::None)
    {
    }
};

struct SCategoryInfo
{
    TCharStr m_Name;
    TCharStr m_Description;
    TCharStr m_Icon;
    TCharStr m_HighlightIcon;
    bool m_Canonical;

    SCategoryInfo()
        : m_Canonical(false)
    {
    }
    SCategoryInfo(TCharStr inName)
        : m_Name(inName)
        , m_Canonical(false)
    {
    }
};

struct SEventInfo
{
    bool operator!=(const SEventInfo &inEvent) const
    {
        return (m_Name != inEvent.m_Name || m_FormalName != inEvent.m_FormalName
                || m_Category != inEvent.m_Category || m_Description != inEvent.m_Description);
    }

    TCharStr m_Name;
    TCharStr m_FormalName;
    TCharStr m_Category;
    TCharStr m_Description;
};

struct SHandlerInfo
{
    TCharStr m_Name;
    TCharStr m_FormalName;
    TCharStr m_Category;
    TCharStr m_Description;

    bool operator!=(const SHandlerInfo &inHandler) const
    {
        return (m_Name != inHandler.m_Name || m_FormalName != inHandler.m_FormalName
                || m_Category != inHandler.m_Category || m_Description != inHandler.m_Description);
    }
};

struct PropertyFilterTypes
{
    enum Enum {
        Unknown,
        ShowIfEqual,
        HideIfEqual,
    };
};

struct SPropertyFilterInfo
{
    PropertyFilterTypes::Enum m_FilterType;
    Qt3DSDMPropertyHandle m_FilterProperty;
    SValue m_Value;
    SPropertyFilterInfo()
        : m_FilterType(PropertyFilterTypes::Unknown)
    {
    }
    SPropertyFilterInfo(PropertyFilterTypes::Enum inFilterType, Qt3DSDMPropertyHandle inProp,
                        const SValue &inValue)
        : m_FilterType(inFilterType)
        , m_FilterProperty(inProp)
        , m_Value(inValue)
    {
    }
};
struct SMetaDataShader
{
    TCharStr m_Name;
    TCharStr m_Type; ///< shader type (GLSL or HLSL)
    TCharStr m_Version; ///< shader version (e.g. 330 vor GLSL)
    // Code contains both the vertex and fragment portions separated by #define's.
    //#define VERTEX_SHADER, #define FRAGMENT_SHADER
    TCharStr m_Code;
    bool m_HasGeomShader;
    bool m_IsComputeShader;
    SMetaDataShader()
        : m_HasGeomShader(false)
        , m_IsComputeShader(false)
    {
    }
    SMetaDataShader(const TCharStr &inName, const TCharStr &inType, const TCharStr &inVersion,
                    const TCharStr &inCode, bool hasGeom, bool isCompute)
        : m_Name(inName)
        , m_Type(inType)
        , m_Version(inVersion)
        , m_Code(inCode)
        , m_HasGeomShader(hasGeom)
        , m_IsComputeShader(isCompute)
    {
    }
};

struct SMetaDataDynamicObject
{
    TCharStr m_Name;
    qt3ds::foundation::NVConstDataRef<SMetaDataShader> m_Shaders;
    qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> m_Properties;
    SMetaDataDynamicObject() {}
    SMetaDataDynamicObject(
        const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders,
        qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties)
        : m_Name(inName)
        , m_Shaders(inShaders)
        , m_Properties(inProperties)
    {
    }
};

struct SMetaDataEffect : public SMetaDataDynamicObject
{
    qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> m_EffectCommands;
    SMetaDataEffect() {}
    SMetaDataEffect(
        const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders,
        qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties,
        qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> inEffectCommands)
        : SMetaDataDynamicObject(inName, inShaders, inProperties)
        , m_EffectCommands(inEffectCommands)
    {
    }
};

struct SMetaDataCustomMaterial : public SMetaDataDynamicObject
{
    qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> m_CustomMaterialCommands;
    bool m_HasTransparency;
    bool m_HasRefraction;
    bool m_AlwaysDirty;
    unsigned int m_ShaderKey;
    unsigned int m_LayerCount;
    SMetaDataCustomMaterial() {}
    SMetaDataCustomMaterial(
        const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders,
        qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties,
        qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> inCustomMaterialCommands,
        bool inHasTransparency, bool inHasRefraction, bool inIsAlwaysDirty,
        unsigned int inShaderKey, unsigned int inLayerCount)
        : SMetaDataDynamicObject(inName, inShaders, inProperties)
        , m_CustomMaterialCommands(inCustomMaterialCommands)
        , m_HasTransparency(inHasTransparency)
        , m_HasRefraction(inHasRefraction)
        , m_AlwaysDirty(inIsAlwaysDirty)
        , m_ShaderKey(inShaderKey)
        , m_LayerCount(inLayerCount)
    {
    }
};
}

Q_DECLARE_METATYPE(qt3dsdm::HandlerArgumentType::Value)