From 797ffd0b878fa0cdf92c1a815229ef357f6e5fb2 Mon Sep 17 00:00:00 2001 From: Jeremy HU Date: Sat, 12 Nov 2022 09:08:02 +1100 Subject: [PATCH] Implement node bone joint mark interface --- application/sources/document.cc | 1 + application/sources/document_window.cc | 1 + .../sources/skeleton_graphics_widget.cc | 18 ++++++++++++++++++ application/sources/skeleton_graphics_widget.h | 1 + 4 files changed, 21 insertions(+) diff --git a/application/sources/document.cc b/application/sources/document.cc index e89c7304..7bd4ca9d 100644 --- a/application/sources/document.cc +++ b/application/sources/document.cc @@ -1897,6 +1897,7 @@ void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSo node.setY(dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "y"))); node.setZ(dust3d::String::toFloat(dust3d::String::valueOrEmpty(nodeKv.second, "z"))); node.partId = oldNewIdMap[dust3d::Uuid(dust3d::String::valueOrEmpty(nodeKv.second, "partId"))]; + node.boneJoint = dust3d::String::isTrue(dust3d::String::valueOrEmpty(nodeKv.second, "boneJoint")); const auto& cutRotationIt = nodeKv.second.find("cutRotation"); if (cutRotationIt != nodeKv.second.end()) node.setCutRotation(dust3d::String::toFloat(cutRotationIt->second)); diff --git a/application/sources/document_window.cc b/application/sources/document_window.cc index 2ee665e9..746f1dfd 100644 --- a/application/sources/document_window.cc +++ b/application/sources/document_window.cc @@ -588,6 +588,7 @@ DocumentWindow::DocumentWindow() connect(m_document, &Document::edgeAdded, canvasGraphicsWidget, &SkeletonGraphicsWidget::edgeAdded); connect(m_document, &Document::edgeRemoved, canvasGraphicsWidget, &SkeletonGraphicsWidget::edgeRemoved); connect(m_document, &Document::nodeRadiusChanged, canvasGraphicsWidget, &SkeletonGraphicsWidget::nodeRadiusChanged); + connect(m_document, &Document::nodeBoneJointStateChanged, canvasGraphicsWidget, &SkeletonGraphicsWidget::nodeBoneJointStateChanged); connect(m_document, &Document::nodeOriginChanged, canvasGraphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); connect(m_document, &Document::edgeReversed, canvasGraphicsWidget, &SkeletonGraphicsWidget::edgeReversed); connect(m_document, &Document::partVisibleStateChanged, canvasGraphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); diff --git a/application/sources/skeleton_graphics_widget.cc b/application/sources/skeleton_graphics_widget.cc index f4b13767..2900066a 100644 --- a/application/sources/skeleton_graphics_widget.cc +++ b/application/sources/skeleton_graphics_widget.cc @@ -2039,6 +2039,22 @@ void SkeletonGraphicsWidget::originChanged() m_sideOriginItem->show(); } +void SkeletonGraphicsWidget::nodeBoneJointStateChanged(const dust3d::Uuid& nodeId) +{ + const Document::Node* node = m_document->findNode(nodeId); + if (nullptr == node) { + qDebug() << "Node changed but node id not exist:" << nodeId; + return; + } + auto it = nodeItemMap.find(nodeId); + if (it == nodeItemMap.end()) { + qDebug() << "Node not found:" << nodeId; + return; + } + it->second.first->setMarkColor(node->boneJoint ? Theme::blue : Qt::transparent); + it->second.second->setMarkColor(node->boneJoint ? Theme::blue : Qt::transparent); +} + void SkeletonGraphicsWidget::nodeAdded(dust3d::Uuid nodeId) { const Document::Node* node = m_document->findNode(nodeId); @@ -2058,6 +2074,8 @@ void SkeletonGraphicsWidget::nodeAdded(dust3d::Uuid nodeId) sideProfileItem->setOrigin(scenePosFromUnified(QPointF(node->getZ(m_rotated), node->getY(m_rotated)))); mainProfileItem->setRadius(sceneRadiusFromUnified(node->radius)); sideProfileItem->setRadius(sceneRadiusFromUnified(node->radius)); + mainProfileItem->setMarkColor(node->boneJoint ? Theme::blue : Qt::transparent); + sideProfileItem->setMarkColor(node->boneJoint ? Theme::blue : Qt::transparent); mainProfileItem->setId(nodeId); sideProfileItem->setId(nodeId); scene()->addItem(mainProfileItem); diff --git a/application/sources/skeleton_graphics_widget.h b/application/sources/skeleton_graphics_widget.h index 9e6a53e5..c915f7de 100644 --- a/application/sources/skeleton_graphics_widget.h +++ b/application/sources/skeleton_graphics_widget.h @@ -120,6 +120,7 @@ public slots: void edgeRemoved(dust3d::Uuid edgeId); void nodeRadiusChanged(dust3d::Uuid nodeId); void nodeOriginChanged(dust3d::Uuid nodeId); + void nodeBoneJointStateChanged(const dust3d::Uuid& nodeId); void edgeReversed(dust3d::Uuid edgeId); void turnaroundChanged(); void canvasResized();