Print message when saving files from the command line.
This commit is contained in:
@@ -537,7 +537,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
{
|
||||
if ((Options.SetCameraAngles = ParseFloatArray(2, Options.CameraLatLon, true)) && (fabsf(Options.CameraLatLon[0]) > 360.0f || fabsf(Options.CameraLatLon[1]) > 360.0f))
|
||||
{
|
||||
Options.Output += QString("Invalid parameter value(s) specified for the '%1' option: limits are +/- 360\n").arg(Option);
|
||||
Options.Output += QString("Invalid parameter value(s) specified for the '%1' option: limits are +/- 360.\n").arg(Option);
|
||||
Options.ParseOK = false;
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
{
|
||||
if ((Options.SetZPlanes = ParseFloatArray(2, Options.ZPlanes, false)) && (Options.ZPlanes[0] < 1.0 || Options.ZPlanes[0] >= Options.ZPlanes[1]))
|
||||
{
|
||||
Options.Output += QString("Invalid parameter value(s) specified for the '%1' option: requirements are: 1 <= <near> < <far>\n").arg(Option);
|
||||
Options.Output += QString("Invalid parameter value(s) specified for the '%1' option: requirements are: 1 <= <near> < <far>.\n").arg(Option);
|
||||
Options.ParseOK = false;
|
||||
}
|
||||
}
|
||||
@@ -612,7 +612,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
mPreferences.mShadingMode = lcShadingMode::Full;
|
||||
else
|
||||
{
|
||||
Options.Output += QString("Invalid parameter value specified for the '%1' option: '%2'\n").arg(Option, ShadingString);
|
||||
Options.Output += QString("Invalid parameter value specified for the '%1' option: '%2'.\n").arg(Option, ShadingString);
|
||||
Options.ParseOK = false;
|
||||
}
|
||||
}
|
||||
@@ -926,7 +926,12 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||
if (Options.CameraName.isEmpty() && !Options.SetCameraPosition)
|
||||
ActiveView->ZoomExtents();
|
||||
|
||||
ActiveView->SaveStepImages(Frame, Options.ImageStart != Options.ImageEnd, Options.ImageStart, Options.ImageEnd);
|
||||
auto ProgressCallback = [](const QString& FileName)
|
||||
{
|
||||
printf("Saved '%s'.\n", FileName.toLatin1().constData());
|
||||
};
|
||||
|
||||
ActiveView->SaveStepImages(Frame, Options.ImageStart != Options.ImageEnd, Options.ImageStart, Options.ImageEnd, ProgressCallback);
|
||||
}
|
||||
|
||||
if (Options.SaveWavefront)
|
||||
@@ -950,7 +955,8 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||
FileName += ".obj";
|
||||
}
|
||||
|
||||
mProject->ExportWavefront(FileName);
|
||||
if (mProject->ExportWavefront(FileName))
|
||||
printf("Saved '%s'.\n", FileName.toLatin1().constData());
|
||||
}
|
||||
|
||||
if (Options.Save3DS)
|
||||
@@ -974,7 +980,8 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||
FileName += ".3ds";
|
||||
}
|
||||
|
||||
mProject->Export3DStudio(FileName);
|
||||
if (mProject->Export3DStudio(FileName))
|
||||
printf("Saved '%s'.\n", FileName.toLatin1().constData());
|
||||
}
|
||||
|
||||
if (Options.SaveCOLLADA)
|
||||
@@ -998,7 +1005,8 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||
FileName += ".dae";
|
||||
}
|
||||
|
||||
mProject->ExportCOLLADA(FileName);
|
||||
if (mProject->ExportCOLLADA(FileName))
|
||||
printf("Saved '%s'.\n", FileName.toLatin1().constData());
|
||||
}
|
||||
|
||||
if (Options.SaveHTML)
|
||||
|
||||
+4
-1
@@ -746,7 +746,7 @@ std::vector<QImage> lcView::GetStepImages(lcStep Start, lcStep End)
|
||||
return Images;
|
||||
}
|
||||
|
||||
void lcView::SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep Start, lcStep End)
|
||||
void lcView::SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep Start, lcStep End, std::function<void(const QString&)> ProgressCallback)
|
||||
{
|
||||
std::vector<QImage> Images = GetStepImages(Start, End);
|
||||
|
||||
@@ -769,6 +769,9 @@ void lcView::SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep
|
||||
QMessageBox::information(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
|
||||
break;
|
||||
}
|
||||
|
||||
if (ProgressCallback)
|
||||
ProgressCallback(FileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ public:
|
||||
void UnbindRenderFramebuffer();
|
||||
QImage GetRenderFramebufferImage() const;
|
||||
std::vector<QImage> GetStepImages(lcStep Start, lcStep End);
|
||||
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep Start, lcStep End);
|
||||
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep Start, lcStep End, std::function<void(const QString&)> ProgressCallback);
|
||||
|
||||
lcContext* mContext = nullptr;
|
||||
|
||||
|
||||
+19
-13
@@ -686,27 +686,27 @@ QString Project::GetExportFileName(const QString& FileName, const QString& Defau
|
||||
return QFileDialog::getSaveFileName(gMainWindow, DialogTitle, SaveFileName, DialogFilter);
|
||||
}
|
||||
|
||||
void Project::Export3DStudio(const QString& FileName)
|
||||
bool Project::Export3DStudio(const QString& FileName)
|
||||
{
|
||||
std::vector<lcModelPartsEntry> ModelParts = GetModelParts();
|
||||
|
||||
if (ModelParts.empty())
|
||||
{
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SaveFileName = GetExportFileName(FileName, "3ds", tr("Export 3D Studio"), tr("3DS Files (*.3ds);;All Files (*.*)"));
|
||||
|
||||
if (SaveFileName.isEmpty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
lcDiskFile File(SaveFileName);
|
||||
|
||||
if (!File.Open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
long M3DStart = File.GetPosition();
|
||||
@@ -1123,6 +1123,8 @@ void Project::Export3DStudio(const QString& FileName)
|
||||
File.Seek(M3DStart + 2, SEEK_SET);
|
||||
File.WriteU32(M3DEnd - M3DStart);
|
||||
File.Seek(M3DEnd, SEEK_SET);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::ExportBrickLink()
|
||||
@@ -1189,27 +1191,27 @@ void Project::ExportBrickLink()
|
||||
BrickLinkFile.WriteLine("</INVENTORY>\n");
|
||||
}
|
||||
|
||||
void Project::ExportCOLLADA(const QString& FileName)
|
||||
bool Project::ExportCOLLADA(const QString& FileName)
|
||||
{
|
||||
std::vector<lcModelPartsEntry> ModelParts = GetModelParts();
|
||||
|
||||
if (ModelParts.empty())
|
||||
{
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SaveFileName = GetExportFileName(FileName, "dae", tr("Export COLLADA"), tr("COLLADA Files (*.dae);;All Files (*.*)"));
|
||||
|
||||
if (SaveFileName.isEmpty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
QFile File(SaveFileName);
|
||||
|
||||
if (!File.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream Stream(&File);
|
||||
@@ -1457,6 +1459,8 @@ void Project::ExportCOLLADA(const QString& FileName)
|
||||
Stream << "</scene>\r\n";
|
||||
|
||||
Stream << "</COLLADA>\r\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::ExportCSV()
|
||||
@@ -2044,20 +2048,20 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::ExportWavefront(const QString& FileName)
|
||||
bool Project::ExportWavefront(const QString& FileName)
|
||||
{
|
||||
std::vector<lcModelPartsEntry> ModelParts = GetModelParts();
|
||||
|
||||
if (ModelParts.empty())
|
||||
{
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SaveFileName = GetExportFileName(FileName, QLatin1String("obj"), tr("Export Wavefront"), tr("Wavefront Files (*.obj);;All Files (*.*)"));
|
||||
|
||||
if (SaveFileName.isEmpty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
lcDiskFile OBJFile(SaveFileName);
|
||||
char Line[1024];
|
||||
@@ -2065,7 +2069,7 @@ void Project::ExportWavefront(const QString& FileName)
|
||||
if (!OBJFile.Open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
quint32 vert = 1;
|
||||
@@ -2082,7 +2086,7 @@ void Project::ExportWavefront(const QString& FileName)
|
||||
if (!MaterialFile.Open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(MaterialFileName));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialFile.WriteLine("# Colors used by LeoCAD\n\n");
|
||||
@@ -2149,6 +2153,8 @@ void Project::ExportWavefront(const QString& FileName)
|
||||
vert += Mesh->mNumVertices;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::SaveImage()
|
||||
|
||||
+3
-3
@@ -88,13 +88,13 @@ public:
|
||||
|
||||
void SaveImage();
|
||||
bool ExportModel(const QString& FileName, lcModel* Model) const;
|
||||
void Export3DStudio(const QString& FileName);
|
||||
bool Export3DStudio(const QString& FileName);
|
||||
void ExportBrickLink();
|
||||
void ExportCOLLADA(const QString& FileName);
|
||||
bool ExportCOLLADA(const QString& FileName);
|
||||
void ExportCSV();
|
||||
void ExportHTML(const lcHTMLExportOptions& Options);
|
||||
bool ExportPOVRay(const QString& FileName);
|
||||
void ExportWavefront(const QString& FileName);
|
||||
bool ExportWavefront(const QString& FileName);
|
||||
|
||||
void UpdatePieceInfo(PieceInfo* Info) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user