1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef Q3DCAMERA_H |
5 | #define Q3DCAMERA_H |
6 | |
7 | #include <QtDataVisualization/q3dobject.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | class Q3DCameraPrivate; |
12 | |
13 | class Q_DATAVISUALIZATION_EXPORT Q3DCamera : public Q3DObject |
14 | { |
15 | Q_OBJECT |
16 | Q_ENUMS(CameraPreset) |
17 | Q_PROPERTY(float xRotation READ xRotation WRITE setXRotation NOTIFY xRotationChanged) |
18 | Q_PROPERTY(float yRotation READ yRotation WRITE setYRotation NOTIFY yRotationChanged) |
19 | Q_PROPERTY(float zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged) |
20 | Q_PROPERTY(CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY cameraPresetChanged) |
21 | Q_PROPERTY(bool wrapXRotation READ wrapXRotation WRITE setWrapXRotation NOTIFY wrapXRotationChanged) |
22 | Q_PROPERTY(bool wrapYRotation READ wrapYRotation WRITE setWrapYRotation NOTIFY wrapYRotationChanged) |
23 | Q_PROPERTY(QVector3D target READ target WRITE setTarget NOTIFY targetChanged REVISION(1, 2)) |
24 | Q_PROPERTY(float minZoomLevel READ minZoomLevel WRITE setMinZoomLevel NOTIFY minZoomLevelChanged REVISION(1, 2)) |
25 | Q_PROPERTY(float maxZoomLevel READ maxZoomLevel WRITE setMaxZoomLevel NOTIFY maxZoomLevelChanged REVISION(1, 2)) |
26 | |
27 | public: |
28 | enum CameraPreset { |
29 | CameraPresetNone = -1, |
30 | CameraPresetFrontLow = 0, |
31 | CameraPresetFront, |
32 | CameraPresetFrontHigh, |
33 | CameraPresetLeftLow, |
34 | CameraPresetLeft, |
35 | CameraPresetLeftHigh, |
36 | CameraPresetRightLow, |
37 | CameraPresetRight, |
38 | CameraPresetRightHigh, |
39 | CameraPresetBehindLow, |
40 | CameraPresetBehind, |
41 | CameraPresetBehindHigh, |
42 | CameraPresetIsometricLeft, |
43 | CameraPresetIsometricLeftHigh, |
44 | CameraPresetIsometricRight, |
45 | CameraPresetIsometricRightHigh, |
46 | CameraPresetDirectlyAbove, |
47 | CameraPresetDirectlyAboveCW45, |
48 | CameraPresetDirectlyAboveCCW45, |
49 | CameraPresetFrontBelow, |
50 | CameraPresetLeftBelow, |
51 | CameraPresetRightBelow, |
52 | CameraPresetBehindBelow, |
53 | CameraPresetDirectlyBelow |
54 | }; |
55 | |
56 | explicit Q3DCamera(QObject *parent = nullptr); |
57 | virtual ~Q3DCamera(); |
58 | |
59 | float xRotation() const; |
60 | void setXRotation(float rotation); |
61 | float yRotation() const; |
62 | void setYRotation(float rotation); |
63 | |
64 | bool wrapXRotation() const; |
65 | void setWrapXRotation(bool isEnabled); |
66 | |
67 | bool wrapYRotation() const; |
68 | void setWrapYRotation(bool isEnabled); |
69 | |
70 | void copyValuesFrom(const Q3DObject &source) override; |
71 | |
72 | CameraPreset cameraPreset() const; |
73 | void setCameraPreset(CameraPreset preset); |
74 | |
75 | float zoomLevel() const; |
76 | void setZoomLevel(float zoomLevel); |
77 | float minZoomLevel() const; |
78 | void setMinZoomLevel(float zoomLevel); |
79 | float maxZoomLevel() const; |
80 | void setMaxZoomLevel(float zoomLevel); |
81 | |
82 | void setCameraPosition(float horizontal, float vertical, float zoom = 100.0f); |
83 | |
84 | QVector3D target() const; |
85 | void setTarget(const QVector3D &target); |
86 | |
87 | Q_SIGNALS: |
88 | void xRotationChanged(float rotation); |
89 | void yRotationChanged(float rotation); |
90 | void zoomLevelChanged(float zoomLevel); |
91 | void cameraPresetChanged(Q3DCamera::CameraPreset preset); |
92 | void wrapXRotationChanged(bool isEnabled); |
93 | void wrapYRotationChanged(bool isEnabled); |
94 | Q_REVISION(1, 2) void targetChanged(const QVector3D &target); |
95 | Q_REVISION(1, 2) void minZoomLevelChanged(float zoomLevel); |
96 | Q_REVISION(1, 2) void maxZoomLevelChanged(float zoomLevel); |
97 | |
98 | private: |
99 | QScopedPointer<Q3DCameraPrivate> d_ptr; |
100 | |
101 | Q_DISABLE_COPY(Q3DCamera) |
102 | |
103 | friend class Q3DCameraPrivate; |
104 | friend class Q3DScenePrivate; |
105 | friend class Abstract3DRenderer; |
106 | friend class Bars3DRenderer; |
107 | friend class Surface3DRenderer; |
108 | friend class Scatter3DRenderer; |
109 | friend class SelectionPointer; |
110 | friend class Q3DInputHandler; |
111 | friend class QTouch3DInputHandlerPrivate; |
112 | }; |
113 | |
114 | QT_END_NAMESPACE |
115 | |
116 | #endif |
117 | |