mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 03:12:07 +00:00
Fix per-obj multi-variant options handling (#14700)
* ENH: config: add logic to apply params to object/region config with multi-extruder JIRA: no-jira Change-Id: Ieab98cd8d031e5ca82a3aad2d0b89d8ae4a794f1 (cherry picked from commit 3179fd416e68ca8bc2d746f859508d07db18fe5b) * FIX: X1C switch to H2D lose Highflow parameter Jira: STUDIO-15272 Change-Id: Id8cf5d93a49d5542ac82f9554974b458e15c1193 (cherry picked from commit 15d9f072ff658a3beb4f916d978dfea12c2d9f16) * Fix mishandling of `stride` param and add unit test for it * Fix modified multi-variant per-obj option highlight * Fix issue that per-obj FloatsOrPercents options are marked as dirty incorrectly when lost focus --------- Co-authored-by: lane.wei <lane.wei@bambulab.com> Co-authored-by: weiting.ji <weiting.ji@bambulab.com>
This commit is contained in:
@@ -9602,7 +9602,7 @@ int DynamicPrintConfig::update_values_from_multi_to_multi_2(const std::vector<st
|
||||
bool has_value = false;
|
||||
double target_value = std::numeric_limits<double>::max();
|
||||
for(auto idx : indices){
|
||||
if(opt && !opt->is_nil(idx)){
|
||||
if(opt && idx < opt->values.size() && !opt->is_nil(idx)){
|
||||
has_value = true;
|
||||
target_value = std::min(target_value, src_values[idx]);
|
||||
}
|
||||
@@ -9789,10 +9789,12 @@ DynamicPrintConfig::get_filament_type() const
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride, unsigned int extruder_id)
|
||||
std::vector<int> DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride, unsigned int extruder_id)
|
||||
{
|
||||
int extruder_count;
|
||||
bool different_extruder = printer_config.support_different_extruders(extruder_count);
|
||||
std::vector<int> variant_index;
|
||||
|
||||
if ((extruder_count > 1) || different_extruder)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: different extruders processing")%__LINE__;
|
||||
@@ -9803,9 +9805,9 @@ void DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig&
|
||||
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(printer_config.option("nozzle_volume_type"));
|
||||
if (!opt_extruder_type || !opt_nozzle_volume_type) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(", Line %1%: extruder_type or nozzle_volume_type option not found, skipping")%__LINE__;
|
||||
return;
|
||||
return variant_index;
|
||||
}
|
||||
std::vector<int> variant_index;
|
||||
|
||||
|
||||
if (extruder_id > 0 && extruder_id <= static_cast<unsigned> (extruder_count)) {
|
||||
variant_index.resize(1);
|
||||
@@ -9844,7 +9846,7 @@ void DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig&
|
||||
const ConfigDef *config_def = this->def();
|
||||
if (!config_def) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", Line %1%: can not find config define")%__LINE__;
|
||||
return;
|
||||
return variant_index;
|
||||
}
|
||||
for (auto& key: key_set)
|
||||
{
|
||||
@@ -9958,6 +9960,8 @@ void DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return variant_index;
|
||||
}
|
||||
|
||||
void DynamicPrintConfig::update_values_to_printer_extruders_for_multiple_filaments(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name)
|
||||
@@ -10490,6 +10494,28 @@ void compute_filament_override_value(const std::string& opt_key, const ConfigOpt
|
||||
}
|
||||
|
||||
|
||||
void update_static_print_config_from_dynamic(ConfigBase& config, const DynamicPrintConfig& dest_config, std::vector<int> variant_index, std::set<std::string>& key_set1, int stride)
|
||||
{
|
||||
if (variant_index.size() > 0) {
|
||||
const t_config_option_keys &keys = dest_config.keys();
|
||||
for (auto& opt : keys) {
|
||||
ConfigOption *opt_src = config.option(opt);
|
||||
const ConfigOption *opt_dest = dest_config.option(opt);
|
||||
if (opt_src && opt_dest && (*opt_src != *opt_dest)) {
|
||||
if (opt_dest->is_scalar() || (key_set1.find(opt) == key_set1.end()))
|
||||
opt_src->set(opt_dest);
|
||||
else {
|
||||
ConfigOptionVectorBase* opt_vec_src = static_cast<ConfigOptionVectorBase*>(opt_src);
|
||||
const ConfigOptionVectorBase* opt_vec_dest = static_cast<const ConfigOptionVectorBase*>(opt_dest);
|
||||
opt_vec_src->set_to_index(opt_vec_dest, variant_index, stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
config.apply(dest_config, true);
|
||||
}
|
||||
|
||||
//BBS: pass map to recording all invalid valies
|
||||
//FIXME localize this function.
|
||||
std::map<std::string, std::string> validate(const FullPrintConfig &cfg, bool under_cli)
|
||||
|
||||
Reference in New Issue
Block a user