1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H
38#define QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H
39
40#include <Qt3DQuickScene2D/qt3dquickscene2d_global.h>
41#include <Qt3DRender/qrendertargetoutput.h>
42
43#include <QtCore/QUrl>
44#include <QtCore/QEvent>
45
46#include <Qt3DCore/qnode.h>
47
48#include <QtQuick/qquickitem.h>
49
50QT_BEGIN_NAMESPACE
51
52namespace Qt3DRender {
53
54/*!
55 \namespace Qt3DRender::Quick
56
57 \brief Internal namespace to import QML types.
58*/
59namespace Quick {
60
61class QScene2DPrivate;
62
63class Q_3DQUICKSCENE2DSHARED_EXPORT QScene2D : public Qt3DCore::QNode
64{
65 Q_OBJECT
66
67 Q_PROPERTY(Qt3DRender::QRenderTargetOutput *output READ output WRITE setOutput NOTIFY outputChanged)
68 Q_PROPERTY(QScene2D::RenderPolicy renderPolicy READ renderPolicy WRITE setRenderPolicy NOTIFY renderPolicyChanged)
69 Q_PROPERTY(QQuickItem *item READ item WRITE setItem NOTIFY itemChanged)
70 Q_PROPERTY(bool mouseEnabled READ isMouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged)
71
72 Q_CLASSINFO("DefaultProperty", "item")
73
74public:
75
76 enum RenderPolicy {
77 Continuous,
78 SingleShot
79 };
80 Q_ENUM(RenderPolicy)
81
82 explicit QScene2D(Qt3DCore::QNode *parent = nullptr);
83
84 Qt3DRender::QRenderTargetOutput *output() const;
85 QScene2D::RenderPolicy renderPolicy() const;
86 QQuickItem *item() const;
87 bool isMouseEnabled() const;
88
89 QVector<Qt3DCore::QEntity *> entities();
90 void addEntity(Qt3DCore::QEntity *entity);
91 void removeEntity(Qt3DCore::QEntity *entity);
92
93public Q_SLOTS:
94 void setOutput(Qt3DRender::QRenderTargetOutput *output);
95 void setRenderPolicy(QScene2D::RenderPolicy policy);
96 void setItem(QQuickItem *item);
97 void setMouseEnabled(bool enabled);
98
99Q_SIGNALS:
100 void outputChanged(Qt3DRender::QRenderTargetOutput *output);
101 void renderPolicyChanged(QScene2D::RenderPolicy policy);
102 void itemChanged(QQuickItem *item);
103 void mouseEnabledChanged(bool enabled);
104
105protected:
106 Q_DECLARE_PRIVATE(QScene2D)
107
108private:
109 Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
110};
111
112} // namespace Quick
113} // namespace Qt3DRender
114
115QT_END_NAMESPACE
116
117#endif // QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H
118