Implement bone nodes selection

master
Jeremy HU 2022-12-05 19:42:22 +11:00
parent 6e53452dc8
commit 3685caa92f
4 changed files with 28 additions and 0 deletions

View File

@ -52,6 +52,16 @@ BoneManageWidget::BoneManageWidget(Document* document, QWidget* parent)
this->m_document->saveSnapshot();
});
connect(m_selectButton, &QPushButton::clicked, [this]() {
for (const auto& boneId : this->m_bonePreviewGridWidget->getSelectedBoneIds()) {
for (const auto& nodeIt : m_document->nodeMap) {
if (nodeIt.second.boneIds.end() == nodeIt.second.boneIds.find(boneId))
continue;
emit this->selectNodeOnCanvas(nodeIt.first);
}
}
});
connect(m_propertyButton, &QPushButton::clicked, this, &BoneManageWidget::showSelectedBoneProperties);
connect(this, &BoneManageWidget::groupOperationAdded, m_document, &Document::saveSnapshot);

View File

@ -615,6 +615,8 @@ DocumentWindow::DocumentWindow()
connect(canvasGraphicsWidget, &SkeletonGraphicsWidget::partComponentChecked, m_partManageWidget, &PartManageWidget::selectComponentByPartId);
connect(m_boneManageWidget, &BoneManageWidget::selectNodeOnCanvas, canvasGraphicsWidget, &SkeletonGraphicsWidget::addNodeToSelection);
connect(m_document, &Document::skeletonChanged, m_document, &Document::generateMesh);
connect(m_document, &Document::textureChanged, m_document, &Document::generateTexture);
connect(m_document, &Document::resultMeshChanged, m_document, &Document::postProcess);

View File

@ -2515,6 +2515,21 @@ void SkeletonGraphicsWidget::addPartToSelection(dust3d::Uuid partId)
}
}
void SkeletonGraphicsWidget::addNodeToSelection(const dust3d::Uuid& nodeId)
{
Document::Profile choosenProfile = Document::Profile::Main;
if (m_hoveredNodeItem) {
choosenProfile = m_hoveredNodeItem->profile();
} else if (m_hoveredEdgeItem) {
choosenProfile = m_hoveredEdgeItem->profile();
}
auto findNodeItem = nodeItemMap.find(nodeId);
if (findNodeItem == nodeItemMap.end())
return;
SkeletonGraphicsNodeItem* item = Document::Profile::Main == choosenProfile ? findNodeItem->second.first : findNodeItem->second.second;
addItemToRangeSelection(item);
}
void SkeletonGraphicsWidget::selectConnectedAll()
{
unselectAll();

View File

@ -137,6 +137,7 @@ public slots:
void selectPartAll();
void selectConnectedAll();
void addPartToSelection(dust3d::Uuid partId);
void addNodeToSelection(const dust3d::Uuid& nodeId);
void cut();
void copy();
void flipHorizontally();