mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-14 04:27:36 +00:00
Add per-filament overrides for toolchange retraction
This commit is contained in:
@@ -220,12 +220,12 @@ double Extruder::retract_restart_extra() const
|
|||||||
|
|
||||||
double Extruder::retract_length_toolchange() const
|
double Extruder::retract_length_toolchange() const
|
||||||
{
|
{
|
||||||
return m_config->retract_length_toolchange.get_at(extruder_id());
|
return m_config->retract_length_toolchange.get_at(m_config_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Extruder::retract_restart_extra_toolchange() const
|
double Extruder::retract_restart_extra_toolchange() const
|
||||||
{
|
{
|
||||||
return m_config->retract_restart_extra_toolchange.get_at(extruder_id());
|
return m_config->retract_restart_extra_toolchange.get_at(m_config_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Extruder::travel_slope() const
|
double Extruder::travel_slope() const
|
||||||
|
|||||||
@@ -1137,8 +1137,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||||||
|
|
||||||
float old_retract_length = (old_filament_id != -1) ? full_config.retraction_length.get_at(old_fi) : 0;
|
float old_retract_length = (old_filament_id != -1) ? full_config.retraction_length.get_at(old_fi) : 0;
|
||||||
float new_retract_length = full_config.retraction_length.get_at(new_fi);
|
float new_retract_length = full_config.retraction_length.get_at(new_fi);
|
||||||
float old_retract_length_toolchange = (old_filament_id != -1) ? full_config.retract_length_toolchange.get_at(old_filament_id) : 0;
|
float old_retract_length_toolchange = (old_filament_id != -1) ? full_config.retract_length_toolchange.get_at(old_fi) : 0;
|
||||||
float new_retract_length_toolchange = full_config.retract_length_toolchange.get_at(new_filament_id);
|
float new_retract_length_toolchange = full_config.retract_length_toolchange.get_at(new_fi);
|
||||||
int old_filament_temp = (old_filament_id != -1) ? (gcodegen.on_first_layer()? full_config.nozzle_temperature_initial_layer.get_at(old_fi) : full_config.nozzle_temperature.get_at(old_fi)) : 210;
|
int old_filament_temp = (old_filament_id != -1) ? (gcodegen.on_first_layer()? full_config.nozzle_temperature_initial_layer.get_at(old_fi) : full_config.nozzle_temperature.get_at(old_fi)) : 210;
|
||||||
int new_filament_temp = gcodegen.on_first_layer() ? full_config.nozzle_temperature_initial_layer.get_at(new_fi) : full_config.nozzle_temperature.get_at(new_fi);
|
int new_filament_temp = gcodegen.on_first_layer() ? full_config.nozzle_temperature_initial_layer.get_at(new_fi) : full_config.nozzle_temperature.get_at(new_fi);
|
||||||
Vec3d nozzle_pos = gcode_writer.get_position();
|
Vec3d nozzle_pos = gcode_writer.get_position();
|
||||||
@@ -9035,7 +9035,7 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
|
|||||||
// per-layer nozzle grouping; resolve the column instead of indexing by the filament id.
|
// per-layer nozzle grouping; resolve the column instead of indexing by the filament id.
|
||||||
size_t new_fi = get_filament_config_index((int)new_filament_id);
|
size_t new_fi = get_filament_config_index((int)new_filament_id);
|
||||||
float new_retract_length = m_config.retraction_length.get_at(new_fi);
|
float new_retract_length = m_config.retraction_length.get_at(new_fi);
|
||||||
float new_retract_length_toolchange = m_config.retract_length_toolchange.get_at(new_filament_id);
|
float new_retract_length_toolchange = m_config.retract_length_toolchange.get_at(new_fi);
|
||||||
int new_filament_temp = this->on_first_layer() ? m_config.nozzle_temperature_initial_layer.get_at(new_fi) : m_config.nozzle_temperature.get_at(new_fi);
|
int new_filament_temp = this->on_first_layer() ? m_config.nozzle_temperature_initial_layer.get_at(new_fi) : m_config.nozzle_temperature.get_at(new_fi);
|
||||||
// BBS: if print_z == 0 use first layer temperature
|
// BBS: if print_z == 0 use first layer temperature
|
||||||
if (abs(print_z) < EPSILON)
|
if (abs(print_z) < EPSILON)
|
||||||
@@ -9066,7 +9066,7 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
|
|||||||
// gap-filled carry-forward, so its current-layer column matches the nozzle it occupies.
|
// gap-filled carry-forward, so its current-layer column matches the nozzle it occupies.
|
||||||
size_t old_fi = get_filament_config_index(old_filament_id);
|
size_t old_fi = get_filament_config_index(old_filament_id);
|
||||||
old_retract_length = m_config.retraction_length.get_at(old_fi);
|
old_retract_length = m_config.retraction_length.get_at(old_fi);
|
||||||
old_retract_length_toolchange = m_config.retract_length_toolchange.get_at(old_filament_id);
|
old_retract_length_toolchange = m_config.retract_length_toolchange.get_at(old_fi);
|
||||||
old_filament_temp = this->on_first_layer()? m_config.nozzle_temperature_initial_layer.get_at(old_fi) : m_config.nozzle_temperature.get_at(old_fi);
|
old_filament_temp = this->on_first_layer()? m_config.nozzle_temperature_initial_layer.get_at(old_fi) : m_config.nozzle_temperature.get_at(old_fi);
|
||||||
|
|
||||||
//During the filament change, the extruder will extrude an extra length of grab_length for the corresponding detection, so the purge can reduce this length.
|
//During the filament change, the extruder will extrude an extra length of grab_length for the corresponding detection, so the purge can reduce this length.
|
||||||
|
|||||||
@@ -1350,6 +1350,8 @@ static std::vector<std::string> s_Preset_filament_options {/*"filament_colour",
|
|||||||
"filament_retraction_length",
|
"filament_retraction_length",
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
"filament_retraction_speed",
|
"filament_retraction_speed",
|
||||||
|
"filament_retract_length_toolchange",
|
||||||
|
"filament_retract_restart_extra_toolchange",
|
||||||
"filament_wipe",
|
"filament_wipe",
|
||||||
"filament_z_hop",
|
"filament_z_hop",
|
||||||
"filament_z_hop_types",
|
"filament_z_hop_types",
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ const std::vector<std::string> filament_extruder_override_keys = {
|
|||||||
"filament_deretraction_speed",
|
"filament_deretraction_speed",
|
||||||
"filament_retract_restart_extra", //not in filament_options_with_variant, added on 20250816
|
"filament_retract_restart_extra", //not in filament_options_with_variant, added on 20250816
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
|
"filament_retract_length_toolchange",
|
||||||
|
"filament_retract_restart_extra_toolchange",
|
||||||
// BBS: floats
|
// BBS: floats
|
||||||
"filament_wipe_distance",
|
"filament_wipe_distance",
|
||||||
// bools
|
// bools
|
||||||
@@ -5706,12 +5708,10 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->set_default_value(new ConfigOptionFloatsNullable{10});
|
def->set_default_value(new ConfigOptionFloatsNullable{10});
|
||||||
|
|
||||||
def = this->add("retract_length_toolchange", coFloats);
|
def = this->add("retract_length_toolchange", coFloats);
|
||||||
def->label = L("Length");
|
def->label = L("Retraction Length (Toolchange)");
|
||||||
//def->full_label = L("Retraction Length (Toolchange)");
|
def->tooltip = L("When retraction is triggered before changing tool, filament is pulled back "
|
||||||
def->full_label = "Retraction Length (Toolchange)";
|
"by the specified amount (the length is measured on raw filament, before it enters "
|
||||||
//def->tooltip = L("When retraction is triggered before changing tool, filament is pulled back "
|
"the extruder).");
|
||||||
// "by the specified amount (the length is measured on raw filament, before it enters "
|
|
||||||
// "the extruder).");
|
|
||||||
def->sidetext = L("mm"); // millimeters, CIS languages need translation
|
def->sidetext = L("mm"); // millimeters, CIS languages need translation
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionFloats { 10. });
|
def->set_default_value(new ConfigOptionFloats { 10. });
|
||||||
@@ -5965,7 +5965,7 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->set_default_value(new ConfigOptionFloats { 0. });
|
def->set_default_value(new ConfigOptionFloats { 0. });
|
||||||
|
|
||||||
def = this->add("retract_restart_extra_toolchange", coFloats);
|
def = this->add("retract_restart_extra_toolchange", coFloats);
|
||||||
def->label = L("Extra length on restart");
|
def->label = L("Extra length on restart (Toolchange)");
|
||||||
def->tooltip = L("When the retraction is compensated after changing tool, the extruder will push "
|
def->tooltip = L("When the retraction is compensated after changing tool, the extruder will push "
|
||||||
"this additional amount of filament.");
|
"this additional amount of filament.");
|
||||||
def->sidetext = L("mm"); // millimeters, CIS languages need translation
|
def->sidetext = L("mm"); // millimeters, CIS languages need translation
|
||||||
@@ -8135,10 +8135,12 @@ void PrintConfigDef::init_extruder_option_keys()
|
|||||||
"long_retractions_when_cut",
|
"long_retractions_when_cut",
|
||||||
"retract_after_wipe",
|
"retract_after_wipe",
|
||||||
"retract_before_wipe",
|
"retract_before_wipe",
|
||||||
|
"retract_length_toolchange",
|
||||||
"retract_lift_above",
|
"retract_lift_above",
|
||||||
"retract_lift_below",
|
"retract_lift_below",
|
||||||
"retract_lift_enforce",
|
"retract_lift_enforce",
|
||||||
"retract_restart_extra",
|
"retract_restart_extra",
|
||||||
|
"retract_restart_extra_toolchange",
|
||||||
"retract_when_changing_layer",
|
"retract_when_changing_layer",
|
||||||
"retraction_distances_when_cut",
|
"retraction_distances_when_cut",
|
||||||
"retraction_length",
|
"retraction_length",
|
||||||
@@ -9226,6 +9228,8 @@ std::set<std::string> filament_options_with_variant = {
|
|||||||
"filament_retract_lift_below",
|
"filament_retract_lift_below",
|
||||||
"filament_retract_lift_enforce",
|
"filament_retract_lift_enforce",
|
||||||
"filament_retract_restart_extra",
|
"filament_retract_restart_extra",
|
||||||
|
"filament_retract_length_toolchange",
|
||||||
|
"filament_retract_restart_extra_toolchange",
|
||||||
"filament_retraction_speed",
|
"filament_retraction_speed",
|
||||||
"filament_deretraction_speed",
|
"filament_deretraction_speed",
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
|
|||||||
@@ -3997,13 +3997,12 @@ void TabFilament::add_filament_overrides_page()
|
|||||||
|
|
||||||
const int extruder_idx = 0; // #ys_FIXME
|
const int extruder_idx = 0; // #ys_FIXME
|
||||||
|
|
||||||
ConfigOptionsGroupShp retraction_optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
auto append_retraction_option = [this](ConfigOptionsGroupShp optgroup, const std::string& opt_key, int opt_index)
|
||||||
auto append_retraction_option = [this, retraction_optgroup](const std::string& opt_key, int opt_index)
|
|
||||||
{
|
{
|
||||||
Line line {"",""};
|
Line line {"",""};
|
||||||
line = retraction_optgroup->create_single_option_line(retraction_optgroup->get_option(opt_key, opt_index));
|
line = optgroup->create_single_option_line(optgroup->get_option(opt_key, opt_index));
|
||||||
|
|
||||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(retraction_optgroup), opt_key, opt_index](wxWindow* parent) {
|
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||||
auto check_box = new ::CheckBox(parent); // ORCA modernize checkboxes
|
auto check_box = new ::CheckBox(parent); // ORCA modernize checkboxes
|
||||||
check_box->Bind(wxEVT_TOGGLEBUTTON, [this, optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
check_box->Bind(wxEVT_TOGGLEBUTTON, [this, optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
||||||
const bool is_checked = evt.IsChecked();
|
const bool is_checked = evt.IsChecked();
|
||||||
@@ -4030,9 +4029,10 @@ void TabFilament::add_filament_overrides_page()
|
|||||||
return check_box;
|
return check_box;
|
||||||
};
|
};
|
||||||
|
|
||||||
retraction_optgroup->append_line(line);
|
optgroup->append_line(line);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ConfigOptionsGroupShp retraction_optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
||||||
for (const std::string opt_key : { "filament_retraction_length",
|
for (const std::string opt_key : { "filament_retraction_length",
|
||||||
"filament_z_hop",
|
"filament_z_hop",
|
||||||
"filament_z_hop_types",
|
"filament_z_hop_types",
|
||||||
@@ -4056,7 +4056,13 @@ void TabFilament::add_filament_overrides_page()
|
|||||||
//SoftFever
|
//SoftFever
|
||||||
// "filament_seam_gap"
|
// "filament_seam_gap"
|
||||||
})
|
})
|
||||||
append_retraction_option(opt_key, extruder_idx);
|
append_retraction_option(retraction_optgroup, opt_key, extruder_idx);
|
||||||
|
|
||||||
|
ConfigOptionsGroupShp toolchange_optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction_material_change");
|
||||||
|
for (const std::string opt_key : { "filament_retract_length_toolchange",
|
||||||
|
"filament_retract_restart_extra_toolchange"
|
||||||
|
})
|
||||||
|
append_retraction_option(toolchange_optgroup, opt_key, extruder_idx);
|
||||||
|
|
||||||
ConfigOptionsGroupShp ironing_optgroup = page->new_optgroup(L("Ironing"), L"param_ironing");
|
ConfigOptionsGroupShp ironing_optgroup = page->new_optgroup(L("Ironing"), L"param_ironing");
|
||||||
auto append_ironing_option = [this, ironing_optgroup](const std::string& opt_key, int opt_index)
|
auto append_ironing_option = [this, ironing_optgroup](const std::string& opt_key, int opt_index)
|
||||||
@@ -4171,6 +4177,8 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
|||||||
"filament_retraction_speed",
|
"filament_retraction_speed",
|
||||||
"filament_deretraction_speed",
|
"filament_deretraction_speed",
|
||||||
"filament_retract_restart_extra",
|
"filament_retract_restart_extra",
|
||||||
|
"filament_retract_length_toolchange",
|
||||||
|
"filament_retract_restart_extra_toolchange",
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
"filament_retract_when_changing_layer",
|
"filament_retract_when_changing_layer",
|
||||||
"filament_wipe",
|
"filament_wipe",
|
||||||
@@ -4201,7 +4209,8 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
|||||||
is_checked &= !dynamic_cast<ConfigOptionVectorBase*>(m_config->option(opt_key))->is_nil(extruder_idx);
|
is_checked &= !dynamic_cast<ConfigOptionVectorBase*>(m_config->option(opt_key))->is_nil(extruder_idx);
|
||||||
m_overrides_options[opt_key]->SetValue(is_checked);
|
m_overrides_options[opt_key]->SetValue(is_checked);
|
||||||
|
|
||||||
Field* field = optgroup->get_fieldc(opt_key, 0);
|
// the toolchange overrides live in their own optgroup, so search the whole page
|
||||||
|
Field* field = page->get_field(opt_key, 0);
|
||||||
if (field == nullptr) continue;
|
if (field == nullptr) continue;
|
||||||
|
|
||||||
if (opt_key == "filament_long_retractions_when_cut") {
|
if (opt_key == "filament_long_retractions_when_cut") {
|
||||||
|
|||||||
Reference in New Issue
Block a user