summaryrefslogtreecommitdiffstats
path: root/src/runtime/api/q3dspresentation_p.h
blob: 56859a554e4ff72752b579d8d3dd041ad3688578 (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
/****************************************************************************
**
** 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 Q3DSPRESENTATION_P_H
#define Q3DSPRESENTATION_P_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 <private/q3dsruntimeglobal_p.h>
#include "q3dspresentation.h"
#include <private/qobject_p.h>
#include <QVariant>

QT_BEGIN_NAMESPACE

class Q3DSEngine;
class Q3DSInlineQmlSubPresentation;

class Q3DSV_PRIVATE_EXPORT Q3DSPresentationController
{
public:
    virtual ~Q3DSPresentationController() { }

    void initializePresentationController(Q3DSEngine *engine, Q3DSPresentation *presentation);

    enum SourceFlag {
        Profiling = 0x01,
        AwakenTheDragon = 0x02
    };
    Q_DECLARE_FLAGS(SourceFlags, SourceFlag)

    virtual void handlePresentationSource(const QUrl &source,
                                          SourceFlags flags,
                                          const QVector<Q3DSInlineQmlSubPresentation *> &inlineQmlSubPresentations) = 0;
    virtual void handlePresentationReload() = 0;

    virtual void handlePresentationKeyPressEvent(QKeyEvent *e);
    virtual void handlePresentationKeyReleaseEvent(QKeyEvent *e);
    virtual void handlePresentationMousePressEvent(QMouseEvent *e);
    virtual void handlePresentationMouseMoveEvent(QMouseEvent *e);
    virtual void handlePresentationMouseReleaseEvent(QMouseEvent *e);
    virtual void handlePresentationMouseDoubleClickEvent(QMouseEvent *e);
#if QT_CONFIG(wheelevent)
    virtual void handlePresentationWheelEvent(QWheelEvent *e);
#endif
    virtual void handlePresentationTouchEvent(QTouchEvent *e);
#if QT_CONFIG(tabletevent)
    virtual void handlePresentationTabletEvent(QTabletEvent *e);
#endif

    virtual void handleDataInputValue(const QString &name, const QVariant &value);
    virtual void handleFireEvent(const QString &elementPath, const QString &eventName);
    virtual void handleGoToTime(const QString &elementPath, float timeSeconds);
    virtual void handleGoToSlideByName(const QString &elementPath, const QString &name);
    virtual void handleGoToSlideByIndex(const QString &elementPath, int index);
    virtual void handleGoToSlideByDirection(const QString &elementPath, bool next, bool wrap);
    virtual QVariant handleGetAttribute(const QString &elementPath, const QString &attribute);
    virtual void handleSetAttribute(const QString &elementPath, const QString &attributeName, const QVariant &value);
    virtual void handleSetProfileUiVisible(bool visible, float scale);

    bool compareElementPath(const QString &a, const QString &b) const;

    Q3DSEngine *pcEngine() const { return m_pcEngine; }

protected:
    Q3DSEngine *m_pcEngine = nullptr; // don't want clashes with commonly used m_engine members
    QVector<QPair<QString, QVariant> > m_pendingDataInputSets;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(Q3DSPresentationController::SourceFlags)

class Q3DSV_PRIVATE_EXPORT Q3DSPresentationPrivate : public QObjectPrivate
{
    Q_DECLARE_PUBLIC(Q3DSPresentation)

public:
    static Q3DSPresentationPrivate *get(Q3DSPresentation *p) { return p->d_func(); }

    void setController(Q3DSPresentationController *c);
    Q3DSPresentationController::SourceFlags sourceFlags() const;
    bool compareElementPath(const QString &a, const QString &b) const;
    void registerInlineQmlSubPresentations(const QVector<Q3DSInlineQmlSubPresentation *> &list);

    QUrl source;
    Q3DSPresentationController *controller = nullptr;
    bool profiling = false; // unlike the viewer, the public API defaults to profile off
    bool profileUiVisible = false;
    float profileUiScale = 1.0f;
    QVector<Q3DSInlineQmlSubPresentation *> inlineQmlSubPresentations;
    bool dragonRenderAspectEnabled = false;
};

QT_END_NAMESPACE

#endif // Q3DSPRESENTATION_P_H