diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 754c6014..843119b5 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -263,7 +263,7 @@ void lcModel::UpdatePieceInfo(std::vector& UpdatedModels) mPieceInfo->SetBoundingBox(Min, Max); } -void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep CurrentStep) const +void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) const { const QLatin1String LineEnding("\r\n"); @@ -273,14 +273,14 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep CurrentSt lcStep Step = 1; int CurrentLine = 0; int AddedSteps = 0; - bool Saved = false; + bool SavedStep = false; for (lcPiece* Piece : mPieces) { if (SelectedOnly && !Piece->IsSelected()) continue; - if ((Saved = CurrentStep && Piece->GetStepShow() > CurrentStep)) + if (SavedStep = (LastStep != 0 && Piece->GetStepShow() > LastStep)) break; while (Piece->GetFileLine() > CurrentLine && CurrentLine < mFileLines.size()) @@ -395,7 +395,7 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep CurrentSt Stream << QLatin1String("0 !LEOCAD SYNTH END\r\n"); } - while ( !Saved && CurrentLine < mFileLines.size()) + while (!SavedStep && CurrentLine < mFileLines.size()) { QString Line = mFileLines[CurrentLine]; QTextStream LineStream(&Line, QIODevice::ReadOnly); @@ -1107,7 +1107,7 @@ void lcModel::Copy() QByteArray File; QTextStream Stream(&File, QIODevice::WriteOnly); - SaveLDraw(Stream, true); + SaveLDraw(Stream, true, 0); gApplication->ExportClipboard(File); } @@ -1301,7 +1301,7 @@ QImage lcModel::GetPartsListImage(int MaxWidth, lcStep Step, quint32 BackgroundC if (Step == 0) GetPartsList(gDefaultColor, true, false, PartsList); else - GetPartsListForStep(Step, gDefaultColor, PartsList); + GetPartsListForStep(Step, gDefaultColor, PartsList, false); if (PartsList.empty()) return QImage(); @@ -1629,7 +1629,7 @@ void lcModel::SaveCheckpoint(const QString& Description) ModelHistoryEntry->Description = Description; QTextStream Stream(&ModelHistoryEntry->File); - SaveLDraw(Stream, false); + SaveLDraw(Stream, false, 0); mUndoHistory.insert(mUndoHistory.begin(), ModelHistoryEntry); for (lcModelHistoryEntry* Entry : mRedoHistory) diff --git a/common/lc_model.h b/common/lc_model.h index da4c7a0f..5ce41599 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -205,7 +205,7 @@ public: void RemoveFocusPieceFromGroup(); void ShowEditGroupsDialog(); - void SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep CurrentStep = 0) const; + void SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) const; void LoadLDraw(QIODevice& Device, Project* Project); bool LoadBinary(lcFile* File); bool LoadLDD(const QString& FileData); @@ -263,7 +263,7 @@ public: bool GetVisiblePiecesBoundingBox(lcVector3& Min, lcVector3& Max) const; std::vector GetPiecesBoundingBoxPoints() const; void GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool AddSubModels, lcPartsList& PartsList) const; - void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative = false) const; + void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative) const; void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector& ModelParts) const; void GetSelectionInformation(int* Flags, lcArray& Selection, lcObject** Focus) const; lcArray GetSelectionModePieces(const lcPiece* SelectedPiece) const; diff --git a/common/project.cpp b/common/project.cpp index 89733b72..5d7cc23c 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -299,7 +299,7 @@ void Project::ShowModelListDialog() QByteArray File; QTextStream SaveStream(&File); - Source->SaveLDraw(SaveStream, false); + Source->SaveLDraw(SaveStream, false, 0); SaveStream.flush(); QBuffer Buffer(&File); @@ -517,7 +517,7 @@ bool Project::Save(QTextStream& Stream) if (MPD) Stream << QLatin1String("0 FILE ") << Model->GetProperties().mFileName << QLatin1String("\r\n"); - Model->SaveLDraw(Stream, false); + Model->SaveLDraw(Stream, false, 0); Model->SetSaved(); if (MPD) @@ -767,7 +767,7 @@ bool Project::ExportModel(const QString& FileName, lcModel* Model) const QTextStream Stream(&File); - Model->SaveLDraw(Stream, false); + Model->SaveLDraw(Stream, false, 0); return true; }