From dab7c73e04cf850819827c3e4c4e7bea6e1a223c Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Mon, 21 Aug 2017 22:13:43 +0100 Subject: Add name property to QJoint And set it from the backend when creating frontend joints. Change-Id: I26d37c7f516944eb353af38716aab4c55bd2f79f Reviewed-by: Paul Lemire --- src/core/transforms/qjoint.cpp | 17 +++++++++++++++++ src/core/transforms/qjoint.h | 4 ++++ src/core/transforms/qjoint_p.h | 2 ++ 3 files changed, 23 insertions(+) (limited to 'src/core/transforms') diff --git a/src/core/transforms/qjoint.cpp b/src/core/transforms/qjoint.cpp index 57603b54f..84d75d55d 100644 --- a/src/core/transforms/qjoint.cpp +++ b/src/core/transforms/qjoint.cpp @@ -310,6 +310,16 @@ void QJoint::setRotationZ(float rotationZ) blockNotifications(wasBlocked); } +void QJoint::setName(const QString &name) +{ + Q_D(QJoint); + if (d->m_name == name) + return; + + d->m_name = name; + emit nameChanged(name); +} + /*! Adds \a joint as a child of this joint. If \a joint has no parent, then this joint takes ownership of it. Child joints are in the coordinate system @@ -366,6 +376,12 @@ QVector QJoint::childJoints() const return d->m_childJoints; } +QString QJoint::name() const +{ + Q_D(const QJoint); + return d->m_name; +} + /*! \internal */ Qt3DCore::QNodeCreatedChangeBasePtr QJoint::createNodeCreationChange() const { @@ -377,6 +393,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QJoint::createNodeCreationChange() const data.rotation = d->m_rotation; data.scale = d->m_scale; data.translation = d->m_translation; + data.name = d->m_name; return creationChange; } diff --git a/src/core/transforms/qjoint.h b/src/core/transforms/qjoint.h index 3160d74ab..732cfdddb 100644 --- a/src/core/transforms/qjoint.h +++ b/src/core/transforms/qjoint.h @@ -63,6 +63,7 @@ class QT3DCORESHARED_EXPORT QJoint : public QNode Q_PROPERTY(float rotationX READ rotationX WRITE setRotationX NOTIFY rotationXChanged) Q_PROPERTY(float rotationY READ rotationY WRITE setRotationY NOTIFY rotationYChanged) Q_PROPERTY(float rotationZ READ rotationZ WRITE setRotationZ NOTIFY rotationZChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) public: explicit QJoint(Qt3DCore::QNode *parent = nullptr); @@ -75,6 +76,7 @@ public: float rotationX() const; float rotationY() const; float rotationZ() const; + QString name() const; void addChildJoint(QJoint *joint); void removeChildJoint(QJoint *joint); @@ -88,6 +90,7 @@ public Q_SLOTS: void setRotationX(float rotationX); void setRotationY(float rotationY); void setRotationZ(float rotationZ); + void setName(const QString &name); Q_SIGNALS: void scaleChanged(const QVector3D &scale); @@ -97,6 +100,7 @@ Q_SIGNALS: void rotationXChanged(float rotationX); void rotationYChanged(float rotationY); void rotationZChanged(float rotationZ); + void nameChanged(const QString &name); private: Q_DECLARE_PRIVATE(QJoint) diff --git a/src/core/transforms/qjoint_p.h b/src/core/transforms/qjoint_p.h index f7ab244bd..82439d55a 100644 --- a/src/core/transforms/qjoint_p.h +++ b/src/core/transforms/qjoint_p.h @@ -72,6 +72,7 @@ public: QQuaternion m_rotation; QVector3D m_translation; QVector3D m_scale; + QString m_name; // Not sent to backend. Purely internal convenience QVector3D m_eulerRotationAngles; @@ -84,6 +85,7 @@ struct QJointData QQuaternion rotation; QVector3D translation; QVector3D scale; + QString name; }; } // namespace Qt3DCore -- cgit v1.2.3