From a665bdb2010c3833f47d364945007cccc00aed2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Thu, 5 Dec 2013 11:26:25 +0200 Subject: QML docs + enum moving Task-number: QTRD-2670 Task-number: QTRD-2505 Change-Id: I51a870f9a57b093e8216759a5577e161ff3afd60 Reviewed-by: Miikka Heikkinen --- .../engine/abstract3dcontroller.cpp | 4 +- .../engine/abstract3dcontroller_p.h | 2 +- src/datavisualization/engine/q3dcamera.cpp | 342 +++++++++++++++------ src/datavisualization/engine/q3dcamera.h | 45 ++- src/datavisualization/engine/q3dcamera_p.h | 2 +- src/datavisualization/engine/q3dlight.cpp | 25 +- src/datavisualization/engine/q3dscene.cpp | 114 ++++++- 7 files changed, 417 insertions(+), 117 deletions(-) (limited to 'src/datavisualization/engine') diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp index 7165ca58..915a0bc7 100644 --- a/src/datavisualization/engine/abstract3dcontroller.cpp +++ b/src/datavisualization/engine/abstract3dcontroller.cpp @@ -952,11 +952,11 @@ void Abstract3DController::handleAxisLabelFormatChanged(const QString &format) handleAxisLabelFormatChangedBySender(sender()); } -void Abstract3DController::handleInputStateChanged(QDataVis::InputState state) +void Abstract3DController::handleInputStateChanged(QAbstract3DInputHandler::InputState state) { // When in automatic slicing mode, input state change to overview disables slice mode if (m_selectionMode.testFlag(QDataVis::SelectionSlice) - && state == QDataVis::InputStateOnOverview) { + && state == QAbstract3DInputHandler::InputStateOnPrimaryView) { setSlicingActive(false); } diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h index 4ecfacdc..2874cbcb 100644 --- a/src/datavisualization/engine/abstract3dcontroller_p.h +++ b/src/datavisualization/engine/abstract3dcontroller_p.h @@ -295,7 +295,7 @@ public slots: void handleAxisSubSegmentCountChanged(int count); void handleAxisAutoAdjustRangeChanged(bool autoAdjust); void handleAxisLabelFormatChanged(const QString &format); - void handleInputStateChanged(QDataVis::InputState state); + void handleInputStateChanged(QAbstract3DInputHandler::InputState state); void handleInputPositionChanged(const QPoint &position); void handleSeriesVisibilityChanged(bool visible); void handlePixelRatioChanged(float ratio); diff --git a/src/datavisualization/engine/q3dcamera.cpp b/src/datavisualization/engine/q3dcamera.cpp index bc936436..6378051c 100644 --- a/src/datavisualization/engine/q3dcamera.cpp +++ b/src/datavisualization/engine/q3dcamera.cpp @@ -29,19 +29,192 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE /*! - \class Q3DCamera - \inmodule QtDataVisualization - \brief Representation of a camera in 3D space. - \since Qt Data Visualization 1.0 + * \class Q3DCamera + * \inmodule QtDataVisualization + * \brief Representation of a camera in 3D space. + * \since Qt Data Visualization 1.0 + * + * Q3DCamera represents a basic orbit around centerpoint 3D camera that is used when rendering the + * data visualization. The class offers simple methods for setting the orbit point in rotations, + * but allows also setting the 4x4 view matrix directly in case a more customized camera behavior is + * needed. + */ + +/*! + * \enum Q3DCamera::CameraPreset + * + * Predefined positions for camera. + * + * \value CameraPresetNone + * Used to indicate a preset has not been set, or the scene has been rotated freely. + * \value CameraPresetFrontLow + * \value CameraPresetFront + * \value CameraPresetFrontHigh + * \value CameraPresetLeftLow + * \value CameraPresetLeft + * \value CameraPresetLeftHigh + * \value CameraPresetRightLow + * \value CameraPresetRight + * \value CameraPresetRightHigh + * \value CameraPresetBehindLow + * \value CameraPresetBehind + * \value CameraPresetBehindHigh + * \value CameraPresetIsometricLeft + * \value CameraPresetIsometricLeftHigh + * \value CameraPresetIsometricRight + * \value CameraPresetIsometricRightHigh + * \value CameraPresetDirectlyAbove + * \value CameraPresetDirectlyAboveCW45 + * \value CameraPresetDirectlyAboveCCW45 + * \value CameraPresetFrontBelow + * In Q3DBars from CameraPresetFrontBelow onward these only work for graphs including negative + * values. They act as Preset...Low for positive-only values. + * \value CameraPresetLeftBelow + * \value CameraPresetRightBelow + * \value CameraPresetBehindBelow + * \value CameraPresetDirectlyBelow + * Acts as CameraPresetFrontLow for positive-only bars. + */ + +/*! + * \qmltype Camera3D + * \inqmlmodule QtDataVisualization + * \since QtDataVisualization 1.0 + * \ingroup datavisualization_qml + * \instantiates Q3DCamera + * \brief Representation of a camera in 3D space. + * + * Camera3D represents a basic orbit around centerpoint 3D camera that is used when rendering the + * data visualization. The class offers simple methods for setting the orbit point in rotations, + * but allows also setting the 4x4 view matrix directly in case a more customized camera behavior is + * needed. + */ + +/*! + * \qmlproperty float Camera3D::xRotation + * + * This property contains the X-rotation angle of the camera around the target point in degrees + * starting from the current base position set by the setBaseOrientation method. + */ + +/*! + * \qmlproperty float Camera3D::yRotation + * + * This property contains the Y-rotation angle of the camera around the target point in degrees + * starting from the current base position set by the setBaseOrientation method. + */ + +/*! + * \qmlproperty float Camera3D::minXRotation + * + * This property contains the current minimum X-rotation for the camera. + * The full circle range is \c{[-180, 180]} and the minimum value is limited to \c -180. + * Also the value can't be higher than the maximum, and is adjusted if necessary. + * + * \sa wrapXRotation, maxXRotation + */ + +/*! + * \qmlproperty float Camera3D::minYRotation + * + * This property contains the current minimum Y-rotation for the camera. + * The full Y angle range is \c{[-90, 90]} and the minimum value is limited to \c -90. + * Also the value can't be higher than the maximum, and is adjusted if necessary. + * + * \sa wrapYRotation, maxYRotation + */ + +/*! + * \qmlproperty float Camera3D::maxXRotation + * + * This property contains the current maximum X-rotation for the camera. + * The full circle range is \c{[-180, 180]} and the maximum value is limited to \c 180. + * Also the value can't be lower than the minimum, and is adjusted if necessary. + * + * \sa wrapXRotation, minXRotation + */ + +/*! + * \qmlproperty float Camera3D::maxYRotation + * + * This property contains the current maximum Y-rotation for the camera. + * The full Y angle range is \c{[-90, 90]} and the maximum value is limited to \c 90. + * Also the value can't be lower than the minimum, and is adjusted if necessary. + * + * \sa wrapYRotation, minYRotation + */ + +/*! + * \qmlmethod void Camera3D::setBaseOrientation(vector3d basePosition, vector3d target, vector3d baseUp) + * + * Sets the base values for the camera that are used when calculating the camera position using the + * rotation values. The base position of the camera is defined by \a basePosition, expectation is + * that the x and y values are 0. Look at target point is defined by \a target and the camera + * rotates around it. Up direction for the camera is defined by \a baseUp, normally this is a + * vector with only y value set to 1. + */ + +/*! + * \qmlproperty matrix4x4 Camera3D::viewMatrix + * + * This property contains the view matrix used in the 3D calculations. When the default orbiting + * camera behavior is sufficient, there is no need to touch this property. If the default + * behavior is insufficient, the view matrix can be set directly. + * \note When setting the view matrix directly remember to set viewMatrixAutoUpdateEnabled + * property to \c false. + */ + +/*! + * \qmlproperty bool Camera3D::viewMatrixAutoUpdateEnabled + * + * This property determines if view matrix is automatically updated each render cycle using the + * current base orientation and rotations. If set to \c false, no automatic recalculation is done and + * the view matrix can be set using the viewMatrix property. + */ + +/*! + * \qmlproperty Camera3D.CameraPreset Camera3D::cameraPreset + * + * This property contains the currently active camera preset, which is one of + * \l{Q3DCamera::CameraPreset}{Camera3D.CameraPreset}. If no preset is active the value + * is \l{Q3DCamera::CameraPresetNone}{Camera3D.CameraPresetNone}. + * \note The base camera orientation set by setBaseOrientation will affect the presets as all + * calculations are based on those values. + */ + +/*! + * \qmlproperty float Camera3D::zoomLevel + * + * This property contains the the camera zoom level in percentage. 100.0 means there is no zoom + * in or out set in the camera. + */ - Q3DCamera represents a basic orbit around centerpoint 3D camera that is used when rendering the data visualization. - The class offers simple methods for setting the orbit point in rotations, but allows also setting the 4x4 viewmatrix - directly in case a more customized camera behavior is needed. -*/ +/*! + * \qmlproperty bool Camera3D::wrapXRotation + * + * 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 \c true the X-rotation of the camera is wrapped from minimum to maximum and from maximum + * to minimum. If set to \c false the X-rotation of the camera is limited to the sector determined by + * minimum and maximum values. + */ /*! - * Constructs a new 3D camera with position set to origo, up direction facing towards the Y-axis and looking at origo by default. An - * optional \a parent parameter can be given and is then passed to QObject constructor. + * \qmlproperty bool Camera3D::wrapYRotation + * + * 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 \c true the Y-rotation of the camera is wrapped from minimum to maximum and from maximum + * to minimum. If \c false the Y-rotation of the camera is limited to the sector determined by minimum + * and maximum values. + */ + +/*! + * 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 \a parent parameter can be given and is then passed + * to QObject constructor. */ Q3DCamera::Q3DCamera(QObject *parent) : Q3DObject(parent), @@ -97,8 +270,8 @@ void Q3DCamera::copyValuesFrom(const Q3DObject &source) /*! * \property Q3DCamera::xRotation * - * This property contains the X-rotation angle of the camera around the target point in degrees starting from - * the current base position set by the setBaseOrientation() methods. + * This property contains the X-rotation angle of the camera around the target point in degrees + * starting from the current base position set by the setBaseOrientation() method. */ float Q3DCamera::xRotation() const { return d_ptr->m_xRotation; @@ -113,8 +286,8 @@ void Q3DCamera::setXRotation(float rotation) if (d_ptr->m_xRotation != rotation) { d_ptr->setXRotation(rotation); - if (d_ptr->m_activePreset != QDataVis::CameraPresetNone) { - d_ptr->m_activePreset = QDataVis::CameraPresetNone; + if (d_ptr->m_activePreset != CameraPresetNone) { + d_ptr->m_activePreset = CameraPresetNone; setDirty(true); } @@ -125,8 +298,8 @@ void Q3DCamera::setXRotation(float rotation) /*! * \property Q3DCamera::yRotation * - * This property contains the Y-rotation angle of the camera around the target point in degrees starting from - * the current base position set by the setBaseOrientation() methods. + * This property contains the Y-rotation angle of the camera around the target point in degrees + * starting from the current base position set by the setBaseOrientation() method. */ float Q3DCamera::yRotation() const { return d_ptr->m_yRotation; @@ -141,8 +314,8 @@ void Q3DCamera::setYRotation(float rotation) if (d_ptr->m_yRotation != rotation) { d_ptr->setYRotation(rotation); - if (d_ptr->m_activePreset != QDataVis::CameraPresetNone) { - d_ptr->m_activePreset = QDataVis::CameraPresetNone; + if (d_ptr->m_activePreset != CameraPresetNone) { + d_ptr->m_activePreset = CameraPresetNone; setDirty(true); } @@ -154,7 +327,7 @@ void Q3DCamera::setYRotation(float rotation) * \property Q3DCamera::minXRotation * * This property contains the current minimum X-rotation for the camera. - * The full circle range is [-180, 180] and the minimum value is limited to -180. + * The full circle range is \c{[-180, 180]} and the minimum value is limited to \c -180. * Also the value can't be higher than the maximum, and is adjusted if necessary. * * \sa wrapXRotation, maxXRotation @@ -164,9 +337,6 @@ float Q3DCamera::minXRotation() const return d_ptr->m_minXRotation; } -/*! - * \internal - */ void Q3DCamera::setMinXRotation(float minRotation) { minRotation = qBound(-180.0f, minRotation, 180.0f); @@ -186,7 +356,7 @@ void Q3DCamera::setMinXRotation(float minRotation) * \property Q3DCamera::minYRotation * * This property contains the current minimum Y-rotation for the camera. - * The full Y angle range is [-90,90] and the minimum value is limited to -90. + * The full Y angle range is \c{[-90, 90]} and the minimum value is limited to \c -90. * Also the value can't be higher than the maximum, and is adjusted if necessary. * * \sa wrapYRotation, maxYRotation @@ -196,9 +366,6 @@ float Q3DCamera::minYRotation() const return d_ptr->m_minYRotation; } -/*! - * \internal - */ void Q3DCamera::setMinYRotation(float minRotation) { minRotation = qBound(-90.0f, minRotation, 90.0f); @@ -218,7 +385,7 @@ void Q3DCamera::setMinYRotation(float minRotation) * \property Q3DCamera::maxXRotation * * This property contains the current maximum X-rotation for the camera. - * The full circle range is [-180,180] and the maximum value is limited to 180. + * The full circle range is \c{[-180, 180]} and the maximum value is limited to \c 180. * Also the value can't be lower than the minimum, and is adjusted if necessary. * * \sa wrapXRotation, minXRotation @@ -228,9 +395,6 @@ float Q3DCamera::maxXRotation() const return d_ptr->m_maxXRotation; } -/*! - * \internal - */ void Q3DCamera::setMaxXRotation(float maxRotation) { maxRotation = qBound(-180.0f, maxRotation, 180.0f); @@ -251,7 +415,7 @@ void Q3DCamera::setMaxXRotation(float maxRotation) * \property Q3DCamera::maxYRotation * * This property contains the current maximum Y-rotation for the camera. - * The full Y angle range is [-90,90] and the maximum value is limited to 90. + * The full Y angle range is \c{[-90, 90]} and the maximum value is limited to \c 90. * Also the value can't be lower than the minimum, and is adjusted if necessary. * * \sa wrapYRotation, minYRotation @@ -261,9 +425,6 @@ float Q3DCamera::maxYRotation() const return d_ptr->m_maxYRotation; } -/*! - * \internal - */ void Q3DCamera::setMaxYRotation(float maxRotation) { maxRotation = qBound(-90.0f, maxRotation, 90.0f); @@ -281,10 +442,11 @@ void Q3DCamera::setMaxYRotation(float maxRotation) } /*! - * Sets the base values for the camera that are used when calculating the camera position using the rotation values. - * The base position of the camera is defined by \a basePosition, expectation is that the x and y values are 0. - * Look at target point is defined by \a target and the camera rotates around it. Up direction for the camera is - * defined by \a baseUp, normally this is a vector with only y values set to 1. + * Sets the base values for the camera that are used when calculating the camera position using the + * rotation values. The base position of the camera is defined by \a basePosition, expectation is + * that the x and y values are 0. Look at target point is defined by \a target and the camera + * rotates around it. Up direction for the camera is defined by \a baseUp, normally this is a + * vector with only y value set to 1. */ void Q3DCamera::setBaseOrientation(const QVector3D &basePosition, const QVector3D &target, @@ -303,9 +465,11 @@ void Q3DCamera::setBaseOrientation(const QVector3D &basePosition, /*! * \property Q3DCamera::viewMatrix * - * This property contains the view matrix used in the 3D calculations. When the default orbiting camera behavior is sufficient, - * there is no need to touch this property. But if the default behavior is insufficient, the view matrix can be set directly. - * When setting the view matrix directly remember to set Q3DCamera::viewMatrixAutoUpdateEnabled to false. + * This property contains the view matrix used in the 3D calculations. When the default orbiting + * camera behavior is sufficient, there is no need to touch this property. If the default + * behavior is insufficient, the view matrix can be set directly. + * \note When setting the view matrix directly remember to set viewMatrixAutoUpdateEnabled to + * \c false. */ QMatrix4x4 Q3DCamera::viewMatrix() const { @@ -324,9 +488,9 @@ void Q3DCamera::setViewMatrix(const QMatrix4x4 &viewMatrix) /*! * \property Q3DCamera::viewMatrixAutoUpdateEnabled * - * This property determines if view matrix is automatically updated each render cycle using the current base orientation and - * rotations. If set to false, no automatic recalculation is done and the view matrix can be set using the - * Q3DMatrix::viewMatrix property. + * This property determines if view matrix is automatically updated each render cycle using the + * current base orientation and rotations. If set to \c false, no automatic recalculation is done + * and the view matrix can be set using the viewMatrix property. */ bool Q3DCamera::isViewMatrixAutoUpdateEnabled() const { @@ -342,141 +506,141 @@ void Q3DCamera::setViewMatrixAutoUpdateEnabled(bool isEnabled) /*! * \property Q3DCamera::cameraPreset * - * This property contains the currently active camera preset, - * if no preset is active the value is QDataVis::CameraPresetNone. + * This property contains the currently active camera preset, if no preset is active the value + * is CameraPresetNone. * \note The base camera orientation set by setBaseOrientation() will affect * the presets as all calculations are based on those values. */ -QDataVis::CameraPreset Q3DCamera::cameraPreset() const +Q3DCamera::CameraPreset Q3DCamera::cameraPreset() const { return d_ptr->m_activePreset; } -void Q3DCamera::setCameraPreset(QDataVis::CameraPreset preset) +void Q3DCamera::setCameraPreset(CameraPreset preset) { switch (preset) { - case QDataVis::CameraPresetFrontLow: { + case CameraPresetFrontLow: { setXRotation(0.0f); setYRotation(0.0f); break; } - case QDataVis::CameraPresetFront: { + case CameraPresetFront: { setXRotation(0.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetFrontHigh: { + case CameraPresetFrontHigh: { setXRotation(0.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetLeftLow: { + case CameraPresetLeftLow: { setXRotation(90.0f); setYRotation(0.0f); break; } - case QDataVis::CameraPresetLeft: { + case CameraPresetLeft: { setXRotation(90.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetLeftHigh: { + case CameraPresetLeftHigh: { setXRotation(90.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetRightLow: { + case CameraPresetRightLow: { setXRotation(-90.0f); setYRotation(0.0f); break; } - case QDataVis::CameraPresetRight: { + case CameraPresetRight: { setXRotation(-90.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetRightHigh: { + case CameraPresetRightHigh: { setXRotation(-90.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetBehindLow: { + case CameraPresetBehindLow: { setXRotation(180.0f); setYRotation(0.0f); break; } - case QDataVis::CameraPresetBehind: { + case CameraPresetBehind: { setXRotation(180.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetBehindHigh: { + case CameraPresetBehindHigh: { setXRotation(180.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetIsometricLeft: { + case CameraPresetIsometricLeft: { setXRotation(45.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetIsometricLeftHigh: { + case CameraPresetIsometricLeftHigh: { setXRotation(45.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetIsometricRight: { + case CameraPresetIsometricRight: { setXRotation(-45.0f); setYRotation(22.5f); break; } - case QDataVis::CameraPresetIsometricRightHigh: { + case CameraPresetIsometricRightHigh: { setXRotation(-45.0f); setYRotation(45.0f); break; } - case QDataVis::CameraPresetDirectlyAbove: { + case CameraPresetDirectlyAbove: { setXRotation(0.0f); setYRotation(90.0f); break; } - case QDataVis::CameraPresetDirectlyAboveCW45: { + case CameraPresetDirectlyAboveCW45: { setXRotation(-45.0f); setYRotation(90.0f); break; } - case QDataVis::CameraPresetDirectlyAboveCCW45: { + case CameraPresetDirectlyAboveCCW45: { setXRotation(45.0f); setYRotation(90.0f); break; } - case QDataVis::CameraPresetFrontBelow: { + case CameraPresetFrontBelow: { setXRotation(0.0f); setYRotation(-45.0f); break; } - case QDataVis::CameraPresetLeftBelow: { + case CameraPresetLeftBelow: { setXRotation(90.0f); setYRotation(-45.0f); break; } - case QDataVis::CameraPresetRightBelow: { + case CameraPresetRightBelow: { setXRotation(-90.0f); setYRotation(-45.0f); break; } - case QDataVis::CameraPresetBehindBelow: { + case CameraPresetBehindBelow: { setXRotation(180.0f); setYRotation(-45.0f); break; } - case QDataVis::CameraPresetDirectlyBelow: { + case CameraPresetDirectlyBelow: { setXRotation(0.0f); setYRotation(-90.0f); break; } default: - preset = QDataVis::CameraPresetNone; + preset = CameraPresetNone; break; } @@ -490,8 +654,8 @@ void Q3DCamera::setCameraPreset(QDataVis::CameraPreset preset) /*! * \property Q3DCamera::zoomLevel * - * This property contains the the camera zoom level in percentages. - * 100% means there is no zoom in or out set in the camera. + * This property contains the the camera zoom level in percentage. \c 100.0f means there is no zoom + * in or out set in the camera. */ int Q3DCamera::zoomLevel() const { @@ -510,10 +674,12 @@ void Q3DCamera::setZoomLevel(int zoomLevel) /*! * Calculates and returns a position relative to the camera using the given parameters * and the current camera viewMatrix property. - * \a relativePosition defines the relative 3D offset to the current camera position. - * \a fixedRotation is optional, if given fixes rotation of the calculated point around the data visualization area to the given value in degrees. - * \a distanceModifier is also optional, if given modifies the distance of the calculated point from the data visualization. - * \return Calculated position relative to this camera's position. + * The relative 3D offset to the current camera position is defined in \a relativePosition. + * An optional fixed rotation of the calculated point around the data visualization area can be + * given in \a fixedRotation. The rotation is given in degrees. + * An optional \a distanceModifier modifies the distance of the calculated point from the data + * visualization. + * \return calculated position relative to this camera's position. */ QVector3D Q3DCamera::calculatePositionRelativeToCamera(const QVector3D &relativePosition, float fixedRotation, @@ -547,8 +713,9 @@ QVector3D Q3DCamera::calculatePositionRelativeToCamera(const QVector3D &relative * 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. + * If set to \c true the X-rotation of the camera is wrapped from minimum to maximum and from + * maximum to minimum. If set to \c false the X-rotation of the camera is limited to the sector + * determined by minimum and maximum values. */ bool Q3DCamera::wrapXRotation() const { @@ -566,8 +733,9 @@ void Q3DCamera::setWrapXRotation(bool isEnabled) * 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. + * If \c true the Y-rotation of the camera is wrapped from minimum to maximum and from maximum to + * minimum. If \c false the Y-rotation of the camera is limited to the sector determined by minimum + * and maximum values. */ bool Q3DCamera::wrapYRotation() const { @@ -580,8 +748,10 @@ void Q3DCamera::setWrapYRotation(bool isEnabled) } /*! - * Utility function that sets the camera rotations and distance.\a horizontal and \a vertical define the camera rotations to be used. - * Optional \a zoom parameter can be given to set the zoom of the camera in range of 10-500%. + * Utility function that sets the camera rotations and distance.\a horizontal and \a vertical + * define the camera rotations to be used. + * Optional \a zoom parameter can be given to set the zoom percentage of the camera in range of + * \c{10.0f - 500.0f}. */ void Q3DCamera::setCameraPosition(float horizontal, float vertical, float zoom) { @@ -602,7 +772,7 @@ Q3DCameraPrivate::Q3DCameraPrivate(Q3DCamera *q) : m_wrapXRotation(true), m_wrapYRotation(false), m_zoomLevel(100), - m_activePreset(QDataVis::CameraPresetNone) + m_activePreset(Q3DCamera::CameraPresetNone) { } diff --git a/src/datavisualization/engine/q3dcamera.h b/src/datavisualization/engine/q3dcamera.h index 6a9d8a0d..8019da8b 100644 --- a/src/datavisualization/engine/q3dcamera.h +++ b/src/datavisualization/engine/q3dcamera.h @@ -32,6 +32,7 @@ class Q3DCameraPrivate; class QT_DATAVISUALIZATION_EXPORT Q3DCamera : public Q3DObject { Q_OBJECT + Q_ENUMS(CameraPreset) Q_PROPERTY(float xRotation READ xRotation WRITE setXRotation NOTIFY xRotationChanged) Q_PROPERTY(float yRotation READ yRotation WRITE setYRotation NOTIFY yRotationChanged) Q_PROPERTY(float minXRotation READ minXRotation NOTIFY minXRotationChanged) @@ -40,11 +41,39 @@ class QT_DATAVISUALIZATION_EXPORT Q3DCamera : public Q3DObject Q_PROPERTY(float maxYRotation READ maxYRotation NOTIFY maxYRotationChanged) Q_PROPERTY(int zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged) Q_PROPERTY(QMatrix4x4 viewMatrix READ viewMatrix WRITE setViewMatrix NOTIFY viewMatrixChanged) - Q_PROPERTY(QtDataVisualization::QDataVis::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY cameraPresetChanged) + Q_PROPERTY(CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY cameraPresetChanged) Q_PROPERTY(bool viewMatrixAutoUpdateEnabled READ isViewMatrixAutoUpdateEnabled WRITE setViewMatrixAutoUpdateEnabled NOTIFY viewMatrixAutoUpdateChanged) Q_PROPERTY(bool wrapXRotation READ wrapXRotation WRITE setWrapXRotation NOTIFY wrapXRotationChanged) Q_PROPERTY(bool wrapYRotation READ wrapYRotation WRITE setWrapYRotation NOTIFY wrapYRotationChanged) - Q_ENUMS(QtDataVisualization::QDataVis::CameraPreset) + +public: + enum CameraPreset { + CameraPresetNone = -1, + CameraPresetFrontLow = 0, + CameraPresetFront, + CameraPresetFrontHigh, + CameraPresetLeftLow, + CameraPresetLeft, + CameraPresetLeftHigh, + CameraPresetRightLow, + CameraPresetRight, + CameraPresetRightHigh, + CameraPresetBehindLow, + CameraPresetBehind, + CameraPresetBehindHigh, + CameraPresetIsometricLeft, + CameraPresetIsometricLeftHigh, + CameraPresetIsometricRight, + CameraPresetIsometricRightHigh, + CameraPresetDirectlyAbove, + CameraPresetDirectlyAboveCW45, + CameraPresetDirectlyAboveCCW45, + CameraPresetFrontBelow, + CameraPresetLeftBelow, + CameraPresetRightBelow, + CameraPresetBehindBelow, + CameraPresetDirectlyBelow + }; public: Q3DCamera(QObject *parent = 0); @@ -75,15 +104,15 @@ public: bool isViewMatrixAutoUpdateEnabled() const; void setViewMatrixAutoUpdateEnabled(bool isEnabled); - QDataVis::CameraPreset cameraPreset() const; - void setCameraPreset(QDataVis::CameraPreset preset); + CameraPreset cameraPreset() const; + void setCameraPreset(CameraPreset preset); int zoomLevel() const; void setZoomLevel(int zoomLevel); - void setBaseOrientation(const QVector3D &defaultPosition, - const QVector3D &defaultTarget, - const QVector3D &defaultUp); + Q_INVOKABLE void setBaseOrientation(const QVector3D &defaultPosition, + const QVector3D &defaultTarget, + const QVector3D &defaultUp); QVector3D calculatePositionRelativeToCamera(const QVector3D &relativePosition, float fixedRotation, @@ -99,7 +128,7 @@ signals: void maxYRotationChanged(float rotation); void zoomLevelChanged(int zoomLevel); void viewMatrixChanged(QMatrix4x4 viewMatrix); - void cameraPresetChanged(QDataVis::CameraPreset preset); + void cameraPresetChanged(CameraPreset preset); void viewMatrixAutoUpdateChanged(bool enabled); void wrapXRotationChanged(bool isEnabled); void wrapYRotationChanged(bool isEnabled); diff --git a/src/datavisualization/engine/q3dcamera_p.h b/src/datavisualization/engine/q3dcamera_p.h index 63f47cf0..ac32248e 100644 --- a/src/datavisualization/engine/q3dcamera_p.h +++ b/src/datavisualization/engine/q3dcamera_p.h @@ -71,7 +71,7 @@ public: bool m_wrapXRotation; bool m_wrapYRotation; int m_zoomLevel; - QDataVis::CameraPreset m_activePreset; + Q3DCamera::CameraPreset m_activePreset; friend class Bars3DRenderer; friend class Surface3DRenderer; diff --git a/src/datavisualization/engine/q3dlight.cpp b/src/datavisualization/engine/q3dlight.cpp index 742b0ce7..bc43c3d7 100644 --- a/src/datavisualization/engine/q3dlight.cpp +++ b/src/datavisualization/engine/q3dlight.cpp @@ -23,16 +23,27 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE /*! - \class Q3DLight - \inmodule QtDataVisualization - \brief Representation of a light source in 3D space. - \since Qt Data Visualization 1.0 + * \class Q3DLight + * \inmodule QtDataVisualization + * \brief Representation of a light source in 3D space. + * \since Qt Data Visualization 1.0 + * + * Q3DLight represents a monochrome non variable light source in 3D space. + */ - Q3DLight represents a monochrome non variable light source in 3D space. -*/ +/*! + * \qmltype Light3D + * \inqmlmodule QtDataVisualization + * \since QtDataVisualization 1.0 + * \ingroup datavisualization_qml + * \instantiates Q3DLight + * \brief Representation of a light source in 3D space. + * + * Light3D represents a monochrome non variable light source in 3D space. + */ /*! - * Constructs a new 3D light located at origo. An optional \a parent parameter can be given + * Constructs a new 3D light located at origin. An optional \a parent parameter can be given * and is then passed to QObject constructor. */ Q3DLight::Q3DLight(QObject *parent) : diff --git a/src/datavisualization/engine/q3dscene.cpp b/src/datavisualization/engine/q3dscene.cpp index cfef3dcf..c7c54bd3 100644 --- a/src/datavisualization/engine/q3dscene.cpp +++ b/src/datavisualization/engine/q3dscene.cpp @@ -43,6 +43,90 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE * \note Not all visualizations support the secondary 2D slicing view. */ +/*! + * \qmltype Scene3D + * \inqmlmodule QtDataVisualization + * \since QtDataVisualization 1.0 + * \ingroup datavisualization_qml + * \instantiates Q3DScene + * \brief Scene3D type provides description of the 3D scene being visualized. + * + * The 3D scene contains a single active camera and a single active light source. + * Visualized data is assumed to be at a fixed location. + * + * The 3D scene also keeps track of the viewport in which visualization rendering is done, + * the primary subviewport inside the viewport where the main 3D data visualization view resides + * and the secondary subviewport where the 2D sliced view of the data resides. + * + * Also the scene has flag for tracking if the secondary 2D slicing view is currently active or not. + * \note Not all visualizations support the secondary 2D slicing view. + */ + +/*! + * \qmlproperty rect Scene3D::viewport + * + * This property contains the current viewport rectangle where all 3D rendering + * is targeted. + */ + +/*! + * \qmlproperty rect Scene3D::primarySubViewport + * + * This property contains the current subviewport rectangle inside the viewport where the + * primary view of the data visualization is targeted to. + */ + +/*! + * \qmlproperty rect Scene3D::secondarySubViewport + * + * This property contains the secondary viewport rectangle inside the viewport. The secondary + * viewport is used for drawing the 2D slice view in some visualizations. + */ + +/*! + * \qmlproperty point Scene3D::selectionQueryPosition + * + * This property contains the coordinates for the user input that should be processed + * by the scene as selection. If this is set to value other than \c{(-1, -1)} the + * graph tries to select a data item at the given point within the primary viewport. + * After the rendering pass the property is returned to its default state of \c{(-1, -1)}. + */ + +/*! + * \qmlproperty bool Scene3D::slicingActive + * + * This property contains whether 2D slicing view is currently active or not. + * \note Not all visualizations support the 2D slicing view. + */ + +/*! + * \qmlproperty bool Scene3D::secondarySubviewOnTop + * + * This property contains whether 2D slicing view is currently drawn on top or if the 3D view is + * drawn on top. + */ + +/*! + * \qmlproperty Camera3D Scene3D::activeCamera + * + * This property contains the currently active camera in the 3D scene. + * When a Camera3D is set in the property it gets automatically added as child of the scene. + */ + +/*! + * \qmlproperty Light3D Scene3D::activeLight + * + * This property contains the currently active light in the 3D scene. + * When a Light3D is set in the property it gets automatically added as child of the scene. + */ + +/*! + * \qmlproperty float Scene3D::devicePixelRatio + * + * This property contains the current device pixel ratio that is used when mapping input + * coordinates to pixel coordinates. + */ + /*! * Constructs a basic scene with one light and one camera in it. An * optional \a parent parameter can be given and is then passed to QObject constructor. @@ -102,7 +186,7 @@ void Q3DScene::setViewportSize(int width, int height) /*! * \property Q3DScene::primarySubViewport * - * This property contains the current main viewport rectangle inside the viewport where the + * This property contains the current subviewport rectangle inside the viewport where the * primary view of the data visualization is targeted to. */ QRect Q3DScene::primarySubViewport() const @@ -123,7 +207,7 @@ void Q3DScene::setPrimarySubViewport(const QRect &primarySubViewport) * Returns whether the given \a point resides inside the primary subview or not. * The method takes care of correctly mapping between OpenGL coordinates used in the * viewport definitions and the Qt event coordinate system used in the input system. - * \return true if the point is inside the primary subview. + * \return \c true if the point is inside the primary subview. */ bool Q3DScene::isPointInPrimarySubView(const QPoint &point) { @@ -142,7 +226,7 @@ bool Q3DScene::isPointInPrimarySubView(const QPoint &point) * Returns whether the given \a point resides inside the secondary subview or not. * The method takes care of correctly mapping between OpenGL coordinates used in the * viewport definitions and the Qt event coordinate system used in the input system. - * \return true if the point is inside the secondary subview. + * \return \c true if the point is inside the secondary subview. */ bool Q3DScene::isPointInSecondarySubView(const QPoint &point) { @@ -179,10 +263,11 @@ void Q3DScene::setSecondarySubViewport(const QRect &secondarySubViewport) /*! * \property Q3DScene::selectionQueryPosition + * * This property contains the coordinates for the user input that should be processed - * by the scene as selection. If this is set to value other than Q3DScene()::invalidSelectionPoint() the - * graph tries to select a data item at the given \a point within the main viewport. - * After the rendering pass the property is returned to its default state of Q3DScene()::invalidSelectionPoint(). + * by the scene as selection. If this is set to value other than invalidSelectionPoint() the + * graph tries to select a data item at the given \a point within the primary viewport. + * After the rendering pass the property is returned to its default state of invalidSelectionPoint(). */ void Q3DScene::setSelectionQueryPosition(const QPoint &point) { @@ -232,7 +317,8 @@ void Q3DScene::setSlicingActive(bool isSlicing) /*! * \property Q3DScene::secondarySubviewOnTop * - * This property contains whether 2D slicing view is currently drawn on top or if the 3D view is drawn on top. + * This property contains whether 2D slicing view is currently drawn on top or if the 3D view is + * drawn on top. */ bool Q3DScene::isSecondarySubviewOnTop() const { @@ -253,7 +339,8 @@ void Q3DScene::setSecondarySubviewOnTop(bool isSecondaryOnTop) * \property Q3DScene::activeCamera * * This property contains the currently active camera in the 3D scene. - * When a new Q3DCamera objects is set in the property it gets automatically added as child of the scene. + * When a new Q3DCamera objects is set in the property it gets automatically added as child of + * the scene. */ Q3DCamera *Q3DScene::activeCamera() const { @@ -299,7 +386,8 @@ void Q3DScene::setActiveCamera(Q3DCamera *camera) * \property Q3DScene::activeLight * * This property contains the currently active light in the 3D scene. - * When a new Q3DLight objects is set in the property it gets automatically added as child of the scene. + * When a new Q3DLight objects is set in the property it gets automatically added as child of + * the scene. */ Q3DLight *Q3DScene::activeLight() const { @@ -341,9 +429,11 @@ void Q3DScene::setDevicePixelRatio(float pixelRatio) } /*! - * Calculates and sets the light position relative to the currently active camera using the given parameters. - * \a relativePosition defines the relative 3D offset to the current camera position. - * Optional \a fixedRotation fixes the light rotation around the data visualization area to the given value in degrees. + * Calculates and sets the light position relative to the currently active camera using the given + * parameters. + * The relative 3D offset to the current camera position is defined in \a relativePosition. + * Optional \a fixedRotation fixes the light rotation around the data visualization area to the + * given value in degrees. * Optional \a distanceModifier modifies the distance of the light from the data visualization. */ void Q3DScene::setLightPositionRelativeToCamera(const QVector3D &relativePosition, -- cgit v1.2.3