ENH: move filament compatibility checking to public

As title. This function need to be used in calibration
page.

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: Ia4228cbd195d87f433b59bc14129bd4acdd9df68
This commit is contained in:
salt.wei 2023-06-30 15:46:34 +08:00 committed by Lane.Wei
parent dac0a90605
commit 73059c79af
2 changed files with 37 additions and 25 deletions

View File

@ -880,8 +880,9 @@ static StringObjectException layered_print_cleareance_valid(const Print &print,
return {}; return {};
} }
//BBS bool Print::check_multi_filaments_compatibility(const std::vector<std::string>& filament_types)
static std::map<std::string, bool> filament_is_high_temp { {
static std::map<std::string, bool> filament_is_high_temp{
{"PLA", false}, {"PLA", false},
{"PLA-CF", false}, {"PLA-CF", false},
//{"PETG", true}, //{"PETG", true},
@ -893,28 +894,37 @@ static std::map<std::string, bool> filament_is_high_temp {
{"PC", true}, {"PC", true},
{"ASA", true}, {"ASA", true},
{"HIPS", true} {"HIPS", true}
}; };
//BBS: this function is used to check whether multi filament can be printed
StringObjectException Print::check_multi_filament_valid(const Print& print)
{
bool has_high_temperature_filament = false; bool has_high_temperature_filament = false;
bool has_low_temperature_filament = false; bool has_low_temperature_filament = false;
auto print_config = print.config(); for (const auto& type : filament_types)
std::vector<unsigned int> extruders = print.extruders(); if (filament_is_high_temp.find(type) != filament_is_high_temp.end()) {
if (filament_is_high_temp[type])
for (const auto& extruder_idx : extruders) {
std::string filament_type = print_config.filament_type.get_at(extruder_idx);
if (filament_is_high_temp.find(filament_type) != filament_is_high_temp.end()) {
if (filament_is_high_temp[filament_type])
has_high_temperature_filament = true; has_high_temperature_filament = true;
else else
has_low_temperature_filament = true; has_low_temperature_filament = true;
} }
}
if (has_high_temperature_filament && has_low_temperature_filament) if (has_high_temperature_filament && has_low_temperature_filament)
return false;
return true;
}
//BBS: this function is used to check whether multi filament can be printed
StringObjectException Print::check_multi_filament_valid(const Print& print)
{
auto print_config = print.config();
std::vector<unsigned int> extruders = print.extruders();
std::vector<std::string> filament_types;
filament_types.reserve(extruders.size());
for (const auto& extruder_idx : extruders)
filament_types.push_back(print_config.filament_type.get_at(extruder_idx));
if (!check_multi_filaments_compatibility(filament_types))
return { L("Can not print multiple filaments which have large difference of temperature together. Otherwise, the extruder and nozzle may be blocked or damaged during printing") }; return { L("Can not print multiple filaments which have large difference of temperature together. Otherwise, the extruder and nozzle may be blocked or damaged during printing") };
return {std::string()}; return {std::string()};

View File

@ -819,6 +819,8 @@ public:
// scaled point // scaled point
Vec2d translate_to_print_space(const Point& point) const; Vec2d translate_to_print_space(const Point& point) const;
static bool check_multi_filaments_compatibility(const std::vector<std::string>& filament_types);
protected: protected:
// Invalidates the step, and its depending steps in Print. // Invalidates the step, and its depending steps in Print.
bool invalidate_step(PrintStep step); bool invalidate_step(PrintStep step);