Merge pull request #896 from gerw/master

Undo/redo preserve selected step
This commit is contained in:
Leonardo Zide 2024-05-11 11:36:40 -07:00 committed by GitHub
commit 63272bcc78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1748,12 +1748,46 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
LoadedInfos.push_back(Info);
}
// Remember the current step
const lcStep CurrentStep = mCurrentStep;
// Remember the camera names
std::vector<QString> CameraNames;
if (gMainWindow)
{
std::vector<lcView*> Views = lcView::GetModelViews(this);
CameraNames.resize( Views.size() );
for (unsigned int i = 0; i < Views.size(); i++)
{
lcCamera* Camera = Views[i]->GetCamera();
if (!Camera->IsSimple() && mCameras.FindIndex(Camera) != -1)
CameraNames[i] = Camera->GetName();
else
CameraNames[i] = "";
}
}
DeleteModel();
QBuffer Buffer(&CheckPoint->File);
Buffer.open(QIODevice::ReadOnly);
LoadLDraw(Buffer, lcGetActiveProject());
// Reset the current step
mCurrentStep = CurrentStep;
CalculateStep(CurrentStep);
// Reset the cameras
if (gMainWindow)
{
std::vector<lcView*> Views = lcView::GetModelViews(this);
for (unsigned int i = 0; i < CameraNames.size(); i++)
{
if (CameraNames[i] != "")
Views[i]->SetCamera(CameraNames[i]);
}
}
gMainWindow->UpdateTimeline(true, false);
gMainWindow->UpdateCurrentStep();
gMainWindow->UpdateSelectedObjects(true);