Fix opengl widget messing up while dock top level changed

master
Jeremy Hu 2018-09-18 22:23:28 +08:00
parent d3e28e88f2
commit 7341259a48
2 changed files with 29 additions and 15 deletions

View File

@ -209,12 +209,21 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
partTreeWidget->setGraphicsFunctions(graphicsWidget); partTreeWidget->setGraphicsFunctions(graphicsWidget);
partTreeDocker->setWidget(partTreeWidget); partTreeDocker->setWidget(partTreeWidget);
addDockWidget(Qt::RightDockWidgetArea, partTreeDocker); 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); QDockWidget *rigDocker = new QDockWidget(tr("Rig"), this);
rigDocker->setAllowedAreas(Qt::RightDockWidgetArea); rigDocker->setAllowedAreas(Qt::RightDockWidgetArea);
RigWidget *rigWidget = new RigWidget(m_document, rigDocker); m_rigWidget = new RigWidget(m_document, rigDocker);
rigDocker->setWidget(rigWidget); rigDocker->setWidget(m_rigWidget);
addDockWidget(Qt::RightDockWidgetArea, rigDocker); addDockWidget(Qt::RightDockWidgetArea, rigDocker);
connect(rigDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
Q_UNUSED(topLevel);
updateRigWeightRenderWidget();
});
//QDockWidget *animationDocker = new QDockWidget(tr("Animation"), this); //QDockWidget *animationDocker = new QDockWidget(tr("Animation"), this);
//animationDocker->setAllowedAreas(Qt::RightDockWidgetArea); //animationDocker->setAllowedAreas(Qt::RightDockWidgetArea);
@ -748,20 +757,11 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState); connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState);
connect(m_document, &SkeletonDocument::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState); 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::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged);
connect(m_document, &SkeletonDocument::resultRigChanged, rigWidget, &RigWidget::updateResultInfo); connect(m_document, &SkeletonDocument::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo);
connect(m_document, &SkeletonDocument::resultRigChanged, [=]() { connect(m_document, &SkeletonDocument::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget);
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::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview); //connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview);
@ -1133,3 +1133,15 @@ void SkeletonDocumentWindow::updateRadiusLockButtonState()
else else
m_radiusLockButton->setStyleSheet("QPushButton {color: " + Theme::white.name() + "}"); 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();
}
}

View File

@ -55,6 +55,7 @@ public slots:
void updateYlockButtonState(); void updateYlockButtonState();
void updateZlockButtonState(); void updateZlockButtonState();
void updateRadiusLockButtonState(); void updateRadiusLockButtonState();
void updateRigWeightRenderWidget();
private: private:
void initLockButton(QPushButton *button); void initLockButton(QPushButton *button);
void setCurrentFilename(const QString &filename); void setCurrentFilename(const QString &filename);
@ -69,6 +70,7 @@ private:
ModelWidget *m_modelRenderWidget; ModelWidget *m_modelRenderWidget;
SkeletonGraphicsWidget *m_graphicsWidget; SkeletonGraphicsWidget *m_graphicsWidget;
RigWidget *m_rigWidget;
QMenu *m_fileMenu; QMenu *m_fileMenu;
QAction *m_newWindowAction; QAction *m_newWindowAction;