diff --git a/src/skeletondocumentwindow.cpp b/src/skeletondocumentwindow.cpp index 01a0291c..0467d7d3 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/skeletondocumentwindow.cpp @@ -209,12 +209,21 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : partTreeWidget->setGraphicsFunctions(graphicsWidget); partTreeDocker->setWidget(partTreeWidget); addDockWidget(Qt::RightDockWidgetArea, partTreeDocker); + connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) { + Q_UNUSED(topLevel); + for (const auto &part: m_document->partMap) + partTreeWidget->partPreviewChanged(part.first); + }); QDockWidget *rigDocker = new QDockWidget(tr("Rig"), this); rigDocker->setAllowedAreas(Qt::RightDockWidgetArea); - RigWidget *rigWidget = new RigWidget(m_document, rigDocker); - rigDocker->setWidget(rigWidget); + m_rigWidget = new RigWidget(m_document, rigDocker); + rigDocker->setWidget(m_rigWidget); addDockWidget(Qt::RightDockWidgetArea, rigDocker); + connect(rigDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) { + Q_UNUSED(topLevel); + updateRigWeightRenderWidget(); + }); //QDockWidget *animationDocker = new QDockWidget(tr("Animation"), this); //animationDocker->setAllowedAreas(Qt::RightDockWidgetArea); @@ -748,20 +757,11 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState); connect(m_document, &SkeletonDocument::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState); - connect(rigWidget, &RigWidget::setRigType, m_document, &SkeletonDocument::setRigType); + connect(m_rigWidget, &RigWidget::setRigType, m_document, &SkeletonDocument::setRigType); - connect(m_document, &SkeletonDocument::rigTypeChanged, rigWidget, &RigWidget::rigTypeChanged); - connect(m_document, &SkeletonDocument::resultRigChanged, rigWidget, &RigWidget::updateResultInfo); - connect(m_document, &SkeletonDocument::resultRigChanged, [=]() { - MeshLoader *resultRigWeightMesh = m_document->takeResultRigWeightMesh(); - if (nullptr == resultRigWeightMesh) { - rigWidget->rigWeightRenderWidget()->hide(); - } else { - rigWidget->rigWeightRenderWidget()->updateMesh(resultRigWeightMesh); - rigWidget->rigWeightRenderWidget()->show(); - rigWidget->rigWeightRenderWidget()->update(); - } - }); + connect(m_document, &SkeletonDocument::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged); + connect(m_document, &SkeletonDocument::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo); + connect(m_document, &SkeletonDocument::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget); //connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview); @@ -1133,3 +1133,15 @@ void SkeletonDocumentWindow::updateRadiusLockButtonState() else m_radiusLockButton->setStyleSheet("QPushButton {color: " + Theme::white.name() + "}"); } + +void SkeletonDocumentWindow::updateRigWeightRenderWidget() +{ + MeshLoader *resultRigWeightMesh = m_document->takeResultRigWeightMesh(); + if (nullptr == resultRigWeightMesh) { + m_rigWidget->rigWeightRenderWidget()->hide(); + } else { + m_rigWidget->rigWeightRenderWidget()->updateMesh(resultRigWeightMesh); + m_rigWidget->rigWeightRenderWidget()->show(); + m_rigWidget->rigWeightRenderWidget()->update(); + } +} diff --git a/src/skeletondocumentwindow.h b/src/skeletondocumentwindow.h index d51f5ae5..6b27b7f3 100644 --- a/src/skeletondocumentwindow.h +++ b/src/skeletondocumentwindow.h @@ -55,6 +55,7 @@ public slots: void updateYlockButtonState(); void updateZlockButtonState(); void updateRadiusLockButtonState(); + void updateRigWeightRenderWidget(); private: void initLockButton(QPushButton *button); void setCurrentFilename(const QString &filename); @@ -69,6 +70,7 @@ private: ModelWidget *m_modelRenderWidget; SkeletonGraphicsWidget *m_graphicsWidget; + RigWidget *m_rigWidget; QMenu *m_fileMenu; QAction *m_newWindowAction;