Implement node bone joint mark interface

master
Jeremy HU 2022-11-12 09:08:02 +11:00
parent 427a692558
commit 797ffd0b87
4 changed files with 21 additions and 0 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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();