Reorganized the Render Dialog. Fixes #875.

This commit is contained in:
Leonardo Zide
2025-08-03 11:47:51 -07:00
parent edad7491ac
commit 44de1f19fc
14 changed files with 657 additions and 684 deletions
+2 -2
View File
@@ -294,7 +294,7 @@ void lcApplication::SetProject(Project* Project)
delete mProject;
mProject = Project;
Project->SetActiveModel(0);
Project->SetActiveModel(0, true);
lcGetPiecesLibrary()->RemoveTemporaryPieces();
if (mProject && !mProject->GetFileName().isEmpty() && mPreferences.mRestoreTabLayout)
@@ -1022,7 +1022,7 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
if (ProjectLoaded)
{
if (!Options.ModelName.isEmpty())
mProject->SetActiveModel(Options.ModelName);
mProject->SetActiveModel(Options.ModelName, true);
std::unique_ptr<lcView> ActiveView;
+42 -41
View File
@@ -1087,7 +1087,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
#else
ScriptName = QLatin1String("blender_test.sh");
#endif
ScriptCommand = QString("%1 %2").arg(BlenderExe).arg(Arguments.join(" "));
ScriptCommand = QString("\"%1\" %2").arg(BlenderExe).arg(Arguments.join(" "));
Script.setFileName(QString("%1/%2").arg(QDir::tempPath()).arg(ScriptName));
if(Script.open(QIODevice::WriteOnly | QIODevice::Text))
@@ -1133,7 +1133,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
{
const QString& Title = tr ("%1 Blender LDraw Addon").arg(LC_PRODUCTNAME_STR);
const QString& Header = tr ("Blender test failed.");
ShowMessage(Header, Title, Message);
ShowMessage(this, Header, Title, Message);
return;
}
} // Test Blender
@@ -1143,7 +1143,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
const QString& Title = tr ("%1 Blender LDraw Addon Modules").arg(LC_PRODUCTNAME_STR);
const QString& Header = tr ("No import module enabled. If you continue, the default import module (Import TN) will be used.<br>If you select No, all addon modules will be disabled.");
const QString& Body = tr ("Continue with the default import module ?");
int Exec = ShowMessage(Header, Title, Body, QString(), MBB_YES_NO, QMessageBox::NoIcon);
int Exec = ShowMessage(this, Header, Title, Body, QString(), MBB_YES_NO, QMessageBox::NoIcon);
if (Exec != QMessageBox::Yes)
{
mRenderActBox->setChecked(false);
@@ -1200,7 +1200,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
if (!QFileInfo(BlenderInstallFile).exists())
{
ShowMessage(tr ("Could not find addon install file: %1").arg(BlenderInstallFile));
ShowMessage(this, tr("Could not find addon install file: %1").arg(BlenderInstallFile));
StatusUpdate(true, true, tr("Not found."));
return;
}
@@ -1248,7 +1248,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
QFile File(QFileInfo(List.at(LblIdx)).absoluteFilePath());
if (!File.open(QFile::ReadOnly | QFile::Text))
{
ShowMessage(tr("Cannot read addon file %1<br>%2").arg(List.at(LblIdx).fileName()).arg(File.errorString()));
ShowMessage(this, tr("Cannot read addon file %1<br>%2").arg(List.at(LblIdx).fileName()).arg(File.errorString()));
break;
}
else
@@ -1286,7 +1286,7 @@ void lcBlenderPreferences::ConfigureBlenderAddon(bool TestBlender, bool AddonUpd
StatusUpdate(true, true, tr("Install failed."));
}
else
ShowMessage(tr("Blender executable not found at [%1]").arg(BlenderExe), tr("Addon install failed."));
ShowMessage(this, tr("Blender executable not found at [%1]").arg(BlenderExe), tr("Addon install failed."));
}
bool lcBlenderPreferences::ExtractBlenderAddon(const QString& BlenderDir)
@@ -1312,7 +1312,7 @@ bool lcBlenderPreferences::ExtractBlenderAddon(const QString& BlenderDir)
if (Result.size())
Message.append(" "+Result);
ShowMessage(Message, tr("Extract addon"));
ShowMessage(this, Message, tr("Extract addon"));
}
}
else if (AddonAction == ADDON_NO_ACTION)
@@ -1374,7 +1374,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
}
else
{
ShowMessage(tr("Check latest addon version failed."), tr("Latest Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
ShowMessage(this, tr("Check latest addon version failed."), tr("Latest Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
return true; // Reload existing archive
}
@@ -1387,7 +1387,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
if (!ZipFile.OpenRead(BlenderAddonFile))
{
ShowMessage(tr("Cannot open addon archive file: %1.").arg(BlenderAddonFile));
ShowMessage(this, tr("Cannot open addon archive file: %1.").arg(BlenderAddonFile));
return false;
}
@@ -1395,14 +1395,14 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
if (!ZipFile.ExtractFile(VersionFile, File))
{
ShowMessage(tr("Cannot extract addon archive version file: %1.").arg(VersionFile));
ShowMessage(this, tr("Cannot extract addon archive version file: %1.").arg(VersionFile));
return false;
}
Ba = QByteArray::fromRawData((const char*)File.mBuffer, (int)File.GetLength());
if (Ba.isEmpty())
{
ShowMessage(tr("Cannot read addon archive version file: %1.").arg(VersionFile));
ShowMessage(this, tr("Cannot read addon archive version file: %1.").arg(VersionFile));
return false; // Download new archive
}
}
@@ -1411,7 +1411,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
QFile File(AddonVersionFile);
if (!File.open(QIODevice::ReadOnly))
{
ShowMessage(tr("Cannot read addon version file: [%1]<br>%2.").arg(AddonVersionFile).arg(File.errorString()));
ShowMessage(this, tr("Cannot read addon version file: [%1]<br>%2.").arg(AddonVersionFile).arg(File.errorString()));
return false; // Download new archive
}
Ba = File.readAll();
@@ -1458,7 +1458,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
const QString& Title = tr ("%1 Blender LDraw Addon").arg(LC_PRODUCTNAME_STR);
const QString& Header = tr ("Detected %1 Blender LDraw addon %2. A newer version %3 exists.").arg(LC_PRODUCTNAME_STR).arg(LocalVersion).arg(OnlineVersion);
const QString& Body = tr ("Do you want to download version %1 ?").arg(OnlineVersion);
int Exec = ShowMessage(Header, Title, Body, QString(), MBB_YES, QMessageBox::NoIcon);
int Exec = ShowMessage(this, Header, Title, Body, QString(), MBB_YES, QMessageBox::NoIcon);
if (Exec == QMessageBox::Cancel)
{
AddonAction = ADDON_CANCELED;
@@ -1494,7 +1494,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
Result &= Dir.rmdir(BlenderAddonDir);
if (!Result)
ShowMessage(tr("Failed to properly remove Blender addon: %1").arg(BlenderAddonDir), tr("Remove Existing Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
ShowMessage(this, tr("Failed to properly remove Blender addon: %1").arg(BlenderAddonDir), tr("Remove Existing Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
}
};
@@ -1510,7 +1510,7 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
if (QFileInfo(BlenderAddonFile).exists())
{
if (!QFile::rename(BlenderAddonFile, OldBlenderAddonFile))
ShowMessage(tr("Failed to rename existing Blender addon archive %1.").arg(BlenderAddonFile));
ShowMessage(this, tr("Failed to rename existing Blender addon archive %1.").arg(BlenderAddonFile));
}
QDir Dir(BlenderDir);
@@ -1556,35 +1556,35 @@ int lcBlenderPreferences::GetBlenderAddon(const QString& BlenderDir)
BlenderAddonValidated = true;
}
else
ShowMessage(tr("Failed to validate Blender addon file name<br>Downloaded:%1<br>Received:%2").arg(ArchiveFileName, ShaReceived.last()));
ShowMessage(this, tr("Failed to validate Blender addon file name<br>Downloaded:%1<br>Received:%2").arg(ArchiveFileName, ShaReceived.last()));
}
else
ShowMessage(tr("Failed to validate Blender addon SHA hash <br>Calculated:%1<br>Received:%2").arg(ShaCalculated, ShaReceived.first()));
ShowMessage(this, tr("Failed to validate Blender addon SHA hash <br>Calculated:%1<br>Received:%2").arg(ShaCalculated, ShaReceived.first()));
gAddonPreferences->mData.clear();
}
else
ShowMessage(tr("Failed to receive SHA hash for Blender addon %1.sha256").arg(LC_BLENDER_ADDON_FILE));
ShowMessage(this, tr("Failed to receive SHA hash for Blender addon %1.sha256").arg(LC_BLENDER_ADDON_FILE));
}
else
ShowMessage(tr("Failed to read Blender addon archive:<br>%1:<br>%2").arg(BlenderAddonFile).arg(File.errorString()));
ShowMessage(this, tr("Failed to read Blender addon archive:<br>%1:<br>%2").arg(BlenderAddonFile).arg(File.errorString()));
}
else
ShowMessage(tr("Failed to write Blender addon archive:<br>%1:<br>%2").arg(BlenderAddonFile).arg(File.errorString()));
ShowMessage(this, tr("Failed to write Blender addon archive:<br>%1:<br>%2").arg(BlenderAddonFile).arg(File.errorString()));
if (!BlenderAddonValidated)
{
if (QFileInfo(BlenderAddonFile).exists())
if (!QFile::remove(BlenderAddonFile))
ShowMessage(tr("Failed to remove invalid Blender addon archive:<br>%1").arg(BlenderAddonFile));
ShowMessage(this, tr("Failed to remove invalid Blender addon archive:<br>%1").arg(BlenderAddonFile));
if (QFileInfo(OldBlenderAddonFile).exists())
if (!QFile::rename(OldBlenderAddonFile, BlenderAddonFile))
ShowMessage(tr("Failed to restore Blender addon archive:<br>%1 from %2").arg(ArchiveFileName, OldArchiveFileName));
ShowMessage(this, tr("Failed to restore Blender addon archive:<br>%1 from %2").arg(ArchiveFileName, OldArchiveFileName));
AddonAction = ADDON_FAIL;
}
}
else
{
ShowMessage(tr("Failed to download Blender addon archive:<br>%1").arg(BlenderAddonFile));
ShowMessage(this, tr("Failed to download Blender addon archive:<br>%1").arg(BlenderAddonFile));
AddonAction = ADDON_FAIL;
}
@@ -1673,7 +1673,7 @@ void lcBlenderPreferences::ShowResult()
const QString& Title = tr ("%1 Blender Addon Install").arg(LC_PRODUCTNAME_STR);
const QString& Header = "<b>" + tr ("Addon install failed.") + "</b>";
const QString& Body = tr ("LDraw addon install encountered one or more errors. See Show Details...");
ShowMessage(Header, Title, Body, StdErrLog, MBB_OK, QMessageBox::Warning);
ShowMessage(this, Header, Title, Body, StdErrLog, MBB_OK, QMessageBox::Warning);
}
else
{
@@ -1709,7 +1709,7 @@ void lcBlenderPreferences::ShowResult()
mProcess = nullptr;
if (Error)
ShowMessage(Message);
ShowMessage(this, Message);
}
void lcBlenderPreferences::SettingChanged(const QString& Value)
@@ -1800,7 +1800,7 @@ void lcBlenderPreferences::GetStandardOutput()
QFileInfo FileInfo(LogFile);
if (!FileInfo.exists())
{
ShowMessage(tr("Blender addon standard output file not found: %1.").arg(FileInfo.absoluteFilePath()));
ShowMessage(this, tr("Blender addon standard output file not found: %1.").arg(FileInfo.absoluteFilePath()));
return;
}
@@ -1957,7 +1957,7 @@ void lcBlenderPreferences::ReadStdOut()
const QString& Title = tr ("%1 Blender Addon Install").arg(LC_PRODUCTNAME_STR);
const QString& Header = "<b>" + tr ("Addon install standard output.") + "</b>";
const QString& Body = tr ("LDraw addon install encountered %1. See Show Details...").arg(Items);
ShowMessage(Header, Title, Body, ErrorsAndWarnings.append(StdOutLog), MBB_OK, Icon);
ShowMessage(this, Header, Title, Body, ErrorsAndWarnings.append(StdOutLog), MBB_OK, Icon);
}
}
@@ -2002,7 +2002,7 @@ void lcBlenderPreferences::WriteStdOut()
mAddonStdOutButton->setEnabled(true);
}
else
ShowMessage(tr("Error writing to %1 file '%2':\n%3").arg("stdout").arg(File.fileName(), File.errorString()));
ShowMessage(this, tr("Error writing to %1 file '%2':\n%3").arg("stdout").arg(File.fileName(), File.errorString()));
}
bool lcBlenderPreferences::PromptCancel()
@@ -2012,7 +2012,7 @@ bool lcBlenderPreferences::PromptCancel()
{
const QString& Title = tr ("Cancel %1 Addon Install").arg(LC_PRODUCTNAME_STR);
const QString& Header = "<b>" + tr("Are you sure you want to cancel the add on install ?") + "</b>";
int Exec = ShowMessage(Header, Title, QString(), QString(), MBB_YES_NO, QMessageBox::Question);
int Exec = ShowMessage(this, Header, Title, QString(), QString(), MBB_YES_NO, QMessageBox::Question);
if (Exec == QMessageBox::Yes)
{
mProcess->kill();
@@ -2623,11 +2623,11 @@ void lcBlenderPreferences::LoadSettings()
gAddonPreferences->ReadStdOut(QString(Ba), Errors);
if (!Errors.isEmpty())
ShowMessage(Errors);
ShowMessage(nullptr, Errors);
}
else
{
ShowMessage(tr("Blender config file was not found. "
ShowMessage(nullptr, tr("Blender config file was not found. "
"Install log check failed:<br>%1:<br>%2")
.arg(File.fileName())
.arg(File.errorString()));
@@ -3079,7 +3079,7 @@ void lcBlenderPreferences::SetModelSize(bool Update)
const QString& Title = tr ("LDraw Render Settings Conflict");
const QString& Header = "<b>" + tr ("Crop image configuration settings conflict were resolved.") + "</b>";
const QString& Body = QString("%1%2%3").arg(Conflict[0] ? tr("Keep aspect ratio set to false.<br>") : "").arg(Conflict[1] ? tr("Add environment (backdrop and base plane) set to false.<br>") : "").arg(Conflict[2] ? tr("Transparent background set to true.<br>") : "");
ShowMessage(Header, Title, Body, QString(), MBB_OK, QMessageBox::Information);
ShowMessage(this, Header, Title, Body, QString(), MBB_OK, QMessageBox::Information);
}
}
@@ -3117,7 +3117,7 @@ void lcBlenderPreferences::ValidateColourScheme(int Index)
const QString& Title = tr ("Custom LDraw Colours");
const QString& Header = "<b>" + tr ("Colour scheme 'custom' cannot be enabled. Custom LDConfig file not found.") + "</b>";
const QString& Body = tr ("Colour scheme 'custom' selected but no LDConfig file was specified.<br>The default colour scheme '%1' will be used.<br>").arg(Settings[Color_Scheme].value);
ShowMessage(Header, Title, Body, QString(), MBB_OK, QMessageBox::Warning);
ShowMessage(this, Header, Title, Body, QString(), MBB_OK, QMessageBox::Warning);
}
else
{
@@ -3131,7 +3131,7 @@ bool lcBlenderPreferences::PromptAccept()
{
const QString& Title = tr ("Render Settings Modified");
const QString& Header = "<b>" + tr("Do you want to accept the modified settings before quitting ?") + "</b>";
int Exec = ShowMessage(Header, Title, QString(), QString(), MBB_YES_NO, QMessageBox::Question);
int Exec = ShowMessage(this, Header, Title, QString(), QString(), MBB_YES_NO, QMessageBox::Question);
if (Exec == QMessageBox::Yes)
return true;
@@ -3503,7 +3503,7 @@ bool lcBlenderPreferences::ExportParameterFile()
Message = tr("Failed to open Blender parameter file: %1:<br>%2")
.arg(File.fileName())
.arg(File.errorString());
ShowMessage(Message);
ShowMessage(nullptr, Message);
return false;
}
return true;
@@ -3519,17 +3519,17 @@ bool lcBlenderPreferences::OverwriteFile(const QString& File)
const QString& Title = tr ("Replace Existing File");
const QString Header = "<b>" + QMessageBox::tr ("Existing file %1 detected.").arg(fileInfo.fileName()) + "</b>";
const QString Body = QMessageBox::tr ("\"%1\"<br>This file already exists.<br>Replace existing file?").arg(fileInfo.fileName());
int Exec = ShowMessage(Header, Title, Body, QString(), MBB_YES, QMessageBox::NoIcon);
int Exec = ShowMessage(nullptr, Header, Title, Body, QString(), MBB_YES, QMessageBox::NoIcon);
return (Exec == QMessageBox::Yes);
}
int lcBlenderPreferences::ShowMessage(const QString& Header, const QString& Title, const QString& Body, const QString& Detail, int const Buttons, int const Icon)
int lcBlenderPreferences::ShowMessage(QWidget* Parent, const QString& Header, const QString& Title, const QString& Body, const QString& Detail, int const Buttons, int const Icon)
{
if (!gMainWindow)
return QMessageBox::Ok;
QMessageBox Box;
QMessageBox Box(Parent);
Box.setWindowIcon(QIcon());
if (!Icon)
{
@@ -3593,7 +3593,8 @@ int lcBlenderPreferences::ShowMessage(const QString& Header, const QString& Tit
const bool DownloadRequest = Body.startsWith(tr("Do you want to download version "));
if (DownloadRequest){
if (DownloadRequest)
{
QCheckBox* AddonVersionCheck = new QCheckBox(tr("Do not show download new addon version message again."));
Box.setCheckBox(AddonVersionCheck);
QObject::connect(AddonVersionCheck, &QCheckBox::stateChanged, [](int State)
@@ -3613,7 +3614,7 @@ void lcBlenderPreferences::DownloadFinished(lcHttpReply* Reply)
if (!Reply->error())
mData = Reply->readAll();
else
ShowMessage(tr("Addon download failed."));
ShowMessage(this, tr("Addon download failed."));
mHttpReply = nullptr;
@@ -3761,7 +3762,7 @@ bool lcBlenderPreferences::ExtractAddon(const QString FileName, QString& Result)
FileInfo.permissions |= QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther;
break;
default:
ShowMessage(tr("ZipFile entry format (HostOS %1) at index %2 is not supported. Extract terminated.").arg(HostOS).arg(FileIdx), tr("Extract Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
ShowMessage(this, tr("ZipFile entry format (HostOS %1) at index %2 is not supported. Extract terminated.").arg(HostOS).arg(FileIdx), tr("Extract Addon"), QString(), QString(), MBB_OK, QMessageBox::Warning);
Ok = false;
}
+3 -3
View File
@@ -64,7 +64,7 @@ public:
static void SaveSettings();
static bool ExportParameterFile();
static bool SettingsModified(bool Update = true, QString const& Module = QString());
static int ShowMessage(QString const& Header, QString const& Title = QString(), QString const& Body = QString(), QString const& Detail = QString(), const int Buttons = MBB_OK, const int Icon = 3 /*QMessageBox::Critical*/);
static int ShowMessage(QWidget* Parent, QString const& Header, QString const& Title = QString(), QString const& Body = QString(), QString const& Detail = QString(), const int Buttons = MBB_OK, const int Icon = 3 /*QMessageBox::Critical*/);
void Apply(const int Response = QDialog::Accepted);
@@ -76,8 +76,8 @@ protected:
static int NumPaths(bool DefaultSettings = false);
static int NumSettings(bool DefaultSettings = false);
static int NumSettingsMM(bool DefaultSettings = false);
static int GetBlenderAddon(const QString& BlenderDir);
static bool ExtractBlenderAddon(const QString& BlenderDir);
int GetBlenderAddon(const QString& BlenderDir);
bool ExtractBlenderAddon(const QString& BlenderDir);
static void LoadDefaultParameters(QByteArray& Buffer, int Which);
static bool OverwriteFile(const QString& File);
+8
View File
@@ -28,6 +28,10 @@
#pragma warning(default : 5038) // data member 'A::y' will be initialized after data member 'A::x'
#endif
#ifdef QT_NO_PRINTER
class QPrinter;
#endif
#ifndef Q_FALLTHROUGH
#define Q_FALLTHROUGH();
#endif
@@ -37,6 +41,10 @@
#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
#endif
#ifdef QT_NO_PROCESS
#define LC_DISABLE_RENDER_DIALOG
#endif
#define LC_ARRAY_COUNT(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#define LC_ARRAY_SIZE_CHECK(a,s) static_assert(LC_ARRAY_COUNT(a) == static_cast<int>(s), QT_STRINGIFY(a) " size mismatch.")
+28 -10
View File
@@ -474,10 +474,12 @@ void lcMainWindow::CreateMenus()
ExportMenu->addAction(mActions[LC_FILE_EXPORT_POVRAY]);
ExportMenu->addAction(mActions[LC_FILE_EXPORT_WAVEFRONT]);
FileMenu->addSeparator();
#ifndef LC_DISABLE_RENDER_DIALOG
QMenu* RenderMenu = FileMenu->addMenu(tr("&Render"));
RenderMenu->addAction(mActions[LC_FILE_RENDER_POVRAY]);
RenderMenu->addAction(mActions[LC_FILE_RENDER_BLENDER]);
RenderMenu->addAction(mActions[LC_FILE_RENDER_OPEN_IN_BLENDER]);
#endif
FileMenu->addAction(mActions[LC_FILE_INSTRUCTIONS]);
FileMenu->addAction(mActions[LC_FILE_PRINT]);
FileMenu->addAction(mActions[LC_FILE_PRINT_PREVIEW]);
@@ -1074,7 +1076,7 @@ void lcMainWindow::ModelTabChanged(int Index)
Project* Project = lcGetActiveProject();
lcModelTabWidget* CurrentTab = (lcModelTabWidget*)mModelTabWidget->widget(Index);
Project->SetActiveModel(CurrentTab ? CurrentTab->GetModel() : nullptr);
Project->SetActiveModel(CurrentTab ? CurrentTab->GetModel() : nullptr, true);
}
void lcMainWindow::ClipboardChanged()
@@ -1317,10 +1319,20 @@ void lcMainWindow::ShowHTMLDialog()
lcGetActiveProject()->ExportHTML(Options);
}
void lcMainWindow::ShowRenderDialog(int Command)
void lcMainWindow::ShowExportPOVRayDialog()
{
lcRenderDialog Dialog(this, Command);
auto [Success, ErrorMessage] = lcGetActiveProject()->ExportPOVRay(QString());
if (!Success && !ErrorMessage.isEmpty())
QMessageBox::warning(this, tr("POV-Ray Export" ), ErrorMessage);
}
void lcMainWindow::ShowRenderDialog(lcRenderDialogMode RenderDialogMode)
{
#ifndef LC_DISABLE_RENDER_DIALOG
lcRenderDialog Dialog(this, RenderDialogMode);
Dialog.exec();
#endif
}
void lcMainWindow::ShowInstructionsDialog()
@@ -1586,9 +1598,9 @@ void lcMainWindow::RestoreTabLayout(const QByteArray& TabLayout)
}
if (!mModelTabWidget->count())
lcGetActiveProject()->SetActiveModel(0);
lcGetActiveProject()->SetActiveModel(0, true);
else
lcGetActiveProject()->SetActiveModel(CurrentTabName);
lcGetActiveProject()->SetActiveModel(CurrentTabName, true);
}
void lcMainWindow::RemoveAllModelTabs()
@@ -2552,7 +2564,7 @@ bool lcMainWindow::SetModelFromFocus()
if (Model)
{
Project* Project = lcGetActiveProject();
Project->SetActiveModel(Model);
Project->SetActiveModel(Model, true);
return true;
}
@@ -2569,7 +2581,7 @@ void lcMainWindow::SetModelFromSelection()
if (Model)
{
Project* Project = lcGetActiveProject();
Project->SetActiveModel(Model);
Project->SetActiveModel(Model, true);
}
}
@@ -2656,7 +2668,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
break;
case LC_FILE_EXPORT_POVRAY:
lcGetActiveProject()->ExportPOVRay(QString());
ShowExportPOVRayDialog();
break;
case LC_FILE_EXPORT_WAVEFRONT:
@@ -2664,9 +2676,15 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
break;
case LC_FILE_RENDER_POVRAY:
ShowRenderDialog(lcRenderDialogMode::RenderPOVRay);
break;
case LC_FILE_RENDER_BLENDER:
ShowRenderDialog(lcRenderDialogMode::RenderBlender);
break;
case LC_FILE_RENDER_OPEN_IN_BLENDER:
ShowRenderDialog(CommandId - LC_FILE_RENDER_POVRAY);
ShowRenderDialog(lcRenderDialogMode::OpenInBlender);
break;
case LC_FILE_INSTRUCTIONS:
@@ -3298,7 +3316,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
case LC_MODEL_38:
case LC_MODEL_39:
case LC_MODEL_40:
lcGetActiveProject()->SetActiveModel(CommandId - LC_MODEL_01);
lcGetActiveProject()->SetActiveModel(CommandId - LC_MODEL_01, true);
break;
case LC_HELP_HOMEPAGE:
+3 -4
View File
@@ -13,9 +13,7 @@ class lcColorList;
class lcPropertiesWidget;
class lcTimelineWidget;
class lcElidedLabel;
#ifdef QT_NO_PRINTER
class QPrinter;
#endif
enum class lcRenderDialogMode;
#define LC_MAX_RECENT_FILES 4
@@ -326,7 +324,8 @@ protected:
void ShowUpdatesDialog();
void ShowAboutDialog();
void ShowHTMLDialog();
void ShowRenderDialog(int Command);
void ShowExportPOVRayDialog();
void ShowRenderDialog(lcRenderDialogMode RenderDialogMode);
void ShowInstructionsDialog();
void ShowPrintDialog();
void CreatePreviewWidget();
+3 -3
View File
@@ -86,7 +86,7 @@ void lcPreviewDockWidget::SetPreviewLock()
lcPreview::lcPreview()
: lcView(lcViewType::Preview, nullptr), mLoader(new Project(true))
{
mLoader->SetActiveModel(0);
mLoader->SetActiveModel(0, false);
mModel = mLoader->GetActiveModel();
}
@@ -127,7 +127,7 @@ bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode)
if (!mLoader->Load(ModelPath, false))
return false;
mLoader->SetActiveModel(0);
mLoader->SetActiveModel(0, false);
lcGetPiecesLibrary()->RemoveTemporaryPieces();
mModel = mLoader->GetActiveModel();
if (!mModel->GetProperties().mDescription.isEmpty())
@@ -145,7 +145,7 @@ bool lcPreview::SetCurrentPiece(const QString& PartType, int ColorCode)
void lcPreview::ClearPreview()
{
mLoader = std::unique_ptr<Project>(new Project(true/*IsPreview*/));
mLoader->SetActiveModel(0);
mLoader->SetActiveModel(0, false);
mModel = mLoader->GetActiveModel();
lcGetPiecesLibrary()->UnloadUnusedParts();
Redraw();
+2
View File
@@ -5,6 +5,7 @@
#include "lc_model.h"
#include "project.h"
#include "lc_viewsphere.h"
#include "lc_renderdialog.h"
lcProfileEntry::lcProfileEntry(const char* Section, const char* Key, int DefaultValue)
{
@@ -147,6 +148,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("Render", "Width", 1280), // LC_PROFILE_RENDER_WIDTH
lcProfileEntry("Render", "Height", 720), // LC_PROFILE_RENDER_HEIGHT
lcProfileEntry("Render", "Height", (int)lcPOVRayRenderQuality::High), // LC_PROFILE_RENDER_QUALITY
lcProfileEntry("Blender", "Path", ""), // LC_PROFILE_BLENDER_PATH
lcProfileEntry("Blender", "LDrawConfigPath", ""), // LC_PROFILE_BLENDER_LDRAW_CONFIG_PATH
+1
View File
@@ -94,6 +94,7 @@ enum LC_PROFILE_KEY
LC_PROFILE_POVRAY_LGEO_PATH,
LC_PROFILE_RENDER_WIDTH,
LC_PROFILE_RENDER_HEIGHT,
LC_PROFILE_RENDER_QUALITY,
LC_PROFILE_BLENDER_PATH,
LC_PROFILE_BLENDER_LDRAW_CONFIG_PATH,
LC_PROFILE_BLENDER_VERSION,
+17 -29
View File
@@ -134,7 +134,7 @@ QString Project::GetImageFileName(bool AllowCurrentFolder) const
return QDir::toNativeSeparators(FileName) + lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
}
void Project::SetActiveModel(lcModel* ActiveModel)
void Project::SetActiveModel(lcModel* ActiveModel, bool UpdateInterface)
{
if (!ActiveModel)
return;
@@ -150,28 +150,28 @@ void Project::SetActiveModel(lcModel* ActiveModel)
mActiveModel = ActiveModel;
if (!mIsPreview && gMainWindow)
if (!mIsPreview && gMainWindow && UpdateInterface)
{
gMainWindow->SetCurrentModelTab(mActiveModel);
mActiveModel->UpdateInterface();
}
}
void Project::SetActiveModel(int ModelIndex)
void Project::SetActiveModel(int ModelIndex, bool UpdateInterface)
{
if (ModelIndex < 0 || ModelIndex >= static_cast<int>(mModels.size()))
return;
SetActiveModel(mModels[ModelIndex].get());
SetActiveModel(mModels[ModelIndex].get(), UpdateInterface);
}
void Project::SetActiveModel(const QString& FileName)
void Project::SetActiveModel(const QString& FileName, bool UpdateInterface)
{
for (const std::unique_ptr<lcModel>& Model : mModels)
{
if (FileName.compare(Model->GetFileName(), Qt::CaseInsensitive) == 0)
{
SetActiveModel(Model.get());
SetActiveModel(Model.get(), UpdateInterface);
return;
}
}
@@ -264,7 +264,7 @@ lcModel* Project::CreateNewModel(bool ShowModel)
if (ShowModel)
{
SetActiveModel(mModels.back().get());
SetActiveModel(mModels.back().get(), true);
lcView* ActiveView = gMainWindow ? gMainWindow->GetActiveView() : nullptr;
if (ActiveView)
@@ -273,7 +273,7 @@ lcModel* Project::CreateNewModel(bool ShowModel)
gMainWindow->UpdateTitle();
}
else
SetActiveModel(mActiveModel);
SetActiveModel(mActiveModel, true);
return Model;
}
@@ -352,7 +352,7 @@ void Project::ShowModelListDialog()
int ModelIndex = Dialog.GetActiveModelIndex();
if (ModelIndex != -1)
SetActiveModel(ModelIndex);
SetActiveModel(ModelIndex, true);
}
void Project::SetFileName(const QString& FileName)
@@ -643,7 +643,7 @@ std::vector<lcModelPartsEntry> Project::GetModelParts()
mModels[0]->GetModelParts(lcMatrix44Identity(), gDefaultColor, ModelParts);
SetActiveModel(mActiveModel);
SetActiveModel(mActiveModel, false);
return ModelParts;
}
@@ -1803,28 +1803,22 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options)
}
}
bool Project::ExportPOVRay(const QString& FileName)
std::pair<bool, QString> Project::ExportPOVRay(const QString& FileName)
{
std::vector<lcModelPartsEntry> ModelParts = GetModelParts();
if (ModelParts.empty())
{
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
return false;
}
return { false, tr("Nothing to export.") };
QString SaveFileName = GetExportFileName(FileName, QLatin1String("pov"), tr("Export POV-Ray"), tr("POV-Ray Files (*.pov);;All Files (*.*)"));
if (SaveFileName.isEmpty())
return false;
return { false, QString() };
lcDiskFile POVFile(SaveFileName);
if (!POVFile.Open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
return false;
}
return { false, tr("Could not open file '%1' for writing.").arg(SaveFileName) };
enum
{
@@ -2226,10 +2220,7 @@ bool Project::ExportPOVRay(const QString& FileName)
lcDiskFile TableFile(QFileInfo(QDir(LGEOPath), QLatin1String("lg_elements.lst")).absoluteFilePath());
if (!TableFile.Open(QIODevice::ReadOnly))
{
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Could not find LGEO files in folder '%1'.").arg(LGEOPath));
return false;
}
return { false, tr("Could not find LGEO files in folder '%1'.").arg(LGEOPath) };
while (TableFile.ReadLine(Line, sizeof(Line)))
{
@@ -2275,10 +2266,7 @@ bool Project::ExportPOVRay(const QString& FileName)
lcDiskFile LgeoColorFile(QFileInfo(QDir(LGEOPath), QLatin1String("lg_colors.lst")).absoluteFilePath());
if (!LgeoColorFile.Open(QIODevice::ReadOnly))
{
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Could not find LGEO files in folder '%1'.").arg(LGEOPath));
return false;
}
return { false, tr("Could not find LGEO files in folder '%1'.").arg(LGEOPath) };
while (LgeoColorFile.ReadLine(Line, sizeof(Line)))
{
@@ -2510,7 +2498,7 @@ bool Project::ExportPOVRay(const QString& FileName)
POVFile.WriteLine(Line);
}
return true;
return { true, QString() };
}
bool Project::ExportWavefront(const QString& FileName)
+4 -4
View File
@@ -68,9 +68,9 @@ public:
lcInstructions* GetInstructions();
void SetActiveModel(lcModel* Model);
void SetActiveModel(int ModelIndex);
void SetActiveModel(const QString& FileName);
void SetActiveModel(lcModel* Model, bool UpdateInterface);
void SetActiveModel(int ModelIndex, bool UpdateInterface);
void SetActiveModel(const QString& FileName, bool UpdateInterface);
lcModel* CreateNewModel(bool ShowModel);
QString GetNewModelName(QWidget* ParentWidget, const QString& DialogTitle, const QString& CurrentName, const QStringList& ExistingModels) const;
@@ -91,7 +91,7 @@ public:
bool ExportCOLLADA(const QString& FileName);
bool ExportCSV(const QString& FileName);
void ExportHTML(const lcHTMLExportOptions& Options);
bool ExportPOVRay(const QString& FileName);
std::pair<bool, QString> ExportPOVRay(const QString& FileName);
bool ExportWavefront(const QString& FileName);
void UpdatePieceInfo(PieceInfo* Info) const;
+489 -452
View File
File diff suppressed because it is too large Load Diff
+34 -21
View File
@@ -1,5 +1,7 @@
#pragma once
#ifndef LC_DISABLE_RENDER_DIALOG
#include <QDialog>
namespace Ui {
@@ -43,64 +45,75 @@ protected:
QImage mScaledImage;
};
enum class lcRenderDialogMode
{
RenderPOVRay,
RenderBlender,
OpenInBlender
};
enum class lcPOVRayRenderQuality
{
Low,
Medium,
High
};
class lcRenderDialog : public QDialog
{
Q_OBJECT
public:
explicit lcRenderDialog(QWidget* Parent, int Command);
~lcRenderDialog();
explicit lcRenderDialog(QWidget* Parent, lcRenderDialogMode Mode);
virtual ~lcRenderDialog();
public slots:
void reject() override;
void on_RenderButton_clicked();
void on_OutputBrowseButton_clicked();
void on_RenderSettingsButton_clicked();
void on_RenderOutputButton_clicked();
void Update();
protected slots:
void RenderButtonClicked();
void SettingsButtonClicked();
void LogButtonClicked();
void ReadStdOut();
void WriteStdOut();
void UpdateElapsedTime() const;
protected:
QString GetStdOutFileName() const;
QString GetStdErrFileName() const;
QString GetPOVFileName() const;
QString ReadStdErr(bool& Error) const;
void RenderPOVRay();
void RenderBlender();
void CloseProcess();
bool PromptCancel();
void ShowResult();
#ifndef QT_NO_PROCESS
lcRenderProcess* mProcess;
#endif
enum CommandType
{
POVRAY_RENDER,
BLENDER_RENDER,
OPEN_IN_BLENDER
};
QTimer mUpdateTimer;
QElapsedTimer mRenderTime;
QFile mOutputFile;
void* mOutputBuffer;
void* mOutputBuffer = nullptr;
QImage mImage;
QStringList mStdErrList;
QStringList mStdOutList;
QPushButton* mRenderButton = nullptr;
QPushButton* mSettingsButton = nullptr;
QPushButton* mLogButton = nullptr;
lcRenderProcess* mProcess = nullptr;
int mWidth;
int mHeight;
int mWidth = 1280;
int mHeight = 720;
lcPOVRayRenderQuality mQuality = lcPOVRayRenderQuality::High;
int mPreviewWidth;
int mPreviewHeight;
int mCommand;
lcRenderDialogMode mDialogMode;
int mBlendProgValue;
int mBlendProgMax;
double mScale;
QString mImportModule;
QString mLabelMessage;
QString mDataPath;
Ui::lcRenderDialog* ui;
};
#endif // LC_DISABLE_RENDER_DIALOG
+21 -115
View File
@@ -15,78 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="topLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Settings</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="widthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="WidthEdit"/>
</item>
<item>
<widget class="QLabel" name="heightLabel">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="HeightEdit"/>
</item>
<item>
<widget class="QPushButton" name="RenderSettingsButton">
<property name="toolTip">
<string>Blender addon settings</string>
</property>
<property name="text">
<string>Settings...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qualityLabel">
<property name="text">
<string>Quality:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="QualityComboBox">
<item>
<property name="text">
<string>High</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Low</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<layout class="QVBoxLayout" name="MainLayout">
<item>
<layout class="QHBoxLayout" name="outputLayout">
<item>
@@ -94,6 +23,9 @@
<property name="text">
<string>Output:</string>
</property>
<property name="buddy">
<cstring>OutputEdit</cstring>
</property>
</widget>
</item>
<item>
@@ -108,49 +40,28 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="renderLayout">
<item>
<widget class="QProgressBar" name="RenderProgress">
<property name="maximum">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="renderLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderButton">
<property name="text">
<string>Render</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderOutputButton">
<property name="toolTip">
<string>Open the standard output log</string>
</property>
<property name="text">
<string>Output...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="lcRenderPreviewWidget" name="preview" native="true"/>
</item>
<item>
<widget class="QProgressBar" name="RenderProgress">
<property name="maximum">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -162,13 +73,8 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>WidthEdit</tabstop>
<tabstop>HeightEdit</tabstop>
<tabstop>RenderSettingsButton</tabstop>
<tabstop>QualityComboBox</tabstop>
<tabstop>OutputEdit</tabstop>
<tabstop>OutputBrowseButton</tabstop>
<tabstop>RenderButton</tabstop>
</tabstops>
<resources/>
<connections/>