Template filaments bundle with filament profiles available for all printers
Profiles are ment to be adjusted and saved as user profile. Selectable in wizard under (Templates). Installed automatically even when profile with same alias is selected. Special category in combo boxes. no_templates option for disabling this.
This commit is contained in:
parent
d9c7c675c4
commit
72540232c8
14 changed files with 1881 additions and 196 deletions
2
resources/profiles/TemplateFilaments.idx
Normal file
2
resources/profiles/TemplateFilaments.idx
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
min_slic3r_version = 2.4.0-rc
|
||||||
|
0.0.1 Initial
|
1410
resources/profiles/TemplateFilaments.ini
Normal file
1410
resources/profiles/TemplateFilaments.ini
Normal file
File diff suppressed because it is too large
Load diff
|
@ -68,6 +68,8 @@ void AppConfig::set_defaults()
|
||||||
// If set, the "- default -" selections of print/filament/printer are suppressed, if there is a valid preset available.
|
// If set, the "- default -" selections of print/filament/printer are suppressed, if there is a valid preset available.
|
||||||
if (get("no_defaults").empty())
|
if (get("no_defaults").empty())
|
||||||
set("no_defaults", "1");
|
set("no_defaults", "1");
|
||||||
|
if (get("no_templates").empty())
|
||||||
|
set("no_templates", "0");
|
||||||
if (get("show_incompatible_presets").empty())
|
if (get("show_incompatible_presets").empty())
|
||||||
set("show_incompatible_presets", "0");
|
set("show_incompatible_presets", "0");
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,11 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
||||||
res.changelog_url = changelog_url->second.data();
|
res.changelog_url = changelog_url->second.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto templates_profile = vendor_section.find("templates_profile");
|
||||||
|
if (templates_profile != vendor_section.not_found()) {
|
||||||
|
res.templates_profile = templates_profile->second.data() == "1";
|
||||||
|
}
|
||||||
|
|
||||||
if (! load_all) {
|
if (! load_all) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +341,8 @@ std::string Preset::label() const
|
||||||
|
|
||||||
bool is_compatible_with_print(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer)
|
bool is_compatible_with_print(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer)
|
||||||
{
|
{
|
||||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
// templates_profile vendor profiles should be decided as same vendor profiles
|
||||||
|
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor && !preset.vendor->templates_profile)
|
||||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||||
return false;
|
return false;
|
||||||
auto &condition = preset.preset.compatible_prints_condition();
|
auto &condition = preset.preset.compatible_prints_condition();
|
||||||
|
@ -358,7 +364,8 @@ bool is_compatible_with_print(const PresetWithVendorProfile &preset, const Prese
|
||||||
|
|
||||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
|
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
|
||||||
{
|
{
|
||||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
// templates_profile vendor profiles should be decided as same vendor profiles
|
||||||
|
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor && !preset.vendor->templates_profile)
|
||||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||||
return false;
|
return false;
|
||||||
auto &condition = preset.preset.compatible_printers_condition();
|
auto &condition = preset.preset.compatible_printers_condition();
|
||||||
|
@ -1185,6 +1192,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
|
||||||
if (opt)
|
if (opt)
|
||||||
config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast<const ConfigOptionFloats*>(opt)->values.size()));
|
config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast<const ConfigOptionFloats*>(opt)->values.size()));
|
||||||
bool some_compatible = false;
|
bool some_compatible = false;
|
||||||
|
std::vector<size_t> indices_of_template_presets;
|
||||||
for (size_t idx_preset = m_num_default_presets; idx_preset < m_presets.size(); ++ idx_preset) {
|
for (size_t idx_preset = m_num_default_presets; idx_preset < m_presets.size(); ++ idx_preset) {
|
||||||
bool selected = idx_preset == m_idx_selected;
|
bool selected = idx_preset == m_idx_selected;
|
||||||
Preset &preset_selected = m_presets[idx_preset];
|
Preset &preset_selected = m_presets[idx_preset];
|
||||||
|
@ -1201,7 +1209,30 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
|
||||||
m_idx_selected = size_t(-1);
|
m_idx_selected = size_t(-1);
|
||||||
if (selected)
|
if (selected)
|
||||||
preset_selected.is_compatible = preset_edited.is_compatible;
|
preset_selected.is_compatible = preset_edited.is_compatible;
|
||||||
|
if (preset_edited.vendor && preset_edited.vendor->templates_profile) {
|
||||||
|
indices_of_template_presets.push_back(idx_preset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// filter out template profiles where profile with same alias and compability exists
|
||||||
|
if (!indices_of_template_presets.empty()) {
|
||||||
|
for (size_t idx_preset = m_num_default_presets; idx_preset < m_presets.size(); ++idx_preset) {
|
||||||
|
if (m_presets[idx_preset].vendor && !m_presets[idx_preset].vendor->templates_profile && m_presets[idx_preset].is_compatible) {
|
||||||
|
std::string preset_alias = m_presets[idx_preset].alias;
|
||||||
|
for (size_t idx_in_templates = 0; idx_in_templates < indices_of_template_presets.size(); ++idx_in_templates) {
|
||||||
|
size_t idx_of_template_in_presets = indices_of_template_presets[idx_in_templates];
|
||||||
|
if (m_presets[idx_of_template_in_presets].alias == preset_alias) {
|
||||||
|
// unselect selected template filament if there is non-template alias compatible
|
||||||
|
if (idx_of_template_in_presets == m_idx_selected && (unselect_if_incompatible == PresetSelectCompatibleType::Always || unselect_if_incompatible == PresetSelectCompatibleType::OnlyIfWasCompatible)) {
|
||||||
|
m_idx_selected = size_t(-1);
|
||||||
|
}
|
||||||
|
m_presets[idx_of_template_in_presets].is_compatible = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update visibility of the default profiles here if the defaults are suppressed, the current profile is not compatible and we don't want to select another compatible profile.
|
// Update visibility of the default profiles here if the defaults are suppressed, the current profile is not compatible and we don't want to select another compatible profile.
|
||||||
if (m_idx_selected >= m_num_default_presets && m_default_suppressed)
|
if (m_idx_selected >= m_num_default_presets && m_default_suppressed)
|
||||||
for (size_t i = 0; i < m_num_default_presets; ++ i)
|
for (size_t i = 0; i < m_num_default_presets; ++ i)
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
Semver config_version;
|
Semver config_version;
|
||||||
std::string config_update_url;
|
std::string config_update_url;
|
||||||
std::string changelog_url;
|
std::string changelog_url;
|
||||||
|
bool templates_profile { false };
|
||||||
|
|
||||||
struct PrinterVariant {
|
struct PrinterVariant {
|
||||||
PrinterVariant() {}
|
PrinterVariant() {}
|
||||||
|
|
|
@ -1314,10 +1314,10 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
|
||||||
const VendorProfile *vendor_profile = nullptr;
|
const VendorProfile *vendor_profile = nullptr;
|
||||||
if (flags.has(LoadConfigBundleAttribute::LoadSystem) || flags.has(LoadConfigBundleAttribute::LoadVendorOnly)) {
|
if (flags.has(LoadConfigBundleAttribute::LoadSystem) || flags.has(LoadConfigBundleAttribute::LoadVendorOnly)) {
|
||||||
auto vp = VendorProfile::from_ini(tree, path);
|
auto vp = VendorProfile::from_ini(tree, path);
|
||||||
if (vp.models.size() == 0) {
|
if (vp.models.size() == 0 && !vp.templates_profile) {
|
||||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer model defined.") % path;
|
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer model defined.") % path;
|
||||||
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
||||||
} else if (vp.num_variants() == 0) {
|
} else if (vp.num_variants() == 0 && !vp.templates_profile) {
|
||||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer variant defined") % path;
|
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer variant defined") % path;
|
||||||
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1359,9 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
|
||||||
} else if (boost::starts_with(section.first, "filament:")) {
|
} else if (boost::starts_with(section.first, "filament:")) {
|
||||||
presets = &this->filaments;
|
presets = &this->filaments;
|
||||||
preset_name = section.first.substr(9);
|
preset_name = section.first.substr(9);
|
||||||
|
if (vendor_profile->templates_profile) {
|
||||||
|
preset_name += " @Template";
|
||||||
|
}
|
||||||
} else if (boost::starts_with(section.first, "sla_print:")) {
|
} else if (boost::starts_with(section.first, "sla_print:")) {
|
||||||
presets = &this->sla_prints;
|
presets = &this->sla_prints;
|
||||||
preset_name = section.first.substr(10);
|
preset_name = section.first.substr(10);
|
||||||
|
|
|
@ -620,6 +620,7 @@ void PagePrinters::set_run_reason(ConfigWizard::RunReason run_reason)
|
||||||
|
|
||||||
|
|
||||||
const std::string PageMaterials::EMPTY;
|
const std::string PageMaterials::EMPTY;
|
||||||
|
const std::string PageMaterials::TEMPLATES = "templates";
|
||||||
|
|
||||||
PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name)
|
PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name)
|
||||||
: ConfigWizardPage(parent, std::move(title), std::move(shortname))
|
: ConfigWizardPage(parent, std::move(title), std::move(shortname))
|
||||||
|
@ -727,6 +728,11 @@ void PageMaterials::reload_presets()
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
list_printer->append(_L("(All)"), &EMPTY);
|
list_printer->append(_L("(All)"), &EMPTY);
|
||||||
|
|
||||||
|
const AppConfig* app_config = wxGetApp().app_config;
|
||||||
|
if (materials->technology == T_FFF && app_config->get("no_templates") == "0")
|
||||||
|
list_printer->append(_L("(Templates)"), &TEMPLATES);
|
||||||
|
|
||||||
//list_printer->SetLabelMarkup("<b>bald</b>");
|
//list_printer->SetLabelMarkup("<b>bald</b>");
|
||||||
for (const Preset* printer : materials->printers) {
|
for (const Preset* printer : materials->printers) {
|
||||||
list_printer->append(printer->name, &printer->name);
|
list_printer->append(printer->name, &printer->name);
|
||||||
|
@ -758,68 +764,75 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
|
||||||
const auto text_clr = wxGetApp().get_label_clr_default();
|
const auto text_clr = wxGetApp().get_label_clr_default();
|
||||||
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));
|
||||||
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
|
||||||
wxString first_line = format_wxstr(_L("%1% marked with <b>*</b> are <b>not</b> compatible with some installed printers."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
|
|
||||||
wxString text;
|
wxString text;
|
||||||
if (all_printers) {
|
if (materials->technology == T_FFF && template_shown) {
|
||||||
wxString second_line = format_wxstr(_L("All installed printers are compatible with the selected %1%."), materials->technology == T_FFF ? _L("filament") : _L("SLA material"));
|
text = format_wxstr(_L("%1% visible for <b>(\"Template\")</b> printer are universal profiles available for all printers. These might not be compatible with your printer."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
|
||||||
text = wxString::Format(
|
|
||||||
"<html>"
|
|
||||||
"<style>"
|
|
||||||
"table{border-spacing: 1px;}"
|
|
||||||
"</style>"
|
|
||||||
"<body bgcolor= %s>"
|
|
||||||
"<font color=%s>"
|
|
||||||
"<font size=\"3\">"
|
|
||||||
"%s<br /><br />%s"
|
|
||||||
"</font>"
|
|
||||||
"</font>"
|
|
||||||
"</body>"
|
|
||||||
"</html>"
|
|
||||||
, bgr_clr_str
|
|
||||||
, text_clr_str
|
|
||||||
, first_line
|
|
||||||
, second_line
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
wxString second_line;
|
wxString first_line = format_wxstr(_L("%1% marked with <b>*</b> are <b>not</b> compatible with some installed printers."), materials->technology == T_FFF ? _L("Filaments") : _L("SLA materials"));
|
||||||
if (!printer_names.empty())
|
|
||||||
second_line = (materials->technology == T_FFF ?
|
if (all_printers) {
|
||||||
_L("Only the following installed printers are compatible with the selected filaments") :
|
wxString second_line = format_wxstr(_L("All installed printers are compatible with the selected %1%."), materials->technology == T_FFF ? _L("filament") : _L("SLA material"));
|
||||||
_L("Only the following installed printers are compatible with the selected SLA materials")) + ":";
|
text = wxString::Format(
|
||||||
text = wxString::Format(
|
"<html>"
|
||||||
"<html>"
|
"<style>"
|
||||||
"<style>"
|
"table{border-spacing: 1px;}"
|
||||||
"table{border-spacing: 1px;}"
|
"</style>"
|
||||||
"</style>"
|
"<body bgcolor= %s>"
|
||||||
"<body bgcolor= %s>"
|
"<font color=%s>"
|
||||||
"<font color=%s>"
|
"<font size=\"3\">"
|
||||||
"<font size=\"3\">"
|
"%s<br /><br />%s"
|
||||||
"%s<br /><br />%s"
|
"</font>"
|
||||||
"<table>"
|
"</font>"
|
||||||
"<tr>"
|
"</body>"
|
||||||
, bgr_clr_str
|
"</html>"
|
||||||
, text_clr_str
|
, bgr_clr_str
|
||||||
, first_line
|
, text_clr_str
|
||||||
, second_line);
|
, first_line
|
||||||
for (size_t i = 0; i < printer_names.size(); ++i)
|
, second_line
|
||||||
{
|
);
|
||||||
text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i]));
|
}
|
||||||
if (i % 3 == 2) {
|
else {
|
||||||
text += wxString::Format(
|
wxString second_line;
|
||||||
"</tr>"
|
if (!printer_names.empty())
|
||||||
"<tr>");
|
second_line = (materials->technology == T_FFF ?
|
||||||
}
|
_L("Only the following installed printers are compatible with the selected filaments") :
|
||||||
|
_L("Only the following installed printers are compatible with the selected SLA materials")) + ":";
|
||||||
|
text = wxString::Format(
|
||||||
|
"<html>"
|
||||||
|
"<style>"
|
||||||
|
"table{border-spacing: 1px;}"
|
||||||
|
"</style>"
|
||||||
|
"<body bgcolor= %s>"
|
||||||
|
"<font color=%s>"
|
||||||
|
"<font size=\"3\">"
|
||||||
|
"%s<br /><br />%s"
|
||||||
|
"<table>"
|
||||||
|
"<tr>"
|
||||||
|
, bgr_clr_str
|
||||||
|
, text_clr_str
|
||||||
|
, first_line
|
||||||
|
, second_line);
|
||||||
|
for (size_t i = 0; i < printer_names.size(); ++i)
|
||||||
|
{
|
||||||
|
text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i]));
|
||||||
|
if (i % 3 == 2) {
|
||||||
|
text += wxString::Format(
|
||||||
|
"</tr>"
|
||||||
|
"<tr>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += wxString::Format(
|
||||||
|
"</tr>"
|
||||||
|
"</table>"
|
||||||
|
"</font>"
|
||||||
|
"</font>"
|
||||||
|
"</body>"
|
||||||
|
"</html>"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
text += wxString::Format(
|
|
||||||
"</tr>"
|
|
||||||
"</table>"
|
|
||||||
"</font>"
|
|
||||||
"</font>"
|
|
||||||
"</body>"
|
|
||||||
"</html>"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxFont font = get_default_font_for_dpi(this, get_dpi_for_window(this));
|
wxFont font = get_default_font_for_dpi(this, get_dpi_for_window(this));
|
||||||
const int fs = font.GetPointSize();
|
const int fs = font.GetPointSize();
|
||||||
int size[] = { fs,fs,fs,fs,fs,fs,fs };
|
int size[] = { fs,fs,fs,fs,fs,fs,fs };
|
||||||
|
@ -863,6 +876,8 @@ void PageMaterials::on_material_highlighted(int sel_material)
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
for (const Preset* printer : materials->printers) {
|
for (const Preset* printer : materials->printers) {
|
||||||
for (const Preset* material : matching_materials) {
|
for (const Preset* material : matching_materials) {
|
||||||
|
if (material->vendor && material->vendor->templates_profile)
|
||||||
|
continue;
|
||||||
if (is_compatible_with_printer(PresetWithVendorProfile(*material, material->vendor), PresetWithVendorProfile(*printer, printer->vendor))) {
|
if (is_compatible_with_printer(PresetWithVendorProfile(*material, material->vendor), PresetWithVendorProfile(*printer, printer->vendor))) {
|
||||||
names.push_back(printer->name);
|
names.push_back(printer->name);
|
||||||
break;
|
break;
|
||||||
|
@ -880,6 +895,8 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
wxArrayInt sel_printers;
|
wxArrayInt sel_printers;
|
||||||
int sel_printers_count = list_printer->GetSelections(sel_printers);
|
int sel_printers_count = list_printer->GetSelections(sel_printers);
|
||||||
|
|
||||||
|
bool templates_available = list_printer->size() > 1 && list_printer->get_data(1) == TEMPLATES;
|
||||||
|
|
||||||
// Does our wxWidgets version support operator== for wxArrayInt ?
|
// Does our wxWidgets version support operator== for wxArrayInt ?
|
||||||
// https://github.com/prusa3d/PrusaSlicer/issues/5152#issuecomment-787208614
|
// https://github.com/prusa3d/PrusaSlicer/issues/5152#issuecomment-787208614
|
||||||
#if wxCHECK_VERSION(3, 1, 1)
|
#if wxCHECK_VERSION(3, 1, 1)
|
||||||
|
@ -895,13 +912,14 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
};
|
};
|
||||||
if (!are_equal(sel_printers, sel_printers_prev)) {
|
if (!are_equal(sel_printers, sel_printers_prev)) {
|
||||||
#endif
|
#endif
|
||||||
|
template_shown = false;
|
||||||
// Refresh type list
|
// Refresh type list
|
||||||
list_type->Clear();
|
list_type->Clear();
|
||||||
list_type->append(_L("(All)"), &EMPTY);
|
list_type->append(_L("(All)"), &EMPTY);
|
||||||
if (sel_printers_count > 0) {
|
if (sel_printers_count > 1) {
|
||||||
// If all is selected with other printers
|
// If all is selected with other printers
|
||||||
// unselect "all" or all printers depending on last value
|
// unselect "all" or all printers depending on last value
|
||||||
|
// same with "templates"
|
||||||
if (sel_printers[0] == 0 && sel_printers_count > 1) {
|
if (sel_printers[0] == 0 && sel_printers_count > 1) {
|
||||||
if (last_selected_printer == 0) {
|
if (last_selected_printer == 0) {
|
||||||
list_printer->SetSelection(wxNOT_FOUND);
|
list_printer->SetSelection(wxNOT_FOUND);
|
||||||
|
@ -911,38 +929,63 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
sel_printers_count = list_printer->GetSelections(sel_printers);
|
sel_printers_count = list_printer->GetSelections(sel_printers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sel_printers[0] != 0) {
|
if (materials->technology == T_FFF && templates_available && (sel_printers[0] == 1 || sel_printers[1] == 1) && sel_printers_count > 1) {
|
||||||
for (int i = 0; i < sel_printers_count; i++) {
|
if (last_selected_printer == 1) {
|
||||||
const std::string& printer_name = list_printer->get_data(sel_printers[i]);
|
list_printer->SetSelection(wxNOT_FOUND);
|
||||||
const Preset* printer = nullptr;
|
list_printer->SetSelection(1);
|
||||||
for (const Preset* it : materials->printers) {
|
}
|
||||||
if (it->name == printer_name) {
|
else if (last_selected_printer != 0) {
|
||||||
printer = it;
|
list_printer->SetSelection(1, false);
|
||||||
break;
|
sel_printers_count = list_printer->GetSelections(sel_printers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
materials->filter_presets(printer, EMPTY, EMPTY, [this](const Preset* p) {
|
}
|
||||||
const std::string& type = this->materials->get_type(p);
|
if (sel_printers_count > 0 && sel_printers[0] != 0 && ((materials->technology == T_FFF && templates_available && sel_printers[0] != 1) || materials->technology != T_FFF || !templates_available)) {
|
||||||
if (list_type->find(type) == wxNOT_FOUND) {
|
for (int i = 0; i < sel_printers_count; i++) {
|
||||||
list_type->append(type, &type);
|
const std::string& printer_name = list_printer->get_data(sel_printers[i]);
|
||||||
}
|
const Preset* printer = nullptr;
|
||||||
});
|
for (const Preset* it : materials->printers) {
|
||||||
}
|
if (it->name == printer_name) {
|
||||||
} else {
|
printer = it;
|
||||||
//clear selection except "ALL"
|
break;
|
||||||
list_printer->SetSelection(wxNOT_FOUND);
|
}
|
||||||
list_printer->SetSelection(0);
|
}
|
||||||
sel_printers_count = list_printer->GetSelections(sel_printers);
|
materials->filter_presets(printer, printer_name, EMPTY, EMPTY, [this](const Preset* p) {
|
||||||
|
const std::string& type = this->materials->get_type(p);
|
||||||
|
if (list_type->find(type) == wxNOT_FOUND) {
|
||||||
|
list_type->append(type, &type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (sel_printers_count > 0 && last_selected_printer == 0) {
|
||||||
|
//clear selection except "ALL"
|
||||||
|
list_printer->SetSelection(wxNOT_FOUND);
|
||||||
|
list_printer->SetSelection(0);
|
||||||
|
sel_printers_count = list_printer->GetSelections(sel_printers);
|
||||||
|
|
||||||
materials->filter_presets(nullptr, EMPTY, EMPTY, [this](const Preset* p) {
|
materials->filter_presets(nullptr, EMPTY, EMPTY, EMPTY, [this](const Preset* p) {
|
||||||
const std::string& type = this->materials->get_type(p);
|
const std::string& type = this->materials->get_type(p);
|
||||||
if (list_type->find(type) == wxNOT_FOUND) {
|
if (list_type->find(type) == wxNOT_FOUND) {
|
||||||
list_type->append(type, &type);
|
list_type->append(type, &type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sort_list_data(list_type, true, true);
|
else if (materials->technology == T_FFF && templates_available && sel_printers_count > 0 && last_selected_printer == 1) {
|
||||||
}
|
//clear selection except "TEMPLATES"
|
||||||
|
list_printer->SetSelection(wxNOT_FOUND);
|
||||||
|
list_printer->SetSelection(1);
|
||||||
|
sel_printers_count = list_printer->GetSelections(sel_printers);
|
||||||
|
template_shown = true;
|
||||||
|
materials->filter_presets(nullptr, TEMPLATES, EMPTY, EMPTY,
|
||||||
|
[this](const Preset* p) {
|
||||||
|
const std::string& type = this->materials->get_type(p);
|
||||||
|
if (list_type->find(type) == wxNOT_FOUND) {
|
||||||
|
list_type->append(type, &type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
sort_list_data(list_type, true, true);
|
||||||
|
|
||||||
sel_printers_prev = sel_printers;
|
sel_printers_prev = sel_printers;
|
||||||
sel_type = 0;
|
sel_type = 0;
|
||||||
|
@ -971,7 +1014,7 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
materials->filter_presets(printer, type, EMPTY, [this](const Preset* p) {
|
materials->filter_presets(printer, printer_name, type, EMPTY, [this](const Preset* p) {
|
||||||
const std::string& vendor = this->materials->get_vendor(p);
|
const std::string& vendor = this->materials->get_vendor(p);
|
||||||
if (list_vendor->find(vendor) == wxNOT_FOUND) {
|
if (list_vendor->find(vendor) == wxNOT_FOUND) {
|
||||||
list_vendor->append(vendor, &vendor);
|
list_vendor->append(vendor, &vendor);
|
||||||
|
@ -996,7 +1039,7 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
if (sel_printers_count != 0 && sel_type != wxNOT_FOUND && sel_vendor != wxNOT_FOUND) {
|
if (sel_printers_count != 0 && sel_type != wxNOT_FOUND && sel_vendor != wxNOT_FOUND) {
|
||||||
const std::string& type = list_type->get_data(sel_type);
|
const std::string& type = list_type->get_data(sel_type);
|
||||||
const std::string& vendor = list_vendor->get_data(sel_vendor);
|
const std::string& vendor = list_vendor->get_data(sel_vendor);
|
||||||
// finst printer preset
|
// first printer preset
|
||||||
std::vector<ProfilePrintData> to_list;
|
std::vector<ProfilePrintData> to_list;
|
||||||
for (int i = 0; i < sel_printers_count; i++) {
|
for (int i = 0; i < sel_printers_count; i++) {
|
||||||
const std::string& printer_name = list_printer->get_data(sel_printers[i]);
|
const std::string& printer_name = list_printer->get_data(sel_printers[i]);
|
||||||
|
@ -1007,15 +1050,14 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
materials->filter_presets(printer, printer_name, type, vendor, [this, &to_list](const Preset* p) {
|
||||||
materials->filter_presets(printer, type, vendor, [this, &to_list](const Preset* p) {
|
|
||||||
const std::string& section = materials->appconfig_section();
|
const std::string& section = materials->appconfig_section();
|
||||||
bool checked = wizard_p()->appconfig_new.has(section, p->name);
|
bool checked = wizard_p()->appconfig_new.has(section, p->name);
|
||||||
bool was_checked = false;
|
bool was_checked = false;
|
||||||
|
|
||||||
int cur_i = list_profile->find(p->alias);
|
int cur_i = list_profile->find(p->alias);
|
||||||
if (cur_i == wxNOT_FOUND) {
|
if (cur_i == wxNOT_FOUND) {
|
||||||
cur_i = list_profile->append(p->alias + (materials->get_omnipresent(p) ? "" : " *"), &p->alias);
|
cur_i = list_profile->append(p->alias + (materials->get_omnipresent(p) || template_shown ? "" : " *"), &p->alias);
|
||||||
to_list.emplace_back(p->alias, materials->get_omnipresent(p), checked);
|
to_list.emplace_back(p->alias, materials->get_omnipresent(p), checked);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1053,10 +1095,15 @@ void PageMaterials::sort_list_data(StringList* list, bool add_All_item, bool mat
|
||||||
|
|
||||||
std::vector<std::reference_wrapper<const std::string>> prusa_profiles;
|
std::vector<std::reference_wrapper<const std::string>> prusa_profiles;
|
||||||
std::vector<std::reference_wrapper<const std::string>> other_profiles;
|
std::vector<std::reference_wrapper<const std::string>> other_profiles;
|
||||||
|
bool add_TEMPLATES_item = false;
|
||||||
for (int i = 0 ; i < list->size(); ++i) {
|
for (int i = 0 ; i < list->size(); ++i) {
|
||||||
const std::string& data = list->get_data(i);
|
const std::string& data = list->get_data(i);
|
||||||
if (data == EMPTY) // do not sort <all> item
|
if (data == EMPTY) // do not sort <all> item
|
||||||
continue;
|
continue;
|
||||||
|
if (data == TEMPLATES) {// do not sort <templates> item
|
||||||
|
add_TEMPLATES_item = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!material_type_ordering && data.find("Prusa") != std::string::npos)
|
if (!material_type_ordering && data.find("Prusa") != std::string::npos)
|
||||||
prusa_profiles.push_back(data);
|
prusa_profiles.push_back(data);
|
||||||
else
|
else
|
||||||
|
@ -1095,10 +1142,13 @@ void PageMaterials::sort_list_data(StringList* list, bool add_All_item, bool mat
|
||||||
list->Clear();
|
list->Clear();
|
||||||
if (add_All_item)
|
if (add_All_item)
|
||||||
list->append(_L("(All)"), &EMPTY);
|
list->append(_L("(All)"), &EMPTY);
|
||||||
|
if (materials->technology == T_FFF && add_TEMPLATES_item)
|
||||||
|
list->append(_L("(Templates)"), &TEMPLATES);
|
||||||
for (const auto& item : prusa_profiles)
|
for (const auto& item : prusa_profiles)
|
||||||
list->append(item, &const_cast<std::string&>(item.get()));
|
list->append(item, &const_cast<std::string&>(item.get()));
|
||||||
for (const auto& item : other_profiles)
|
for (const auto& item : other_profiles)
|
||||||
list->append(item, &const_cast<std::string&>(item.get()));
|
list->append(item, &const_cast<std::string&>(item.get()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageMaterials::sort_list_data(PresetList* list, const std::vector<ProfilePrintData>& data)
|
void PageMaterials::sort_list_data(PresetList* list, const std::vector<ProfilePrintData>& data)
|
||||||
|
@ -1125,11 +1175,11 @@ void PageMaterials::sort_list_data(PresetList* list, const std::vector<ProfilePr
|
||||||
});
|
});
|
||||||
list->Clear();
|
list->Clear();
|
||||||
for (size_t i = 0; i < prusa_profiles.size(); ++i) {
|
for (size_t i = 0; i < prusa_profiles.size(); ++i) {
|
||||||
list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get()));
|
list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent || template_shown ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get()));
|
||||||
list->Check(i, prusa_profiles[i].checked);
|
list->Check(i, prusa_profiles[i].checked);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < other_profiles.size(); ++i) {
|
for (size_t i = 0; i < other_profiles.size(); ++i) {
|
||||||
list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get()));
|
list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent || template_shown ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get()));
|
||||||
list->Check(i + prusa_profiles.size(), other_profiles[i].checked);
|
list->Check(i + prusa_profiles.size(), other_profiles[i].checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1139,6 +1189,15 @@ void PageMaterials::select_material(int i)
|
||||||
const bool checked = list_profile->IsChecked(i);
|
const bool checked = list_profile->IsChecked(i);
|
||||||
|
|
||||||
const std::string& alias_key = list_profile->get_data(i);
|
const std::string& alias_key = list_profile->get_data(i);
|
||||||
|
if (checked && template_shown && !notification_shown) {
|
||||||
|
notification_shown = true;
|
||||||
|
wxString message = _L("You have selelected template filament. Please note that these filaments are available for all printers but are NOT certain to be compatible with your printer. Do you still wish to have this filament selected?\n(This message won't be displayed again.)");
|
||||||
|
MessageDialog msg(this, message, _L("Notice"), wxYES_NO);
|
||||||
|
if (msg.ShowModal() == wxID_NO) {
|
||||||
|
list_profile->Check(i, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
wizard_p()->update_presets_in_config(materials->appconfig_section(), alias_key, checked);
|
wizard_p()->update_presets_in_config(materials->appconfig_section(), alias_key, checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2197,13 +2256,19 @@ void ConfigWizard::priv::load_pages()
|
||||||
index->add_page(page_temps);
|
index->add_page(page_temps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filaments & Materials
|
// Filaments & Materials
|
||||||
if (any_fff_selected) { index->add_page(page_filaments); }
|
if (any_fff_selected) { index->add_page(page_filaments); }
|
||||||
|
// Filaments page if only custom printer is selected
|
||||||
|
const AppConfig* app_config = wxGetApp().app_config;
|
||||||
|
if (!any_fff_selected && (custom_printer_selected || custom_printer_in_bundle) && (app_config->get("no_templates") == "0")) {
|
||||||
|
update_materials(T_ANY);
|
||||||
|
index->add_page(page_filaments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (any_sla_selected) { index->add_page(page_sla_materials); }
|
if (any_sla_selected) { index->add_page(page_sla_materials); }
|
||||||
|
|
||||||
// there should to be selected at least one printer
|
// there should to be selected at least one printer
|
||||||
btn_finish->Enable(any_fff_selected || any_sla_selected || custom_printer_selected);
|
btn_finish->Enable(any_fff_selected || any_sla_selected || custom_printer_selected || custom_printer_in_bundle);
|
||||||
|
|
||||||
index->add_page(page_update);
|
index->add_page(page_update);
|
||||||
index->add_page(page_downloader);
|
index->add_page(page_downloader);
|
||||||
|
@ -2265,6 +2330,13 @@ void ConfigWizard::priv::load_vendors()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& printer : wxGetApp().preset_bundle->printers) {
|
||||||
|
if (!printer.is_default && !printer.is_system && printer.is_visible) {
|
||||||
|
custom_printer_in_bundle = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the is_visible flag in printer Presets
|
// Initialize the is_visible flag in printer Presets
|
||||||
for (auto &pair : bundles) {
|
for (auto &pair : bundles) {
|
||||||
pair.second.preset_bundle->load_installed_printers(appconfig_new);
|
pair.second.preset_bundle->load_installed_printers(appconfig_new);
|
||||||
|
@ -2386,7 +2458,7 @@ void ConfigWizard::priv::set_run_reason(RunReason run_reason)
|
||||||
|
|
||||||
void ConfigWizard::priv::update_materials(Technology technology)
|
void ConfigWizard::priv::update_materials(Technology technology)
|
||||||
{
|
{
|
||||||
if (any_fff_selected && (technology & T_FFF)) {
|
if ((any_fff_selected || custom_printer_in_bundle || custom_printer_selected) && (technology & T_FFF)) {
|
||||||
filaments.clear();
|
filaments.clear();
|
||||||
aliases_fff.clear();
|
aliases_fff.clear();
|
||||||
// Iterate filaments in all bundles
|
// Iterate filaments in all bundles
|
||||||
|
@ -2409,11 +2481,22 @@ void ConfigWizard::priv::update_materials(Technology technology)
|
||||||
filaments.add_printer(&printer);
|
filaments.add_printer(&printer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// template filament bundle has no printers - filament would be never added
|
||||||
|
if(pair.second.vendor_profile->templates_profile && pair.second.preset_bundle->printers.begin() == pair.second.preset_bundle->printers.end())
|
||||||
|
{
|
||||||
|
if (!filaments.containts(&filament)) {
|
||||||
|
filaments.push(&filament);
|
||||||
|
if (!filament.alias.empty())
|
||||||
|
aliases_fff[filament.alias].insert(filament.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// count compatible printers
|
// count compatible printers
|
||||||
for (const auto& preset : filaments.presets) {
|
for (const auto& preset : filaments.presets) {
|
||||||
|
// skip template filaments
|
||||||
|
if (preset->vendor && preset->vendor->templates_profile)
|
||||||
|
continue;
|
||||||
|
|
||||||
const auto filter = [preset](const std::pair<std::string, size_t> element) {
|
const auto filter = [preset](const std::pair<std::string, size_t> element) {
|
||||||
return preset->alias == element.first;
|
return preset->alias == element.first;
|
||||||
|
@ -2421,17 +2504,19 @@ void ConfigWizard::priv::update_materials(Technology technology)
|
||||||
if (std::find_if(filaments.compatibility_counter.begin(), filaments.compatibility_counter.end(), filter) != filaments.compatibility_counter.end()) {
|
if (std::find_if(filaments.compatibility_counter.begin(), filaments.compatibility_counter.end(), filter) != filaments.compatibility_counter.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// find all aliases (except templates)
|
||||||
std::vector<size_t> idx_with_same_alias;
|
std::vector<size_t> idx_with_same_alias;
|
||||||
for (size_t i = 0; i < filaments.presets.size(); ++i) {
|
for (size_t i = 0; i < filaments.presets.size(); ++i) {
|
||||||
if (preset->alias == filaments.presets[i]->alias)
|
if (preset->alias == filaments.presets[i]->alias && ((filaments.presets[i]->vendor && !filaments.presets[i]->vendor->templates_profile) || !filaments.presets[i]->vendor))
|
||||||
idx_with_same_alias.push_back(i);
|
idx_with_same_alias.push_back(i);
|
||||||
}
|
}
|
||||||
|
// check compatibility with each printer
|
||||||
size_t counter = 0;
|
size_t counter = 0;
|
||||||
for (const auto& printer : filaments.printers) {
|
for (const auto& printer : filaments.printers) {
|
||||||
if (!(*printer).is_visible || (*printer).printer_technology() != ptFFF)
|
if (!(*printer).is_visible || (*printer).printer_technology() != ptFFF)
|
||||||
continue;
|
continue;
|
||||||
bool compatible = false;
|
bool compatible = false;
|
||||||
// Test otrher materials with same alias
|
// Test other materials with same alias
|
||||||
for (size_t i = 0; i < idx_with_same_alias.size() && !compatible; ++i) {
|
for (size_t i = 0; i < idx_with_same_alias.size() && !compatible; ++i) {
|
||||||
const Preset& prst = *(filaments.presets[idx_with_same_alias[i]]);
|
const Preset& prst = *(filaments.presets[idx_with_same_alias[i]]);
|
||||||
const Preset& prntr = *printer;
|
const Preset& prntr = *printer;
|
||||||
|
@ -2694,6 +2779,21 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo
|
||||||
has_material = true;
|
has_material = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find if preset.first is part of the templates profile (up is searching if preset.first is part of printer vendor preset)
|
||||||
|
for (const auto& bp : bundles) {
|
||||||
|
if (!bp.second.preset_bundle->vendors.empty() && bp.second.preset_bundle->vendors.begin()->second.templates_profile) {
|
||||||
|
const PresetCollection& template_materials = bp.second.preset_bundle->materials(technology);
|
||||||
|
const Preset* template_material = template_materials.find_preset(preset.first, false);
|
||||||
|
if (template_material && is_compatible_with_printer(PresetWithVendorProfile(*template_material, &bp.second.preset_bundle->vendors.begin()->second), PresetWithVendorProfile(printer, nullptr))) {
|
||||||
|
has_material = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_material)
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! has_material)
|
if (! has_material)
|
||||||
|
@ -2702,6 +2802,23 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// template_profile_selected check
|
||||||
|
template_profile_selected = false;
|
||||||
|
for (const auto& bp : bundles) {
|
||||||
|
if (!bp.second.preset_bundle->vendors.empty() && bp.second.preset_bundle->vendors.begin()->second.templates_profile) {
|
||||||
|
for (const auto& preset : appconfig_presets) {
|
||||||
|
const PresetCollection& template_materials = bp.second.preset_bundle->materials(technology);
|
||||||
|
const Preset* template_material = template_materials.find_preset(preset.first, false);
|
||||||
|
if (template_material){
|
||||||
|
template_profile_selected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (template_profile_selected) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
assert(printer_models_without_material.empty() || only_for_model_id.empty() || only_for_model_id == (*printer_models_without_material.begin())->id);
|
assert(printer_models_without_material.empty() || only_for_model_id.empty() || only_for_model_id == (*printer_models_without_material.begin())->id);
|
||||||
return printer_models_without_material;
|
return printer_models_without_material;
|
||||||
};
|
};
|
||||||
|
@ -2865,7 +2982,13 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto vendor = enabled_vendors.find(pair.first);
|
const auto vendor = enabled_vendors.find(pair.first);
|
||||||
if (vendor == enabled_vendors.end()) { continue; }
|
if (vendor == enabled_vendors.end() && ((pair.second.vendor_profile && !pair.second.vendor_profile->templates_profile) || !pair.second.vendor_profile) ) { continue; }
|
||||||
|
|
||||||
|
if (template_profile_selected && pair.second.vendor_profile && pair.second.vendor_profile->templates_profile && vendor == enabled_vendors.end()) {
|
||||||
|
// Templates vendor needs to be installed
|
||||||
|
install_bundles.emplace_back(pair.first);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
size_t size_sum = 0;
|
size_t size_sum = 0;
|
||||||
for (const auto &model : vendor->second) { size_sum += model.second.size(); }
|
for (const auto &model : vendor->second) { size_sum += model.second.size(); }
|
||||||
|
|
|
@ -84,74 +84,8 @@ struct BundleMap : std::map<std::string /* = vendor ID */, Bundle>
|
||||||
const Bundle& prusa_bundle() const;
|
const Bundle& prusa_bundle() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Materials
|
struct Materials;
|
||||||
{
|
|
||||||
Technology technology;
|
|
||||||
// use vector for the presets to purpose of save of presets sorting in the bundle
|
|
||||||
std::vector<const Preset*> presets;
|
|
||||||
// String is alias of material, size_t number of compatible counters
|
|
||||||
std::vector<std::pair<std::string, size_t>> compatibility_counter;
|
|
||||||
std::set<std::string> types;
|
|
||||||
std::set<const Preset*> printers;
|
|
||||||
|
|
||||||
Materials(Technology technology) : technology(technology) {}
|
|
||||||
|
|
||||||
void push(const Preset *preset);
|
|
||||||
void add_printer(const Preset* preset);
|
|
||||||
void clear();
|
|
||||||
bool containts(const Preset *preset) const {
|
|
||||||
//return std::find(presets.begin(), presets.end(), preset) != presets.end();
|
|
||||||
return std::find_if(presets.begin(), presets.end(),
|
|
||||||
[preset](const Preset* element) { return element == preset; }) != presets.end();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_omnipresent(const Preset* preset) {
|
|
||||||
return get_printer_counter(preset) == printers.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<const Preset*> get_presets_by_alias(const std::string name) {
|
|
||||||
std::vector<const Preset*> ret_vec;
|
|
||||||
for (auto it = presets.begin(); it != presets.end(); ++it) {
|
|
||||||
if ((*it)->alias == name)
|
|
||||||
ret_vec.push_back((*it));
|
|
||||||
}
|
|
||||||
return ret_vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t get_printer_counter(const Preset* preset) {
|
|
||||||
for (auto it : compatibility_counter) {
|
|
||||||
if (it.first == preset->alias)
|
|
||||||
return it.second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& appconfig_section() const;
|
|
||||||
const std::string& get_type(const Preset *preset) const;
|
|
||||||
const std::string& get_vendor(const Preset *preset) const;
|
|
||||||
|
|
||||||
template<class F> void filter_presets(const Preset* printer, const std::string& type, const std::string& vendor, F cb) {
|
|
||||||
for (auto preset : presets) {
|
|
||||||
const Preset& prst = *(preset);
|
|
||||||
const Preset& prntr = *printer;
|
|
||||||
if ((printer == nullptr || is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor))) &&
|
|
||||||
(type.empty() || get_type(preset) == type) &&
|
|
||||||
(vendor.empty() || get_vendor(preset) == vendor)) {
|
|
||||||
|
|
||||||
cb(preset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string UNKNOWN;
|
|
||||||
static const std::string& get_filament_type(const Preset *preset);
|
|
||||||
static const std::string& get_filament_vendor(const Preset *preset);
|
|
||||||
static const std::string& get_material_type(const Preset *preset);
|
|
||||||
static const std::string& get_material_vendor(const Preset *preset);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct PrinterPickerEvent;
|
struct PrinterPickerEvent;
|
||||||
|
@ -344,6 +278,10 @@ struct PageMaterials: ConfigWizardPage
|
||||||
std::string empty_printers_label;
|
std::string empty_printers_label;
|
||||||
bool first_paint = { false };
|
bool first_paint = { false };
|
||||||
static const std::string EMPTY;
|
static const std::string EMPTY;
|
||||||
|
static const std::string TEMPLATES;
|
||||||
|
// notify user first time they choose template profile
|
||||||
|
bool template_shown = { false };
|
||||||
|
bool notification_shown = { false };
|
||||||
int last_hovered_item = { -1 } ;
|
int last_hovered_item = { -1 } ;
|
||||||
|
|
||||||
PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name);
|
PageMaterials(ConfigWizard *parent, Materials *materials, wxString title, wxString shortname, wxString list1name);
|
||||||
|
@ -368,6 +306,82 @@ struct PageMaterials: ConfigWizardPage
|
||||||
virtual void on_activate() override;
|
virtual void on_activate() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Materials
|
||||||
|
{
|
||||||
|
Technology technology;
|
||||||
|
// use vector for the presets to purpose of save of presets sorting in the bundle
|
||||||
|
std::vector<const Preset*> presets;
|
||||||
|
// String is alias of material, size_t number of compatible counters
|
||||||
|
std::vector<std::pair<std::string, size_t>> compatibility_counter;
|
||||||
|
std::set<std::string> types;
|
||||||
|
std::set<const Preset*> printers;
|
||||||
|
|
||||||
|
Materials(Technology technology) : technology(technology) {}
|
||||||
|
|
||||||
|
void push(const Preset* preset);
|
||||||
|
void add_printer(const Preset* preset);
|
||||||
|
void clear();
|
||||||
|
bool containts(const Preset* preset) const {
|
||||||
|
//return std::find(presets.begin(), presets.end(), preset) != presets.end();
|
||||||
|
return std::find_if(presets.begin(), presets.end(),
|
||||||
|
[preset](const Preset* element) { return element == preset; }) != presets.end();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_omnipresent(const Preset* preset) {
|
||||||
|
return get_printer_counter(preset) == printers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<const Preset*> get_presets_by_alias(const std::string name) {
|
||||||
|
std::vector<const Preset*> ret_vec;
|
||||||
|
for (auto it = presets.begin(); it != presets.end(); ++it) {
|
||||||
|
if ((*it)->alias == name)
|
||||||
|
ret_vec.push_back((*it));
|
||||||
|
}
|
||||||
|
return ret_vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
size_t get_printer_counter(const Preset* preset) {
|
||||||
|
for (auto it : compatibility_counter) {
|
||||||
|
if (it.first == preset->alias)
|
||||||
|
return it.second;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& appconfig_section() const;
|
||||||
|
const std::string& get_type(const Preset* preset) const;
|
||||||
|
const std::string& get_vendor(const Preset* preset) const;
|
||||||
|
|
||||||
|
template<class F> void filter_presets(const Preset* printer, const std::string& printer_name, const std::string& type, const std::string& vendor, F cb) {
|
||||||
|
for (auto preset : presets) {
|
||||||
|
const Preset& prst = *(preset);
|
||||||
|
const Preset& prntr = *printer;
|
||||||
|
if (((printer == nullptr && printer_name == PageMaterials::EMPTY) || (printer != nullptr && is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor)))) &&
|
||||||
|
(type.empty() || get_type(preset) == type) &&
|
||||||
|
(vendor.empty() || get_vendor(preset) == vendor) &&
|
||||||
|
!prst.vendor->templates_profile) {
|
||||||
|
|
||||||
|
cb(preset);
|
||||||
|
}
|
||||||
|
else if ((printer == nullptr && printer_name == PageMaterials::TEMPLATES) && prst.vendor->templates_profile &&
|
||||||
|
(type.empty() || get_type(preset) == type) &&
|
||||||
|
(vendor.empty() || get_vendor(preset) == vendor)) {
|
||||||
|
cb(preset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const std::string UNKNOWN;
|
||||||
|
static const std::string& get_filament_type(const Preset* preset);
|
||||||
|
static const std::string& get_filament_vendor(const Preset* preset);
|
||||||
|
static const std::string& get_material_type(const Preset* preset);
|
||||||
|
static const std::string& get_material_vendor(const Preset* preset);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PageCustom: ConfigWizardPage
|
struct PageCustom: ConfigWizardPage
|
||||||
{
|
{
|
||||||
PageCustom(ConfigWizard *parent);
|
PageCustom(ConfigWizard *parent);
|
||||||
|
@ -608,9 +622,11 @@ struct ConfigWizard::priv
|
||||||
std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition
|
std::unique_ptr<DynamicPrintConfig> custom_config; // Backing for custom printer definition
|
||||||
bool any_fff_selected; // Used to decide whether to display Filaments page
|
bool any_fff_selected; // Used to decide whether to display Filaments page
|
||||||
bool any_sla_selected; // Used to decide whether to display SLA Materials page
|
bool any_sla_selected; // Used to decide whether to display SLA Materials page
|
||||||
bool custom_printer_selected { false };
|
bool custom_printer_selected { false }; // New custom printer is requested
|
||||||
|
bool custom_printer_in_bundle { false }; // Older custom printer already exists when wizard starts
|
||||||
// Set to true if there are none FFF printers on the main FFF page. If true, only SLA printers are shown (not even custum printers)
|
// Set to true if there are none FFF printers on the main FFF page. If true, only SLA printers are shown (not even custum printers)
|
||||||
bool only_sla_mode { false };
|
bool only_sla_mode { false };
|
||||||
|
bool template_profile_selected { false }; // This bool has one purpose - to tell that template profile should be installed if its not (because it cannot be added to appconfig)
|
||||||
|
|
||||||
wxScrolledWindow *hscroll = nullptr;
|
wxScrolledWindow *hscroll = nullptr;
|
||||||
wxBoxSizer *hscroll_sizer = nullptr;
|
wxBoxSizer *hscroll_sizer = nullptr;
|
||||||
|
|
|
@ -301,6 +301,11 @@ void PreferencesDialog::build()
|
||||||
L("Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available."),
|
L("Suppress \" - default - \" presets in the Print / Filament / Printer selections once there are any other valid presets available."),
|
||||||
app_config->get("no_defaults") == "1");
|
app_config->get("no_defaults") == "1");
|
||||||
|
|
||||||
|
append_bool_option(m_optgroup_general, "no_templates",
|
||||||
|
L("Suppress \" Template \" filament presets"),
|
||||||
|
L("Suppress \" Template \" filament presets in configuration wizard and sidebar visibility."),
|
||||||
|
app_config->get("no_templates") == "1");
|
||||||
|
|
||||||
append_bool_option(m_optgroup_general, "show_incompatible_presets",
|
append_bool_option(m_optgroup_general, "show_incompatible_presets",
|
||||||
L("Show incompatible print and filament presets"),
|
L("Show incompatible print and filament presets"),
|
||||||
L("When checked, the print and filament presets are shown in the preset editor "
|
L("When checked, the print and filament presets are shown in the preset editor "
|
||||||
|
@ -692,6 +697,8 @@ void PreferencesDialog::accept(wxEvent&)
|
||||||
DesktopIntegrationDialog::perform_desktop_integration(true);
|
DesktopIntegrationDialog::perform_desktop_integration(true);
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
||||||
|
bool update_filament_sidebar = (m_values.find("no_templates") != m_values.end());
|
||||||
|
|
||||||
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled" };
|
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled" };
|
||||||
|
|
||||||
for (const std::string& option : options_to_recreate_GUI) {
|
for (const std::string& option : options_to_recreate_GUI) {
|
||||||
|
@ -761,6 +768,9 @@ void PreferencesDialog::accept(wxEvent&)
|
||||||
|
|
||||||
wxGetApp().update_ui_from_settings();
|
wxGetApp().update_ui_from_settings();
|
||||||
clear_cache();
|
clear_cache();
|
||||||
|
|
||||||
|
if (update_filament_sidebar)
|
||||||
|
wxGetApp().plater()->sidebar().update_presets(Preset::Type::TYPE_FILAMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::revert(wxEvent&)
|
void PreferencesDialog::revert(wxEvent&)
|
||||||
|
|
|
@ -836,6 +836,7 @@ void PlaterPresetComboBox::update()
|
||||||
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
|
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
|
||||||
|
|
||||||
std::map<wxString, wxBitmapBundle*> nonsys_presets;
|
std::map<wxString, wxBitmapBundle*> nonsys_presets;
|
||||||
|
std::map<wxString, wxBitmapBundle*> template_presets;
|
||||||
|
|
||||||
wxString selected_user_preset;
|
wxString selected_user_preset;
|
||||||
wxString tooltip;
|
wxString tooltip;
|
||||||
|
@ -883,10 +884,18 @@ void PlaterPresetComboBox::update()
|
||||||
|
|
||||||
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
|
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
|
||||||
if (preset.is_default || preset.is_system) {
|
if (preset.is_default || preset.is_system) {
|
||||||
Append(get_preset_name(preset), *bmp);
|
if (preset.vendor && preset.vendor->templates_profile) {
|
||||||
validate_selection(is_selected);
|
template_presets.emplace(get_preset_name(preset), bmp);
|
||||||
if (is_selected)
|
if (is_selected) {
|
||||||
tooltip = from_u8(preset.name);
|
selected_user_preset = get_preset_name(preset);
|
||||||
|
tooltip = from_u8(preset.name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Append(get_preset_name(preset), *bmp);
|
||||||
|
validate_selection(is_selected);
|
||||||
|
if (is_selected)
|
||||||
|
tooltip = from_u8(preset.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -899,6 +908,15 @@ void PlaterPresetComboBox::update()
|
||||||
if (i + 1 == m_collection->num_default_presets())
|
if (i + 1 == m_collection->num_default_presets())
|
||||||
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AppConfig* app_config = wxGetApp().app_config;
|
||||||
|
if (!template_presets.empty() && app_config->get("no_templates") == "0") {
|
||||||
|
set_label_marker(Append(separator(L("Template presets")), wxNullBitmap));
|
||||||
|
for (std::map<wxString, wxBitmap*>::iterator it = template_presets.begin(); it != template_presets.end(); ++it) {
|
||||||
|
Append(it->first, *it->second);
|
||||||
|
validate_selection(it->first == selected_user_preset);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!nonsys_presets.empty())
|
if (!nonsys_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||||
|
@ -1046,6 +1064,8 @@ void TabPresetComboBox::update()
|
||||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||||
|
|
||||||
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
|
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
|
||||||
|
std::map<wxString, std::pair<wxBitmapBundle*, bool>> template_presets;
|
||||||
|
|
||||||
wxString selected = "";
|
wxString selected = "";
|
||||||
if (!presets.front().is_visible)
|
if (!presets.front().is_visible)
|
||||||
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
|
@ -1078,11 +1098,19 @@ void TabPresetComboBox::update()
|
||||||
auto bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
auto bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
if (preset.is_default || preset.is_system) {
|
if (preset.is_default || preset.is_system) {
|
||||||
int item_id = Append(get_preset_name(preset), *bmp);
|
if (preset.vendor && preset.vendor->templates_profile) {
|
||||||
if (!is_enabled)
|
template_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
|
||||||
set_label_marker(item_id, LABEL_ITEM_DISABLED);
|
if (i == idx_selected)
|
||||||
validate_selection(i == idx_selected);
|
selected = get_preset_name(preset);
|
||||||
|
} else {
|
||||||
|
int item_id = Append(get_preset_name(preset), *bmp);
|
||||||
|
if (!is_enabled)
|
||||||
|
set_label_marker(item_id, LABEL_ITEM_DISABLED);
|
||||||
|
validate_selection(i == idx_selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1094,6 +1122,17 @@ void TabPresetComboBox::update()
|
||||||
if (i + 1 == m_collection->num_default_presets())
|
if (i + 1 == m_collection->num_default_presets())
|
||||||
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
}
|
}
|
||||||
|
const AppConfig* app_config = wxGetApp().app_config;
|
||||||
|
if (!template_presets.empty() && app_config->get("no_templates") == "0") {
|
||||||
|
set_label_marker(Append(separator(L("Template presets")), wxNullBitmap));
|
||||||
|
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = template_presets.begin(); it != template_presets.end(); ++it) {
|
||||||
|
int item_id = Append(it->first, *it->second.first);
|
||||||
|
bool is_enabled = it->second.second;
|
||||||
|
if (!is_enabled)
|
||||||
|
set_label_marker(item_id, LABEL_ITEM_DISABLED);
|
||||||
|
validate_selection(it->first == selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!nonsys_presets.empty())
|
if (!nonsys_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||||
|
|
|
@ -285,17 +285,17 @@ void SavePresetDialog::Item::Enable(bool enable /*= true*/)
|
||||||
// SavePresetDialog
|
// SavePresetDialog
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix)
|
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix, bool template_filament)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
|
||||||
{
|
{
|
||||||
build(std::vector<Preset::Type>{type}, suffix);
|
build(std::vector<Preset::Type>{type}, suffix, template_filament);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix, PresetBundle* preset_bundle/* = nullptr*/)
|
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix, bool template_filament/* =false*/, PresetBundle* preset_bundle/* = nullptr*/)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("Save presets"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER),
|
: DPIDialog(parent, wxID_ANY, _L("Save presets"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER),
|
||||||
m_preset_bundle(preset_bundle)
|
m_preset_bundle(preset_bundle)
|
||||||
{
|
{
|
||||||
build(types, suffix);
|
build(types, suffix, template_filament);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention)
|
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention)
|
||||||
|
@ -312,7 +312,7 @@ SavePresetDialog::~SavePresetDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix)
|
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix, bool template_filament)
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
// ys_FIXME! temporary workaround for correct font scaling
|
// ys_FIXME! temporary workaround for correct font scaling
|
||||||
|
@ -341,6 +341,15 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
||||||
btnOK->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(enable_ok_btn()); });
|
btnOK->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(enable_ok_btn()); });
|
||||||
|
|
||||||
topSizer->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
topSizer->Add(m_presets_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
|
||||||
|
// Add checkbox for Template filament saving
|
||||||
|
if (template_filament && types.size() == 1 && *types.begin() == Preset::Type::TYPE_FILAMENT) {
|
||||||
|
m_template_filament_checkbox = new wxCheckBox(this, wxID_ANY, _L("Save as profile derived from current printer only."));
|
||||||
|
wxBoxSizer* check_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
check_sizer->Add(m_template_filament_checkbox);
|
||||||
|
topSizer->Add(check_sizer, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
}
|
||||||
|
|
||||||
topSizer->Add(btns, 0, wxEXPAND | wxALL, BORDER_W);
|
topSizer->Add(btns, 0, wxEXPAND | wxALL, BORDER_W);
|
||||||
|
|
||||||
SetSizer(topSizer);
|
SetSizer(topSizer);
|
||||||
|
@ -371,6 +380,15 @@ std::string SavePresetDialog::get_name(Preset::Type type)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SavePresetDialog::get_template_filament_checkbox()
|
||||||
|
{
|
||||||
|
if (m_template_filament_checkbox)
|
||||||
|
{
|
||||||
|
return m_template_filament_checkbox->GetValue();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool SavePresetDialog::enable_ok_btn() const
|
bool SavePresetDialog::enable_ok_btn() const
|
||||||
{
|
{
|
||||||
for (const Item* item : m_items)
|
for (const Item* item : m_items)
|
||||||
|
|
|
@ -76,6 +76,7 @@ private:
|
||||||
wxStaticText* m_label {nullptr};
|
wxStaticText* m_label {nullptr};
|
||||||
wxBoxSizer* m_radio_sizer {nullptr};
|
wxBoxSizer* m_radio_sizer {nullptr};
|
||||||
ActionType m_action {UndefAction};
|
ActionType m_action {UndefAction};
|
||||||
|
wxCheckBox* m_template_filament_checkbox {nullptr};
|
||||||
|
|
||||||
std::string m_ph_printer_name;
|
std::string m_ph_printer_name;
|
||||||
std::string m_old_preset_name;
|
std::string m_old_preset_name;
|
||||||
|
@ -86,10 +87,11 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
<<<<<<< master
|
||||||
const wxString& get_info_line_extention() { return m_info_line_extention; }
|
const wxString& get_info_line_extention() { return m_info_line_extention; }
|
||||||
|
|
||||||
SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "");
|
SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "", bool template_filament = false);
|
||||||
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "", PresetBundle* preset_bundle = nullptr);
|
SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "", bool template_filament = false, PresetBundle* preset_bundle = nullptr);
|
||||||
SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention);
|
SavePresetDialog(wxWindow* parent, Preset::Type type, bool rename, const wxString& info_line_extention);
|
||||||
~SavePresetDialog() override;
|
~SavePresetDialog() override;
|
||||||
|
|
||||||
|
@ -105,12 +107,13 @@ public:
|
||||||
bool Layout() override;
|
bool Layout() override;
|
||||||
bool is_for_rename() { return m_use_for_rename; }
|
bool is_for_rename() { return m_use_for_rename; }
|
||||||
|
|
||||||
|
bool get_template_filament_checkbox();
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override {}
|
void on_sys_color_changed() override {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void build(std::vector<Preset::Type> types, std::string suffix = "");
|
void build(std::vector<Preset::Type> types, std::string suffix = "", bool template_filament = false);
|
||||||
void update_physical_printers(const std::string& preset_name);
|
void update_physical_printers(const std::string& preset_name);
|
||||||
void accept();
|
void accept();
|
||||||
};
|
};
|
||||||
|
|
|
@ -3715,11 +3715,25 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
||||||
// focus currently.is there anything better than this ?
|
// focus currently.is there anything better than this ?
|
||||||
//! m_treectrl->OnSetFocus();
|
//! m_treectrl->OnSetFocus();
|
||||||
|
|
||||||
|
auto& old_preset = m_presets->get_edited_preset();
|
||||||
|
bool from_template = false;
|
||||||
|
std::string edited_printer;
|
||||||
|
if (m_type == Preset::TYPE_FILAMENT && old_preset.vendor && old_preset.vendor->templates_profile)
|
||||||
|
{
|
||||||
|
//TODO: is this really the best way to get "printer_model" option of currently edited printer?
|
||||||
|
edited_printer = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt<ConfigOptionString>("printer_model")->serialize();
|
||||||
|
if (!edited_printer.empty())
|
||||||
|
from_template = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "");
|
SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "", from_template);
|
||||||
if (dlg.ShowModal() != wxID_OK)
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
return;
|
return;
|
||||||
name = dlg.get_name();
|
name = dlg.get_name();
|
||||||
|
if (from_template)
|
||||||
|
from_template = dlg.get_template_filament_checkbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detach && m_type == Preset::TYPE_PRINTER)
|
if (detach && m_type == Preset::TYPE_PRINTER)
|
||||||
|
@ -3731,6 +3745,19 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
||||||
if (detach && m_type == Preset::TYPE_PRINTER)
|
if (detach && m_type == Preset::TYPE_PRINTER)
|
||||||
wxGetApp().mainframe->on_config_changed(m_config);
|
wxGetApp().mainframe->on_config_changed(m_config);
|
||||||
|
|
||||||
|
// Update compatible printers
|
||||||
|
if (from_template && !edited_printer.empty()) {
|
||||||
|
auto& new_preset = m_presets->get_edited_preset();
|
||||||
|
std::string cond = new_preset.compatible_printers_condition();
|
||||||
|
if (!cond.empty())
|
||||||
|
cond += " and ";
|
||||||
|
cond += "printer_model == \""+edited_printer+"\"";
|
||||||
|
new_preset.config.set("compatible_printers_condition", cond);
|
||||||
|
new_preset.save();
|
||||||
|
m_presets->save_current_preset(name, detach);
|
||||||
|
load_current_preset();
|
||||||
|
}
|
||||||
|
|
||||||
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||||
// If saving the preset changes compatibility with other presets, keep the now incompatible dependent presets selected, however with a "red flag" icon showing that they are no more compatible.
|
// If saving the preset changes compatibility with other presets, keep the now incompatible dependent presets selected, however with a "red flag" icon showing that they are no more compatible.
|
||||||
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||||
|
|
|
@ -480,7 +480,7 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version
|
||||||
bundle_path_idx_to_install = idx.path();
|
bundle_path_idx_to_install = idx.path();
|
||||||
found = true;
|
found = true;
|
||||||
} else {
|
} else {
|
||||||
throw std::exception("Some resources are missing.");
|
throw Slic3r::CriticalException("Some resources are missing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue