diff --git a/src/libslic3r/Format/SL1.hpp b/src/libslic3r/Format/SL1.hpp index a56c640ecd..7ba00d7c8d 100644 --- a/src/libslic3r/Format/SL1.hpp +++ b/src/libslic3r/Format/SL1.hpp @@ -36,8 +36,6 @@ public: const ThumbnailsList &thumbnails, const std::string &projectname = "") override; }; - - } // namespace Slic3r::sla diff --git a/src/libslic3r/Format/SLAArchiveReader.cpp b/src/libslic3r/Format/SLAArchiveReader.cpp index 3c7334a127..0c36031e6a 100644 --- a/src/libslic3r/Format/SLAArchiveReader.cpp +++ b/src/libslic3r/Format/SLAArchiveReader.cpp @@ -283,23 +283,14 @@ std::vector extract_slices_from_sla_archive( return slices; } -} // namespace - -ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrintConfig &out) -{ - ArchiveData arch = extract_sla_archive(zipfname, "png"); - return out.load(arch.profile, ForwardCompatibilitySubstitutionRule::Enable); -} - // If the profile is missing from the archive (older PS versions did not have // it), profile_out's initial value will be used as fallback. profile_out will be empty on // function return if the archive did not contain any profile. -ConfigSubstitutions import_sla_archive( - const std::string & zipfname, - Vec2i windowsize, - indexed_triangle_set & out, - DynamicPrintConfig & profile_out, - std::function progr) +ConfigSubstitutions import_sla_archive(const std::string &zipfname, + Vec2i windowsize, + indexed_triangle_set &out, + DynamicPrintConfig &profile_out, + std::function progr) { // Ensure minimum window size for marching squares windowsize.x() = std::max(2, windowsize.x()); @@ -329,8 +320,8 @@ ConfigSubstitutions import_sla_archive( } } - // If the archive contains an empty profile, use the one that was passed as output argument - // then replace it with the readed profile to report that it was empty. + // If the archive contains an empty profile, use the one that was passed as output argument + // then replace it with the readed profile to report that it was empty. profile_use = profile_in.empty() ? profile_out : profile_in; profile_out = profile_in; @@ -348,5 +339,42 @@ ConfigSubstitutions import_sla_archive( return config_substitutions; } +} // namespace + +//inline ConfigSubstitutions import_sla_archive( +// const std::string & zipfname, +// Vec2i windowsize, +// indexed_triangle_set & out, +// std::function progr = [](int) { return true; }) +//{ +// DynamicPrintConfig profile; +// return import_sla_archive(zipfname, windowsize, out, profile, progr); +//} + +ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrintConfig &out) +{ + ArchiveData arch = extract_sla_archive(zipfname, "png"); + return out.load(arch.profile, ForwardCompatibilitySubstitutionRule::Enable); +} + +ConfigSubstitutions import_sla_archive(const std::string &zipfname, + indexed_triangle_set &out, + DynamicPrintConfig &profile, + SLAImportQuality quality, + std::function progr) +{ + Vec2i window; + + switch(quality) + { + case SLAImportQuality::Fast: window = {8, 8}; break; + case SLAImportQuality:: Balanced: window = {4, 4}; break; + default: + case SLAImportQuality::Accurate: + window = {2, 2}; + }; + + return import_sla_archive(zipfname, window, out, profile, progr); +} } // namespace Slic3r diff --git a/src/libslic3r/Format/SLAArchiveReader.hpp b/src/libslic3r/Format/SLAArchiveReader.hpp index 20ba3f3850..f092a9a09e 100644 --- a/src/libslic3r/Format/SLAArchiveReader.hpp +++ b/src/libslic3r/Format/SLAArchiveReader.hpp @@ -9,22 +9,14 @@ namespace Slic3r { ConfigSubstitutions import_sla_archive(const std::string &zipfname, DynamicPrintConfig &out); -ConfigSubstitutions import_sla_archive( - const std::string & zipfname, - Vec2i windowsize, - indexed_triangle_set & out, - DynamicPrintConfig & profile, - std::function progr = [](int) { return true; }); +enum class SLAImportQuality { Accurate, Balanced, Fast }; -inline ConfigSubstitutions import_sla_archive( - const std::string & zipfname, - Vec2i windowsize, - indexed_triangle_set & out, - std::function progr = [](int) { return true; }) -{ - DynamicPrintConfig profile; - return import_sla_archive(zipfname, windowsize, out, profile, progr); -} +ConfigSubstitutions import_sla_archive( + const std::string &zipfname, + indexed_triangle_set &out, + DynamicPrintConfig &profile, + SLAImportQuality quality = SLAImportQuality::Balanced, + std::function progr = [](int) { return true; }); class MissingProfileError : public RuntimeError { using RuntimeError::RuntimeError; }; diff --git a/src/slic3r/GUI/Jobs/SLAImportDialog.hpp b/src/slic3r/GUI/Jobs/SLAImportDialog.hpp index 15cab9ed1b..70adb2c272 100644 --- a/src/slic3r/GUI/Jobs/SLAImportDialog.hpp +++ b/src/slic3r/GUI/Jobs/SLAImportDialog.hpp @@ -64,7 +64,7 @@ public: }; m_quality_dropdown = new wxComboBox( - this, wxID_ANY, qual_choices[0], wxDefaultPosition, wxDefaultSize, + this, wxID_ANY, qual_choices[1], wxDefaultPosition, wxDefaultSize, qual_choices.size(), qual_choices.data(), wxCB_READONLY | wxCB_DROPDOWN); szchoices->Add(m_quality_dropdown, 1); @@ -96,17 +96,15 @@ public: return Sel(std::min(int(Sel::modelOnly), std::max(0, sel))); } - Vec2i get_marchsq_windowsize() const override + SLAImportQuality get_quality() const override { - enum { Accurate, Balanced, Fast}; - switch(m_quality_dropdown->GetSelection()) { - case Fast: return {8, 8}; - case Balanced: return {4, 4}; + case 2: return SLAImportQuality::Fast; + case 1: return SLAImportQuality::Balanced; + case 0: return SLAImportQuality::Accurate; default: - case Accurate: - return {2, 2}; + return SLAImportQuality::Balanced; } } diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.cpp b/src/slic3r/GUI/Jobs/SLAImportJob.cpp index 2b29764e68..36c1f09145 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.cpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.cpp @@ -25,7 +25,7 @@ public: indexed_triangle_set mesh; DynamicPrintConfig profile; wxString path; - Vec2i win = {2, 2}; + Quality quality = Quality::Balanced; std::string err; ConfigSubstitutions config_substitutions; @@ -60,7 +60,9 @@ void SLAImportJob::process(Ctl &ctl) switch (p->sel) { case Sel::modelAndProfile: case Sel::modelOnly: - p->config_substitutions = import_sla_archive(path, p->win, p->mesh, p->profile, progr); + p->config_substitutions = import_sla_archive(path, p->mesh, + p->profile, + p->quality, progr); break; case Sel::profileOnly: p->config_substitutions = import_sla_archive(path, p->profile); @@ -82,7 +84,7 @@ void SLAImportJob::reset() p->sel = Sel::modelAndProfile; p->mesh = {}; p->profile = p->plater->sla_print().full_print_config(); - p->win = {2, 2}; + p->quality = SLAImportQuality::Balanced; p->path.Clear(); } @@ -90,11 +92,12 @@ void SLAImportJob::prepare() { reset(); - auto path = p->import_dlg->get_path(); - auto nm = wxFileName(path); - p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath(); - p->sel = p->import_dlg->get_selection(); - p->win = p->import_dlg->get_marchsq_windowsize(); + auto path = p->import_dlg->get_path(); + auto nm = wxFileName(path); + p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath(); + p->sel = p->import_dlg->get_selection(); + p->quality = p->import_dlg->get_quality(); + p->config_substitutions.clear(); } diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.hpp b/src/slic3r/GUI/Jobs/SLAImportJob.hpp index b2aea8bf89..0a691b6e8b 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.hpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.hpp @@ -3,7 +3,7 @@ #include "Job.hpp" -#include "libslic3r/Point.hpp" +#include "libslic3r/Format/SLAArchiveReader.hpp" namespace Slic3r { namespace GUI { @@ -14,7 +14,7 @@ public: virtual ~SLAImportJobView() = default; virtual Sel get_selection() const = 0; - virtual Vec2i get_marchsq_windowsize() const = 0; + virtual SLAImportQuality get_quality() const = 0; virtual std::string get_path() const = 0; }; @@ -25,6 +25,7 @@ class SLAImportJob : public Job { std::unique_ptr p; using Sel = SLAImportJobView::Sel; + using Quality = SLAImportQuality; public: void prepare();