mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 08:41:11 -06:00
Implemented compatible_printer / compatible_printer_condition
for filaments and SLA materials. Fixed compatible_printers / compatible_prints dialog to show system profiles as well.
This commit is contained in:
parent
129c35b714
commit
c586ca4ae0
12 changed files with 387 additions and 226 deletions
|
@ -227,44 +227,6 @@ t_config_option_keys ConfigBase::diff(const ConfigBase &other) const
|
|||
return diff;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& vec, const ConfigBase &other, const ConfigBase *this_c)
|
||||
{
|
||||
const T* opt_init = static_cast<const T*>(other.option(opt_key));
|
||||
const T* opt_cur = static_cast<const T*>(this_c->option(opt_key));
|
||||
int opt_init_max_id = opt_init->values.size() - 1;
|
||||
for (int i = 0; i < opt_cur->values.size(); i++)
|
||||
{
|
||||
int init_id = i <= opt_init_max_id ? i : 0;
|
||||
if (opt_cur->values[i] != opt_init->values[init_id])
|
||||
vec.emplace_back(opt_key + "#" + std::to_string(i));
|
||||
}
|
||||
}
|
||||
|
||||
t_config_option_keys ConfigBase::deep_diff(const ConfigBase &other) const
|
||||
{
|
||||
t_config_option_keys diff;
|
||||
for (const t_config_option_key &opt_key : this->keys()) {
|
||||
const ConfigOption *this_opt = this->option(opt_key);
|
||||
const ConfigOption *other_opt = other.option(opt_key);
|
||||
if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
|
||||
{
|
||||
if (opt_key == "bed_shape"){ diff.emplace_back(opt_key); continue; }
|
||||
switch (other_opt->type())
|
||||
{
|
||||
case coInts: add_correct_opts_to_diff<ConfigOptionInts >(opt_key, diff, other, this); break;
|
||||
case coBools: add_correct_opts_to_diff<ConfigOptionBools >(opt_key, diff, other, this); break;
|
||||
case coFloats: add_correct_opts_to_diff<ConfigOptionFloats >(opt_key, diff, other, this); break;
|
||||
case coStrings: add_correct_opts_to_diff<ConfigOptionStrings >(opt_key, diff, other, this); break;
|
||||
case coPercents:add_correct_opts_to_diff<ConfigOptionPercents >(opt_key, diff, other, this); break;
|
||||
case coPoints: add_correct_opts_to_diff<ConfigOptionPoints >(opt_key, diff, other, this); break;
|
||||
default: diff.emplace_back(opt_key); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
t_config_option_keys ConfigBase::equal(const ConfigBase &other) const
|
||||
{
|
||||
t_config_option_keys equal;
|
||||
|
|
|
@ -1105,9 +1105,6 @@ public:
|
|||
void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false);
|
||||
bool equals(const ConfigBase &other) const { return this->diff(other).empty(); }
|
||||
t_config_option_keys diff(const ConfigBase &other) const;
|
||||
// Use deep_diff to correct return of changed options,
|
||||
// considering individual options for each extruder
|
||||
t_config_option_keys deep_diff(const ConfigBase &other) const;
|
||||
t_config_option_keys equal(const ConfigBase &other) const;
|
||||
std::string serialize(const t_config_option_key &opt_key) const;
|
||||
// Set a configuration value from a string, it will call an overridable handle_legacy()
|
||||
|
|
|
@ -1666,7 +1666,7 @@ void GCode::append_full_config(const Print& print, std::string& str)
|
|||
"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
|
||||
"printer_model", "printer_variant",
|
||||
"default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile",
|
||||
"compatible_printers_condition_cummulative", "inherits_cummulative" }) {
|
||||
"compatible_prints_condition_cummulative", "compatible_printers_condition_cummulative", "inherits_cummulative" }) {
|
||||
const ConfigOption *opt = full_config.option(key);
|
||||
if (opt != nullptr)
|
||||
str += std::string("; ") + key + " = " + opt->serialize() + "\n";
|
||||
|
|
|
@ -211,10 +211,25 @@ void PrintConfigDef::init_fff_params()
|
|||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString();
|
||||
|
||||
def = this->add("compatible_prints", coStrings);
|
||||
def->label = L("Compatible print profiles");
|
||||
def->mode = comAdvanced;
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
def = this->add("compatible_prints_condition", coString);
|
||||
def->label = L("Compatible print profiles condition");
|
||||
def->tooltip = L("A boolean expression using the configuration values of an active print profile. "
|
||||
"If this expression evaluates to true, this profile is considered compatible "
|
||||
"with the active print profile.");
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString();
|
||||
|
||||
// The following value is to be stored into the project file (AMF, 3MF, Config ...)
|
||||
// and it contains a sum of "compatible_printers_condition" values over the print and filament profiles.
|
||||
def = this->add("compatible_printers_condition_cummulative", coStrings);
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
def = this->add("compatible_prints_condition_cummulative", coStrings);
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
def = this->add("complete_objects", coBool);
|
||||
def->label = L("Complete individual objects");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue