mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
ENH: add check logic of filament_map when Print::Apply
Change-Id: Ibab353c4b16183611d63d75bcdf5f370cb578f21 (cherry picked from commit bbc4d701bf0f492566fb0ebefbf286630ae2136d)
This commit is contained in:
@@ -1086,12 +1086,14 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
new_full_config.option("print_settings_id", true);
|
||||
new_full_config.option("filament_settings_id", true);
|
||||
new_full_config.option("printer_settings_id", true);
|
||||
|
||||
// BBS
|
||||
int used_filaments = this->extruders(true).size();
|
||||
std::vector <unsigned int> used_filaments = this->extruders(true);
|
||||
std::unordered_set <unsigned int> used_filament_set(used_filaments.begin(), used_filaments.end());
|
||||
|
||||
//new_full_config.normalize_fdm(used_filaments);
|
||||
new_full_config.normalize_fdm_1();
|
||||
t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments);
|
||||
t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments.size());
|
||||
if (changed_keys.size() > 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got changed_keys, size=%1%")%changed_keys.size();
|
||||
for (int i = 0; i < changed_keys.size(); i++)
|
||||
@@ -1132,6 +1134,40 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
t_config_option_keys object_diff = m_default_object_config.diff(new_full_config);
|
||||
t_config_option_keys region_diff = m_default_region_config.diff(new_full_config);
|
||||
|
||||
//BBS: process the filament_map related logic
|
||||
std::unordered_set<std::string> print_diff_set(print_diff.begin(), print_diff.end());
|
||||
if (print_diff_set.find("filament_map_mode") == print_diff_set.end())
|
||||
{
|
||||
FilamentMapMode map_mode = new_full_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value;
|
||||
if (map_mode == fmmAuto) {
|
||||
print_diff_set.erase("filament_map");
|
||||
}
|
||||
else {
|
||||
print_diff_set.erase("extruder_filament_count");
|
||||
std::vector<int> old_filament_map = m_config.filament_map.values;
|
||||
std::vector<int> new_filament_map = new_full_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
if (old_filament_map.size() == new_filament_map.size())
|
||||
{
|
||||
bool same_map = true;
|
||||
for (size_t index = 0; index < old_filament_map.size(); index++)
|
||||
{
|
||||
if ((old_filament_map[index] == new_filament_map[index])
|
||||
|| (used_filament_set.find(index + 1) == used_filament_set.end()))
|
||||
continue;
|
||||
else {
|
||||
same_map = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (same_map)
|
||||
print_diff_set.erase("filament_map");
|
||||
}
|
||||
}
|
||||
if (print_diff_set.size() != print_diff.size())
|
||||
print_diff.assign(print_diff_set.begin(), print_diff_set.end());
|
||||
}
|
||||
|
||||
// Do not use the ApplyStatus as we will use the max function when updating apply_status.
|
||||
unsigned int apply_status = APPLY_STATUS_UNCHANGED;
|
||||
auto update_apply_status = [&apply_status](bool invalidated)
|
||||
|
||||
Reference in New Issue
Block a user