FIX: Use the same api to get the extruder id

jira: none
Change-Id: I05b3040b176374deee3e95bc52364fe7b33bb257
This commit is contained in:
zhimin.zeng 2024-06-13 14:11:46 +08:00 committed by lane.wei
parent 8af6f6d13b
commit 8b2544df41
9 changed files with 34 additions and 29 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

@ -30,13 +30,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

@ -375,7 +375,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)
@ -1865,10 +1865,10 @@ 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);
// 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 (print.config().close_fan_the_first_x_layers.get_at(initial_extruder_id)) {
@ -5296,7 +5296,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

@ -171,11 +171,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

@ -1990,6 +1990,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

@ -125,7 +125,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

@ -54,6 +54,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;
@ -5378,8 +5384,8 @@ 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++)
{
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);
@ -5387,6 +5393,7 @@ bool DynamicPrintConfig::support_different_extruders(int& extruder_count)
variant_set.insert(variants_list.begin(), variants_list.end());
}
}
}
return (variant_set.size() > 1);
}

View File

@ -364,11 +364,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type)
return "";
}
static size_t get_extruder_index(unsigned int filament_id)
{
// todo:
return 0;
}
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(); \

View File

@ -714,6 +714,7 @@ bool PrintObject::invalidate_state_by_config_options(
steps.emplace_back(posPerimeters);
} 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);