1// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_QLEVELOFDETAIL_H
5#define QT3DRENDER_QLEVELOFDETAIL_H
6
7#include <Qt3DCore/qcomponent.h>
8#include <Qt3DRender/qt3drender_global.h>
9#include <Qt3DRender/qlevelofdetailboundingsphere.h>
10#include <Qt3DRender/qcamera.h>
11
12#include <QtGui/QVector3D>
13
14QT_BEGIN_NAMESPACE
15
16namespace Qt3DRender {
17
18class QLevelOfDetailPrivate;
19
20class Q_3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
21{
22 Q_OBJECT
23 Q_PROPERTY(Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
24 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
25 Q_PROPERTY(ThresholdType thresholdType READ thresholdType WRITE setThresholdType NOTIFY thresholdTypeChanged)
26 Q_PROPERTY(QList<qreal> thresholds READ thresholds WRITE setThresholds NOTIFY thresholdsChanged)
27 Q_PROPERTY(Qt3DRender::QLevelOfDetailBoundingSphere volumeOverride READ volumeOverride WRITE setVolumeOverride NOTIFY volumeOverrideChanged)
28
29public:
30 enum ThresholdType {
31 DistanceToCameraThreshold,
32 ProjectedScreenPixelSizeThreshold,
33 };
34 Q_ENUM(ThresholdType) // LCOV_EXCL_LINE
35
36 explicit QLevelOfDetail(Qt3DCore::QNode *parent = nullptr);
37 ~QLevelOfDetail();
38
39 QCamera *camera() const;
40 int currentIndex() const;
41 ThresholdType thresholdType() const;
42 QList<qreal> thresholds() const;
43 QLevelOfDetailBoundingSphere volumeOverride() const;
44
45 Q_INVOKABLE Qt3DRender::QLevelOfDetailBoundingSphere createBoundingSphere(const QVector3D &center, float radius);
46
47public Q_SLOTS:
48 void setCamera(QCamera *camera);
49 void setCurrentIndex(int currentIndex);
50 void setThresholdType(ThresholdType thresholdType);
51 void setThresholds(const QList<qreal> &thresholds);
52 void setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride);
53
54Q_SIGNALS:
55 void cameraChanged(QCamera *camera);
56 void currentIndexChanged(int currentIndex);
57 void thresholdTypeChanged(ThresholdType thresholdType);
58 void thresholdsChanged(const QList<qreal> &thresholds);
59 void volumeOverrideChanged(const QLevelOfDetailBoundingSphere &volumeOverride);
60
61protected:
62 explicit QLevelOfDetail(QLevelOfDetailPrivate &dd, Qt3DCore::QNode *parent = nullptr);
63
64private:
65 Q_DECLARE_PRIVATE(QLevelOfDetail)
66};
67
68} // namespace Qt3DRender
69
70QT_END_NAMESPACE
71
72#endif // QT3DRENDER_QLEVELOFDETAIL_H
73

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