Q3DCamera Class
摄像机在三维空间中的表现形式。更多
头文件: | #include <Q3DCamera> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS DataVisualization) target_link_libraries(mytarget PRIVATE Qt6::DataVisualization) |
qmake: | QT += datavisualization |
自 | QtDataVisualization 1.0 |
在 QML 中: | Camera3D |
继承: | Q3DObject |
公共类型
enum | CameraPreset { CameraPresetNone, CameraPresetFrontLow, CameraPresetFront, CameraPresetFrontHigh, CameraPresetLeftLow, …, CameraPresetDirectlyBelow } |
属性
|
|
公共函数
Q3DCamera(QObject *parent = nullptr) | |
virtual | ~Q3DCamera() |
Q3DCamera::CameraPreset | cameraPreset() const |
float | maxZoomLevel() const |
float | minZoomLevel() const |
void | setCameraPosition(float horizontal, float vertical, float zoom = 100.0f) |
void | setCameraPreset(Q3DCamera::CameraPreset preset) |
void | setMaxZoomLevel(float zoomLevel) |
void | setMinZoomLevel(float zoomLevel) |
void | setTarget(const QVector3D &target) |
void | setWrapXRotation(bool isEnabled) |
void | setWrapYRotation(bool isEnabled) |
void | setXRotation(float rotation) |
void | setYRotation(float rotation) |
void | setZoomLevel(float zoomLevel) |
QVector3D | target() const |
bool | wrapXRotation() const |
bool | wrapYRotation() const |
float | xRotation() const |
float | yRotation() const |
float | zoomLevel() const |
重新实现的公共函数
virtual void | copyValuesFrom(const Q3DObject &source) override |
信号
void | cameraPresetChanged(Q3DCamera::CameraPreset preset) |
void | maxZoomLevelChanged(float zoomLevel) |
void | minZoomLevelChanged(float zoomLevel) |
void | targetChanged(const QVector3D &target) |
void | wrapXRotationChanged(bool isEnabled) |
void | wrapYRotationChanged(bool isEnabled) |
void | xRotationChanged(float rotation) |
void | yRotationChanged(float rotation) |
void | zoomLevelChanged(float zoomLevel) |
成员类型文档
enum Q3DCamera::CameraPreset
摄像机的预定义位置
常数 | 值 | 说明 |
---|---|---|
Q3DCamera::CameraPresetNone | -1 | 用于表示未设置预置或场景已自由旋转。 |
Q3DCamera::CameraPresetFrontLow | 0 | |
Q3DCamera::CameraPresetFront | 1 | |
Q3DCamera::CameraPresetFrontHigh | 2 | |
Q3DCamera::CameraPresetLeftLow | 3 | |
Q3DCamera::CameraPresetLeft | 4 | |
Q3DCamera::CameraPresetLeftHigh | 5 | |
Q3DCamera::CameraPresetRightLow | 6 | |
Q3DCamera::CameraPresetRight | 7 | |
Q3DCamera::CameraPresetRightHigh | 8 | |
Q3DCamera::CameraPresetBehindLow | 9 | |
Q3DCamera::CameraPresetBehind | 10 | |
Q3DCamera::CameraPresetBehindHigh | 11 | |
Q3DCamera::CameraPresetIsometricLeft | 12 | |
Q3DCamera::CameraPresetIsometricLeftHigh | 13 | |
Q3DCamera::CameraPresetIsometricRight | 14 | |
Q3DCamera::CameraPresetIsometricRightHigh | 15 | |
Q3DCamera::CameraPresetDirectlyAbove | 16 | |
Q3DCamera::CameraPresetDirectlyAboveCW45 | 17 | |
Q3DCamera::CameraPresetDirectlyAboveCCW45 | 18 | |
Q3DCamera::CameraPresetFrontBelow | 19 | 在Q3DBars (从 CameraPresetFrontBelow 开始)中,这些值仅适用于包含负值的图形。对于只有正值的情况,它们的作用与预置...低相同。 |
Q3DCamera::CameraPresetLeftBelow | 20 | |
Q3DCamera::CameraPresetRightBelow | 21 | |
Q3DCamera::CameraPresetBehindBelow | 22 | |
Q3DCamera::CameraPresetDirectlyBelow | 23 | 对于只有正值的条形图,其作用与 CameraPresetFrontLow 相同。 |
属性文档
cameraPreset : CameraPreset
此属性保存当前激活的摄像机预置。
如果没有设置CameraPreset 值,则默认使用CameraPresetNone 。
访问功能:
Q3DCamera::CameraPreset | cameraPreset() const |
void | setCameraPreset(Q3DCamera::CameraPreset preset) |
通知信号:
void | cameraPresetChanged(Q3DCamera::CameraPreset preset) |
maxZoomLevel : float
此属性保存允许的最大摄像机缩放级别。
如果最大缩放级别设置为低于现有最小缩放级别的新值,则最小缩放级别也会调整为新的最大值。如果当前的zoomLevel 超出了新的范围,也会进行调整。默认值为500.0f
。
访问功能:
float | maxZoomLevel() const |
void | setMaxZoomLevel(float zoomLevel) |
通知信号:
void | maxZoomLevelChanged(float zoomLevel) |
另请参阅 zoomLevel 和minZoomLevel 。
minZoomLevel : float
此属性用于保存允许的最小摄像机缩放级别。
如果最小水平设置为高于现有最大水平的新值,则最大水平也会调整为新的最小值。如果当前的zoomLevel 超出了新的范围,也会进行调整。minZoomLevel 不能设置为低于1.0f
。默认值为10.0f
。
访问功能:
float | minZoomLevel() const |
void | setMinZoomLevel(float zoomLevel) |
Notifier 信号:
void | minZoomLevelChanged(float zoomLevel) |
另请参阅 zoomLevel 和maxZoomLevel 。
[since QtDataVisualization 1.2]
target : QVector3D
此属性将摄像机目标作为三维空间中的一个向量或顶点。
默认值为QVector3D(0.0, 0.0, 0.0)
。
有效坐标值介于-1.0...1.0
之间,其中边缘值表示相应坐标轴范围的边缘。任何超出此范围的值都会被箝位在边缘上。
注: 对于条形图,Y 坐标将被忽略,摄像机始终以水平背景上的一个点为目标。
此属性在 QtDataVisualization 1.2 中引入。
访问功能:
QVector3D | target() const |
void | setTarget(const QVector3D &target) |
Notifier 信号:
void | targetChanged(const QVector3D &target) |
wrapXRotation : bool
此属性用于设置 X 轴旋转的最小和最大限制。
如果设置为true
,摄像机的 X 轴旋转将从最小值包络到最大值,从最大值包络到最小值。如果设置为false
,摄像机的 X 轴旋转将限制在由最小值和最大值决定的扇形范围内。默认设置为true
。
访问功能:
bool | wrapXRotation() const |
void | setWrapXRotation(bool isEnabled) |
通知信号:
void | wrapXRotationChanged(bool isEnabled) |
wrapYRotation : bool
此属性用于设置 Y 轴旋转的最小和最大限制。
如果true
,摄像机的 Y 轴旋转将从最小值到最大值以及从最大值到最小值进行包络。如果设置为false
,摄像机的 Y 轴旋转将限制在由最小值和最大值决定的扇形范围内。默认设置为true
。
访问功能:
bool | wrapYRotation() const |
void | setWrapYRotation(bool isEnabled) |
通知信号:
void | wrapYRotationChanged(bool isEnabled) |
xRotation : float
该属性用于保存摄像机绕目标点的 X 旋转角度(单位:度)。
访问功能
float | xRotation() const |
void | setXRotation(float rotation) |
通知信号:
void | xRotationChanged(float rotation) |
yRotation : float
该属性保存摄像机绕目标点的 Y 轴旋转角度(度)。
访问功能
float | yRotation() const |
void | setYRotation(float rotation) |
通知信号:
void | yRotationChanged(float rotation) |
zoomLevel : float
此属性以百分比表示摄像机的缩放级别。
默认值为100.0f
,表示摄像机没有设置放大或缩小。该值受minZoomLevel 和maxZoomLevel 属性的限制。
访问功能:
float | zoomLevel() const |
void | setZoomLevel(float zoomLevel) |
通知信号:
void | zoomLevelChanged(float zoomLevel) |
另请参阅 minZoomLevel 和maxZoomLevel 。
成员函数文档
[explicit]
Q3DCamera::Q3DCamera(QObject *parent = nullptr)
构造一个新的 3D 摄像机,位置设置为原点,向上方向朝向 Y 轴,默认情况下看着原点。可以给出一个可选的parent 参数,然后将其传递给QObject 构造函数。
[virtual noexcept]
Q3DCamera::~Q3DCamera()
销毁摄像机对象。
[override virtual]
void Q3DCamera::copyValuesFrom(const Q3DObject &source)
重实现:Q3DObject::copyValuesFrom(const Q3DObject &source)。
从给定的源相机复制 3D 相机的属性。值将从source 复制到此对象。
void Q3DCamera::setCameraPosition(float horizontal, float vertical, float zoom = 100.0f)
horizontal 和vertical 定义了要使用的摄像机旋转角度。可选择zoom 参数,在minZoomLevel 和maxZoomLevel 属性定义的范围内设置摄像机的缩放百分比。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.