1/****************************************************************************
2**
3** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QT3DRENDER_QLEVELOFDETAIL_H
41#define QT3DRENDER_QLEVELOFDETAIL_H
42
43#include <Qt3DCore/qcomponent.h>
44#include <Qt3DRender/qt3drender_global.h>
45#include <Qt3DRender/qlevelofdetailboundingsphere.h>
46
47#include <QtGui/QVector3D>
48
49QT_BEGIN_NAMESPACE
50
51namespace Qt3DRender {
52
53class QCamera;
54class QLevelOfDetailPrivate;
55
56class Q_3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
57{
58 Q_OBJECT
59 Q_PROPERTY(Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
60 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
61 Q_PROPERTY(ThresholdType thresholdType READ thresholdType WRITE setThresholdType NOTIFY thresholdTypeChanged)
62 Q_PROPERTY(QVector<qreal> thresholds READ thresholds WRITE setThresholds NOTIFY thresholdsChanged)
63 Q_PROPERTY(Qt3DRender::QLevelOfDetailBoundingSphere volumeOverride READ volumeOverride WRITE setVolumeOverride NOTIFY volumeOverrideChanged)
64
65public:
66 enum ThresholdType {
67 DistanceToCameraThreshold,
68 ProjectedScreenPixelSizeThreshold,
69 };
70 Q_ENUM(ThresholdType) // LCOV_EXCL_LINE
71
72 explicit QLevelOfDetail(Qt3DCore::QNode *parent = nullptr);
73 ~QLevelOfDetail();
74
75 QCamera *camera() const;
76 int currentIndex() const;
77 ThresholdType thresholdType() const;
78 QVector<qreal> thresholds() const;
79 QLevelOfDetailBoundingSphere volumeOverride() const;
80
81 Q_INVOKABLE Qt3DRender::QLevelOfDetailBoundingSphere createBoundingSphere(const QVector3D &center, float radius);
82
83public Q_SLOTS:
84 void setCamera(QCamera *camera);
85 void setCurrentIndex(int currentIndex);
86 void setThresholdType(ThresholdType thresholdType);
87 void setThresholds(const QVector<qreal> &thresholds);
88 void setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride);
89
90Q_SIGNALS:
91 void cameraChanged(QCamera *camera);
92 void currentIndexChanged(int currentIndex);
93 void thresholdTypeChanged(ThresholdType thresholdType);
94 void thresholdsChanged(const QVector<qreal> &thresholds);
95 void volumeOverrideChanged(const QLevelOfDetailBoundingSphere &volumeOverride);
96
97protected:
98 explicit QLevelOfDetail(QLevelOfDetailPrivate &dd, Qt3DCore::QNode *parent = nullptr);
99 Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
100 // TODO Unused remove in Qt6
101 void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
102
103private:
104 Q_DECLARE_PRIVATE(QLevelOfDetail)
105};
106
107} // namespace Qt3DRender
108
109QT_END_NAMESPACE
110
111Q_DECLARE_METATYPE(Qt3DRender::QLevelOfDetailBoundingSphere)
112
113#endif // QT3DRENDER_QLEVELOFDETAIL_H
114

source code of qt3d/src/render/frontend/qlevelofdetail.h