diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index f5b2121317..1046109e70 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -706,8 +706,8 @@ void GCodeProcessor::apply_config(const PrintConfig& config) m_single_extruder_multi_material = config.single_extruder_multi_material; - size_t extruders_count = config.filament_diameter.values.size(); - m_result.filaments_count = extruders_count; + size_t filament_count = config.filament_diameter.values.size(); + m_result.filaments_count = filament_count; // Orca: m_is_XL_printer = is_XL_printer(config); @@ -718,19 +718,27 @@ void GCodeProcessor::apply_config(const PrintConfig& config) m_preheat_steps = 1; m_result.backtrace_enabled = m_preheat_time > 0 && (m_is_XL_printer || (!m_single_extruder_multi_material && extruders_count > 1)); - m_extruder_offsets.resize(extruders_count); - m_extruder_colors.resize(extruders_count); - m_result.filament_diameters.resize(extruders_count); - m_result.required_nozzle_HRC.resize(extruders_count); - m_result.filament_densities.resize(extruders_count); - m_result.filament_vitrification_temperature.resize(extruders_count); - m_result.filament_costs.resize(extruders_count); - m_extruder_temps.resize(extruders_count); - m_extruder_temps_config.resize(extruders_count); - m_extruder_temps_first_layer_config.resize(extruders_count); + assert(config.nozzle_volume.size() == config.nozzle_diameter.size()); + m_nozzle_volume.resize(config.nozzle_volume.size()); + for (size_t idx = 0; idx < config.nozzle_volume.size(); ++idx) + m_nozzle_volume[idx] = config.nozzle_volume.values[idx]; + + m_extruder_offsets.resize(filament_count); + m_extruder_colors.resize(filament_count); + m_result.filament_diameters.resize(filament_count); + m_result.required_nozzle_HRC.resize(filament_count); + m_result.filament_densities.resize(filament_count); + m_result.filament_vitrification_temperature.resize(filament_count); + m_result.filament_costs.resize(filament_count); + m_extruder_temps.resize(filament_count); + m_extruder_temps_config.resize(filament_count); + m_extruder_temps_first_layer_config.resize(filament_count); m_result.nozzle_hrc = static_cast(config.nozzle_hrc.getInt()); - m_result.nozzle_type = config.nozzle_type; - for (size_t i = 0; i < extruders_count; ++ i) { + std::vector(config.nozzle_type.size()).swap(m_result.nozzle_type); + for (size_t idx = 0; idx < m_result.nozzle_type.size(); ++idx) { + m_result.nozzle_type[idx] = NozzleType(config.nozzle_type.values[idx]); + } + for (size_t i = 0; i < filament_count; ++ i) { m_extruder_offsets[i] = to_3d(config.extruder_offset.get_at(i).cast().eval(), 0.f); m_extruder_colors[i] = static_cast(i); m_extruder_temps_first_layer_config[i] = static_cast(config.nozzle_temperature_initial_layer.get_at(i)); @@ -820,16 +828,23 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) m_parser.apply_config(config); //BBS - const ConfigOptionFloat* nozzle_volume = config.option("nozzle_volume"); - if (nozzle_volume != nullptr) - m_nozzle_volume = nozzle_volume->value; + const ConfigOptionFloatsNullable* nozzle_volume = config.option("nozzle_volume"); + if (nozzle_volume != nullptr) { + m_nozzle_volume.resize(nozzle_volume->size(), 0); + for (size_t idx = 0; idx < nozzle_volume->size(); ++idx) + m_nozzle_volume[idx] = nozzle_volume->values[idx]; + } const ConfigOptionInt *nozzle_HRC = config.option("nozzle_hrc"); if (nozzle_HRC != nullptr) m_result.nozzle_hrc = nozzle_HRC->value; - const ConfigOptionEnum* nozzle_type = config.option>("nozzle_type"); - if (nozzle_type != nullptr) - m_result.nozzle_type=nozzle_type->value; + const ConfigOptionEnumsGenericNullable* nozzle_type = config.option("nozzle_type"); + if (nozzle_type != nullptr) { + m_result.nozzle_type.resize(nozzle_type->size()); + for (size_t idx = 0; idx < nozzle_type->values.size(); ++idx) { + m_result.nozzle_type[idx] = NozzleType(nozzle_type->values[idx]); + } + } const ConfigOptionEnum* gcode_flavor = config.option>("gcode_flavor"); if (gcode_flavor != nullptr) @@ -1139,7 +1154,7 @@ void GCodeProcessor::reset() m_e_local_positioning_type = EPositioningType::Absolute; m_extruder_offsets = std::vector(MIN_EXTRUDERS_COUNT, Vec3f::Zero()); m_flavor = gcfRepRapSprinter; - m_nozzle_volume = 0.f; + m_nozzle_volume = {0.f,0.f}; m_start_position = { 0.0f, 0.0f, 0.0f, 0.0f }; m_end_position = { 0.0f, 0.0f, 0.0f, 0.0f }; @@ -1148,7 +1163,7 @@ void GCodeProcessor::reset() m_wiping = false; m_flushing = false; m_wipe_tower = false; - m_remaining_volume = 0.f; + m_remaining_volume = { 0.f,0.f }; // BBS: arc move related data m_move_path_type = EMovePathType::Noop_move; m_arc_center = Vec3f::Zero(); @@ -2749,16 +2764,17 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line, const std::o #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING } else if (type == EMoveType::Unretract && m_flushing) { + int extruder_id = get_extruder_id(); float volume_flushed_filament = area_filament_cross_section * delta_pos[E]; - if (m_remaining_volume > volume_flushed_filament) + if (m_remaining_volume[extruder_id] > volume_flushed_filament) { m_used_filaments.update_flush_per_filament(last_filament_id, volume_flushed_filament); - m_remaining_volume -= volume_flushed_filament; + m_remaining_volume[extruder_id] -= volume_flushed_filament; } else { - m_used_filaments.update_flush_per_filament(last_filament_id, m_remaining_volume); - m_used_filaments.update_flush_per_filament(filament_id, volume_flushed_filament - m_remaining_volume); - m_remaining_volume = 0.f; + m_used_filaments.update_flush_per_filament(last_filament_id, m_remaining_volume[extruder_id]); + m_used_filaments.update_flush_per_filament(filament_id, volume_flushed_filament - m_remaining_volume[extruder_id]); + m_remaining_volume[extruder_id] = 0.f; } } @@ -5105,7 +5121,8 @@ void GCodeProcessor::process_filaments(CustomGCode::Type code) m_used_filaments.process_support_cache(this); m_used_filaments.process_total_volume_cache(this); //BBS: reset remaining filament - m_remaining_volume = m_nozzle_volume; + size_t last_extruder_id = get_extruder_id(); + m_remaining_volume[last_extruder_id] = m_nozzle_volume[last_extruder_id]; } } @@ -5148,24 +5165,24 @@ void GCodeProcessor::update_slice_warnings() { m_result.warnings.clear(); - auto get_used_extruders = [this]() { - std::vector used_extruders; - used_extruders.reserve(m_used_filaments.total_volumes_per_filament.size()); + auto get_used_filaments = [this]() { + std::vector used_filaments; + used_filaments.reserve(m_used_filaments.total_volumes_per_filament.size()); for (auto item : m_used_filaments.total_volumes_per_filament) { - used_extruders.push_back(item.first); + used_filaments.push_back(item.first); } - return used_extruders; + return used_filaments; }; - auto used_extruders = get_used_extruders(); - assert(!used_extruders.empty()); + auto used_filaments = get_used_filaments(); + assert(!used_filaments.empty()); GCodeProcessorResult::SliceWarning warning; warning.level = 1; if (m_highest_bed_temp != 0) { - for (size_t i = 0; i < used_extruders.size(); i++) { - int temperature = get_filament_vitrification_temperature(used_extruders[i]); + for (size_t i = 0; i < used_filaments.size(); i++) { + int temperature = get_filament_vitrification_temperature(used_filaments[i]); if (temperature != 0 && m_highest_bed_temp >= temperature) - warning.params.push_back(std::to_string(used_extruders[i])); + warning.params.push_back(std::to_string(used_filaments[i])); } } @@ -5179,17 +5196,26 @@ void GCodeProcessor::update_slice_warnings() warning.params.clear(); warning.level=1; - int nozzle_hrc = m_result.nozzle_hrc; - if(nozzle_hrc <= 0) - nozzle_hrc = Print::get_hrc_by_nozzle_type(m_result.nozzle_type); - if (nozzle_hrc!=0) { - for (size_t i = 0; i < used_extruders.size(); i++) { - int HRC=0; - if (used_extruders[i] < m_result.required_nozzle_HRC.size()) - HRC = m_result.required_nozzle_HRC[used_extruders[i]]; - if (HRC != 0 && (nozzle_hrcnozzle_hrc_lists(m_result.nozzle_type.size(), 0); + // store the nozzle hrc of each extruder + for (size_t idx = 0; idx < m_result.nozzle_type.size(); ++idx) + nozzle_hrc_lists[idx] = m_result.nozzle_hrc; + if(nozzle_hrc_lists[idx] <= 0) + nozzle_hrc_lists[idx] = Print::get_hrc_by_nozzle_type(m_result.nozzle_type[idx]); + + for (size_t idx = 0; idx < used_filaments.size(); ++idx) { + int filament_hrc = 0; + + if (used_filaments[idx] < m_result.required_nozzle_HRC.size()) + filament_hrc = m_result.required_nozzle_HRC[used_filaments[idx]]; + + int filament_extruder_id = m_filament_maps[used_filaments[idx]]; + int extruder_hrc = nozzle_hrc_lists[filament_extruder_id]; + + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": Check HRC: filament:%1%, hrc=%2%, extruder:%3%, hrc:%4%") % used_filaments[idx] % filament_hrc % filament_extruder_id % extruder_hrc; + + if (extruder_hrc!=0 && extruder_hrc < filament_hrc) + warning.params.push_back(std::to_string(used_filaments[idx])); } if (!warning.params.empty()) { diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 00de2a6600..3da88e0e61 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -226,7 +226,7 @@ class Print; //BBS std::vector warnings; int nozzle_hrc; - NozzleType nozzle_type; + std::vector nozzle_type; BedType bed_type = BedType::btCount; #if ENABLE_GCODE_VIEWER_STATISTICS int64_t time{ 0 }; @@ -680,7 +680,7 @@ class Print; EPositioningType m_e_local_positioning_type; std::vector m_extruder_offsets; GCodeFlavor m_flavor; - float m_nozzle_volume; + std::vector m_nozzle_volume; AxisCoords m_start_position; // mm AxisCoords m_end_position; // mm AxisCoords m_origin; // mm diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index aceac9b000..9b7d06c39f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3099,7 +3099,7 @@ void PrintConfigDef::init_fff_params() // def->mode = comSimple; // def->set_default_value(new ConfigOptionBool(false)); - def = this->add("nozzle_type", coEnum); + def = this->add("nozzle_type", coEnums); def->label = L("Nozzle type"); def->tooltip = L("The metallic material of nozzle. This determines the abrasive resistance of nozzle, and " "what kind of filament can be printed."); @@ -3113,7 +3113,8 @@ void PrintConfigDef::init_fff_params() def->enum_labels.push_back(L("Stainless steel")); def->enum_labels.push_back(L("Brass")); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionEnum(ntUndefine)); + def->nullable = true; + def->set_default_value(new ConfigOptionEnumsGenericNullable({ ntUndefine })); def = this->add("nozzle_hrc", coInt); @@ -4025,15 +4026,15 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->cli = ConfigOptionDef::nocli; def->set_default_value(new ConfigOptionEnum(htOctoPrint)); - - def = this->add("nozzle_volume", coFloat); + def = this->add("nozzle_volume", coFloats); def->label = L("Nozzle volume"); def->tooltip = L("Volume of nozzle between the cutter and the end of nozzle."); def->sidetext = u8"mm³"; // cubic milimeters, don't need translation def->mode = comAdvanced; def->readonly = false; - def->set_default_value(new ConfigOptionFloat { 0.0 }); + def->nullable = true; + def->set_default_value(new ConfigOptionFloatsNullable { {0.0} }); def = this->add("cooling_tube_retraction", coFloat); def->label = L("Cooling tube position"); @@ -7182,6 +7183,8 @@ const PrintConfigDef print_config_def; //todo std::set print_options_with_variant = { + "initial_layer_speed", + "initial_layer_infill_speed", "outer_wall_speed", "inner_wall_speed", "small_perimeter_speed", @@ -7196,8 +7199,8 @@ std::set print_options_with_variant = { "overhang_4_4_speed", "bridge_speed", "gap_infill_speed", - "initial_layer_speed", - "initial_layer_infill_speed", + "support_speed", + "support_interface_speed", "travel_speed", "travel_speed_z", "default_acceleration", @@ -7206,8 +7209,6 @@ std::set print_options_with_variant = { "inner_wall_acceleration", "sparse_infill_acceleration", "top_surface_acceleration", - "support_interface_speed", - "support_speed", "print_extruder_id", "print_extruder_variant" }; @@ -7261,6 +7262,8 @@ std::set printer_options_with_variant_1 = { "retract_restart_extra_toolchange", "long_retractions_when_cut", "retraction_distances_when_cut", + "nozzle_volume", + "nozzle_type", "printer_extruder_id", "printer_extruder_variant" }; @@ -7528,6 +7531,7 @@ size_t DynamicPrintConfig::get_parameter_size(const std::string& param_name, siz if (nozzle_volume_type_opt) { volume_type_size = nozzle_volume_type_opt->values.size(); } + bool flag = (param_name == "nozzle_volume"); if (printer_options_with_variant_1.count(param_name) > 0) { return extruder_nums * volume_type_size; } diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index b8f08e4639..20e4213e8e 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1257,7 +1257,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, machine_pause_gcode)) ((ConfigOptionString, template_custom_gcode)) //BBS - ((ConfigOptionEnum, nozzle_type)) + ((ConfigOptionEnumsGenericNullable,nozzle_type)) ((ConfigOptionInt, nozzle_hrc)) ((ConfigOptionBool, auxiliary_fan)) ((ConfigOptionBool, support_air_filtration)) @@ -1446,7 +1446,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( // BBS: project filaments ((ConfigOptionFloats, filament_colour_new)) // BBS: not in any preset, calculated before slicing - ((ConfigOptionFloat, nozzle_volume)) + ((ConfigOptionFloatsNullable, nozzle_volume)) ((ConfigOptionPoints, start_end_points)) ((ConfigOptionEnum, timelapse_type)) ((ConfigOptionString, thumbnails)) diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index dfdbd6f446..54a5ca6469 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -309,6 +309,7 @@ public: std::vector get_extruders(bool conside_custom_gcode = false) const; std::vector get_extruders_under_cli(bool conside_custom_gcode, DynamicPrintConfig& full_config) const; std::vector get_extruders_without_support(bool conside_custom_gcode = false) const; + // get used filaments, 1 based idx std::vector get_used_extruders(); /* instance related operations*/ @@ -490,6 +491,7 @@ public: bool has_auto_filament_map_reslut(); void set_auto_filament_map_result(bool has_result); + // get filament map, 0 based filament ids, 1 based extruder ids std::vector get_filament_maps(); void set_filament_maps(const std::vector& f_maps); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e2ac77800c..b31bbc4fa4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -496,8 +496,8 @@ std::vector get_min_flush_volumes(const DynamicPrintConfig &full_config, si //const auto& full_config = wxGetApp().preset_bundle->full_config(); //auto& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config; - const ConfigOption* nozzle_volume_opt = full_config.option("nozzle_volume"); - int nozzle_volume_val = nozzle_volume_opt ? (int)nozzle_volume_opt->getFloat() : 0; + const ConfigOptionFloatsNullable* nozzle_volume_opt = full_config.option("nozzle_volume"); + int nozzle_volume_val = nozzle_volume_opt ? (int)nozzle_volume_opt->get_at(nozzle_id) : 0; const ConfigOptionInt* enable_long_retraction_when_cut_opt = full_config.option("enable_long_retraction_when_cut"); int machine_enabled_level = 0; diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index 42454854bc..0b2865e459 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -97,18 +97,36 @@ static bool is_same_nozzle_diameters(const DynamicPrintConfig &full_config, cons try { std::string nozzle_type; - const ConfigOptionEnum * config_nozzle_type = full_config.option>("nozzle_type"); - nozzle_type = NozzleTypeEumnToStr[config_nozzle_type->value]; + + const ConfigOptionEnumsGenericNullable * config_nozzle_type = full_config.option("nozzle_type"); + std::vector config_nozzle_types_str(config_nozzle_type->size()); + for (size_t idx = 0; idx < config_nozzle_type->size(); ++idx) + config_nozzle_types_str[idx] = NozzleTypeEumnToStr[NozzleType(config_nozzle_type->values[idx])]; auto opt_nozzle_diameters = full_config.option("nozzle_diameter"); - if (opt_nozzle_diameters != nullptr) { - float preset_nozzle_diameter = opt_nozzle_diameters->get_at(0); - if (preset_nozzle_diameter != obj->m_extder_data.extders[0].current_nozzle_diameter) { - wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"), wxString::Format("%.1f", preset_nozzle_diameter).ToStdString(), to_wstring_name(nozzle_type)); - wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj->m_extder_data.extders[0].current_nozzle_diameter, to_wstring_name(NozzleTypeEumnToStr[obj->m_extder_data.extders[0].current_nozzle_type])); - error_msg = _L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?") + "\n " + nozzle_in_preset + - "\n " + nozzle_in_printer + "\n"; + std::vector config_nozzle_diameters(opt_nozzle_diameters->size()); + for (size_t idx = 0; idx < opt_nozzle_diameters->size(); ++idx) + config_nozzle_diameters[idx] = opt_nozzle_diameters->values[idx]; + + std::vector machine_nozzle_diameters(obj->m_extder_data.extders.size()); + for (size_t idx = 0; idx < obj->m_extder_data.extders.size(); ++idx) + machine_nozzle_diameters[idx] = obj->m_extder_data.extders[idx].current_nozzle_diameter; + + if (config_nozzle_diameters.size() != machine_nozzle_diameters.size()) { + wxString nozzle_in_preset = wxString::Format(_L("nozzle size in preset: %d"), config_nozzle_diameters.size()); + wxString nozzle_in_printer = wxString::Format(_L("nozzle size memorized: %d"), machine_nozzle_diameters.size()); + error_msg = _L("The size of nozzle type in preset is not consistent with memorized nozzle.Did you change your nozzle lately ? ") + "\n " + nozzle_in_preset + + "\n " + nozzle_in_printer + "\n"; + return false; + } + + for (size_t idx = 0; idx < config_nozzle_diameters.size(); ++idx) { + if (config_nozzle_diameters[idx] != machine_nozzle_diameters[idx]) { + wxString nozzle_in_preset = wxString::Format(_L("nozzle[%d] in preset: %.1f"), idx, config_nozzle_diameters[idx]); + wxString nozzle_in_printer = wxString::Format(_L("nozzle[%d] memorized: %.1f"), idx, machine_nozzle_diameters[idx]); + error_msg = _L("Your nozzle type in preset is not consistent with memorized nozzle.Did you change your nozzle lately ? ") + "\n " + nozzle_in_preset + + "\n " + nozzle_in_printer + "\n"; return false; } }