mirror of
https://github.com/leozide/leocad
synced 2024-11-17 07:47:55 +01:00
Undo/redo try to preserve cameras
Addresses leozide/leocad#534 It does not work if * the name of a camera is changed * a camera does not exist after undo/redo * multiple cameras have the same name In order to address these remaining issues, one could add a unique ID to all cameras in the model.
This commit is contained in:
parent
b520fe0b6d
commit
81262d2f88
1 changed files with 27 additions and 0 deletions
|
@ -1751,6 +1751,22 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
|
|||
// 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);
|
||||
|
@ -1761,6 +1777,17 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
|
|||
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->UpdateCameraMenu();
|
||||
gMainWindow->UpdateCurrentStep();
|
||||
|
|
Loading…
Reference in a new issue