Limiting the application of Machine Limits

https://github.com/prusa3d/PrusaSlicer/issues/1212

WIP: The hints do not rescale when switching the "usage" combo box.
The new g-code time estimator needs to be updated to not read
the machine limits if not enabled.
This commit is contained in:
bubnikv 2020-10-02 17:31:55 +02:00
parent 0f44caa99c
commit 8df01818dd
11 changed files with 161 additions and 50 deletions

View file

@ -1084,6 +1084,8 @@ boost::any& Choice::get_value()
m_value = static_cast<IroningType>(ret_enum);
else if (m_opt_id.compare("gcode_flavor") == 0)
m_value = static_cast<GCodeFlavor>(ret_enum);
else if (m_opt_id.compare("machine_limits_usage") == 0)
m_value = static_cast<MachineLimitsUsage>(ret_enum);
else if (m_opt_id.compare("support_material_pattern") == 0)
m_value = static_cast<SupportMaterialPattern>(ret_enum);
else if (m_opt_id.compare("seam_position") == 0)

View file

@ -184,6 +184,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
config.set_key_value(opt_key, new ConfigOptionEnum<IroningType>(boost::any_cast<IroningType>(value)));
else if (opt_key.compare("gcode_flavor") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<GCodeFlavor>(boost::any_cast<GCodeFlavor>(value)));
else if (opt_key.compare("machine_limits_usage") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<MachineLimitsUsage>(boost::any_cast<MachineLimitsUsage>(value)));
else if (opt_key.compare("support_material_pattern") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialPattern>(boost::any_cast<SupportMaterialPattern>(value)));
else if (opt_key.compare("seam_position") == 0)

View file

@ -821,6 +821,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
else if (opt_key == "gcode_flavor") {
ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value);
}
else if (opt_key == "machine_limits_usage") {
ret = static_cast<int>(config.option<ConfigOptionEnum<MachineLimitsUsage>>(opt_key)->value);
}
else if (opt_key == "support_material_pattern") {
ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value);
}

View file

@ -2510,6 +2510,7 @@ void TabPrinter::build_sla()
build_preset_description_line(optgroup.get());
}
/*
void TabPrinter::update_serial_ports()
{
@ -2556,7 +2557,18 @@ PageShp TabPrinter::build_kinematics_page()
{
auto page = add_options_page(L("Machine limits"), "cog", true);
if (m_use_silent_mode) {
auto optgroup = page->new_optgroup(L("General"));
{
optgroup->append_single_option_line("machine_limits_usage");
Line line { "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
return description_line_widget(parent, &m_machine_limits_description_line);
};
optgroup->append_line(line);
}
if (m_use_silent_mode) {
// Legend for OptionsGroups
auto optgroup = page->new_optgroup("");
optgroup->set_show_modified_btns_val(false);
@ -2583,7 +2595,7 @@ PageShp TabPrinter::build_kinematics_page()
}
std::vector<std::string> axes{ "x", "y", "z", "e" };
auto optgroup = page->new_optgroup(L("Maximum feedrates"));
optgroup = page->new_optgroup(L("Maximum feedrates"));
for (const std::string &axis : axes) {
append_option_line(optgroup, "machine_max_feedrate_" + axis);
}
@ -2953,6 +2965,17 @@ void TabPrinter::toggle_options()
toggle_option("retract_restart_extra_toolchange", have_multiple_extruders && toolchange_retraction, i);
}
if (m_active_page->title() == "Machine limits") {
assert(m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlin);
const auto *machine_limits_usage = m_config->option<ConfigOptionEnum<MachineLimitsUsage>>("machine_limits_usage");
bool enabled = machine_limits_usage->value != MachineLimitsUsage::Ignore;
bool silent_mode = m_config->opt_bool("silent_mode");
int max_field = silent_mode ? 2 : 1;
for (const std::string &opt : Preset::machine_limits_options())
for (int i = 0; i < max_field; ++ i)
toggle_option(opt, enabled, i);
update_machine_limits_description(machine_limits_usage->value);
}
}
void TabPrinter::update()
@ -3847,6 +3870,25 @@ void TabPrinter::apply_extruder_cnt_from_cache()
}
}
void TabPrinter::update_machine_limits_description(const MachineLimitsUsage usage)
{
wxString text;
switch (usage) {
case MachineLimitsUsage::EmitToGCode:
text = _L("Machine limits will be emitted to G-code and used to estimate print time.");
break;
case MachineLimitsUsage::TimeEstimateOnly:
text = _L("Machine limits will NOT be emitted to G-code, however they will be used to estimate print time, \
which may herefore not be accurate as the printer may apply a different set of machine limits.");
break;
case MachineLimitsUsage::Ignore:
text = _L("Machine limits are not set, therefore the print time estimate may not be accurate.");
break;
default: assert(false);
}
m_machine_limits_description_line->SetText(text);
}
void Tab::compatible_widget_reload(PresetDependencies &deps)
{
Field* field = this->get_field(deps.key_condition);

View file

@ -376,10 +376,6 @@ public:
Tab(parent, _(L("Print Settings")), Slic3r::Preset::TYPE_PRINT) {}
~TabPrint() {}
ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr;
ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr;
bool m_support_material_overhangs_queried = false;
void build() override;
void reload_config() override;
void update_description_lines() override;
@ -388,10 +384,16 @@ public:
// void OnActivate() override;
void clear_pages() override;
bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; }
private:
ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr;
ogStaticText* m_top_bottom_shell_thickness_explanation = nullptr;
bool m_support_material_overhangs_queried = false;
};
class TabFilament : public Tab
{
private:
ogStaticText* m_volumetric_speed_description_line {nullptr};
ogStaticText* m_cooling_description_line {nullptr};
@ -418,10 +420,13 @@ public:
class TabPrinter : public Tab
{
private:
bool m_has_single_extruder_MM_page = false;
bool m_use_silent_mode = false;
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key);
bool m_rebuild_kinematics_page = false;
ogStaticText* m_machine_limits_description_line {nullptr};
void update_machine_limits_description(const MachineLimitsUsage usage);
std::vector<PageShp> m_pages_fff;
std::vector<PageShp> m_pages_sla;

View file

@ -809,6 +809,8 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
return get_string_from_enum<InfillPattern>(opt_key, config, true);
if (opt_key == "gcode_flavor")
return get_string_from_enum<GCodeFlavor>(opt_key, config);
if (opt_key == "machine_limits_usage")
return get_string_from_enum<MachineLimitsUsage>(opt_key, config);
if (opt_key == "ironing_type")
return get_string_from_enum<IroningType>(opt_key, config);
if (opt_key == "support_material_pattern")