mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-06 01:16:05 +08:00
Get rid of window size parameter from import interface
Make 'Balanced' the default import quality
This commit is contained in:
parent
5ecf29f303
commit
e0fc337b2d
@ -37,8 +37,6 @@ public:
|
|||||||
const std::string &projectname = "") override;
|
const std::string &projectname = "") override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Slic3r::sla
|
} // namespace Slic3r::sla
|
||||||
|
|
||||||
#endif // ARCHIVETRAITS_HPP
|
#endif // ARCHIVETRAITS_HPP
|
||||||
|
@ -283,22 +283,13 @@ std::vector<ExPolygons> extract_slices_from_sla_archive(
|
|||||||
return slices;
|
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
|
// 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
|
// 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.
|
// function return if the archive did not contain any profile.
|
||||||
ConfigSubstitutions import_sla_archive(
|
ConfigSubstitutions import_sla_archive(const std::string &zipfname,
|
||||||
const std::string & zipfname,
|
|
||||||
Vec2i windowsize,
|
Vec2i windowsize,
|
||||||
indexed_triangle_set & out,
|
indexed_triangle_set &out,
|
||||||
DynamicPrintConfig & profile_out,
|
DynamicPrintConfig &profile_out,
|
||||||
std::function<bool(int)> progr)
|
std::function<bool(int)> progr)
|
||||||
{
|
{
|
||||||
// Ensure minimum window size for marching squares
|
// Ensure minimum window size for marching squares
|
||||||
@ -348,5 +339,42 @@ ConfigSubstitutions import_sla_archive(
|
|||||||
return config_substitutions;
|
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
|
} // 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, DynamicPrintConfig &out);
|
||||||
|
|
||||||
ConfigSubstitutions import_sla_archive(
|
enum class SLAImportQuality { Accurate, Balanced, Fast };
|
||||||
const std::string & zipfname,
|
|
||||||
Vec2i windowsize,
|
|
||||||
indexed_triangle_set & out,
|
|
||||||
DynamicPrintConfig & profile,
|
|
||||||
std::function<bool(int)> progr = [](int) { return true; });
|
|
||||||
|
|
||||||
inline ConfigSubstitutions import_sla_archive(
|
ConfigSubstitutions import_sla_archive(
|
||||||
const std::string & zipfname,
|
const std::string &zipfname,
|
||||||
Vec2i windowsize,
|
indexed_triangle_set &out,
|
||||||
indexed_triangle_set & out,
|
DynamicPrintConfig &profile,
|
||||||
std::function<bool(int)> progr = [](int) { return true; })
|
SLAImportQuality quality = SLAImportQuality::Balanced,
|
||||||
{
|
std::function<bool(int)> progr = [](int) { return true; });
|
||||||
DynamicPrintConfig profile;
|
|
||||||
return import_sla_archive(zipfname, windowsize, out, profile, progr);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MissingProfileError : public RuntimeError { using RuntimeError::RuntimeError; };
|
class MissingProfileError : public RuntimeError { using RuntimeError::RuntimeError; };
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
m_quality_dropdown = new wxComboBox(
|
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);
|
qual_choices.size(), qual_choices.data(), wxCB_READONLY | wxCB_DROPDOWN);
|
||||||
szchoices->Add(m_quality_dropdown, 1);
|
szchoices->Add(m_quality_dropdown, 1);
|
||||||
|
|
||||||
@ -96,17 +96,15 @@ public:
|
|||||||
return Sel(std::min(int(Sel::modelOnly), std::max(0, sel)));
|
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())
|
switch(m_quality_dropdown->GetSelection())
|
||||||
{
|
{
|
||||||
case Fast: return {8, 8};
|
case 2: return SLAImportQuality::Fast;
|
||||||
case Balanced: return {4, 4};
|
case 1: return SLAImportQuality::Balanced;
|
||||||
|
case 0: return SLAImportQuality::Accurate;
|
||||||
default:
|
default:
|
||||||
case Accurate:
|
return SLAImportQuality::Balanced;
|
||||||
return {2, 2};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
indexed_triangle_set mesh;
|
indexed_triangle_set mesh;
|
||||||
DynamicPrintConfig profile;
|
DynamicPrintConfig profile;
|
||||||
wxString path;
|
wxString path;
|
||||||
Vec2i win = {2, 2};
|
Quality quality = Quality::Balanced;
|
||||||
std::string err;
|
std::string err;
|
||||||
ConfigSubstitutions config_substitutions;
|
ConfigSubstitutions config_substitutions;
|
||||||
|
|
||||||
@ -60,7 +60,9 @@ void SLAImportJob::process(Ctl &ctl)
|
|||||||
switch (p->sel) {
|
switch (p->sel) {
|
||||||
case Sel::modelAndProfile:
|
case Sel::modelAndProfile:
|
||||||
case Sel::modelOnly:
|
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;
|
break;
|
||||||
case Sel::profileOnly:
|
case Sel::profileOnly:
|
||||||
p->config_substitutions = import_sla_archive(path, p->profile);
|
p->config_substitutions = import_sla_archive(path, p->profile);
|
||||||
@ -82,7 +84,7 @@ void SLAImportJob::reset()
|
|||||||
p->sel = Sel::modelAndProfile;
|
p->sel = Sel::modelAndProfile;
|
||||||
p->mesh = {};
|
p->mesh = {};
|
||||||
p->profile = p->plater->sla_print().full_print_config();
|
p->profile = p->plater->sla_print().full_print_config();
|
||||||
p->win = {2, 2};
|
p->quality = SLAImportQuality::Balanced;
|
||||||
p->path.Clear();
|
p->path.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +96,8 @@ void SLAImportJob::prepare()
|
|||||||
auto nm = wxFileName(path);
|
auto nm = wxFileName(path);
|
||||||
p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath();
|
p->path = !nm.Exists(wxFILE_EXISTS_REGULAR) ? "" : nm.GetFullPath();
|
||||||
p->sel = p->import_dlg->get_selection();
|
p->sel = p->import_dlg->get_selection();
|
||||||
p->win = p->import_dlg->get_marchsq_windowsize();
|
p->quality = p->import_dlg->get_quality();
|
||||||
|
|
||||||
p->config_substitutions.clear();
|
p->config_substitutions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Job.hpp"
|
#include "Job.hpp"
|
||||||
|
|
||||||
#include "libslic3r/Point.hpp"
|
#include "libslic3r/Format/SLAArchiveReader.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ public:
|
|||||||
virtual ~SLAImportJobView() = default;
|
virtual ~SLAImportJobView() = default;
|
||||||
|
|
||||||
virtual Sel get_selection() const = 0;
|
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;
|
virtual std::string get_path() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ class SLAImportJob : public Job {
|
|||||||
|
|
||||||
std::unique_ptr<priv> p;
|
std::unique_ptr<priv> p;
|
||||||
using Sel = SLAImportJobView::Sel;
|
using Sel = SLAImportJobView::Sel;
|
||||||
|
using Quality = SLAImportQuality;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void prepare();
|
void prepare();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user