mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-17 10:15:56 +08:00
Update filament overrides UI.
After introducing the new z-hop strategy the filament overrides were in a state of disarray. This commit fixes it.
This commit is contained in:
parent
0c64950151
commit
9a68645106
@ -1986,21 +1986,18 @@ void TabFilament::update_line_with_near_label_widget(ConfigOptionsGroupShp optgr
|
|||||||
field->toggle(is_checked);
|
field->toggle(is_checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabFilament::add_filament_overrides_page()
|
std::vector<std::pair<std::string, std::vector<std::string>>> option_keys {
|
||||||
{
|
{"Travel lift", {
|
||||||
PageShp page = add_options_page(L("Filament Overrides"), "wrench");
|
|
||||||
ConfigOptionsGroupShp optgroup = page->new_optgroup(L("Travels"));
|
|
||||||
|
|
||||||
const int extruder_idx = 0; // #ys_FIXME
|
|
||||||
|
|
||||||
for (const std::string opt_key : {
|
|
||||||
"filament_travel_ramping_lift",
|
|
||||||
"filament_travel_slope",
|
|
||||||
"filament_retract_lift",
|
"filament_retract_lift",
|
||||||
|
"filament_travel_ramping_lift",
|
||||||
"filament_travel_max_lift",
|
"filament_travel_max_lift",
|
||||||
"filament_retract_length",
|
"filament_travel_slope",
|
||||||
|
"filament_travel_lift_before_obstacle",
|
||||||
"filament_retract_lift_above",
|
"filament_retract_lift_above",
|
||||||
"filament_retract_lift_below",
|
"filament_retract_lift_below"
|
||||||
|
}},
|
||||||
|
{"Retraction", {
|
||||||
|
"filament_retract_length",
|
||||||
"filament_retract_speed",
|
"filament_retract_speed",
|
||||||
"filament_deretract_speed",
|
"filament_deretract_speed",
|
||||||
"filament_retract_restart_extra",
|
"filament_retract_restart_extra",
|
||||||
@ -2008,16 +2005,37 @@ void TabFilament::add_filament_overrides_page()
|
|||||||
"filament_retract_layer_change",
|
"filament_retract_layer_change",
|
||||||
"filament_wipe",
|
"filament_wipe",
|
||||||
"filament_retract_before_wipe",
|
"filament_retract_before_wipe",
|
||||||
"filament_travel_lift_before_obstacle"
|
}},
|
||||||
})
|
{"Retraction when tool is disabled", {
|
||||||
create_line_with_near_label_widget(optgroup, opt_key, extruder_idx);
|
"filament_retract_length_toolchange",
|
||||||
|
|
||||||
optgroup = page->new_optgroup(L("Retraction when tool is disabled"));
|
|
||||||
for (const std::string opt_key : { "filament_retract_length_toolchange",
|
|
||||||
"filament_retract_restart_extra_toolchange"
|
"filament_retract_restart_extra_toolchange"
|
||||||
})
|
}}
|
||||||
create_line_with_near_label_widget(optgroup, opt_key, extruder_idx);
|
};
|
||||||
|
|
||||||
|
void TabFilament::add_filament_overrides_page()
|
||||||
|
{
|
||||||
|
PageShp page = add_options_page(L("Filament Overrides"), "wrench");
|
||||||
|
|
||||||
|
const int extruder_idx = 0; // #ys_FIXME
|
||||||
|
|
||||||
|
for (const auto&[title, keys] : option_keys) {
|
||||||
|
ConfigOptionsGroupShp optgroup = page->new_optgroup(L(title));
|
||||||
|
for (const std::string& opt_key : keys) {
|
||||||
|
create_line_with_near_label_widget(optgroup, opt_key, extruder_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ConfigOptionsGroupShp> get_option_group(const Page* page, const std::string& title) {
|
||||||
|
auto og_it = std::find_if(
|
||||||
|
page->m_optgroups.begin(), page->m_optgroups.end(),
|
||||||
|
[&](const ConfigOptionsGroupShp& og) {
|
||||||
|
return og->title == title;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (og_it == page->m_optgroups.end())
|
||||||
|
return {};
|
||||||
|
return *og_it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabFilament::update_filament_overrides_page()
|
void TabFilament::update_filament_overrides_page()
|
||||||
@ -2026,57 +2044,77 @@ void TabFilament::update_filament_overrides_page()
|
|||||||
return;
|
return;
|
||||||
Page* page = m_active_page;
|
Page* page = m_active_page;
|
||||||
|
|
||||||
auto og_it = std::find_if(page->m_optgroups.begin(), page->m_optgroups.end(), [](const ConfigOptionsGroupShp og) { return og->title == "Travels"; });
|
|
||||||
if (og_it == page->m_optgroups.end())
|
|
||||||
return;
|
|
||||||
ConfigOptionsGroupShp optgroup = *og_it;
|
|
||||||
|
|
||||||
std::vector<std::string> opt_keys = { "filament_retract_length",
|
|
||||||
"filament_retract_lift_above",
|
|
||||||
"filament_retract_lift_below",
|
|
||||||
"filament_retract_speed",
|
|
||||||
"filament_deretract_speed",
|
|
||||||
"filament_retract_restart_extra",
|
|
||||||
"filament_retract_before_travel",
|
|
||||||
"filament_retract_layer_change",
|
|
||||||
"filament_wipe",
|
|
||||||
"filament_retract_before_wipe",
|
|
||||||
"filament_travel_slope",
|
|
||||||
"filament_travel_max_lift",
|
|
||||||
"filament_retract_lift",
|
|
||||||
"filament_travel_lift_before_obstacle"
|
|
||||||
};
|
|
||||||
|
|
||||||
const int extruder_idx = 0; // #ys_FIXME
|
const int extruder_idx = 0; // #ys_FIXME
|
||||||
|
|
||||||
const bool have_retract_length = m_config->option("filament_retract_length")->is_nil() ||
|
const bool have_retract_length = (
|
||||||
m_config->opt_float("filament_retract_length", extruder_idx) > 0;
|
m_config->option("filament_retract_length")->is_nil()
|
||||||
|
|| m_config->opt_float("filament_retract_length", extruder_idx) > 0
|
||||||
|
);
|
||||||
|
|
||||||
for (const std::string& opt_key : opt_keys)
|
const bool uses_ramping_lift = (
|
||||||
{
|
m_config->option("filament_travel_ramping_lift")->is_nil()
|
||||||
bool is_checked = opt_key=="filament_retract_length" ? true : have_retract_length;
|
|| m_config->opt_bool("filament_travel_ramping_lift", extruder_idx)
|
||||||
update_line_with_near_label_widget(optgroup, opt_key, extruder_idx, is_checked);
|
);
|
||||||
/*
|
|
||||||
m_overrides_options[opt_key]->Enable(is_checked);
|
|
||||||
|
|
||||||
is_checked &= !m_config->option(opt_key)->is_nil();
|
const bool is_lifting = (
|
||||||
CheckBox::SetValue(m_overrides_options[opt_key], is_checked);
|
m_config->option("filament_travel_max_lift")->is_nil()
|
||||||
|
|| m_config->opt_float("filament_travel_max_lift", extruder_idx) > 0
|
||||||
|
|| m_config->option("filament_retract_lift")->is_nil()
|
||||||
|
|| m_config->opt_float("filament_retract_lift", extruder_idx) > 0
|
||||||
|
);
|
||||||
|
|
||||||
Field* field = optgroup->get_fieldc(opt_key, extruder_idx);
|
for (const auto&[title, keys] : option_keys) {
|
||||||
if (field != nullptr)
|
std::optional<ConfigOptionsGroupShp> optgroup{get_option_group(page, title)};
|
||||||
field->toggle(is_checked);
|
if (!optgroup) {
|
||||||
*/
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
og_it = std::find_if(page->m_optgroups.begin(), page->m_optgroups.end(), [](const ConfigOptionsGroupShp og) { return og->title == "Retraction when tool is disabled"; });
|
for (const std::string& opt_key : keys) {
|
||||||
if (og_it == page->m_optgroups.end())
|
bool is_checked{true};
|
||||||
return;
|
if (
|
||||||
optgroup = *og_it;
|
title == "Retraction"
|
||||||
|
&& opt_key != "filament_retract_length"
|
||||||
|
&& !have_retract_length
|
||||||
|
) {
|
||||||
|
is_checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (const std::string& opt_key : {"filament_retract_length_toolchange", "filament_retract_restart_extra_toolchange"})
|
if (
|
||||||
update_line_with_near_label_widget(optgroup, opt_key, extruder_idx);
|
title == "Travel lift"
|
||||||
|
&& uses_ramping_lift
|
||||||
|
&& opt_key == "filament_retract_lift"
|
||||||
|
&& !m_config->option("filament_travel_ramping_lift")->is_nil()
|
||||||
|
&& m_config->opt_bool("filament_travel_ramping_lift", extruder_idx)
|
||||||
|
) {
|
||||||
|
is_checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
title == "Travel lift"
|
||||||
|
&& !is_lifting
|
||||||
|
&& (
|
||||||
|
opt_key == "filament_retract_lift_above"
|
||||||
|
|| opt_key == "filament_retract_lift_below"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
is_checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
title == "Travel lift"
|
||||||
|
&& !uses_ramping_lift
|
||||||
|
&& opt_key != "filament_travel_ramping_lift"
|
||||||
|
&& opt_key != "filament_retract_lift"
|
||||||
|
&& opt_key != "filament_retract_lift_above"
|
||||||
|
&& opt_key != "filament_retract_lift_below"
|
||||||
|
) {
|
||||||
|
is_checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_line_with_near_label_widget(*optgroup, opt_key, extruder_idx, is_checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabFilament::create_extruder_combobox()
|
void TabFilament::create_extruder_combobox()
|
||||||
@ -3267,7 +3305,7 @@ void TabPrinter::build_extruder_pages(size_t n_before_extruders)
|
|||||||
|
|
||||||
optgroup = page->new_optgroup(L("Travel lift"));
|
optgroup = page->new_optgroup(L("Travel lift"));
|
||||||
optgroup->append_single_option_line("retract_lift", "", extruder_idx);
|
optgroup->append_single_option_line("retract_lift", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("travel_ramping_lift");
|
optgroup->append_single_option_line("travel_ramping_lift", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("travel_max_lift", "", extruder_idx);
|
optgroup->append_single_option_line("travel_max_lift", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("travel_slope", "", extruder_idx);
|
optgroup->append_single_option_line("travel_slope", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("travel_lift_before_obstacle", "", extruder_idx);
|
optgroup->append_single_option_line("travel_lift_before_obstacle", "", extruder_idx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user