FIX: Use the same api to get the extruder id

jira: none
Change-Id: I05b3040b176374deee3e95bc52364fe7b33bb257
(cherry picked from commit 8b2544df41456377b09719de15460b19b7c71e09)
This commit is contained in:
zhimin.zeng 2024-06-13 14:11:46 +08:00 committed by Noisyfox
parent cca85fe861
commit 57916c7452
9 changed files with 40 additions and 30 deletions

View file

@ -18,6 +18,11 @@ Extruder::Extruder(unsigned int id, GCodeConfig *config, bool share_extruder) :
m_e_per_mm3 /= this->filament_crossection();
}
unsigned int Extruder::extruder_id() const
{
return get_extruder_index(m_id);
}
double Extruder::extrude(double dE)
{
// BBS

View file

@ -29,13 +29,7 @@ public:
unsigned int id() const { return m_id; }
unsigned int extruder_id() const
{
//TODO: get extruder id
unsigned int extruder_id = -1;
// get matched id
return extruder_id;
}
unsigned int extruder_id() const;
double extrude(double dE);
double retract(double length, double restart_extra);
double unretract();

View file

@ -435,7 +435,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
if (new_filament_id != -1 && new_filament_id != tcr.new_tool)
throw Slic3r::InvalidArgument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
int new_extruder_id = gcodegen.get_extruder_id(new_filament_id);
int new_extruder_id = get_extruder_index(new_filament_id);
std::string gcode;
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
@ -2155,13 +2155,13 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_cooling_buffer = make_unique<CoolingBuffer>(*this);
m_cooling_buffer->set_current_extruder(initial_extruder_id);
int extruder_id = get_extruder_id(initial_extruder_id);
int extruder_id = get_extruder_index(initial_extruder_id);
// Orca: Initialise AdaptivePA processor filter
m_pa_processor = std::make_unique<AdaptivePAProcessor>(*this, tool_ordering.all_extruders());
// Emit machine envelope limits for the Marlin firmware.
this->print_machine_envelope(file, print);
this->print_machine_envelope(file, print, initial_extruder_id);
// Disable fan.
if (m_config.auxiliary_fan.value && print.config().close_fan_the_first_x_layers.get_at(initial_extruder_id)) {
@ -6370,7 +6370,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
std::string GCode::set_extruder(unsigned int filament_id, double print_z, bool by_object)
{
int extruder_id = get_extruder_id(filament_id);
int extruder_id = get_extruder_index(filament_id);
if (!m_writer.need_toolchange(filament_id))
return "";

View file

@ -193,11 +193,6 @@ public:
// throws std::runtime_exception on error,
// throws CanceledException through print->throw_if_canceled().
void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
int get_extruder_id(unsigned int) {
//TODO: get matched extruder
int extruder_id = -1;
return extruder_id;
};
//BBS: set offset for gcode writer
void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);}

View file

@ -2119,6 +2119,12 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
// BBS
size_t num_filaments = this->filament_presets.size();
// todo multi_extruders: to delete
for (size_t i = 0; i < num_filaments; ++i) {
this->filament_maps.push_back(1);
}
auto* extruder_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter"));
// Collect the "compatible_printers_condition" and "inherits" values over all presets (print, filaments, printers) into a single vector.
std::vector<std::string> compatible_printers_condition;

View file

@ -150,7 +150,8 @@ public:
std::map<int, DynamicPrintConfig> filament_ams_list;
std::vector<std::vector<std::string>> ams_multi_color_filment;
std::vector<int> filament_maps;
// todo multi_extruders: delete mutable
mutable std::vector<int> filament_maps;
// Calibrate
Preset const * calibrate_printer = nullptr;
std::set<Preset const *> calibrate_filaments;

View file

@ -53,6 +53,12 @@ namespace Slic3r {
#define L(s) (s)
#define _(s) Slic3r::I18N::translate(s)
size_t get_extruder_index(unsigned int filament_id)
{
// todo multi_extruders:
return 0;
}
static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values &enum_keys_map)
{
t_config_enum_names names;
@ -7486,13 +7492,14 @@ bool DynamicPrintConfig::support_different_extruders(int& extruder_count)
int size = nozzle_diameters_opt->size();
extruder_count = size;
auto extruder_variant_opt = dynamic_cast<const ConfigOptionStrings*>(this->option("extruder_variant_list"));
for (int index = 0; index < size; index++)
{
std::string variant = extruder_variant_opt->get_at(index);
std::vector<std::string> variants_list;
boost::split(variants_list, variant, boost::is_any_of(","), boost::token_compress_on);
if (!variants_list.empty())
variant_set.insert(variants_list.begin(), variants_list.end());
if (extruder_variant_opt != nullptr) {
for (int index = 0; index < size; index++) {
std::string variant = extruder_variant_opt->get_at(index);
std::vector<std::string> variants_list;
boost::split(variants_list, variant, boost::is_any_of(","), boost::token_compress_on);
if (!variants_list.empty())
variant_set.insert(variants_list.begin(), variants_list.end());
}
}
}
@ -7532,14 +7539,14 @@ void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::str
//apply process settings
//auto opt_nozzle_diameters = this->option<ConfigOptionFloats>("nozzle_diameter");
//int extruder_count = opt_nozzle_diameters->size();
auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("extruder_type"));
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("nozzle_volume_type"));
//auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("extruder_type"));
//auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("nozzle_volume_type"));
std::vector<int> variant_index;
if (extruder_id > 0 && extruder_id < extruder_count) {
variant_index.resize(1);
ExtruderType extruder_type = (ExtruderType)(opt_extruder_type->get_at(extruder_id - 1));
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType)(opt_nozzle_volume_type->get_at(extruder_id - 1));
ExtruderType extruder_type = ExtruderType::etDirectDrive; // TODO:Orca hack (ExtruderType)(opt_extruder_type->get_at(extruder_id - 1));
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal; // TODO:Orca hack (NozzleVolumeType)(opt_nozzle_volume_type->get_at(extruder_id - 1));
//variant index
variant_index[0] = get_index_for_extruder(extruder_id, id_name, extruder_type, nozzle_volume_type, variant_name);
@ -7551,8 +7558,8 @@ void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::str
for (int e_index = 0; e_index < extruder_count; e_index++)
{
ExtruderType extruder_type = (ExtruderType)(opt_extruder_type->get_at(e_index));
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType)(opt_nozzle_volume_type->get_at(e_index));
ExtruderType extruder_type = ExtruderType::etDirectDrive; // TODO:Orca hack (ExtruderType)(opt_extruder_type->get_at(e_index));
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal; // (NozzleVolumeType)(opt_nozzle_volume_type->get_at(e_index));
//variant index
variant_index[e_index] = get_index_for_extruder(e_index+1, id_name, extruder_type, nozzle_volume_type, variant_name);

View file

@ -457,6 +457,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type)
return "";
}
size_t get_extruder_index(unsigned int filament_id);
#define CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NAME) \
template<> const t_config_enum_names& ConfigOptionEnum<NAME>::get_enum_names(); \
template<> const t_config_enum_values& ConfigOptionEnum<NAME>::get_enum_values();

View file

@ -927,6 +927,7 @@ bool PrintObject::invalidate_state_by_config_options(
} else if (opt_key == "gap_infill_speed"
|| opt_key == "filter_out_gap_fill" ) {
// Return true if gap-fill speed has changed from zero value to non-zero or from non-zero value to zero.
// todo multi_extruders: Parameter migration between single and double extruder printers
auto is_gap_fill_changed_state_due_to_speed = [&opt_key, &old_config, &new_config]() -> bool {
if (opt_key == "gap_infill_speed") {
const auto *old_gap_fill_speed = old_config.option<ConfigOptionFloat>(opt_key);