1// Copyright (C) 2023 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 <QtGraphs/q3dobject.h>
8
9QT_BEGIN_NAMESPACE
10
11class Q3DCameraPrivate;
12
13class Q_GRAPHS_EXPORT Q3DCamera : public Q3DObject
14{
15 Q_OBJECT
16 Q_DECLARE_PRIVATE(Q3DCamera)
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(Q3DCamera::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)
24 Q_PROPERTY(float minZoomLevel READ minZoomLevel WRITE setMinZoomLevel NOTIFY minZoomLevelChanged)
25 Q_PROPERTY(float maxZoomLevel READ maxZoomLevel WRITE setMaxZoomLevel NOTIFY maxZoomLevelChanged)
26
27public:
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 Q_ENUM(CameraPreset)
56
57 explicit Q3DCamera(QObject *parent = nullptr);
58 virtual ~Q3DCamera();
59
60 float xRotation() const;
61 void setXRotation(float rotation);
62 float yRotation() const;
63 void setYRotation(float rotation);
64
65 bool wrapXRotation() const;
66 void setWrapXRotation(bool isEnabled);
67
68 bool wrapYRotation() const;
69 void setWrapYRotation(bool isEnabled);
70
71 void copyValuesFrom(const Q3DObject &source) override;
72
73 Q3DCamera::CameraPreset cameraPreset() const;
74 void setCameraPreset(Q3DCamera::CameraPreset preset);
75
76 float zoomLevel() const;
77 void setZoomLevel(float zoomLevel);
78 float minZoomLevel() const;
79 void setMinZoomLevel(float zoomLevel);
80 float maxZoomLevel() const;
81 void setMaxZoomLevel(float zoomLevel);
82
83 void setCameraPosition(float horizontal, float vertical, float zoom = 100.0f);
84
85 QVector3D target() const;
86 void setTarget(const QVector3D &target);
87
88Q_SIGNALS:
89 void xRotationChanged(float rotation);
90 void yRotationChanged(float rotation);
91 void zoomLevelChanged(float zoomLevel);
92 void cameraPresetChanged(Q3DCamera::CameraPreset preset);
93 void wrapXRotationChanged(bool isEnabled);
94 void wrapYRotationChanged(bool isEnabled);
95 void targetChanged(const QVector3D &target);
96 void minZoomLevelChanged(float zoomLevel);
97 void maxZoomLevelChanged(float zoomLevel);
98 void minXRotationChanged(float rotation);
99 void minYRotationChanged(float rotation);
100 void maxXRotationChanged(float rotation);
101 void maxYRotationChanged(float rotation);
102 void viewMatrixChanged(const QMatrix4x4 &viewMatrix);
103 void viewMatrixAutoUpdateChanged(bool enabled);
104
105private:
106 Q_DISABLE_COPY(Q3DCamera)
107
108 friend class Q3DScenePrivate;
109 friend class QQuickGraphsScatter;
110 friend class QQuickGraphsBars;
111};
112
113QT_END_NAMESPACE
114
115#endif
116

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