3D Preview - update background from submodel properties. Treats #513

This commit is contained in:
Trevor SANDY 2020-10-12 22:59:14 +02:00
parent 28437d16f7
commit c5426abf24
3 changed files with 32 additions and 0 deletions

View file

@ -4453,6 +4453,10 @@ void lcModel::ShowPropertiesDialog()
UpdateBackgroundTexture();
lcPreferences& Preferences = lcGetPreferences();
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition != lcPreviewPosition::Floating)
gMainWindow->GetPreviewWidget()->UpdatePreview();
SaveCheckpoint(tr("Changing Properties"));
}

View file

@ -52,6 +52,11 @@ bool lcPreviewDockWidget::SetCurrentPiece(const QString& PartType, int ColorCode
return false;
}
void lcPreviewDockWidget::UpdatePreview()
{
mPreview->UpdatePreview();
}
void lcPreviewDockWidget::ClearPreview()
{
if (mPreview->GetActiveModel()->GetPieces().GetSize())
@ -171,6 +176,27 @@ void lcPreviewWidget::ClearPreview()
Redraw();
}
void lcPreviewWidget::UpdatePreview()
{
QString PartType;
int ColorCode = -1;
lcModel* ActiveModel = GetActiveModel();
for (lcPiece* ModelPiece : ActiveModel->GetPieces())
{
if (ModelPiece->mPieceInfo)
{
PartType = ModelPiece->mPieceInfo->mFileName;
ColorCode = ModelPiece->mColorCode;
break;
}
}
ClearPreview();
if (!PartType.isEmpty() && ColorCode > -1)
SetCurrentPiece(PartType, ColorCode);
}
void lcPreviewWidget::SetDefaultCamera()
{
if (!mCamera || !mCamera->IsSimple())

View file

@ -24,6 +24,7 @@ public:
explicit lcPreviewDockWidget(QMainWindow* parent = nullptr);
bool SetCurrentPiece(const QString& PartType, int ColorCode);
void ClearPreview();
void UpdatePreview();
protected slots:
void SetPreviewLock();
@ -86,6 +87,7 @@ public:
}
void ClearPreview();
void UpdatePreview();
bool SetCurrentPiece(const QString& PartType, int ColorCode);
lcMatrix44 GetProjectionMatrix() const;
lcModel* GetActiveModel() const;