summaryrefslogtreecommitdiffstats
path: root/src/Runtime/api/studio3d/q3dscommandqueue_p.h
blob: c396ec8e16223e73e3a987ecd62ef60066d55b5f (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
/****************************************************************************
**
** 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$
**
****************************************************************************/

#ifndef Q3DS_COMMAND_QUEUE_H
#define Q3DS_COMMAND_QUEUE_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the QtStudio3D API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include "q3dsviewersettings.h"

#include <QtGui/qcolor.h>
#include <QtCore/qsize.h>
#include <QtCore/qvector.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>

QT_BEGIN_NAMESPACE

enum CommandType {
    CommandType_Invalid = 0,
    CommandType_SetAttribute,
    CommandType_SetPresentationActive,
    CommandType_GoToSlideByName,
    CommandType_GoToSlide,
    CommandType_GoToSlideRelative,
    CommandType_GoToTime,
    CommandType_FireEvent,
    CommandType_MousePress,
    CommandType_MouseRelease,
    CommandType_MouseMove,
    CommandType_MouseWheel,
    CommandType_KeyPress,
    CommandType_KeyRelease,
    CommandType_SetGlobalAnimationTime,
    CommandType_SetDataInputValue,
    CommandType_CreateElements,
    CommandType_DeleteElements,
    CommandType_CreateMaterials,

    // Requests
    CommandType_RequestSlideInfo,
    CommandType_RequestDataInputs,
    CommandType_PreloadSlide,
    CommandType_UnloadSlide
};

class Q_STUDIO3D_EXPORT ElementCommand
{
public:
    ElementCommand();

    CommandType m_commandType;
    QString m_elementPath;
    QString m_stringValue;
    QVariant m_variantValue;
    void *m_data = nullptr; // Data is owned by the queue and is deleted once command is handled
    union {
        bool m_boolValue;
        float m_floatValue;
        int m_intValues[4];
        qint64 m_int64Value;
    };

    QString toString() const;
};

typedef QVector<ElementCommand> CommandList;

class Q_STUDIO3D_EXPORT CommandQueue
{
public:
    CommandQueue();

    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 const QString &attributeName, const QVariant &value);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 const QString &attributeName, const QVariant &value,
                                 int intValue);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 const QString &value);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 bool value);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 float value);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 int value0, int value1 = 0,
                                 int value2 = 0, int value3 = 0);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 const QString &stringValue, void *commandData);
    ElementCommand &queueCommand(CommandType commandType, void *commandData);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType);
    ElementCommand &queueCommand(const QString &elementPath, CommandType commandType,
                                 void *commandData);

    void copyCommands(CommandQueue &fromQueue);

    bool m_visibleChanged;
    bool m_scaleModeChanged;
    bool m_shadeModeChanged;
    bool m_showRenderStatsChanged;
    bool m_matteColorChanged;
    bool m_sourceChanged;
    bool m_variantListChanged;
    bool m_globalAnimationTimeChanged;
    bool m_delayedLoadingChanged;

    bool m_visible;
    Q3DSViewerSettings::ScaleMode m_scaleMode;
    Q3DSViewerSettings::ShadeMode m_shadeMode;
    bool m_showRenderStats;
    QColor m_matteColor;
    QUrl m_source;
    QStringList m_variantList;
    qint64 m_globalAnimationTime;
    bool m_delayedLoading;

    void clear(bool deleteCommandData);
    int size() const { return m_size; }
    const ElementCommand &constCommandAt(int index) const { return m_elementCommands.at(index); }
    ElementCommand &commandAt(int index) { return m_elementCommands[index]; }

private:
    ElementCommand &nextFreeCommand();

    CommandList m_elementCommands;
    int m_size;
};

QT_END_NAMESPACE

Q_DECLARE_METATYPE(CommandType)

#endif // Q3DS_COMMAND_QUEUE_H