ENH: CLI: some refines on compatible logic

1. export compatible related values to 3mf
2. process compatible related values when loading

Change-Id: Ib7ed3d165cda5d62e0074652d474567494141631
(cherry picked from commit 989fe6439d573457fa78afc5376d04d3120dbbfd)
This commit is contained in:
lane.wei 2022-12-02 10:45:01 +08:00 committed by Lane.Wei
parent dcbe442184
commit 8375c73ac9
4 changed files with 607 additions and 239 deletions

View file

@ -1515,10 +1515,15 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
std::vector<std::string> compatible_prints_condition;
std::vector<std::string> inherits;
std::vector<std::string> filament_ids;
std::vector<std::string> print_compatible_printers;
//BBS: add logic for settings check between different system presets
std::vector<std::string> different_settings;
std::string different_print_settings, different_printer_settings;
compatible_printers_condition.emplace_back(this->prints.get_edited_preset().compatible_printers_condition());
const ConfigOptionStrings* compatible_printers = (const_cast<PresetBundle*>(this))->prints.get_edited_preset().config.option<ConfigOptionStrings>("compatible_printers", false);
if (compatible_printers)
print_compatible_printers = compatible_printers->values;
//BBS: add logic for settings check between different system presets
std::string print_inherits = this->prints.get_edited_preset().inherits();
inherits .emplace_back(print_inherits);
@ -1693,6 +1698,7 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
add_if_some_non_empty(std::move(inherits), "inherits_group");
//BBS: add logic for settings check between different system presets
add_if_some_non_empty(std::move(different_settings), "different_settings_to_system");
add_if_some_non_empty(std::move(print_compatible_printers), "print_compatible_printers");
out.option<ConfigOptionEnumGeneric>("printer_technology", true)->value = ptFFF;
return out;
@ -1826,16 +1832,15 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
{
PrinterTechnology printer_technology = Preset::printer_technology(config);
// The "compatible_printers" field should not have been exported into a config.ini or a G-code anyway,
// but some of the alpha versions of Slic3r did.
{
auto clear_compatible_printers = [](DynamicPrintConfig& config){
ConfigOption *opt_compatible = config.optptr("compatible_printers");
if (opt_compatible != nullptr) {
assert(opt_compatible->type() == coStrings);
if (opt_compatible->type() == coStrings)
static_cast<ConfigOptionStrings*>(opt_compatible)->values.clear();
}
}
};
clear_compatible_printers(config);
#if 0
size_t num_extruders = (printer_technology == ptFFF) ?
@ -1857,6 +1862,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
std::vector<std::string> compatible_prints_condition_values = std::move(config.option<ConfigOptionStrings>("compatible_process_expression_group", true)->values);
std::vector<std::string> inherits_values = std::move(config.option<ConfigOptionStrings>("inherits_group", true)->values);
std::vector<std::string> filament_ids = std::move(config.option<ConfigOptionStrings>("filament_ids", true)->values);
std::vector<std::string> print_compatible_printers = std::move(config.option<ConfigOptionStrings>("print_compatible_printers", true)->values);
//BBS: add different settings check logic
bool has_different_settings_to_system = config.option("different_settings_to_system")?true:false;
std::vector<std::string> different_values = std::move(config.option<ConfigOptionStrings>("different_settings_to_system", true)->values);
@ -1921,8 +1927,16 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
//}
//else
print_different_keys_set.insert(ignore_settings_list.begin(), ignore_settings_list.end());
if (!print_compatible_printers.empty()) {
ConfigOptionStrings* compatible_printers = config.option<ConfigOptionStrings>("compatible_printers", true);
compatible_printers->values = print_compatible_printers;
}
load_preset(this->prints, 0, "print_settings_id", print_different_keys_set, std::string());
//clear compatible printers
clear_compatible_printers(config);
std::vector<std::string> printer_different_keys_vector;
std::string printer_different_settings = different_values[num_filaments + 1];
Slic3r::unescape_strings_cstyle(printer_different_settings, printer_different_keys_vector);

View file

@ -829,6 +829,10 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionStrings());
def->cli = ConfigOptionDef::nocli;
def = this->add("print_compatible_printers", coStrings);
def->set_default_value(new ConfigOptionStrings());
def->cli = ConfigOptionDef::nocli;
def = this->add("print_sequence", coEnum);
def->label = L("Print sequence");
def->tooltip = L("Print sequence, layer by layer or object by object");
@ -4465,6 +4469,12 @@ CLIActionsConfigDef::CLIActionsConfigDef()
def->cli = "help|h";
def->set_default_value(new ConfigOptionBool(false));
def = this->add("uptodate", coBool);
def->label = L("UpToDate");
def->tooltip = L("Update the configs values of 3mf to latest.");
def->cli = "uptodate";
def->set_default_value(new ConfigOptionBool(false));
/*def = this->add("help_fff", coBool);
def->label = L("Help (FFF options)");
def->tooltip = L("Show the full list of print/G-code configuration options.");

View file

@ -31,6 +31,10 @@
#define CLI_EXPORT_OBJ_ERROR -12
#define CLI_EXPORT_3MF_ERROR -13
#define CLI_OUT_OF_MEMORY -14
#define CLI_3MF_NOT_SUPPORT_MACHINE_CHANGE -15
#define CLI_3MF_NEW_MACHINE_NOT_SUPPORTED -16
#define CLI_PROCESS_NOT_COMPATIBLE -17
#define CLI_NO_SUITABLE_OBJECTS -50
#define CLI_VALIDATE_ERROR -51