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

View File

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