Get rid of window size parameter from import interface
Make 'Balanced' the default import quality
This commit is contained in:
parent
5ecf29f303
commit
e0fc337b2d
6 changed files with 71 additions and 51 deletions
|
@ -36,8 +36,6 @@ public:
|
|||
const ThumbnailsList &thumbnails,
|
||||
const std::string &projectname = "") override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Slic3r::sla
|
||||
|
||||
|
|
|
@ -283,23 +283,14 @@ std::vector<ExPolygons> 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<bool(int)> progr)
|
||||
ConfigSubstitutions import_sla_archive(const std::string &zipfname,
|
||||
Vec2i windowsize,
|
||||
indexed_triangle_set &out,
|
||||
DynamicPrintConfig &profile_out,
|
||||
std::function<bool(int)> 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<bool(int)> 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<bool(int)> 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
|
||||
|
|
|
@ -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<bool(int)> 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<bool(int)> 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<bool(int)> progr = [](int) { return true; });
|
||||
|
||||
class MissingProfileError : public RuntimeError { using RuntimeError::RuntimeError; };
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<priv> p;
|
||||
using Sel = SLAImportJobView::Sel;
|
||||
using Quality = SLAImportQuality;
|
||||
|
||||
public:
|
||||
void prepare();
|
||||
|
|
Loading…
Reference in a new issue