From ccadcf7e1aed7c2c199d16220a6fd7f0b8a46583 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Wed, 7 Dec 2016 09:08:23 -0800 Subject: [PATCH] Fixed file name formatting when saving an image from the command line. --- common/lc_application.cpp | 2 +- common/lc_model.cpp | 9 +++++++-- common/lc_model.h | 2 +- common/project.cpp | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index dd676412..b9e0e02d 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -383,7 +383,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal else Frame = FileName; - lcGetActiveModel()->SaveStepImages(Frame, ImageWidth, ImageHeight, ImageStart, ImageEnd); + lcGetActiveModel()->SaveStepImages(Frame, ImageStart != ImageEnd, ImageWidth, ImageHeight, ImageStart, ImageEnd); } if (SaveWavefront) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 38ebcaa0..9c183813 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1182,7 +1182,7 @@ void lcModel::DrawBackground(lcContext* Context) glDepthMask(GL_TRUE); } -void lcModel::SaveStepImages(const QString& BaseName, int Width, int Height, lcStep Start, lcStep End) +void lcModel::SaveStepImages(const QString& BaseName, bool AddStepSuffix, int Width, int Height, lcStep Start, lcStep End) { gMainWindow->mPreviewWidget->MakeCurrent(); lcContext* Context = gMainWindow->mPreviewWidget->mContext; @@ -1206,7 +1206,12 @@ void lcModel::SaveStepImages(const QString& BaseName, int Width, int Height, lcS SetTemporaryStep(Step); View.OnDraw(); - QString FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0')); + QString FileName; + + if (AddStepSuffix) + FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0')); + else + FileName = BaseName; if (!Context->SaveRenderToTextureImage(FileName, Width, Height)) break; diff --git a/common/lc_model.h b/common/lc_model.h index 35ada581..aa01a787 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -213,7 +213,7 @@ public: void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface) const; void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const; void DrawBackground(lcContext* Context); - void SaveStepImages(const QString& BaseName, int Width, int Height, lcStep Start, lcStep End); + void SaveStepImages(const QString& BaseName, bool AddStepSuffix, int Width, int Height, lcStep Start, lcStep End); void RayTest(lcObjectRayTest& ObjectRayTest) const; void BoxTest(lcObjectBoxTest& ObjectBoxTest) const; diff --git a/common/project.cpp b/common/project.cpp index e40bf03c..3f4f5b38 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1294,7 +1294,7 @@ void Project::ExportHTML() } QString StepImageBaseName = QFileInfo(Dir, BaseName + QLatin1String("-%1.png")).absoluteFilePath(); - Model->SaveStepImages(StepImageBaseName, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep); + Model->SaveStepImages(StepImageBaseName, true, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep); if (Options.PartsListImages) { @@ -1788,7 +1788,7 @@ void Project::SaveImage() if (Dialog.mStart != Dialog.mEnd) Dialog.mFileName = Dialog.mFileName.insert(Dialog.mFileName.length() - Extension.length() - 1, QLatin1String("%1")); - mActiveModel->SaveStepImages(Dialog.mFileName, Dialog.mWidth, Dialog.mHeight, Dialog.mStart, Dialog.mEnd); + mActiveModel->SaveStepImages(Dialog.mFileName, Dialog.mStart != Dialog.mEnd, Dialog.mWidth, Dialog.mHeight, Dialog.mStart, Dialog.mEnd); } void Project::UpdatePieceInfo(PieceInfo* Info) const