diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-02-07 15:30:53 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-02-10 08:25:28 +0200 |
commit | 61c84e2d9c46de40d22f6fafbdd23d4015025516 (patch) | |
tree | 13c04fa5a90e75d5730babd6ab1cefef54b54417 /src/datavisualization/data/qabstract3dseries.cpp | |
parent | ffc2e2039f58de256a98da395b5d0e87d5a176fc (diff) |
Mostly revert the rotations refactor
Quaternions are actually easier to use in most use cases.
Added some convenience functionality for QML to enable using
axis/angle combinations, too.
Change-Id: I61c76e0967b4808aa9adaf43dfe6f4596c9ce353
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/data/qabstract3dseries.cpp')
-rw-r--r-- | src/datavisualization/data/qabstract3dseries.cpp | 100 |
1 files changed, 34 insertions, 66 deletions
diff --git a/src/datavisualization/data/qabstract3dseries.cpp b/src/datavisualization/data/qabstract3dseries.cpp index fbc72410..4d201c45 100644 --- a/src/datavisualization/data/qabstract3dseries.cpp +++ b/src/datavisualization/data/qabstract3dseries.cpp @@ -142,28 +142,15 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION */ /*! - * \qmlproperty vector3d Abstract3DSeries::meshRotationAxis + * \qmlproperty quaternion Abstract3DSeries::meshRotation * - * Sets the mesh rotation \a axis that is applied to all items of the series. - * For those series types that support item specific rotation, the resulting - * rotation quaternions are multiplied together at render time. - * Bar3DSeries ignores rotation axis, as it only supports rotation around Y-axis. + * Sets the mesh \a rotation that is applied to all items of the series. + * The \a rotation should be a normalized quaternion. + * For those series types that support item specific rotation, the rotations are + * multiplied together. + * Bar3DSeries ignores any rotation that is not around Y-axis. * Surface3DSeries applies the rotation only to the selection pointer. - * Defaults to Y-axis. - * - * \sa meshRotationAngle - */ - -/*! - * \qmlproperty float Abstract3DSeries::meshRotationAngle - * - * Sets the mesh rotation \a angle that is applied to all items of the series. - * For those series types that support item specific rotation, the resulting - * rotation quaternions are multiplied together at render time. - * Surface3DSeries applies the rotation only to the selection pointer. - * Defaults to 0. - * - * \sa meshRotationAxis + * Defaults to no rotation. */ /*! @@ -253,6 +240,14 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION */ /*! + * \qmlmethod void Abstract3DSeries::setMeshAxisAndAngle(vector3d axis, real angle) + * + * A convenience function to construct mesh rotation quaternion from axis and angle. + * + * \sa meshRotation + */ + +/*! * \internal */ QAbstract3DSeries::QAbstract3DSeries(QAbstract3DSeriesPrivate *d, QObject *parent) : @@ -364,54 +359,37 @@ bool QAbstract3DSeries::isMeshSmooth() const } /*! - * \property QAbstract3DSeries::meshRotationAxis + * \property QAbstract3DSeries::meshRotation * - * Sets the mesh rotation \a axis that is applied to all items of the series. - * For those series types that support item specific rotation, the resulting - * rotation quaternions are multiplied together at render time. - * QBar3DSeries ignores rotation axis, as it only supports rotation around Y-axis. + * Sets the mesh \a rotation that is applied to all items of the series. + * The \a rotation should be a normalized QQuaternion. + * For those series types that support item specific rotation, the rotations are + * multiplied together. + * QBar3DSeries ignores any rotation that is not around Y-axis. * QSurface3DSeries applies the rotation only to the selection pointer. - * Defaults to Y-axis. - * - * \sa meshRotationAngle + * Defaults to no rotation. */ -void QAbstract3DSeries::setMeshRotationAxis(const QVector3D &axis) +void QAbstract3DSeries::setMeshRotation(const QQuaternion &rotation) { - if (d_ptr->m_type != SeriesTypeBar) { - if (d_ptr->m_meshRotationAxis != axis) { - d_ptr->setMeshRotationAxis(axis); - emit meshRotationAxisChanged(axis); - } + if (d_ptr->m_meshRotation != rotation) { + d_ptr->setMeshRotation(rotation); + emit meshRotationChanged(rotation); } } -QVector3D QAbstract3DSeries::meshRotationAxis() const +QQuaternion QAbstract3DSeries::meshRotation() const { - return d_ptr->m_meshRotationAxis; + return d_ptr->m_meshRotation; } /*! - * \property QAbstract3DSeries::meshRotationAngle + * A convenience function to construct mesh rotation quaternion from \a axis and \a angle. * - * Sets the mesh rotation \a angle that is applied to all items of the series. - * For those series types that support item specific rotation, the resulting - * rotation quaternions are multiplied together at render time. - * QSurface3DSeries applies the rotation only to the selection pointer. - * Defaults to 0. - * - * \sa meshRotationAxis + * \sa meshRotation */ -void QAbstract3DSeries::setMeshRotationAngle(float angle) -{ - if (d_ptr->m_meshRotationAngle != angle) { - d_ptr->setMeshRotationAngle(angle); - emit meshRotationAngleChanged(angle); - } -} - -float QAbstract3DSeries::meshRotationAngle() const +void QAbstract3DSeries::setMeshAxisAndAngle(const QVector3D &axis, float angle) { - return d_ptr->m_meshRotationAngle; + setMeshRotation(QQuaternion::fromAxisAndAngle(axis, angle)); } /*! @@ -619,8 +597,6 @@ QAbstract3DSeriesPrivate::QAbstract3DSeriesPrivate(QAbstract3DSeries *q, QAbstra m_controller(0), m_mesh(QAbstract3DSeries::MeshCube), m_meshSmooth(false), - m_meshRotationAxis(upVector), - m_meshRotationAngle(0.0f), m_colorStyle(Q3DTheme::ColorStyleUniform) { } @@ -687,17 +663,9 @@ void QAbstract3DSeriesPrivate::setMeshSmooth(bool enable) m_controller->markSeriesVisualsDirty(); } -void QAbstract3DSeriesPrivate::setMeshRotationAxis(const QVector3D &axis) -{ - m_meshRotationAxis = axis; - m_changeTracker.meshRotationChanged = true; - if (m_controller) - m_controller->markSeriesVisualsDirty(); -} - -void QAbstract3DSeriesPrivate::setMeshRotationAngle(float angle) +void QAbstract3DSeriesPrivate::setMeshRotation(const QQuaternion &rotation) { - m_meshRotationAngle = angle; + m_meshRotation = rotation; m_changeTracker.meshRotationChanged = true; if (m_controller) m_controller->markSeriesVisualsDirty(); |