mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 14:51:06 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf97ae0536 |
@@ -3618,6 +3618,9 @@ int CLI::run(int argc, char **argv)
|
||||
{
|
||||
if (opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "model_id" || opt_key == "dev_model_name" || opt_key == "filament_settings_id")
|
||||
continue;
|
||||
// rebuilt from every filament after this loop
|
||||
if (filament_dev_options.find(opt_key) != filament_dev_options.end())
|
||||
continue;
|
||||
ConfigOption *opt = m_print_config.option(opt_key, true);
|
||||
if (opt == nullptr) {
|
||||
// opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def().
|
||||
@@ -3681,6 +3684,14 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// The stored values cannot be told apart per filament, so they are kept as they are unless every slot has a config.
|
||||
std::vector<const DynamicPrintConfig *> filament_configs(filament_count, nullptr);
|
||||
for (size_t index = 0; index < load_filaments_config.size(); index++)
|
||||
if (load_filaments_index[index] >= 1 && load_filaments_index[index] <= filament_count)
|
||||
filament_configs[load_filaments_index[index] - 1] = &load_filaments_config[index];
|
||||
if (std::find(filament_configs.begin(), filament_configs.end(), nullptr) == filament_configs.end())
|
||||
set_filament_dev_options(m_print_config, filament_configs);
|
||||
|
||||
if (m_print_config.option<ConfigOptionStrings>("filament_extruder_variant")) {
|
||||
std::vector<int>& filament_self_indice = m_print_config.option<ConfigOptionInts>("filament_self_index", true)->values;
|
||||
int index_size = m_print_config.option<ConfigOptionStrings>("filament_extruder_variant")->size();
|
||||
|
||||
@@ -10815,6 +10815,22 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config)
|
||||
}
|
||||
}
|
||||
|
||||
void set_filament_dev_options(DynamicPrintConfig &config, const std::vector<const DynamicPrintConfig *> &filament_configs)
|
||||
{
|
||||
for (const std::string &key : filament_dev_options) {
|
||||
if (std::none_of(filament_configs.begin(), filament_configs.end(), [&key](const DynamicPrintConfig *filament) { return filament->has(key); }))
|
||||
continue;
|
||||
const ConfigOption *default_value = print_config_def.get(key)->default_value.get();
|
||||
auto *dst = static_cast<ConfigOptionVectorBase *>(config.option(key, true));
|
||||
dst->clear();
|
||||
for (const DynamicPrintConfig *filament : filament_configs) {
|
||||
const auto *src = static_cast<const ConfigOptionVectorBase *>(filament->has(key) ? filament->option(key) : default_value);
|
||||
if (!src->empty())
|
||||
dst->append(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//used for object/region config
|
||||
//use the smallest of multiple to single
|
||||
|
||||
@@ -928,6 +928,11 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config);
|
||||
|
||||
extern std::set<std::string> filament_dev_options;
|
||||
|
||||
// Orca: a filament_dev_options option holds several values per filament, and how many is up to the
|
||||
// filament preset, so one filament's values cannot be replaced in place. This rebuilds each option from
|
||||
// filament_configs, one config per filament in slot order, as the filaments' values one after another.
|
||||
void set_filament_dev_options(DynamicPrintConfig &config, const std::vector<const DynamicPrintConfig *> &filament_configs);
|
||||
|
||||
extern 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 = 1);
|
||||
extern void compute_filament_override_value(const std::string& opt_key, const ConfigOption *opt_old_machine, const ConfigOption *opt_new_machine, const ConfigOption *opt_new_filament, const DynamicPrintConfig& new_full_config,
|
||||
t_config_option_keys& diff_keys, DynamicPrintConfig& filament_overrides, std::vector<int>& f_map_indices);
|
||||
|
||||
@@ -799,3 +799,30 @@ TEST_CASE("A per-variant filament option read with a single value gives it to ev
|
||||
config.load_from_ini_string("pressure_advance = 0.021", ForwardCompatibilitySubstitutionRule::Disable);
|
||||
REQUIRE(config.option<ConfigOptionFloats>("pressure_advance")->values == std::vector<double>({0.021, 0.021, 0.021}));
|
||||
}
|
||||
|
||||
// The device drying options hold several values per filament, as many as each filament preset gives.
|
||||
TEST_CASE("The device drying options are rebuilt as each filament's values in slot order", "[Config]")
|
||||
{
|
||||
DynamicPrintConfig two_values, one_value, no_value;
|
||||
two_values.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations", true)->values = {"1", "0"};
|
||||
two_values.option<ConfigOptionFloats>("filament_dev_ams_drying_temperature", true)->values = {45., 45., 55., 55.};
|
||||
one_value.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations", true)->values = {"1"};
|
||||
one_value.option<ConfigOptionFloats>("filament_dev_ams_drying_temperature", true)->values = {65., 65., 75., 75.};
|
||||
|
||||
// values a project stored for three other filaments
|
||||
DynamicPrintConfig config;
|
||||
config.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations", true)->values = {"0", "0", "0"};
|
||||
config.option<ConfigOptionFloats>("filament_dev_chamber_drying_time", true)->values = {12., 8., 12.};
|
||||
|
||||
set_filament_dev_options(config, {&two_values, &one_value, &two_values});
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations")->values ==
|
||||
std::vector<std::string>({"1", "0", "1", "1", "0"}));
|
||||
REQUIRE(config.option<ConfigOptionFloats>("filament_dev_ams_drying_temperature")->values ==
|
||||
std::vector<double>({45., 45., 55., 55., 65., 65., 75., 75., 45., 45., 55., 55.}));
|
||||
// an option no filament defines keeps the stored values
|
||||
REQUIRE(config.option<ConfigOptionFloats>("filament_dev_chamber_drying_time")->values == std::vector<double>({12., 8., 12.}));
|
||||
|
||||
// a filament without the option takes the option's default
|
||||
set_filament_dev_options(config, {&two_values, &no_value});
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations")->values == std::vector<std::string>({"1", "0", ""}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user