Fix bone removing
parent
6b4192161e
commit
d23113e204
|
@ -65,6 +65,7 @@ BoneManageWidget::BoneManageWidget(Document* document, QWidget* parent)
|
|||
connect(m_propertyButton, &QPushButton::clicked, this, &BoneManageWidget::showSelectedBoneProperties);
|
||||
|
||||
connect(this, &BoneManageWidget::groupOperationAdded, m_document, &Document::saveSnapshot);
|
||||
connect(this, &BoneManageWidget::removeBone, m_document, &Document::removeBone);
|
||||
|
||||
connect(this, &BoneManageWidget::customContextMenuRequested, this, &BoneManageWidget::showContextMenu);
|
||||
|
||||
|
@ -130,6 +131,14 @@ void BoneManageWidget::updateToolButtons()
|
|||
m_propertyButton->setEnabled(enablePropertyButton);
|
||||
}
|
||||
|
||||
void BoneManageWidget::removeSelectedBones()
|
||||
{
|
||||
auto selectedBoneIds = m_bonePreviewGridWidget->getSelectedBoneIds();
|
||||
for (const auto& boneId : selectedBoneIds)
|
||||
emit removeBone(boneId);
|
||||
emit groupOperationAdded();
|
||||
}
|
||||
|
||||
void BoneManageWidget::showContextMenu(const QPoint& pos)
|
||||
{
|
||||
auto selectedBoneIds = m_bonePreviewGridWidget->getSelectedBoneIds();
|
||||
|
@ -138,5 +147,9 @@ void BoneManageWidget::showContextMenu(const QPoint& pos)
|
|||
|
||||
QMenu contextMenu(this);
|
||||
|
||||
QAction deleteAction(tr("Delete"), this);
|
||||
connect(&deleteAction, &QAction::triggered, this, &BoneManageWidget::removeSelectedBones);
|
||||
contextMenu.addAction(&deleteAction);
|
||||
|
||||
contextMenu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
|
|
@ -16,12 +16,16 @@ class BoneManageWidget : public QWidget {
|
|||
signals:
|
||||
void unselectAllOnCanvas();
|
||||
void selectNodeOnCanvas(const dust3d::Uuid& nodeId);
|
||||
void removeBone(const dust3d::Uuid& boneId);
|
||||
void groupOperationAdded();
|
||||
public slots:
|
||||
void selectBoneByBoneId(const dust3d::Uuid& boneId);
|
||||
void showSelectedBoneProperties();
|
||||
void showContextMenu(const QPoint& pos);
|
||||
|
||||
private slots:
|
||||
void removeSelectedBones();
|
||||
|
||||
public:
|
||||
BoneManageWidget(Document* document, QWidget* parent = nullptr);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void BonePropertyWidget::updateBoneJointComboBox()
|
|||
m_parentJointComboBox->clear();
|
||||
for (size_t i = 0; i < parentBone->joints.size(); ++i) {
|
||||
m_parentJointComboBox->addItem(QString::number(i + 1));
|
||||
if (i == m_bone->attachBoneJointIndex)
|
||||
if (i == (size_t)m_bone->attachBoneJointIndex)
|
||||
m_parentJointComboBox->setCurrentIndex(m_parentJointComboBox->count() - 1);
|
||||
}
|
||||
m_parentJointComboBox->setVisible(true);
|
||||
|
|
|
@ -2966,7 +2966,7 @@ void Document::applyBoneJoints(const dust3d::Uuid& boneId, const std::vector<dus
|
|||
|
||||
void Document::removeBone(const dust3d::Uuid& boneId)
|
||||
{
|
||||
if (boneMap.end() != boneMap.find(boneId))
|
||||
if (boneMap.end() == boneMap.find(boneId))
|
||||
return;
|
||||
|
||||
for (auto& it : nodeMap)
|
||||
|
|
Loading…
Reference in New Issue