mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-04 05:50:37 -07:00
ENH: config: add extrudrer variant check logic
when load config from 3mf Change-Id: I946ba777853e479418fcd1b49209f75ed41f33f3 (cherry picked from commit 5defd2b7c315d658be52caf8eb97e80b41458f31)
This commit is contained in:
parent
508c5d5bc9
commit
082c213dcf
6 changed files with 157 additions and 24 deletions
|
|
@ -7070,6 +7070,9 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
opt_key = "wall_sequence";
|
||||
}
|
||||
}
|
||||
else if (opt_key == "extruder_type" && value == "DirectDrive") {
|
||||
value = "Direct Drive";
|
||||
}
|
||||
else if(opt_key == "ensure_vertical_shell_thickness") {
|
||||
if(value == "1") {
|
||||
value = "ensure_all";
|
||||
|
|
@ -8087,7 +8090,82 @@ void DynamicPrintConfig::update_values_to_printer_extruders_for_multiple_filamen
|
|||
}
|
||||
}
|
||||
|
||||
void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfig& new_config, const t_config_option_keys& keys, const std::set<std::string>& different_keys,
|
||||
std::string extruder_id_name, std::string extruder_variant_name, std::set<std::string>& key_set1, std::set<std::string>& key_set2)
|
||||
{
|
||||
std::vector<int> cur_extruder_ids, target_extruder_ids, variant_index;
|
||||
std::vector<std::string> cur_extruder_variants, target_extruder_variants;
|
||||
|
||||
if (!extruder_id_name.empty()) {
|
||||
if (this->option(extruder_id_name))
|
||||
cur_extruder_ids = this->option<ConfigOptionInts>(extruder_id_name)->values;
|
||||
if (new_config.option(extruder_id_name))
|
||||
target_extruder_ids = new_config.option<ConfigOptionInts>(extruder_id_name)->values;
|
||||
}
|
||||
if (this->option(extruder_variant_name))
|
||||
cur_extruder_variants = this->option<ConfigOptionStrings>(extruder_variant_name, true)->values;
|
||||
if (new_config.option(extruder_variant_name))
|
||||
target_extruder_variants = new_config.option<ConfigOptionStrings>(extruder_variant_name, true)->values;
|
||||
|
||||
int cur_variant_count = cur_extruder_variants.size();
|
||||
int target_variant_count = target_extruder_variants.size();
|
||||
|
||||
variant_index.resize(target_variant_count, -1);
|
||||
if (cur_variant_count == 0) {
|
||||
variant_index[0] = 0;
|
||||
}
|
||||
else if ((cur_extruder_ids.size() > 0) && cur_variant_count != cur_extruder_ids.size()){
|
||||
//should not happen
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" size of %1% = %2%, not equal to size of %3% = %4%")
|
||||
%extruder_variant_name %cur_variant_count %extruder_id_name %cur_extruder_ids.size();
|
||||
}
|
||||
else if ((target_extruder_ids.size() > 0) && target_variant_count != target_extruder_ids.size()){
|
||||
//should not happen
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" size of %1% = %2%, not equal to size of %3% = %4%")
|
||||
%extruder_variant_name %target_variant_count %extruder_id_name %target_extruder_ids.size();
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < target_variant_count; i++)
|
||||
{
|
||||
for (int j = 0; j < cur_variant_count; j++)
|
||||
{
|
||||
if ((target_extruder_variants[i] == cur_extruder_variants[j])
|
||||
&&(target_extruder_ids.empty() || (target_extruder_ids[i] == cur_extruder_ids[j])))
|
||||
{
|
||||
variant_index[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& opt : keys) {
|
||||
ConfigOption *opt_src = this->option(opt);
|
||||
const ConfigOption *opt_target = new_config.option(opt);
|
||||
if (opt_src && opt_target && (*opt_src != *opt_target)) {
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" change key %1% from old_value %2% to inherit's value %3%")
|
||||
%opt %(opt_src->serialize()) %(opt_target->serialize());
|
||||
if (different_keys.find(opt) == different_keys.end()) {
|
||||
opt_src->set(opt_target);
|
||||
}
|
||||
else {
|
||||
if (opt_target->is_scalar()
|
||||
|| ((key_set1.find(opt) == key_set1.end()) && (key_set2.empty() || (key_set2.find(opt) == key_set2.end())))) {
|
||||
//nothing to do, keep the original one
|
||||
}
|
||||
else {
|
||||
ConfigOptionVectorBase* opt_vec_src = static_cast<ConfigOptionVectorBase*>(opt_src);
|
||||
const ConfigOptionVectorBase* opt_vec_dest = static_cast<const ConfigOptionVectorBase*>(opt_target);
|
||||
int stride = 1;
|
||||
if (key_set2.find(opt) != key_set2.end())
|
||||
stride = 2;
|
||||
opt_vec_src->set_with_keep(opt_vec_dest, variant_index, stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//BBS: pass map to recording all invalid valies
|
||||
//FIXME localize this function.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue