1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef Q3DSCENE_H
5#define Q3DSCENE_H
6
7#include <QtGraphs/qgraphsglobal.h>
8#include <QtGraphs/q3dcamera.h>
9#include <QtGraphs/q3dlight.h>
10#include <QtCore/QObject>
11#include <QtCore/QRect>
12
13QT_BEGIN_NAMESPACE
14
15class Q3DScenePrivate;
16
17class Q_GRAPHS_EXPORT Q3DScene : public QObject
18{
19 Q_OBJECT
20 Q_DECLARE_PRIVATE(Q3DScene)
21 Q_PROPERTY(QRect viewport READ viewport NOTIFY viewportChanged)
22 Q_PROPERTY(QRect primarySubViewport READ primarySubViewport WRITE setPrimarySubViewport NOTIFY primarySubViewportChanged)
23 Q_PROPERTY(QRect secondarySubViewport READ secondarySubViewport WRITE setSecondarySubViewport NOTIFY secondarySubViewportChanged)
24 Q_PROPERTY(QPoint selectionQueryPosition READ selectionQueryPosition WRITE setSelectionQueryPosition NOTIFY selectionQueryPositionChanged)
25 Q_PROPERTY(bool secondarySubviewOnTop READ isSecondarySubviewOnTop WRITE setSecondarySubviewOnTop NOTIFY secondarySubviewOnTopChanged)
26 Q_PROPERTY(bool slicingActive READ isSlicingActive WRITE setSlicingActive NOTIFY slicingActiveChanged)
27 Q_PROPERTY(Q3DCamera* activeCamera READ activeCamera WRITE setActiveCamera NOTIFY activeCameraChanged)
28 Q_PROPERTY(Q3DLight* activeLight READ activeLight WRITE setActiveLight NOTIFY activeLightChanged)
29 Q_PROPERTY(float devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
30 Q_PROPERTY(QPoint graphPositionQuery READ graphPositionQuery WRITE setGraphPositionQuery NOTIFY graphPositionQueryChanged)
31
32public:
33 explicit Q3DScene(QObject *parent = nullptr);
34 virtual ~Q3DScene();
35
36 QRect viewport() const;
37
38 QRect primarySubViewport() const;
39 void setPrimarySubViewport(const QRect &primarySubViewport);
40 bool isPointInPrimarySubView(const QPoint &point);
41
42 QRect secondarySubViewport() const;
43 void setSecondarySubViewport(const QRect &secondarySubViewport);
44 bool isPointInSecondarySubView(const QPoint &point);
45
46 void setSelectionQueryPosition(const QPoint &point);
47 QPoint selectionQueryPosition() const;
48 static QPoint invalidSelectionPoint();
49
50 void setGraphPositionQuery(const QPoint &point);
51 QPoint graphPositionQuery() const;
52
53 void setSlicingActive(bool isSlicing);
54 bool isSlicingActive() const;
55
56 void setSecondarySubviewOnTop(bool isSecondaryOnTop);
57 bool isSecondarySubviewOnTop() const;
58
59 Q3DCamera *activeCamera() const;
60 void setActiveCamera(Q3DCamera *camera);
61
62 Q3DLight *activeLight() const;
63 void setActiveLight(Q3DLight *light);
64
65 float devicePixelRatio() const;
66 void setDevicePixelRatio(float pixelRatio);
67
68Q_SIGNALS:
69 void viewportChanged(const QRect &viewport);
70 void primarySubViewportChanged(const QRect &subViewport);
71 void secondarySubViewportChanged(const QRect &subViewport);
72 void secondarySubviewOnTopChanged(bool isSecondaryOnTop);
73 void slicingActiveChanged(bool isSlicingActive);
74 void activeCameraChanged(Q3DCamera *camera);
75 void activeLightChanged(Q3DLight *light);
76 void devicePixelRatioChanged(float pixelRatio);
77 void selectionQueryPositionChanged(const QPoint &position);
78 void graphPositionQueryChanged(const QPoint &position);
79
80protected:
81 QScopedPointer<Q3DScenePrivate> d_ptr;
82
83private:
84 Q_DISABLE_COPY(Q3DScene)
85
86 friend class QAbstract3DGraph;
87 friend class Abstract3DController;
88 friend class Q3DObject;
89 friend class QQuickGraphsItem;
90};
91
92QT_END_NAMESPACE
93
94#endif
95

source code of qtgraphs/src/graphs/engine/q3dscene.h