Fixed file name formatting when saving an image from the command line.

This commit is contained in:
Leonardo Zide 2016-12-07 09:08:23 -08:00
parent dedc429685
commit ccadcf7e1a
4 changed files with 11 additions and 6 deletions

View file

@ -383,7 +383,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
else else
Frame = FileName; Frame = FileName;
lcGetActiveModel()->SaveStepImages(Frame, ImageWidth, ImageHeight, ImageStart, ImageEnd); lcGetActiveModel()->SaveStepImages(Frame, ImageStart != ImageEnd, ImageWidth, ImageHeight, ImageStart, ImageEnd);
} }
if (SaveWavefront) if (SaveWavefront)

View file

@ -1182,7 +1182,7 @@ void lcModel::DrawBackground(lcContext* Context)
glDepthMask(GL_TRUE); 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(); gMainWindow->mPreviewWidget->MakeCurrent();
lcContext* Context = gMainWindow->mPreviewWidget->mContext; lcContext* Context = gMainWindow->mPreviewWidget->mContext;
@ -1206,7 +1206,12 @@ void lcModel::SaveStepImages(const QString& BaseName, int Width, int Height, lcS
SetTemporaryStep(Step); SetTemporaryStep(Step);
View.OnDraw(); 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)) if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
break; break;

View file

@ -213,7 +213,7 @@ public:
void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface) const; void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface) const;
void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const; void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const;
void DrawBackground(lcContext* Context); 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 RayTest(lcObjectRayTest& ObjectRayTest) const;
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const; void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;

View file

@ -1294,7 +1294,7 @@ void Project::ExportHTML()
} }
QString StepImageBaseName = QFileInfo(Dir, BaseName + QLatin1String("-%1.png")).absoluteFilePath(); 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) if (Options.PartsListImages)
{ {
@ -1788,7 +1788,7 @@ void Project::SaveImage()
if (Dialog.mStart != Dialog.mEnd) if (Dialog.mStart != Dialog.mEnd)
Dialog.mFileName = Dialog.mFileName.insert(Dialog.mFileName.length() - Extension.length() - 1, QLatin1String("%1")); 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 void Project::UpdatePieceInfo(PieceInfo* Info) const