Implementation for FR #8720 - Copy extruder settings to all extruders
This commit is contained in:
parent
e2010761e9
commit
0e55ffc07f
2 changed files with 175 additions and 111 deletions
|
@ -2638,6 +2638,179 @@ PageShp TabPrinter::build_kinematics_page()
|
|||
return page;
|
||||
}
|
||||
|
||||
const std::vector<std::string> extruder_options = {
|
||||
"min_layer_height", "max_layer_height", "extruder_offset",
|
||||
"retract_length", "retract_lift", "retract_lift_above", "retract_lift_below",
|
||||
"retract_speed", "deretract_speed", "retract_restart_extra", "retract_before_travel",
|
||||
"retract_layer_change", "wipe", "retract_before_wipe",
|
||||
"retract_length_toolchange", "retract_restart_extra_toolchange",
|
||||
};
|
||||
|
||||
void TabPrinter::build_extruder_pages(size_t n_before_extruders)
|
||||
{
|
||||
for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) {
|
||||
//# build page
|
||||
const wxString&page_name = wxString::Format("Extruder %d", int(extruder_idx + 1));
|
||||
auto page = add_options_page(page_name, "funnel", true);
|
||||
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
||||
|
||||
auto optgroup = page->new_optgroup(L("Size"));
|
||||
optgroup->append_single_option_line("nozzle_diameter", "", extruder_idx);
|
||||
|
||||
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key&opt_key, boost::any value)
|
||||
{
|
||||
if (m_config->opt_bool("single_extruder_multi_material") && m_extruders_count > 1 && opt_key.find_first_of("nozzle_diameter") != std::string::npos)
|
||||
{
|
||||
SuppressBackgroundProcessingUpdate sbpu;
|
||||
const double new_nd = boost::any_cast<double>(value);
|
||||
std::vector<double> nozzle_diameters = static_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"))->values;
|
||||
|
||||
// if value was changed
|
||||
if (fabs(nozzle_diameters[extruder_idx == 0 ? 1 : 0] - new_nd) > EPSILON)
|
||||
{
|
||||
const wxString msg_text = _L("This is a single extruder multimaterial printer, diameters of all extruders "
|
||||
"will be set to the new value. Do you want to proceed?");
|
||||
//wxMessageDialog dialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
|
||||
MessageDialog dialog(parent(), msg_text, _L("Nozzle diameter"), wxICON_WARNING | wxYES_NO);
|
||||
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
if (dialog.ShowModal() == wxID_YES) {
|
||||
for (size_t i = 0; i < nozzle_diameters.size(); i++) {
|
||||
if (i==extruder_idx)
|
||||
continue;
|
||||
nozzle_diameters[i] = new_nd;
|
||||
}
|
||||
}
|
||||
else
|
||||
nozzle_diameters[extruder_idx] = nozzle_diameters[extruder_idx == 0 ? 1 : 0];
|
||||
|
||||
new_conf.set_key_value("nozzle_diameter", new ConfigOptionFloats(nozzle_diameters));
|
||||
load_config(new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
};
|
||||
|
||||
optgroup = page->new_optgroup(L("Preview"));
|
||||
|
||||
auto reset_to_filament_color = [this, extruder_idx](wxWindow*parent) {
|
||||
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
btn->SetSize(btn->GetBestSize());
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [this, extruder_idx](wxCommandEvent&e)
|
||||
{
|
||||
std::vector<std::string> colors = static_cast<const ConfigOptionStrings*>(m_config->option("extruder_colour"))->values;
|
||||
colors[extruder_idx] = "";
|
||||
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value("extruder_colour", new ConfigOptionStrings(colors));
|
||||
load_config(new_conf);
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
});
|
||||
|
||||
parent->Bind(wxEVT_UPDATE_UI, [this, extruder_idx](wxUpdateUIEvent& evt) {
|
||||
evt.Enable(!static_cast<const ConfigOptionStrings*>(m_config->option("extruder_colour"))->values[extruder_idx].empty());
|
||||
}, btn->GetId());
|
||||
|
||||
return sizer;
|
||||
};
|
||||
Line line = optgroup->create_single_option_line("extruder_colour", "", extruder_idx);
|
||||
line.append_widget(reset_to_filament_color);
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup = page->new_optgroup(L(""));
|
||||
|
||||
auto copy_settings_btn =
|
||||
line = { "", ""};
|
||||
line.full_width = 1;
|
||||
line.widget = [this, extruder_idx](wxWindow* parent) {
|
||||
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "copy", _L("Apply below setting to other extruders"),
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [this, extruder_idx](wxCommandEvent& e) {
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
|
||||
for (const std::string& opt : extruder_options) {
|
||||
const ConfigOption* other_opt = m_config->option(opt);
|
||||
for (size_t extruder = 0; extruder < m_extruders_count; ++extruder) {
|
||||
if (extruder == extruder_idx)
|
||||
continue;
|
||||
static_cast<ConfigOptionVectorBase*>(new_conf.option(opt, false))->set_at(other_opt, extruder, extruder_idx);
|
||||
}
|
||||
}
|
||||
load_config(new_conf);
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
});
|
||||
|
||||
auto has_changes = [this, extruder_idx]() {
|
||||
auto dirty_options = m_presets->current_dirty_options(true);
|
||||
#if 1
|
||||
dirty_options.erase(std::remove_if(dirty_options.begin(), dirty_options.end(),
|
||||
[](const std::string& opt) { return opt.find("extruder_colour") != std::string::npos || opt.find("nozzle_diameter") != std::string::npos; }), dirty_options.end());
|
||||
return !dirty_options.empty();
|
||||
#else
|
||||
// if we wont to apply enable status for each extruder separately
|
||||
for (const std::string& opt : extruder_options)
|
||||
if (std::find(dirty_options.begin(), dirty_options.end(), opt+"#"+std::to_string(extruder_idx)) != dirty_options.end())
|
||||
return true;
|
||||
return false;
|
||||
#endif
|
||||
};
|
||||
|
||||
parent->Bind(wxEVT_UPDATE_UI, [this, has_changes](wxUpdateUIEvent& evt) {
|
||||
evt.Enable(m_extruders_count > 1 && has_changes());
|
||||
}, btn->GetId());
|
||||
|
||||
return sizer;
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup = page->new_optgroup(L("Layer height limits"));
|
||||
optgroup->append_single_option_line("min_layer_height", "", extruder_idx);
|
||||
optgroup->append_single_option_line("max_layer_height", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Position (for multi-extruder printers)"));
|
||||
optgroup->append_single_option_line("extruder_offset", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Retraction"));
|
||||
optgroup->append_single_option_line("retract_length", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_lift", "", extruder_idx);
|
||||
line = { L("Only lift Z"), "" };
|
||||
line.append_option(optgroup->get_option("retract_lift_above", extruder_idx));
|
||||
line.append_option(optgroup->get_option("retract_lift_below", extruder_idx));
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup->append_single_option_line("retract_speed", "", extruder_idx);
|
||||
optgroup->append_single_option_line("deretract_speed", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_before_travel", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_layer_change", "", extruder_idx);
|
||||
optgroup->append_single_option_line("wipe", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Retraction when tool is disabled (advanced settings for multi-extruder setups)"));
|
||||
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_restart_extra_toolchange", "", extruder_idx);
|
||||
}
|
||||
|
||||
// # remove extra pages
|
||||
if (m_extruders_count < m_extruders_count_old)
|
||||
m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count,
|
||||
m_pages.begin() + n_before_extruders + m_extruders_count_old);
|
||||
}
|
||||
|
||||
/* Previous name build_extruder_pages().
|
||||
*
|
||||
* This function was renamed because of now it implements not just an extruder pages building,
|
||||
|
@ -2709,114 +2882,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
|
|||
}
|
||||
|
||||
// Build missed extruder pages
|
||||
for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) {
|
||||
//# build page
|
||||
const wxString& page_name = wxString::Format("Extruder %d", int(extruder_idx + 1));
|
||||
auto page = add_options_page(page_name, "funnel", true);
|
||||
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
||||
|
||||
auto optgroup = page->new_optgroup(L("Size"));
|
||||
optgroup->append_single_option_line("nozzle_diameter", "", extruder_idx);
|
||||
|
||||
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
|
||||
{
|
||||
if (m_config->opt_bool("single_extruder_multi_material") && m_extruders_count > 1 && opt_key.find_first_of("nozzle_diameter") != std::string::npos)
|
||||
{
|
||||
SuppressBackgroundProcessingUpdate sbpu;
|
||||
const double new_nd = boost::any_cast<double>(value);
|
||||
std::vector<double> nozzle_diameters = static_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"))->values;
|
||||
|
||||
// if value was changed
|
||||
if (fabs(nozzle_diameters[extruder_idx == 0 ? 1 : 0] - new_nd) > EPSILON)
|
||||
{
|
||||
const wxString msg_text = _(L("This is a single extruder multimaterial printer, diameters of all extruders "
|
||||
"will be set to the new value. Do you want to proceed?"));
|
||||
//wxMessageDialog dialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
|
||||
MessageDialog dialog(parent(), msg_text, _(L("Nozzle diameter")), wxICON_WARNING | wxYES_NO);
|
||||
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
if (dialog.ShowModal() == wxID_YES) {
|
||||
for (size_t i = 0; i < nozzle_diameters.size(); i++) {
|
||||
if (i==extruder_idx)
|
||||
continue;
|
||||
nozzle_diameters[i] = new_nd;
|
||||
}
|
||||
}
|
||||
else
|
||||
nozzle_diameters[extruder_idx] = nozzle_diameters[extruder_idx == 0 ? 1 : 0];
|
||||
|
||||
new_conf.set_key_value("nozzle_diameter", new ConfigOptionFloats(nozzle_diameters));
|
||||
load_config(new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
};
|
||||
|
||||
optgroup = page->new_optgroup(L("Layer height limits"));
|
||||
optgroup->append_single_option_line("min_layer_height", "", extruder_idx);
|
||||
optgroup->append_single_option_line("max_layer_height", "", extruder_idx);
|
||||
|
||||
|
||||
optgroup = page->new_optgroup(L("Position (for multi-extruder printers)"));
|
||||
optgroup->append_single_option_line("extruder_offset", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Retraction"));
|
||||
optgroup->append_single_option_line("retract_length", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_lift", "", extruder_idx);
|
||||
Line line = { L("Only lift Z"), "" };
|
||||
line.append_option(optgroup->get_option("retract_lift_above", extruder_idx));
|
||||
line.append_option(optgroup->get_option("retract_lift_below", extruder_idx));
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup->append_single_option_line("retract_speed", "", extruder_idx);
|
||||
optgroup->append_single_option_line("deretract_speed", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_before_travel", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_layer_change", "", extruder_idx);
|
||||
optgroup->append_single_option_line("wipe", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Retraction when tool is disabled (advanced settings for multi-extruder setups)"));
|
||||
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
|
||||
optgroup->append_single_option_line("retract_restart_extra_toolchange", "", extruder_idx);
|
||||
|
||||
optgroup = page->new_optgroup(L("Preview"));
|
||||
|
||||
auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
|
||||
m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
ScalableButton* btn = m_reset_to_filament_color;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
btn->SetSize(btn->GetBestSize());
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [this, extruder_idx](wxCommandEvent& e)
|
||||
{
|
||||
std::vector<std::string> colors = static_cast<const ConfigOptionStrings*>(m_config->option("extruder_colour"))->values;
|
||||
colors[extruder_idx] = "";
|
||||
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value("extruder_colour", new ConfigOptionStrings(colors));
|
||||
load_config(new_conf);
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
});
|
||||
|
||||
return sizer;
|
||||
};
|
||||
line = optgroup->create_single_option_line("extruder_colour", "", extruder_idx);
|
||||
line.append_widget(reset_to_filament_color);
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
// # remove extra pages
|
||||
if (m_extruders_count < m_extruders_count_old)
|
||||
m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count,
|
||||
m_pages.begin() + n_before_extruders + m_extruders_count_old);
|
||||
build_extruder_pages(n_before_extruders);
|
||||
|
||||
Thaw();
|
||||
|
||||
|
@ -2902,7 +2968,6 @@ void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
|
|||
void TabPrinter::clear_pages()
|
||||
{
|
||||
Tab::clear_pages();
|
||||
m_reset_to_filament_color = nullptr;
|
||||
}
|
||||
|
||||
void TabPrinter::toggle_options()
|
||||
|
|
|
@ -473,8 +473,6 @@ private:
|
|||
std::vector<PageShp> m_pages_sla;
|
||||
|
||||
public:
|
||||
ScalableButton* m_reset_to_filament_color = nullptr;
|
||||
|
||||
size_t m_extruders_count;
|
||||
size_t m_extruders_count_old = 0;
|
||||
size_t m_initial_extruders_count;
|
||||
|
@ -501,6 +499,7 @@ public:
|
|||
void update_pages(); // update m_pages according to printer technology
|
||||
void extruders_count_changed(size_t extruders_count);
|
||||
PageShp build_kinematics_page();
|
||||
void build_extruder_pages(size_t n_before_extruders);
|
||||
void build_unregular_pages(bool from_initial_build = false);
|
||||
void on_preset_loaded() override;
|
||||
void init_options_list() override;
|
||||
|
|
Loading…
Reference in a new issue