diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-10-26 11:41:46 +0000 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-11-16 14:45:44 +0000 |
commit | 96d8600620016ba29b91c4f87755500e1321d6f9 (patch) | |
tree | 3c510760693093be79730cd3ed884175eaa0eddb /src/core/transforms/qtransform.cpp | |
parent | a2847483f2d6f7582faeaa8836616df37d53218c (diff) |
Add scale, rotation and translation properties to QTransform
This is the first step in refactoring QTransform to make it able to
receive changes from aspects and be able to decompose affine matrices
into these 3 properties. Something that is not possible in the current
implementation that uses arbitrary sequences of sub-transforms.
Change-Id: I794fcbdb2c33d874ff7142f28c8eeef15c77fba3
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core/transforms/qtransform.cpp')
-rw-r--r-- | src/core/transforms/qtransform.cpp | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp index 5f3711eb2..1c1f95a1b 100644 --- a/src/core/transforms/qtransform.cpp +++ b/src/core/transforms/qtransform.cpp @@ -49,8 +49,11 @@ namespace Qt3DCore { \internal */ QTransformPrivate::QTransformPrivate() - : QComponentPrivate(), - m_transformsDirty(false) + : QComponentPrivate() + , m_transformsDirty(false) + , m_rotation() + , m_scale(1.0f, 1.0f, 1.0f) + , m_translation() { } @@ -159,6 +162,51 @@ QMatrix4x4 QTransform::matrix() const return d->m_matrix; } +void QTransform::setScale(const QVector3D &scale) +{ + Q_D(QTransform); + if (scale != d->m_scale) { + d->m_scale = scale; + emit scaleChanged(); + } +} + +QVector3D QTransform::scale() const +{ + Q_D(const QTransform); + return d->m_scale; +} + +void QTransform::setRotation(const QQuaternion &rotation) +{ + Q_D(QTransform); + if (rotation != d->m_rotation) { + d->m_rotation = rotation; + emit rotationChanged(); + } +} + +QQuaternion QTransform::rotation() const +{ + Q_D(const QTransform); + return d->m_rotation; +} + +void QTransform::setTranslation(const QVector3D &translation) +{ + Q_D(QTransform); + if (translation != d->m_translation) { + d->m_translation = translation; + emit translationChanged(); + } +} + +QVector3D QTransform::translation() const +{ + Q_D(const QTransform); + return d->m_translation; +} + } // namespace Qt3DCore QT_END_NAMESPACE |