mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
ENH: update prompt for filament mix printing
jira: NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I92c86edadd6720b0e566057bd2593605ee4a3f77 (cherry picked from commit a93f6a54a2be94807702e3c75bdb4c79d508f260)
This commit is contained in:
@@ -1822,6 +1822,48 @@ bool PartPlate::check_mixture_of_pla_and_petg(const DynamicPrintConfig &config)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartPlate::check_mixture_filament_compatible(const DynamicPrintConfig &config, std::string &error_msg)
|
||||
{
|
||||
static std::unordered_map<std::string, std::unordered_set<std::string>> incompatible_filament_pairs;
|
||||
|
||||
auto add_incompatibility = [&](std::string filament_type1, std::string filament_type2) {
|
||||
incompatible_filament_pairs[filament_type1].insert(filament_type2);
|
||||
incompatible_filament_pairs[filament_type2].insert(filament_type1);
|
||||
};
|
||||
|
||||
if (incompatible_filament_pairs.empty()) { add_incompatibility("PVA", "PETG"); }
|
||||
|
||||
std::vector<int> used_filaments = get_extruders(true); // 1 based idx
|
||||
std::vector<std::string> filament_types;
|
||||
auto filament_type_opt = config.option<ConfigOptionStrings>("filament_type");
|
||||
for (auto filament : used_filaments) {
|
||||
int filament_idx = filament - 1;
|
||||
filament_types.push_back(filament_type_opt->values[filament_idx]);
|
||||
};
|
||||
|
||||
{
|
||||
std::unordered_set<std::string> seen;
|
||||
filament_types.erase(std::remove_if(filament_types.begin(), filament_types.end(), [&](const std::string &s) { return !seen.insert(s).second; }), filament_types.end());
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> conflicts;
|
||||
|
||||
for (size_t i = 0; i < filament_types.size(); i++) {
|
||||
auto it = incompatible_filament_pairs.find(filament_types[i]);
|
||||
if (it == incompatible_filament_pairs.end()) continue;
|
||||
for (size_t j = i + 1; j < filament_types.size(); ++j) {
|
||||
if (it->second.count(filament_types[j])) { conflicts.emplace_back(filament_types[i], filament_types[j]); }
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts.empty()) {
|
||||
// TODO: add the full text if has multi conflict
|
||||
auto conflict = conflicts.front();
|
||||
error_msg = GUI::format(_L("Mixing %1% with %2% in printing is not recommended.\n"), conflict.first, conflict.second);
|
||||
}
|
||||
return conflicts.empty();
|
||||
}
|
||||
|
||||
bool PartPlate::check_compatible_of_nozzle_and_filament(const DynamicPrintConfig &config, const std::vector<std::string> &filament_presets, std::string &error_msg)
|
||||
{
|
||||
float nozzle_diameter = config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values[0];
|
||||
|
||||
Reference in New Issue
Block a user