Modification of extruders filaments for support XL multitool (#36)
* Fix for SPE-1659 : Wrong filaments update, when templates are allowed/suppressed * Per Extruder Filaments (related to SPE 1599) * Implemented compatibility for each extruder separately * Update of the filaments compatibility is extracted to separate function update_filaments_compatible() * Fixed synchronization of config.ini with the current selections, when preset is changed from sidebar. * Filament Settings Tab improvements: * Added extruder combobox to select active extruder * PresetCombobox is updated in respect to compatibility for active extruder * For MM printer: Cog icon near the filament will switch to Filament Settings for selected filament * Bug fixing for https://dev.prusa3d.com/browse/SPE-1599 * Next round of bugfixing for https://dev.prusa3d.com/browse/SPE-1599 * Fixed crashes from https://dev.prusa3d.com/browse/SPE-1599 + code refactoring for Tab:save_preset()
This commit is contained in:
parent
989cbeceb1
commit
9e4859ebbf
12 changed files with 769 additions and 246 deletions
|
@ -1068,12 +1068,6 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||
dynamic_cast<ConfigOptionFloats*>(preset_bundle.printers.get_edited_preset().config.option("nozzle_diameter"))->values.size();
|
||||
const size_t filament_cnt = p->combos_filament.size() > extruder_cnt ? extruder_cnt : p->combos_filament.size();
|
||||
|
||||
if (filament_cnt == 1) {
|
||||
// Single filament printer, synchronize the filament presets.
|
||||
const std::string &name = preset_bundle.filaments.get_selected_preset_name();
|
||||
preset_bundle.set_filament_preset(0, name);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < filament_cnt; i++)
|
||||
p->combos_filament[i]->update();
|
||||
|
||||
|
@ -1417,14 +1411,14 @@ void Sidebar::update_sliced_info_sizer()
|
|||
new_label = _L("Used Filament (g)");
|
||||
info_text = wxString::Format("%.2f", ps.total_weight);
|
||||
|
||||
const std::vector<std::string>& filament_presets = wxGetApp().preset_bundle->filament_presets;
|
||||
const auto& extruders_filaments = wxGetApp().preset_bundle->extruders_filaments;
|
||||
const PresetCollection& filaments = wxGetApp().preset_bundle->filaments;
|
||||
|
||||
if (ps.filament_stats.size() > 1)
|
||||
new_label += ":";
|
||||
|
||||
for (auto filament : ps.filament_stats) {
|
||||
const Preset* filament_preset = filaments.find_preset(filament_presets[filament.first], false);
|
||||
const Preset* filament_preset = filaments.find_preset(extruders_filaments[filament.first].get_selected_preset_name(), false);
|
||||
if (filament_preset) {
|
||||
double filament_weight;
|
||||
if (ps.filament_stats.size() == 1)
|
||||
|
@ -2405,8 +2399,8 @@ void Plater::check_selected_presets_visibility(PrinterTechnology loaded_printer_
|
|||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
if (loaded_printer_technology == ptFFF) {
|
||||
update_selected_preset_visibility(preset_bundle->prints, names);
|
||||
for (const std::string& filament : preset_bundle->filament_presets) {
|
||||
Preset* preset = preset_bundle->filaments.find_preset(filament);
|
||||
for (const auto& extruder_filaments : preset_bundle->extruders_filaments) {
|
||||
Preset* preset = preset_bundle->filaments.find_preset(extruder_filaments.get_selected_preset_name());
|
||||
if (preset && !preset->is_visible) {
|
||||
preset->is_visible = true;
|
||||
names.emplace_back(preset->name);
|
||||
|
@ -4018,19 +4012,25 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
//! combo->GetStringSelection().ToUTF8().data());
|
||||
|
||||
std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
||||
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));
|
||||
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||
}
|
||||
Preset::remove_suffix_modified(into_u8(combo->GetString(selection))), idx);
|
||||
|
||||
std::string last_selected_ph_printer_name = combo->get_selected_ph_printer_name();
|
||||
|
||||
bool select_preset = !combo->selection_is_changed_according_to_physical_printers();
|
||||
// TODO: ?
|
||||
if (preset_type == Preset::TYPE_FILAMENT && sidebar->is_multifilament()) {
|
||||
// Only update the plater UI for the 2nd and other filaments.
|
||||
combo->update();
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||
|
||||
TabFilament* tab = dynamic_cast<TabFilament*>(wxGetApp().get_tab(Preset::TYPE_FILAMENT));
|
||||
if (tab && combo->get_extruder_idx() == tab->get_active_extruder() && !tab->select_preset(preset_name)) {
|
||||
// revert previously selection
|
||||
const std::string& old_name = wxGetApp().preset_bundle->filaments.get_edited_preset().name;
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, old_name);
|
||||
combo->update();
|
||||
}
|
||||
else
|
||||
// Synchronize config.ini with the current selections.
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
}
|
||||
else if (select_preset) {
|
||||
wxWindowUpdateLocker noUpdates(sidebar->presets_panel());
|
||||
|
@ -6886,6 +6886,8 @@ void Plater::on_extruders_change(size_t num_extruders)
|
|||
if (num_extruders == choices.size())
|
||||
return;
|
||||
|
||||
dynamic_cast<TabFilament*>(wxGetApp().get_tab(Preset::TYPE_FILAMENT))->update_extruder_combobox();
|
||||
|
||||
wxWindowUpdateLocker noUpdates_scrolled_panel(&sidebar()/*.scrolled_panel()*/);
|
||||
|
||||
size_t i = choices.size();
|
||||
|
@ -6912,16 +6914,16 @@ bool Plater::update_filament_colors_in_full_config()
|
|||
// There is a case, when we use filament_color instead of extruder_color (when extruder_color == "").
|
||||
// Thus plater config option "filament_colour" should be filled with filament_presets values.
|
||||
// Otherwise, on 3dScene will be used last edited filament color for all volumes with extruder_color == "".
|
||||
const std::vector<std::string> filament_presets = wxGetApp().preset_bundle->filament_presets;
|
||||
if (filament_presets.size() == 1 || !p->config->has("filament_colour"))
|
||||
const auto& extruders_filaments = wxGetApp().preset_bundle->extruders_filaments;
|
||||
if (extruders_filaments.size() == 1 || !p->config->has("filament_colour"))
|
||||
return false;
|
||||
|
||||
const PresetCollection& filaments = wxGetApp().preset_bundle->filaments;
|
||||
std::vector<std::string> filament_colors;
|
||||
filament_colors.reserve(filament_presets.size());
|
||||
filament_colors.reserve(extruders_filaments.size());
|
||||
|
||||
for (const std::string& filament_preset : filament_presets)
|
||||
filament_colors.push_back(filaments.find_preset(filament_preset, true)->config.opt_string("filament_colour", (unsigned)0));
|
||||
for (const auto& extr_filaments : extruders_filaments)
|
||||
filament_colors.push_back(filaments.find_preset(extr_filaments.get_selected_preset_name(), true)->config.opt_string("filament_colour", (unsigned)0));
|
||||
|
||||
p->config->option<ConfigOptionStrings>("filament_colour")->values = filament_colors;
|
||||
return true;
|
||||
|
@ -7016,16 +7018,17 @@ void Plater::force_filament_colors_update()
|
|||
{
|
||||
bool update_scheduled = false;
|
||||
DynamicPrintConfig* config = p->config;
|
||||
const std::vector<std::string> filament_presets = wxGetApp().preset_bundle->filament_presets;
|
||||
if (filament_presets.size() > 1 &&
|
||||
p->config->option<ConfigOptionStrings>("filament_colour")->values.size() == filament_presets.size())
|
||||
|
||||
const auto& extruders_filaments = wxGetApp().preset_bundle->extruders_filaments;
|
||||
if (extruders_filaments.size() > 1 &&
|
||||
p->config->option<ConfigOptionStrings>("filament_colour")->values.size() == extruders_filaments.size())
|
||||
{
|
||||
const PresetCollection& filaments = wxGetApp().preset_bundle->filaments;
|
||||
std::vector<std::string> filament_colors;
|
||||
filament_colors.reserve(filament_presets.size());
|
||||
filament_colors.reserve(extruders_filaments.size());
|
||||
|
||||
for (const std::string& filament_preset : filament_presets)
|
||||
filament_colors.push_back(filaments.find_preset(filament_preset, true)->config.opt_string("filament_colour", (unsigned)0));
|
||||
for (const auto& extr_filaments : extruders_filaments)
|
||||
filament_colors.push_back(extr_filaments.get_selected_preset()->config.opt_string("filament_colour", (unsigned)0));
|
||||
|
||||
if (config->option<ConfigOptionStrings>("filament_colour")->values != filament_colors) {
|
||||
config->option<ConfigOptionStrings>("filament_colour")->values = filament_colors;
|
||||
|
@ -7042,6 +7045,20 @@ void Plater::force_filament_colors_update()
|
|||
this->p->schedule_background_process();
|
||||
}
|
||||
|
||||
void Plater::force_filament_cb_update()
|
||||
{
|
||||
// Update visibility for templates presets according to app_config
|
||||
PresetCollection& filaments = wxGetApp().preset_bundle->filaments;
|
||||
AppConfig& config = *wxGetApp().app_config;
|
||||
for (Preset& preset : filaments)
|
||||
preset.set_visible_from_appconfig(config);
|
||||
wxGetApp().preset_bundle->update_compatible(PresetSelectCompatibleType::Never, PresetSelectCompatibleType::OnlyIfWasCompatible);
|
||||
|
||||
// Update preset comboboxes on sidebar and filaments tab
|
||||
p->sidebar->update_presets(Preset::TYPE_FILAMENT);
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filaments.get_selected_preset_name());
|
||||
}
|
||||
|
||||
void Plater::force_print_bed_update()
|
||||
{
|
||||
// Fill in the printer model key with something which cannot possibly be valid, so that Plater::on_config_change() will update the print bed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue