Qt 5.7 | Qt Data Visualization | C++ Classes | Q3DCamera

Qt 5.7.1 Reference Documentation

# Q3DCamera Class

Representation of a camera in 3D space. More...

Header: | #include <Q3DCamera>
Since: | QtDataVisualization 1.0
Instantiated By: | Camera3D
Inherits: | Q3DObject

- List of all members, including inherited members

## Public Types

enum | CameraPreset { CameraPresetNone, CameraPresetFrontLow, CameraPresetFront, CameraPresetFrontHigh, ..., CameraPresetDirectlyBelow }

## Properties

cameraPreset : CameraPreset maxZoomLevel : float minZoomLevel : float target : QVector3D wrapXRotation : bool | wrapYRotation : bool xRotation : float yRotation : float zoomLevel : float

- 2 properties inherited from Q3DObject

## Public Functions

| Q3DCamera(QObject *parent = Q_NULLPTR)
virtual | ~Q3DCamera()
CameraPreset | cameraPreset() const
float | maxZoomLevel() const
float | minZoomLevel() const
void | setCameraPosition(float horizontal, float vertical, float zoom = 100.0f)
void | setCameraPreset(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

## Reimplemented Public Functions

virtual void | copyValuesFrom(const Q3DObject &source)

- 4 public functions inherited from Q3DObject

## Signals

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)

- 1 signal inherited from Q3DObject

### Additional Inherited Members

- 2 protected functions inherited from Q3DObject

## Detailed Description

Representation of a camera in 3D space.

Q3DCamera represents a basic orbit around centerpoint 3D camera that is used when rendering the data visualization. The class offers simple methods for rotating the camera around the origin and setting zoom level.

## Member Type Documentation

### enum Q3DCamera::CameraPreset

Predefined positions for camera.

Constant | Value | Description
--- | --- | ---
`Q3DCamera::CameraPresetNone` | `-1` | Used to indicate a preset has not been set, or the scene has been rotated freely.
`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` | In Q3DBars from CameraPresetFrontBelow onward these only work for graphs including negative values. They act as Preset...Low for positive-only values.
`Q3DCamera::CameraPresetLeftBelow` | `20` |
`Q3DCamera::CameraPresetRightBelow` | `21` |
`Q3DCamera::CameraPresetBehindBelow` | `22` |
`Q3DCamera::CameraPresetDirectlyBelow` | `23` | Acts as CameraPresetFrontLow for positive-only bars.

## Property Documentation

### cameraPreset : CameraPreset

This property contains the currently active camera preset, if no preset is active the value is CameraPresetNone.

Access functions:

CameraPreset | cameraPreset() const
void | setCameraPreset(CameraPreset preset)

Notifier signal:

void | cameraPresetChanged(Q3DCamera::CameraPreset preset)

### maxZoomLevel : float

This property contains the the maximum allowed camera zoom level. If the new maximum level is less than the existing minimum level, the minimum level is adjusted to the new maximum as well. If current zoomLevel is outside the new bounds, it is adjusted as well. Defaults to `500.0f`.

Access functions:

float | maxZoomLevel() const
void | setMaxZoomLevel(float zoomLevel)

Notifier signal:

void | maxZoomLevelChanged(float zoomLevel)

See also zoomLevel and minZoomLevel.

### minZoomLevel : float

This property contains the the minimum allowed camera zoom level. If the new minimum level is more than the existing maximum level, the maximum level is adjusted to the new minimum as well. If current zoomLevel is outside the new bounds, it is adjusted as well. The minZoomLevel cannot be set below `1.0f`. Defaults to `10.0f`.

Access functions:

float | minZoomLevel() const
void | setMinZoomLevel(float zoomLevel)

Notifier signal:

void | minZoomLevelChanged(float zoomLevel)

See also zoomLevel and maxZoomLevel.

### target : QVector3D

Holds the camera target as a QVector3D. Defaults to `QVector3D(0.0, 0.0, 0.0)`.

Valid coordinate values are between `-1.0...1.0`, where the edge values indicate the edges of the corresponding axis range. Any values outside this range are clamped to the edge.

Note: For bar graphs, the Y-coordinate is ignored and camera always targets a point on the horizontal background.

This property was introduced in QtDataVisualization 1.2.

Access functions:

QVector3D | target() const
void | setTarget(const QVector3D &target)

Notifier signal:

void | targetChanged(const QVector3D &target)

### wrapXRotation : bool

This property determines the behavior of the minimum and maximum limits in the X-rotation. By default the X-rotation wraps from minimum value to maximum and from maximum to minimum.

If set to `true` the X-rotation of the camera is wrapped from minimum to maximum and from maximum to minimum. If set to `false` the X-rotation of the camera is limited to the sector determined by minimum and maximum values.

Access functions:

bool | wrapXRotation() const
void | setWrapXRotation(bool isEnabled)

Notifier signal:

void | wrapXRotationChanged(bool isEnabled)

### wrapYRotation : bool

This property determines the behavior of the minimum and maximum limits in the Y-rotation. By default the Y-rotation is limited between the minimum and maximum values without any wrapping.

If `true` the Y-rotation of the camera is wrapped from minimum to maximum and from maximum to minimum. If `false` the Y-rotation of the camera is limited to the sector determined by minimum and maximum values.

Access functions:

bool | wrapYRotation() const
void | setWrapYRotation(bool isEnabled)

Notifier signal:

void | wrapYRotationChanged(bool isEnabled)

### xRotation : float

This property contains the X-rotation angle of the camera around the target point in degrees.

Access functions:

float | xRotation() const
void | setXRotation(float rotation)

Notifier signal:

void | xRotationChanged(float rotation)

### yRotation : float

This property contains the Y-rotation angle of the camera around the target point in degrees.

Access functions:

float | yRotation() const
void | setYRotation(float rotation)

Notifier signal:

void | yRotationChanged(float rotation)

### zoomLevel : float

This property contains the the camera zoom level in percentage. The default value of `100.0f` means there is no zoom in or out set in the camera. The value is limited within the bounds defined by minZoomLevel and maxZoomLevel properties.

Access functions:

float | zoomLevel() const
void | setZoomLevel(float zoomLevel)

Notifier signal:

void | zoomLevelChanged(float zoomLevel)

See also minZoomLevel and maxZoomLevel.

## Member Function Documentation

### Q3DCamera::Q3DCamera(QObject *parent = Q_NULLPTR)

Constructs a new 3D camera with position set to origin, up direction facing towards the Y-axis and looking at origin by default. An optional parent parameter can be given and is then passed to QObject constructor.

### `[virtual]` Q3DCamera::~Q3DCamera()

Destroys the camera object.

### `[virtual]` void Q3DCamera::copyValuesFrom(const Q3DObject &source)

Reimplemented from Q3DObject::copyValuesFrom().

Copies the 3D camera's properties from the given source camera. Values are copied from the source to this object.

### void Q3DCamera::setCameraPosition(float horizontal, float vertical, float zoom = 100.0f)

Utility function that sets the camera rotations and distance.horizontal and vertical define the camera rotations to be used. Optional zoom parameter can be given to set the zoom percentage of the camera within the bounds defined by minZoomLevel and maxZoomLevel properties.