OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::StaticPrintConfig Class Referenceabstract

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/PrintConfig.hpp>

Inheritance diagram for Slic3r::StaticPrintConfig:
Collaboration diagram for Slic3r::StaticPrintConfig:

Classes

class  StaticCacheBase
class  StaticCache

Public Member Functions

 StaticPrintConfig ()
const ConfigDef * def () const override
virtual const t_config_option_keys & keys_ref () const =0
t_config_option_keys keys () const
 Gets list of config option names for each config option of this->def, which has a static counter-part defined by the derived object and which could be resolved by this->optptr(key) call.
virtual ConfigOption * optptr (const t_config_option_key &opt_key, bool create=false)=0
virtual const ConfigOption * optptr (const t_config_option_key &opt_key) const=0
virtual bool apply_to (ConfigBase &) const
ConfigOption * option (const t_config_option_key &opt_key, bool create=false)
const ConfigOption * option (const t_config_option_key &opt_key) const
ConfigOption * option_throw (const t_config_option_key &opt_key, bool create=false)
const ConfigOption * option_throw (const t_config_option_key &opt_key) const
void apply (const ConfigBase &other, bool ignore_nonexistent=false)
void apply_only (const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent=false)
bool equals (const ConfigBase &other, const std::set< std::string > *skipped_keys=nullptr) const
t_config_option_keys diff (const ConfigBase &other) const
t_config_option_keys equal (const ConfigBase &other) const
std::string opt_serialize (const t_config_option_key &opt_key) const
void set (const std::string &opt_key, bool value, bool create=false)
void set (const std::string &opt_key, int value, bool create=false)
void set (const std::string &opt_key, double value, bool create=false)
void set (const std::string &opt_key, const char *value, bool create=false)
void set (const std::string &opt_key, const std::string &value, bool create=false)
bool set_deserialize_nothrow (const t_config_option_key &opt_key_src, const std::string &value_src, ConfigSubstitutionContext &substitutions, bool append=false)
void set_deserialize (const t_config_option_key &opt_key, const std::string &str, ConfigSubstitutionContext &config_substitutions, bool append=false)
void set_deserialize (std::initializer_list< SetDeserializeItem > items, ConfigSubstitutionContext &substitutions)
void set_deserialize_strict (const t_config_option_key &opt_key, const std::string &str, bool append=false)
void set_deserialize_strict (std::initializer_list< SetDeserializeItem > items)
double get_abs_value_at (const t_config_option_key &opt_key, size_t index) const
double get_abs_value (const t_config_option_key &opt_key) const
double get_abs_value (const t_config_option_key &opt_key, double ratio_over) const
void setenv_ () const
ConfigSubstitutions load (const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
ConfigSubstitutions load (const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule)
ConfigSubstitutions load_string_map (std::map< std::string, std::string > &key_values, ForwardCompatibilitySubstitutionRule compatibility_rule)
int load_from_json (const std::string &file, ConfigSubstitutionContext &substitutions, bool load_inherits_in_config, std::map< std::string, std::string > &key_values, std::string &reason)
ConfigSubstitutions load_from_json (const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule, std::map< std::string, std::string > &key_values, std::string &reason)
ConfigSubstitutions load_from_ini (const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
ConfigSubstitutions load_from_ini_string (const std::string &data, ForwardCompatibilitySubstitutionRule compatibility_rule)
ConfigSubstitutions load_from_ini_string_commented (std::string &&data, ForwardCompatibilitySubstitutionRule compatibility_rule)
ConfigSubstitutions load_from_gcode_file (const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
void save (const std::string &file) const
void save_to_json (const std::string &file, const std::string &name, const std::string &from, const std::string &version) const
void save_to_json (std::ostream &os, const std::string &name, const std::string &from, const std::string &version, bool replace_invalid_utf8=false) const
void update_plugin_manifest ()
void null_nullables ()
bool has (const t_config_option_key &opt_key) const

Static Public Member Functions

static size_t load_from_gcode_string_legacy (ConfigBase &config, const char *str, ConfigSubstitutionContext &substitutions)
static void set_resolve_capability_fn (std::function< std::string(std::string, std::string)> fn)

Protected Member Functions

void handle_legacy (t_config_option_key &opt_key, std::string &value) const override
void set_defaults ()
 Set all statically defined config options to their defaults defined by this->def().
virtual void handle_legacy_composite ()

Detailed Description

Constructor & Destructor Documentation

◆ StaticPrintConfig()

Slic3r::StaticPrintConfig::StaticPrintConfig ( )
inline
1043{}

Member Function Documentation

◆ apply()

void Slic3r::ConfigBase::apply ( const ConfigBase & other,
bool ignore_nonexistent = false )
inlineinherited
2803 { if (! other.apply_to(*this)) this->apply_only(other, other.keys(), ignore_nonexistent); }
void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent=false)
Definition Config.cpp:484

References ConfigBase(), apply_only(), apply_to(), and keys().

Referenced by Slic3r::BackgroundSlicingProcess::apply(), Slic3r::GCodeProcessor::apply_config_superslicer(), Slic3r::GUI::CalibUtils::calib_flowrate(), Slic3r::GUI::CalibUtils::calib_generic_PA(), Slic3r::GUI::CalibUtils::calib_max_vol_speed(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), Slic3r::GUI::CalibUtils::calib_retraction(), Slic3r::GUI::CalibUtils::calib_temptue(), Slic3r::GUI::CalibUtils::calib_VFA(), Slic3r::PresetBundle::config_from_gcode(), Slic3r::PresetBundle::construct_full_config(), Slic3r::GUI::SLAImportJob::finalize(), Slic3r::PresetBundle::full_fff_config(), Slic3r::PresetBundle::full_sla_config(), Slic3r::PresetBundle::import_json_presets(), Slic3r::GUI::PartPlate::load_gcode_from_file(), Slic3r::PresetCollection::load_user_preset(), Slic3r::GCodeProcessor::process_file(), Slic3r::Preset::reload(), Slic3r::PresetBundle::resolve_vendor_preset(), Slic3r::CLI::run(), Slic3r::GUI::CalibUtils::set_for_auto_pa_model_and_config(), Slic3r::GUI::PartPlateList::store_to_3mf_structure(), Slic3r::GUI::PlaterPresetComboBox::sync_colour_config(), Slic3r::GUI::PresetComboBox::update_ams_color(), Slic3r::GUI::ObjectSettings::update_config_values(), and Slic3r::update_static_print_config_from_dynamic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_only()

void Slic3r::ConfigBase::apply_only ( const ConfigBase & other,
const t_config_option_keys & keys,
bool ignore_nonexistent = false )
inherited
485{
486 // loop through options and apply them
487 for (const t_config_option_key &opt_key : keys) {
488 // Create a new option with default value for the key.
489 // If the key is not in the parameter definition, or this ConfigBase is a static type and it does not support the parameter,
490 // an exception is thrown if not ignore_nonexistent.
491 ConfigOption *my_opt = this->option(opt_key, true);
492 if (my_opt == nullptr) {
493 // opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def().
494 // This is only possible if other is of DynamicConfig type.
495 if (auto n = opt_key.find('#'); n != std::string::npos) {
496 auto opt_key2 = opt_key.substr(0, n);
497 auto my_opt2 = dynamic_cast<ConfigOptionVectorBase*>(this->option(opt_key2));
498 auto other_opt = other.option(opt_key2);
499 if (my_opt2 == nullptr && other_opt) {
500 my_opt2 = dynamic_cast<ConfigOptionVectorBase *>(this->option(opt_key2, true));
501 if (my_opt2->empty()) {
502 my_opt2->resize(1, other_opt);
503 }
504 }
505 if (my_opt2) {
506 int index = std::atoi(opt_key.c_str() + n + 1);
507 if (other_opt)
508 my_opt2->set_at(other_opt, index, index);
509 continue;
510 }
511 }
512 if (ignore_nonexistent)
513 continue;
514 throw UnknownOptionException(opt_key);
515 }
516 const ConfigOption *other_opt = other.option(opt_key);
517 if (other_opt == nullptr) {
518 // The key was not found in the source config, therefore it will not be initialized!
519// printf("Not found, therefore not initialized: %s\n", opt_key.c_str());
520 } else
521 my_opt->set(other_opt);
522 }
523}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2768
virtual t_config_option_keys keys() const =0
std::string t_config_option_key
Definition Config.hpp:96

References ConfigBase(), keys(), option(), and Slic3r::ConfigOption::set().

Referenced by apply(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::Preset::load_external_config(), Slic3r::PresetCollection::load_external_preset(), Slic3r::PresetCollection::load_preset(), Slic3r::PresetCollection::load_user_preset(), Slic3r::GUI::Tab::may_discard_current_dirty_preset(), Slic3r::PresetBundle::reload_local_bundle(), Slic3r::CLI::run(), Slic3r::PresetBundle::save_changes_for_preset(), Slic3r::GUI::CreatePrinterPresetDialog::save_printable_area_config(), and Slic3r::GUI::TabPrintModel::update_model_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to()

virtual bool Slic3r::ConfigBase::apply_to ( ConfigBase & ) const
inlinevirtualinherited
2750{ return false; }

References ConfigBase().

Referenced by apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ def()

const ConfigDef * Slic3r::StaticPrintConfig::def ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigBase.

1046{ return &print_config_def; }
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099

References Slic3r::print_config_def.

Referenced by Slic3r::StaticPrintConfig::StaticCache< T >::finalize().

Here is the caller graph for this function:

◆ diff()

t_config_option_keys Slic3r::ConfigBase::diff ( const ConfigBase & other) const
inherited
542{
544 for (const t_config_option_key &opt_key : this->keys()) {
545 const ConfigOption *this_opt = this->option(opt_key);
546 const ConfigOption *other_opt = other.option(opt_key);
547 if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
548 diff.emplace_back(opt_key);
549 }
550 return diff;
551}
t_config_option_keys diff(const ConfigBase &other) const
Definition Config.cpp:541
std::vector< std::string > t_config_option_keys
Definition Config.hpp:97

References ConfigBase(), diff(), keys(), and option().

Referenced by diff().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equal()

t_config_option_keys Slic3r::ConfigBase::equal ( const ConfigBase & other) const
inherited
555{
557 for (const t_config_option_key &opt_key : this->keys()) {
558 const ConfigOption *this_opt = this->option(opt_key);
559 const ConfigOption *other_opt = other.option(opt_key);
560 if (this_opt != nullptr && other_opt != nullptr && *this_opt == *other_opt)
561 equal.emplace_back(opt_key);
562 }
563 return equal;
564}
t_config_option_keys equal(const ConfigBase &other) const
Definition Config.cpp:554

References ConfigBase(), equal(), keys(), and option().

Referenced by equal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

bool Slic3r::ConfigBase::equals ( const ConfigBase & other,
const std::set< std::string > * skipped_keys = nullptr ) const
inherited
528{
529 for (const t_config_option_key &opt_key : this->keys()) {
530 if (skipped_keys && (skipped_keys->count(opt_key) != 0))
531 continue;
532 const ConfigOption *this_opt = this->option(opt_key);
533 const ConfigOption *other_opt = other.option(opt_key);
534 if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
535 return false;
536 }
537 return true;
538}

References ConfigBase(), keys(), and option().

Here is the call graph for this function:

◆ get_abs_value() [1/2]

double Slic3r::ConfigBase::get_abs_value ( const t_config_option_key & opt_key) const
inherited
740{
741 // Get stored option value.
742 const ConfigOption *raw_opt = this->option(opt_key);
743 if (raw_opt == nullptr) {
744 std::stringstream ss;
745 ss << "You can't define an option that need " << opt_key << " without defining it!";
746 throw std::runtime_error(ss.str());
747 }
748 assert(raw_opt != nullptr);
749
750 if (raw_opt->type() == coFloat)
751 return static_cast<const ConfigOptionFloat*>(raw_opt)->value;
752 if (raw_opt->type() == coInt)
753 return static_cast<const ConfigOptionInt *>(raw_opt)->value;
754 if (raw_opt->type() == coBool)
755 return static_cast<const ConfigOptionBool *>(raw_opt)->value ? 1 : 0;
756
757 const ConfigOptionPercent *cast_opt = nullptr;
758 if (raw_opt->type() == coFloatOrPercent) {
759 auto cofop = static_cast<const ConfigOptionFloatOrPercent*>(raw_opt);
760 if (cofop->value == 0 && boost::ends_with(opt_key, "_line_width")) {
761 return this->get_abs_value("line_width");
762 }
763 if (!cofop->percent)
764 return cofop->value;
765 cast_opt = cofop;
766 }
767
768 if (raw_opt->type() == coPercent) {
769 cast_opt = static_cast<const ConfigOptionPercent *>(raw_opt);
770 }
771
772 // Get option definition.
773 const ConfigDef *def = this->def();
774 if (def == nullptr)
775 throw NoDefinitionException(opt_key);
776 const ConfigOptionDef *opt_def = def->get(opt_key);
777
778
779 assert(opt_def != nullptr);
780 if (opt_def->ratio_over == "")
781 return cast_opt->get_abs_value(1);
782 // Compute absolute value over the absolute value of the base option.
783 //FIXME there are some ratio_over chains, which end with empty ratio_with.
784 // For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
785 return opt_def->ratio_over.empty() ? 0. :
786 static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->get_abs_value(this->get_abs_value(opt_def->ratio_over));
787
788
789 throw ConfigurationError("ConfigBase::get_abs_value(): Not a valid option type for get_abs_value()");
790}
virtual const ConfigDef * def() const =0
double get_abs_value(const t_config_option_key &opt_key) const
Definition Config.cpp:739
zaa_minimize_perimeter_height ConfigOptionFloat
Definition PrintConfig.hpp:1954
@ coInt
Definition Config.hpp:188
@ coBool
Definition Config.hpp:210
@ coFloat
Definition Config.hpp:184
@ coFloatOrPercent
Definition Config.hpp:200
@ coPercent
Definition Config.hpp:196

References Slic3r::coBool, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coPercent, def(), get_abs_value(), Slic3r::ConfigOptionPercent::get_abs_value(), option(), Slic3r::ConfigOptionDef::ratio_over, Slic3r::ConfigOption::type(), and Slic3r::ConfigOptionSingle< T >::value.

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), get_abs_value(), get_abs_value(), Slic3r::GUI::GLGizmoBrimEars::get_brim_default_radius(), Slic3r::GUI::CalibUtils::set_for_auto_pa_model_and_config(), and Slic3r::GUI::ConfigManipulation::update_print_fff_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_abs_value() [2/2]

double Slic3r::ConfigBase::get_abs_value ( const t_config_option_key & opt_key,
double ratio_over ) const
inherited
795{
796 // Get stored option value.
797 const ConfigOption *raw_opt = this->option(opt_key);
798 // Mirror the single-arg overload — assert() is a no-op under NDEBUG.
799 if (raw_opt == nullptr)
800 throw ConfigurationError("ConfigBase::get_abs_value(): \"" + opt_key + "\" is not defined");
801 if (raw_opt->type() != coFloatOrPercent)
802 throw ConfigurationError("ConfigBase::get_abs_value(): opt_key is not of coFloatOrPercent");
803 // Compute absolute value.
804 return static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->get_abs_value(ratio_over);
805}

References Slic3r::coFloatOrPercent, get_abs_value(), option(), and Slic3r::ConfigOption::type().

Here is the call graph for this function:

◆ get_abs_value_at()

double Slic3r::ConfigBase::get_abs_value_at ( const t_config_option_key & opt_key,
size_t index ) const
inherited
712{
713 const ConfigOption *raw_opt = this->option(opt_key);
714 assert(raw_opt != nullptr);
715 if (raw_opt->type() == coFloats) {
716 return static_cast<const ConfigOptionFloats*>(raw_opt)->get_at(index);
717 }
718 if (raw_opt->type() == coFloatsOrPercents) {
719 const ConfigDef *def = this->def();
720 if (def == nullptr) throw NoDefinitionException(opt_key);
721 const ConfigOptionDef *opt_def = def->get(opt_key);
722 assert(opt_def != nullptr);
723
724 if (opt_def->ratio_over.empty()) {
725 return 0;
726 } else {
727 const ConfigOption *ratio_opt = this->option(opt_def->ratio_over);
728 assert(ratio_opt->type() == coFloats);
729 const ConfigOptionFloats *ratio_values = static_cast<const ConfigOptionFloats *>(ratio_opt);
730 return static_cast<const ConfigOptionFloatsOrPercents *>(raw_opt)->get_at(index).get_abs_value(ratio_values->get_at(index));
731 }
732 }
733
734 throw ConfigurationError("ConfigBase::get_abs_value_at(): Not a valid option type for get_abs_value_at()");
735}
@ coFloatsOrPercents
Definition Config.hpp:202
@ coFloats
Definition Config.hpp:186
ConfigOptionFloatsOrPercentsTempl< false > ConfigOptionFloatsOrPercents
Definition Config.hpp:1531
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

References Slic3r::coFloats, Slic3r::coFloatsOrPercents, def(), Slic3r::ConfigOptionVector< double >::get_at(), option(), Slic3r::ConfigOptionDef::ratio_over, and Slic3r::ConfigOption::type().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_legacy()

void Slic3r::StaticPrintConfig::handle_legacy ( t_config_option_key & opt_key,
std::string & value ) const
inlineoverrideprotectedvirtual

Reimplemented from Slic3r::ConfigBase.

1056 { PrintConfigDef::handle_legacy(opt_key, value); }
static void handle_legacy(t_config_option_key &opt_key, std::string &value)
Definition PrintConfig.cpp:9745

References Slic3r::PrintConfigDef::handle_legacy().

Here is the call graph for this function:

◆ handle_legacy_composite()

virtual void Slic3r::ConfigBase::handle_legacy_composite ( )
inlineprotectedvirtualinherited

Reimplemented in Slic3r::DynamicPrintConfig.

2761{}

Referenced by load(), load_from_gcode_file(), load_from_gcode_string_legacy(), and load_from_json().

Here is the caller graph for this function:

◆ has()

bool Slic3r::ConfigOptionResolver::has ( const t_config_option_key & opt_key) const
inlineinherited
2697{ return this->optptr(opt_key) != nullptr; }
virtual const ConfigOption * optptr(const t_config_option_key &opt_key) const =0

References optptr().

Referenced by Slic3r::_BBS_3MF_Exporter::_add_slice_info_config_file_to_archive(), Slic3r::active_bed_exclude_volume_mode(), Slic3r::append_bed_exclude_volumes(), Slic3r::append_printer_bed_assets(), Slic3r::GUI::change_opt_value(), Slic3r::GUI::ConfigManipulation::check_adaptive_pressure_advance_model(), Slic3r::GUI::PartPlateList::check_all_plate_local_bed_type(), Slic3r::GUI::ConfigManipulation::check_chamber_minimal_temperature(), Slic3r::GUI::ConfigManipulation::check_chamber_temperature(), Slic3r::GUI::ConfigManipulation::check_filament_max_volumetric_speed(), Slic3r::GUI::ConfigManipulation::check_nozzle_recommended_temperature_range(), Slic3r::GUI::ConfigManipulation::check_nozzle_temperature_initial_layer_range(), Slic3r::GUI::ConfigManipulation::check_nozzle_temperature_range(), Slic3r::config_value_or_none(), Slic3r::GUI::Bed3D::detect_type(), Slic3r::PresetCollection::dirty_options(), Slic3r::PresetCollection::dirty_options_without_option_list(), Slic3r::GUI::ensure_belt_purge_tower(), Slic3r::extend_default_config_length(), Slic3r::extend_extruder_variant(), Slic3r::anonymous_namespace{PluginResolver.cpp}::find_option_for_capability(), Slic3r::get_bed_excluded_regions_by_extruder(), Slic3r::GUI::PartPlate::get_bed_type(), Slic3r::anonymous_namespace{SL1.cpp}::get_cfg_value(), Slic3r::GUI::GLGizmoBrimEars::get_config_options(), Slic3r::GUI::ConfigOptionsGroup::get_config_value(), Slic3r::GUI::get_formatted_tooltip_text(), Slic3r::get_instance_arrange_poly(), Slic3r::GUI::PartPlate::get_object_filament_extruders(), Slic3r::GUI::OrientJob::get_orient_mesh(), Slic3r::DynamicPrintConfig::get_parameter_size(), Slic3r::GUI::CalibrationPresetPage::get_print_preset(), Slic3r::GUI::PartPlate::get_spiral_vase_mode(), Slic3r::GUI::ConfigManipulation::get_temperature_range(), Slic3r::GUI::PresetComboBox::get_tooltip(), Slic3r::PrintConfigDef::handle_legacy_composite(), Slic3r::handle_legacy_project_loaded(), Slic3r::handle_legacy_sla(), Slic3r::has_bed_exclude_volumes(), Slic3r::PresetBundle::import_json_presets(), Slic3r::PresetCollection::is_dirty(), Slic3r::GUI::is_same_nozzle_type(), Slic3r::GUI::ObjectList::load_shape_object(), Slic3r::PresetCollection::load_user_preset(), Slic3r::DynamicPrintConfig::normalize_fdm(), Slic3r::DynamicPrintConfig::normalize_fdm_1(), Slic3r::GUI::PartPlateList::notify_instance_update(), Slic3r::GUI::TabPrintPlate::on_value_change(), Slic3r::DynamicConfig::read_cli(), Slic3r::Preset::remove_invalid_keys(), Slic3r::GUI::PartPlate::render_logo(), Slic3r::PresetBundle::resolve_vendor_preset(), Slic3r::CLI::run(), Slic3r::GUI::PartPlate::set_bed_type(), Slic3r::set_filament_dev_options(), Slic3r::Model::setExtruderParams(), Slic3r::Model::setPrintSpeedTable(), Slic3r::GUI::TabFilament::toggle_options(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), Slic3r::GLVolumeCollection::update_colors_by_extruder(), Slic3r::PresetBundle::update_compatible(), Slic3r::GUI::TabPrintPlate::update_custom_dirty(), Slic3r::GUI::TabPrintModel::update_model_config(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), and Slic3r::GUI::Tab::validate_filament_temperature_pairs().

Here is the call graph for this function:

◆ keys()

t_config_option_keys Slic3r::StaticConfig::keys ( ) const
virtualinherited

Gets list of config option names for each config option of this->def, which has a static counter-part defined by the derived object and which could be resolved by this->optptr(key) call.

Implements Slic3r::ConfigBase.

2018{
2020 assert(this->def() != nullptr);
2021 for (const auto &opt_def : this->def()->options)
2022 if (this->option(opt_def.first) != nullptr)
2023 keys.push_back(opt_def.first);
2024 return keys;
2025}
t_config_option_keys keys() const
Gets list of config option names for each config option of this->def, which has a static counter-part...
Definition Config.cpp:2017

References Slic3r::ConfigBase::def(), keys(), and Slic3r::ConfigBase::option().

Referenced by Slic3r::PresetCollection::add_default_preset(), keys(), and set_defaults().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keys_ref()

virtual const t_config_option_keys & Slic3r::StaticPrintConfig::keys_ref ( ) const
pure virtual

◆ load() [1/2]

ConfigSubstitutions Slic3r::ConfigBase::load ( const boost::property_tree::ptree & tree,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
1229{
1230 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
1231 for (const boost::property_tree::ptree::value_type &v : tree) {
1232 try {
1233 t_config_option_key opt_key = v.first;
1234 this->set_deserialize(opt_key, v.second.get_value<std::string>(), substitutions_ctxt);
1235 } catch (UnknownOptionException & /* e */) {
1236 // ignore
1237 }
1238 }
1239 // Do legacy conversion on a completely loaded dictionary.
1240 // Perform composite conversions, for example merging multiple keys into one key.
1242 return std::move(substitutions_ctxt.substitutions);
1243}
virtual void handle_legacy_composite()
Definition Config.hpp:2761
void set_deserialize(const t_config_option_key &opt_key, const std::string &str, ConfigSubstitutionContext &config_substitutions, bool append=false)
Definition Config.cpp:614

References handle_legacy_composite(), set_deserialize(), and Slic3r::ConfigSubstitutionContext::substitutions.

Here is the call graph for this function:

◆ load() [2/2]

ConfigSubstitutions Slic3r::ConfigBase::load ( const std::string & file,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
846{
847 std::map<std::string, std::string> key_values;
848 if (is_gcode_file(file))
849 return this->load_from_gcode_file(file, compatibility_rule);
850 else if (is_json_file(file)) {
851 std::string reason;
852 return this->load_from_json(file, compatibility_rule, key_values, reason);
853 }
854 else {
855 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "unsupported format for config file" << file;
856 return ConfigSubstitutions();
857 //return this->load_from_ini(file, compatibility_rule);
858 }
859}
ConfigSubstitutions load_from_gcode_file(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:1402
int load_from_json(const std::string &file, ConfigSubstitutionContext &substitutions, bool load_inherits_in_config, std::map< std::string, std::string > &key_values, std::string &reason)
Definition Config.cpp:871
std::vector< ConfigSubstitution > ConfigSubstitutions
Definition Config.hpp:269
bool is_json_file(const std::string &path)
Definition utils.cpp:1214
bool is_gcode_file(const std::string &path)
Definition utils.cpp:1208

References Slic3r::is_gcode_file(), Slic3r::is_json_file(), load_from_gcode_file(), and load_from_json().

Referenced by Slic3r::extract_profile(), Slic3r::import_sla_archive(), Slic3r::import_sla_archive(), load_from_ini(), and load_from_ini_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_gcode_file()

ConfigSubstitutions Slic3r::ConfigBase::load_from_gcode_file ( const std::string & file,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
1403{
1404 // Read a 64k block from the end of the G-code.
1405 boost::nowide::ifstream ifs(file);
1406 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": before parse_file %1%") % file.c_str();
1407 // Look for Slic3r or OrcaSlicer header.
1408 // Look for the header across the whole file as the G-code may have been extended at the start by a post-processing script or the user.
1409 //BBS
1410 bool has_delimiters = true;
1411 {
1412 //BBS
1413 std::string bambuslicer_gcode_header = "; OrcaSlicer";
1414
1415 std::string orcaslicer_gcode_header = std::string("; generated by ");
1416 orcaslicer_gcode_header += SLIC3R_APP_NAME;
1417
1418 std::string header;
1419 bool header_found = false;
1420 while (std::getline(ifs, header)) {
1421 // BBS
1422 const char* line_c = skip_whitespaces(header.c_str());
1423 if (std::toupper(*line_c) == 'N')
1424 line_c = skip_word(line_c);
1425 line_c = skip_whitespaces(line_c);
1426 // BBS
1427 if (strncmp(bambuslicer_gcode_header.c_str(), line_c, strlen(bambuslicer_gcode_header.c_str())) == 0 ||
1428 strncmp(orcaslicer_gcode_header.c_str(), line_c, strlen(orcaslicer_gcode_header.c_str())) == 0) {
1429 header_found = true;
1430 break;
1431 }
1432 }
1433 if (!header_found) {
1434 // TRN %1% is the application name.
1435 std::string error_message = format(_u8L("Not a G-code file generated by %1%."), SLIC3R_APP_FULL_NAME);
1436 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << error_message;
1437 throw Slic3r::RuntimeError(error_message.c_str());
1438 }
1439 }
1440
1441 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
1442 size_t key_value_pairs = 0;
1443
1444 if (has_delimiters)
1445 {
1446 //BBS
1447 // PrusaSlicer starting with 2.4.0-alpha0 delimits the config section stored into G-code with
1448 // ; CONFIG_BLOCK_START
1449 // ...
1450 // ; CONFIG_BLOCK_END
1451 bool begin_found = false;
1452 bool end_found = false;
1453 std::string line;
1454 while (std::getline(ifs, line))
1455 if (line.rfind("; CONFIG_BLOCK_START",0)==0) {
1456 begin_found = true;
1457 break;
1458 }
1459 if (!begin_found) {
1460 //BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << format("Configuration block closing tag \"; CONFIG_BLOCK_START\" not found when reading %1%", file);
1461 // TRN %1% is a tag in the G-code file that must not be translated.
1462 throw Slic3r::RuntimeError(format(_u8L("Config tag \"%1%\" not found"), "; CONFIG_BLOCK_START"));
1463 }
1464 std::string key, value;
1465 while (std::getline(ifs, line)) {
1466 if (line.rfind("; CONFIG_BLOCK_END",0)==0) {
1467 end_found = true;
1468 break;
1469 }
1470 // line should be a valid key = value pair.
1471 auto pos = line.find('=');
1472 if (pos != std::string::npos && pos > 1 && line.front() == ';') {
1473 key = line.substr(1, pos - 1);
1474 value = line.substr(pos + 1);
1475 boost::trim(key);
1476 boost::trim(value);
1477 try {
1478 this->set_deserialize(key, value, substitutions_ctxt);
1479 ++ key_value_pairs;
1480 } catch (UnknownOptionException & /* e */) {
1481 // ignore
1482 }
1483 }
1484 }
1485 if (!end_found) {
1486 //BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << format("Configuration block opening tag \"; CONFIG_BLOCK_END\" not found when reading %1%", file);
1487 throw Slic3r::RuntimeError(format(_u8L("Config tag \"%1%\" not found"), "; CONFIG_BLOCK_END"));
1488 }
1489 }
1490 else
1491 {
1492 auto header_end_pos = ifs.tellg();
1493 // Slicer older than 2.4.0-alpha0 do not emit any delimiter.
1494 // Try a heuristics reading the G-code from back.
1495 ifs.seekg(0, ifs.end);
1496 auto file_length = ifs.tellg();
1497 auto data_length = std::min<std::fstream::pos_type>(65535, file_length - header_end_pos);
1498 ifs.seekg(file_length - data_length, ifs.beg);
1499 std::vector<char> data(size_t(data_length) + 1, 0);
1500 ifs.read(data.data(), data_length);
1501 ifs.close();
1502 key_value_pairs = load_from_gcode_string_legacy(*this, data.data(), substitutions_ctxt);
1503 }
1504
1505 if (key_value_pairs < 80) {
1506 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << format("Suspiciously low number of configuration values extracted from %1%: %2%", file, key_value_pairs);
1507 throw Slic3r::RuntimeError(format(_u8L("Suspiciously low number of configuration values extracted from %1%: %2%"), file, key_value_pairs));
1508 }
1509
1510 // Do legacy conversion on a completely loaded dictionary.
1511 // Perform composite conversions, for example merging multiple keys into one key.
1513
1514 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": finished to parse_file %1%") % file.c_str();
1515 return std::move(substitutions_ctxt.substitutions);
1516}
static size_t load_from_gcode_string_legacy(ConfigBase &config, const char *str, ConfigSubstitutionContext &substitutions)
Definition Config.cpp:1264
#define SLIC3R_APP_FULL_NAME
Definition libslic3r.h:11
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
static const char * skip_whitespaces(const char *c)
Definition Config.cpp:1257
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
static const char * skip_word(const char *c)
Definition Config.cpp:1251
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, Slic3r::format(), handle_legacy_composite(), load_from_gcode_string_legacy(), set_deserialize(), Slic3r::skip_whitespaces(), Slic3r::skip_word(), SLIC3R_APP_FULL_NAME, and Slic3r::ConfigSubstitutionContext::substitutions.

Referenced by Slic3r::PresetBundle::config_from_gcode(), load(), and Slic3r::GCodeProcessor::process_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_gcode_string_legacy()

size_t Slic3r::ConfigBase::load_from_gcode_string_legacy ( ConfigBase & config,
const char * str,
ConfigSubstitutionContext & substitutions )
staticinherited
1265{
1266 if (str == nullptr)
1267 return 0;
1268
1269 // BBS. Remove line numbers.
1270 std::regex match_pattern("\nN[0-9]* *");
1271 std::string replace_pattern = "\n";
1272 char* result = (char*)calloc(strlen(str) + 1, 1);
1273 std::regex_replace(result, str, str + strlen(str), match_pattern, replace_pattern);
1274
1275 // Walk line by line in reverse until a non-configuration key appears.
1276 const char *data_start = result;
1277 data_start = skip_whitespaces(data_start);
1278 if (std::toupper(*data_start) == 'N')
1279 data_start = skip_word(data_start);
1280
1281 // boost::nowide::ifstream seems to cook the text data somehow, so less then the 64k of characters may be retrieved.
1282 const char *end = data_start + strlen(data_start);
1283 size_t num_key_value_pairs = 0;
1284 for (;;) {
1285 // Extract next line.
1286 for (--end; end > data_start && (*end == '\r' || *end == '\n'); --end);
1287 if (end == data_start)
1288 break;
1289 const char *start = end ++;
1290 for (; start > data_start && *start != '\r' && *start != '\n'; --start);
1291 if (start == data_start)
1292 break;
1293 // Extracted a line from start to end. Extract the key = value pair.
1294 if (end - (++ start) < 10 || start[0] != ';' || start[1] != ' ')
1295 break;
1296 const char *key = start + 2;
1297 if (!((*key >= 'a' && *key <= 'z') || (*key >= 'A' && *key <= 'Z')))
1298 // A key must start with a letter.
1299 break;
1300 const char *sep = key;
1301 for (; sep != end && *sep != '='; ++ sep) ;
1302 if (sep == end || sep[-1] != ' ' || sep[1] != ' ')
1303 break;
1304 const char *value = sep + 2;
1305 if (value > end)
1306 break;
1307 const char *key_end = sep - 1;
1308 if (key_end - key < 3)
1309 break;
1310 // The key may contain letters, digits and underscores.
1311 for (const char *c = key; c != key_end; ++ c)
1312 if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_')) {
1313 key = nullptr;
1314 break;
1315 }
1316 if (key == nullptr)
1317 break;
1318 try {
1319 config.set_deserialize(std::string(key, key_end), std::string(value, end), substitutions);
1320 ++num_key_value_pairs;
1321 }
1322 catch (UnknownOptionException & /* e */) {
1323 // ignore
1324 }
1325 end = start;
1326 }
1327
1328 // Do legacy conversion on a completely loaded dictionary.
1329 // Perform composite conversions, for example merging multiple keys into one key.
1330 config.handle_legacy_composite();
1331
1332 free(result);
1333 return num_key_value_pairs;
1334}
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841

References ConfigBase(), handle_legacy_composite(), set_deserialize(), Slic3r::skip_whitespaces(), and Slic3r::skip_word().

Referenced by Slic3r::_3MF_Importer::_extract_print_config_from_archive(), Slic3r::_BBS_3MF_Importer::_extract_print_config_from_archive(), load_from_gcode_file(), and Slic3r::load_from_superslicer_gcode_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_ini()

ConfigSubstitutions Slic3r::ConfigBase::load_from_ini ( const std::string & file,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
1170{
1171 try {
1172 boost::property_tree::ptree tree;
1173 boost::nowide::ifstream ifs(file);
1174 boost::property_tree::read_ini(ifs, tree);
1175 return this->load(tree, compatibility_rule);
1176 } catch (const ConfigurationError &e) {
1177 throw ConfigurationError(format(_u8L("Failed loading configuration file \"%1%\": %2%"), file, e.what()));
1178 }
1179}
ConfigSubstitutions load(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:845

References _u8L, Slic3r::format(), and load().

Referenced by Slic3r::_BBS_3MF_Importer::_extract_project_embedded_presets_from_archive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_ini_string()

ConfigSubstitutions Slic3r::ConfigBase::load_from_ini_string ( const std::string & data,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
1182{
1183 boost::property_tree::ptree tree;
1184 std::istringstream iss(data);
1185 boost::property_tree::read_ini(iss, tree);
1186 return this->load(tree, compatibility_rule);
1187}

References load().

Referenced by Slic3r::GUI::Plater::priv::load_files(), and load_from_ini_string_commented().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_ini_string_commented()

ConfigSubstitutions Slic3r::ConfigBase::load_from_ini_string_commented ( std::string && data,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
1192{
1193 // Convert the "data" string into INI format by removing the semi-colons at the start of a line.
1194 // Also the "; generated by PrusaSlicer ..." comment line will be removed.
1195 size_t j = 0;
1196 for (size_t i = 0; i < data.size();)
1197 if (i == 0 || data[i] == '\n') {
1198 // Start of a line.
1199 if (data[i] == '\n') {
1200 // Consume LF, don't keep empty lines.
1201 if (j > 0 && data[j - 1] != '\n')
1202 data[j ++] = data[i];
1203 ++ i;
1204 }
1205 // Skip all leading spaces;
1206 for (; i < data.size() && (data[i] == ' ' || data[i] == '\t'); ++ i) ;
1207 // Skip the semicolon (comment indicator).
1208 if (i < data.size() && data[i] == ';')
1209 ++ i;
1210 // Skip all leading spaces after semicolon.
1211 for (; i < data.size() && (data[i] == ' ' || data[i] == '\t'); ++ i) ;
1212 if (strncmp(data.data() + i, "generated by ", 13) == 0) {
1213 // Skip the "; generated by ..." line.
1214 for (; i < data.size() && data[i] != '\n'; ++ i);
1215 }
1216 } else if (data[i] == '\r' && i + 1 < data.size() && data[i + 1] == '\n') {
1217 // Skip CR.
1218 ++ i;
1219 } else {
1220 // Consume the rest of the data.
1221 data[j ++] = data[i ++];
1222 }
1223 data.erase(data.begin() + j, data.end());
1224
1225 return this->load_from_ini_string(data, compatibility_rule);
1226}
ConfigSubstitutions load_from_ini_string(const std::string &data, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:1181

References load_from_ini_string().

Here is the call graph for this function:

◆ load_from_json() [1/2]

int Slic3r::ConfigBase::load_from_json ( const std::string & file,
ConfigSubstitutionContext & substitutions,
bool load_inherits_in_config,
std::map< std::string, std::string > & key_values,
std::string & reason )
inherited
872{
873 json j;
874 std::list<std::string> different_settings_append;
875 std::string new_support_style;
876 std::string is_infill_first;
877 std::string get_wall_sequence;
878 bool is_project_settings = false;
879
880 CNumericLocalesSetter locales_setter;
881
882 std::function<bool(const json::const_iterator&, const char,const char,const bool,std::string&)> parse_str_arr = [&parse_str_arr](const json::const_iterator& it, const char single_sep,const char array_sep,const bool escape_string_style,std::string& value_str)->bool {
883 // must have consistent type name
884 std::string consistent_type;
885 for (auto iter = it.value().begin(); iter != it.value().end(); ++iter) {
886 if (consistent_type.empty())
887 consistent_type = iter.value().type_name();
888 else {
889 if (consistent_type != iter.value().type_name())
890 return false;
891 }
892 }
893
894 bool first = true;
895 for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
896 if (iter.value().is_array()) {
897 if (!first)
898 value_str += array_sep;
899 else
900 first = false;
901 bool success = parse_str_arr(iter, single_sep, array_sep,escape_string_style, value_str);
902 if (!success)
903 return false;
904 }
905 else if (iter.value().is_string()) {
906 if (!first)
907 value_str += single_sep;
908 else
909 first = false;
910 if (!escape_string_style)
911 value_str += iter.value();
912 else {
913 value_str += "\"";
914 value_str += escape_string_cstyle(iter.value());
915 value_str += "\"";
916 }
917 }
918 else {
919 //should not happen
920 return false;
921 }
922 }
923 return true;
924 };
925
926 try {
927 boost::nowide::ifstream ifs(file);
928 ifs >> j;
929 ifs.close();
930
931 const ConfigDef* config_def = this->def();
932 if (config_def == nullptr) {
933 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": no config defs!";
934 return -1;
935 }
936 //parse the json elements
937 for (auto it = j.begin(); it != j.end(); it++) {
938 if (ascii_iequals(it.key(), BBL_JSON_KEY_VERSION)) {
939 key_values.emplace(BBL_JSON_KEY_VERSION, it.value());
940 }
941 else if (ascii_iequals(it.key(), BBL_JSON_KEY_IS_CUSTOM)) {
942 //skip it
943 }
944 else if (ascii_iequals(it.key(), BBL_JSON_KEY_NAME)) {
945 key_values.emplace(BBL_JSON_KEY_NAME, it.value());
946 if (it.value() == "project_settings")
947 is_project_settings = true;
948 }
949 else if (ascii_iequals(it.key(), BBL_JSON_KEY_URL)) {
950 key_values.emplace(BBL_JSON_KEY_URL, it.value());
951 }
952 else if (ascii_iequals(it.key(), BBL_JSON_KEY_TYPE)) {
953 key_values.emplace(BBL_JSON_KEY_TYPE, it.value());
954 }
955 else if (ascii_iequals(it.key(), BBL_JSON_KEY_SETTING_ID)) {
956 key_values.emplace(BBL_JSON_KEY_SETTING_ID, it.value());
957 }
958 else if (ascii_iequals(it.key(), BBL_JSON_KEY_FILAMENT_ID)) {
959 key_values.emplace(BBL_JSON_KEY_FILAMENT_ID, it.value());
960 }
961 else if (ascii_iequals(it.key(), BBL_JSON_KEY_FROM)) {
962 key_values.emplace(BBL_JSON_KEY_FROM, it.value());
963 }
964 else if (ascii_iequals(it.key(), BBL_JSON_KEY_DESCRIPTION)) {
965 key_values.emplace(BBL_JSON_KEY_DESCRIPTION, it.value());
966 }
967 else if (ascii_iequals(it.key(), BBL_JSON_KEY_INSTANTIATION)) {
968 key_values.emplace(BBL_JSON_KEY_INSTANTIATION, it.value());
969 }
970 else if (!load_inherits_to_config && ascii_iequals(it.key(), BBL_JSON_KEY_INHERITS)) {
971 key_values.emplace(BBL_JSON_KEY_INHERITS, it.value());
972 }
973 else if (!load_inherits_to_config && ascii_iequals(it.key(), BBL_JSON_KEY_INCLUDES)) {
974 key_values.emplace(BBL_JSON_KEY_INCLUDES, it.value().dump());
975 } else if (ascii_iequals(it.key(), ORCA_JSON_KEY_RENAMED_FROM)) {
976 key_values.emplace(ORCA_JSON_KEY_RENAMED_FROM, it.value());
977 } else {
978 t_config_option_key opt_key = it.key();
979 std::string value_str;
980
981 if (it.value().is_string()) {
982 //bool test1 = (it.key() == std::string("end_gcode"));
983 this->set_deserialize(opt_key, it.value(), substitution_context);
984 //some logic for special values
985 if (opt_key == "support_type") {
986 //std::string new_value = dynamic_cast<ConfigOptionString*>(this->option(opt_key))->value;
987 if (it.value() == "hybrid(auto)") {
988 different_settings_append.push_back(opt_key);
989 different_settings_append.push_back("support_style");
990 new_support_style = "tree_hybrid";
991 }
992 } else if (opt_key == "wall_infill_order") {
993 //BBS: check wall_infill order to decide if it be different and append to diff_setting_append
994 if (it.value() == "outer wall/inner wall/infill" || it.value() == "infill/outer wall/inner wall" || it.value() == "inner-outer-inner wall/infill") {
995 get_wall_sequence = "wall_seq_diff_to_system";
996 }
997
998 if (it.value() == "infill/outer wall/inner wall" || it.value() == "infill/inner wall/outer wall") {
999 different_settings_append.push_back("is_infill_first");
1000 is_infill_first = "true";
1001 }
1002 }
1003 }
1004 else if (it.value().is_array()) {
1005 t_config_option_key opt_key_src = opt_key;
1006 this->handle_legacy(opt_key, value_str);
1007 if (opt_key.empty()) {
1008 //BBS: record these options
1009 substitution_context.unrecogized_keys.push_back(opt_key_src);
1010 continue;
1011 }
1012 bool valid = true, first = true;
1013 const ConfigOptionDef* optdef = config_def->get(opt_key);
1014 if (optdef == nullptr) {
1015 // If we didn't find an option, look for any other option having this as an alias.
1016 for (const auto& opt : config_def->options) {
1017 for (const t_config_option_key& opt_key2 : opt.second.aliases) {
1018 if (opt_key2 == opt_key) {
1019 opt_key = opt.first;
1020 optdef = &opt.second;
1021 break;
1022 }
1023 }
1024 if (optdef != nullptr)
1025 break;
1026 }
1027 }
1028
1029 char single_sep = ',';
1030 char array_sep = '#'; // currenty not used
1031 bool escape_string_type = false;
1032 if (optdef) {
1033 switch (optdef->type)
1034 {
1035 case coStrings:
1036 escape_string_type = true;
1037 single_sep = ';';
1038 break;
1039 case coPointsGroups:
1040 single_sep = '#';
1041 break;
1042 default:
1043 break;
1044 }
1045 }
1046
1047 // BBS: we only support 2 depth array
1048 valid = parse_str_arr(it, single_sep, array_sep,escape_string_type, value_str);
1049 if (!valid) {
1050 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse " << file << " error, invalid json array for " << it.key();
1051 break;
1052 }
1053 if (valid)
1054 this->set_deserialize(opt_key, value_str, substitution_context);
1055 }
1056 else {
1057 //should not happen
1058 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<file<<" error, invalid json type for " << it.key();
1059 }
1060 }
1061 }
1062 if (!different_settings_append.empty()) {
1063 if (!new_support_style.empty()) {
1064 ConfigOptionEnum<SupportMaterialStyle>* opt = this->option<ConfigOptionEnum<SupportMaterialStyle>>("support_style", true);
1065 opt->value = smsTreeHybrid;
1066 }
1067
1068 if (!is_infill_first.empty()) {
1069 ConfigOptionBool *opt = this->option<ConfigOptionBool>("is_infill_first", true);
1070 opt->value = true;
1071 }
1072
1073 if (is_project_settings) {
1074 std::vector<std::string>& different_settings = this->option<ConfigOptionStrings>("different_settings_to_system", true)->values;
1075 size_t size = different_settings.size();
1076 if (size == 0) {
1077 const auto *filament_ids = this->option<ConfigOptionStrings>("filament_settings_id");
1078 size = (filament_ids ? filament_ids->values.size() : 0) + 2;
1079 different_settings.resize(size);
1080 }
1081
1082 std::vector<bool> is_first(size, false);
1083 std::vector<std::vector<std::string>> original_diffs(size);
1084 for (int index = 0; index < size; index++)
1085 {
1086 if (different_settings[index].empty()) {
1087 is_first[index] = true;
1088 }
1089 else {
1090 // remove unneeded key
1091 if (get_wall_sequence.empty()) {
1092 std::string wall_sqe_string = "wall_sequence";
1093 int pos=different_settings[index].find(wall_sqe_string);
1094
1095 if (pos != different_settings[index].npos) {
1096 int erase_len = wall_sqe_string.size();
1097 if (pos + erase_len < different_settings[index].size() && different_settings[index][pos + erase_len] == ';')
1098 erase_len++;
1099 different_settings[index].erase(pos, erase_len);
1100 }
1101
1102 }
1103
1104 if (different_settings[index].empty()) {
1105 is_first[index] = true;
1106 continue;
1107 }
1108
1109 Slic3r::unescape_strings_cstyle(different_settings[index], original_diffs[index]);
1110 }
1111 }
1112
1113 for (auto diff_key : different_settings_append)
1114 {
1115 //get the index in the group
1116 int index = 0;
1117 bool need_insert = true;
1118 if (diff_key == "support_type")
1119 index = 0;
1120 else if (diff_key == "support_style")
1121 index = 0;
1122 else if (diff_key == "is_infill_first")
1123 index = 0;
1124
1125 //check whether exist firstly
1126 if (!original_diffs[index].empty()) {
1127 for (int j = 0; j < original_diffs[index].size(); j++) {
1128 if (original_diffs[index][j] == diff_key) {
1129 need_insert = false;
1130 break;
1131 }
1132 }
1133 }
1134 if (!need_insert)
1135 continue;
1136
1137 //insert this key
1138 if (!is_first[index])
1139 different_settings[index] += ";";
1140 else
1141 is_first[index] = false;
1142 different_settings[index] += diff_key;
1143 }
1144 }
1145 }
1146
1147 // Do legacy conversion on a completely loaded dictionary.
1148 // Perform composite conversions, for example merging multiple keys into one key.
1150 return 0;
1151 }
1152 catch (const std::ifstream::failure &err) {
1153 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<file<<" got a ifstream error, reason = " << err.what();
1154 reason = std::string("ifstreamError: ") + err.what();
1155 //throw ConfigurationError(format("Failed loading configuration file \"%1%\": %2%", file, e.what()));
1156 }
1157 catch(nlohmann::detail::parse_error &err) {
1158 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<file<<" got a nlohmann::detail::parse_error, reason = " << err.what();
1159 reason = std::string("JsonParseError: ") + err.what();
1160 //throw ConfigurationError(format("Failed loading configuration file \"%1%\": %2%", file, err.what()));
1161 }
1162 catch(std::exception &err) {
1163 BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<file<<" got a generic exception, reason = " << err.what();
1164 reason = std::string("std::exception: ") + err.what();
1165 }
1166 return -1;
1167}
#define BBL_JSON_KEY_DESCRIPTION
Definition Preset.hpp:59
#define BBL_JSON_KEY_VERSION
Definition Preset.hpp:55
#define BBL_JSON_KEY_INCLUDES
Definition Preset.hpp:76
#define BBL_JSON_KEY_INSTANTIATION
Definition Preset.hpp:77
#define BBL_JSON_KEY_NAME
Definition Preset.hpp:58
#define BBL_JSON_KEY_URL
Definition Preset.hpp:57
#define BBL_JSON_KEY_TYPE
Definition Preset.hpp:66
#define BBL_JSON_KEY_IS_CUSTOM
Definition Preset.hpp:56
#define BBL_JSON_KEY_FROM
Definition Preset.hpp:67
#define ORCA_JSON_KEY_RENAMED_FROM
Definition Preset.hpp:96
#define BBL_JSON_KEY_FILAMENT_ID
Definition Preset.hpp:71
#define BBL_JSON_KEY_INHERITS
Definition Preset.hpp:75
#define BBL_JSON_KEY_SETTING_ID
Definition Preset.hpp:68
virtual void handle_legacy(t_config_option_key &, std::string &) const
Definition Config.hpp:2757
bool unescape_strings_cstyle(const std::string &str, std::vector< std::string > &out)
Definition Config.cpp:173
is_infill_first((ConfigOptionBool, small_area_infill_flow_compensation))((ConfigOptionEnum< WallDirection >
std::string escape_string_cstyle(const std::string &str)
Definition Config.cpp:76
nlohmann::json json
Definition AssembleList.cpp:42
@ smsTreeHybrid
Definition PrintConfig.hpp:363
@ coPointsGroups
Definition Config.hpp:217
@ coStrings
Definition Config.hpp:194
zaa_minimize_perimeter_height filament_ids((ConfigOptionStrings, filament_colour))((ConfigOptionStrings
bool ascii_iequals(std::string_view a, std::string_view b)
Definition Utils.hpp:306
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References Slic3r::ascii_iequals(), BBL_JSON_KEY_DESCRIPTION, BBL_JSON_KEY_FILAMENT_ID, BBL_JSON_KEY_FROM, BBL_JSON_KEY_INCLUDES, BBL_JSON_KEY_INHERITS, BBL_JSON_KEY_INSTANTIATION, BBL_JSON_KEY_IS_CUSTOM, BBL_JSON_KEY_NAME, BBL_JSON_KEY_SETTING_ID, BBL_JSON_KEY_TYPE, BBL_JSON_KEY_URL, BBL_JSON_KEY_VERSION, Slic3r::coPointsGroups, Slic3r::coStrings, def(), Slic3r::empty(), Slic3r::escape_string_cstyle(), Slic3r::filament_ids(), Slic3r::ConfigDef::get(), handle_legacy(), handle_legacy_composite(), Slic3r::is_infill_first(), option(), Slic3r::ConfigDef::options, ORCA_JSON_KEY_RENAMED_FROM, set_deserialize(), Slic3r::smsTreeHybrid, Slic3r::ConfigOptionDef::type, Slic3r::unescape_strings_cstyle(), Slic3r::ConfigSubstitutionContext::unrecogized_keys, and Slic3r::ConfigOptionSingle< T >::value.

Referenced by Slic3r::_BBS_3MF_Importer::_extract_project_config_from_archive(), Slic3r::_BBS_3MF_Importer::_extract_project_embedded_presets_from_archive(), Slic3r::PresetBundle::import_json_presets(), load(), load_from_json(), Slic3r::PhysicalPrinterCollection::load_printers(), and Slic3r::PresetCollection::resolve_user_preset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_json() [2/2]

ConfigSubstitutions Slic3r::ConfigBase::load_from_json ( const std::string & file,
ForwardCompatibilitySubstitutionRule compatibility_rule,
std::map< std::string, std::string > & key_values,
std::string & reason )
inherited
863{
864 int ret = 0;
865 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
866
867 ret = load_from_json(file, substitutions_ctxt, true, key_values, reason);
868 return std::move(substitutions_ctxt.substitutions);
869}

References load_from_json(), and Slic3r::ConfigSubstitutionContext::substitutions.

Here is the call graph for this function:

◆ load_string_map()

ConfigSubstitutions Slic3r::ConfigBase::load_string_map ( std::map< std::string, std::string > & key_values,
ForwardCompatibilitySubstitutionRule compatibility_rule )
inherited
827{
828 CNumericLocalesSetter locales_setter;
829
830 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
831 std::map<std::string, std::string>::iterator it;
832 for (it = key_values.begin(); it != key_values.end(); it++) {
833 try {
834 t_config_option_key opt_key = it->first;
835 this->set_deserialize(opt_key, it->second, substitutions_ctxt);
836 }
837 catch (UnknownOptionException& /* e */) {
838 // ignore
839 }
840 }
841 return std::move(substitutions_ctxt.substitutions);
842}

References set_deserialize(), and Slic3r::ConfigSubstitutionContext::substitutions.

Referenced by Slic3r::PresetCollection::load_user_preset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ null_nullables()

void Slic3r::ConfigBase::null_nullables ( )
inherited
1617{
1618 for (const std::string &opt_key : this->keys()) {
1619 ConfigOption *opt = this->optptr(opt_key, false);
1620 assert(opt != nullptr);
1621 if (opt->nullable())
1622 opt->deserialize("nil", ForwardCompatibilitySubstitutionRule::Disable);
1623 }
1624}
virtual ConfigOption * optptr(const t_config_option_key &opt_key, bool create=false)=0
@ Disable
Definition Config.hpp:243

References Slic3r::Disable, keys(), and optptr().

Here is the call graph for this function:

◆ opt_serialize()

std::string Slic3r::ConfigBase::opt_serialize ( const t_config_option_key & opt_key) const
inherited
567{
568 const ConfigOption* opt = this->option(opt_key);
569 assert(opt != nullptr);
570 return opt->serialize();
571}

References option().

Referenced by Slic3r::_3MF_Exporter::_add_print_config_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_print_config_file_to_archive(), Slic3r::GCode::_do_export(), Slic3r::GCode::append_full_config(), Slic3r::config_value_or_none(), Slic3r::GUI::Plater::export_published_3mf(), and save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ option() [1/2]

const ConfigOption * Slic3r::ConfigOptionResolver::option ( const t_config_option_key & opt_key) const
inlineinherited
2699{ return this->optptr(opt_key); }

◆ option() [2/2]

ConfigOption * Slic3r::ConfigBase::option ( const t_config_option_key & opt_key,
bool create = false )
inlineinherited
2769 { return this->optptr(opt_key, create); }

References optptr().

Referenced by Slic3r::DynamicConfig::DynamicConfig(), Slic3r::Flashforge::Flashforge(), Slic3r::_BBS_3MF_Exporter::_add_model_config_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_slice_info_config_file_to_archive(), Slic3r::_BBS_3MF_Importer::_extract_project_config_from_archive(), Slic3r::_BBS_3MF_Importer::_extract_project_embedded_presets_from_archive(), Slic3r::GUI::GLCanvas3D::_render_arrange_menu(), Slic3r::active_capability_config(), Slic3r::GUI::PresetComboBox::add_ams_filaments(), Slic3r::GUI::ObjectList::add_category_to_settings_from_frequent(), Slic3r::GUI::ObjectList::add_category_to_settings_from_selection(), Slic3r::add_correct_opts_to_diff(), Slic3r::GUI::ObjectSettings::add_missed_options(), Slic3r::GUI::ObjectTableSettings::add_missed_options(), Slic3r::append_bed_exclude_volumes(), Slic3r::GCode::append_full_config(), Slic3r::GUI::MenuFactory::append_menu_items_flush_options(), Slic3r::Search::SettingsIndex::append_options(), Slic3r::WipeTowerIntegration::append_tcr(), Slic3r::GUI::ConfigManipulation::apply(), Slic3r::Print::apply(), Slic3r::SLAPrint::apply(), Slic3r::GCodeProcessor::apply_config(), Slic3r::GUI::ConfigWizard::priv::apply_config(), Slic3r::PlaceholderParser::apply_config(), Slic3r::apply_first_layer_order(), Slic3r::GUI::ConfigManipulation::apply_null_fff_config(), apply_only(), Slic3r::PlaceholderParser::apply_only(), Slic3r::GUI::GLCanvas3D::WipeTowerInfo::apply_wipe_tower(), Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), Slic3r::GUI::PartPlate::belt_open_y(), Slic3r::GUI::PartPlate::build_imex_cache_key(), Slic3r::GUI::SelectMachineDialog::build_nozzles_info(), Slic3r::GUI::SyncAmsInfoDialog::build_nozzles_info(), Slic3r::GUI::PublishSettingsDialog::build_option_model(), Slic3r::GUI::build_plate_tilt_up_direction(), Slic3r::GUI::TabPrinter::cache_extruder_cnt(), Slic3r::GUI::PartPlate::calc_imex_zones(), Slic3r::GUI::CalibUtils::calib_flowrate(), Slic3r::GUI::CalibUtils::calib_max_vol_speed(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), Slic3r::cfg_bool(), Slic3r::cfg_float(), Slic3r::Search::change_opt_key(), Slic3r::GUI::change_opt_value(), Slic3r::GUI::ConfigManipulation::check_adaptive_pressure_advance_model(), Slic3r::GUI::Plater::priv::check_ams_status_impl(), Slic3r::GUI::ConfigManipulation::check_chamber_minimal_temperature(), Slic3r::GUI::ConfigManipulation::check_chamber_temperature(), Slic3r::GUI::ConfigManipulation::check_filament_ironing_spacing(), Slic3r::check_filaments_printable(), Slic3r::GUI::ConfigManipulation::check_nozzle_recommended_temperature_range(), Slic3r::PresetBundle::check_preset_references(), Slic3r::GUI::collect_imex_warnings(), collect_plugin_manifest(), Slic3r::Preset::compatible_printers_condition(), Slic3r::Preset::compatible_prints_condition(), Slic3r::compute_filament_override_value(), Slic3r::compute_imex_zone_layout(), Slic3r::PresetBundle::config_from_gcode(), Slic3r::GUI::construct_extruder_unprintable_error(), Slic3r::PresetBundle::construct_full_config(), Slic3r::GUI::ObjectGridTable::construct_object_configs(), Slic3r::GUI::CreateFilamentPresetDialog::create_filament_preset_item(), Slic3r::GUI::GLGizmoRotate3D::data_changed(), Slic3r::deep_diff(), Slic3r::GUI::Bed3D::detect_type(), diff(), Slic3r::GUI::GLCanvas3D::do_move(), Slic3r::effective_physical_extruder_map(), Slic3r::GUI::ensure_belt_purge_tower(), Slic3r::ensure_process_variant_columns(), equal(), equals(), Slic3r::GUI::Plater::export_3mf(), Slic3r::extend_default_config_length(), Slic3r::extend_extruder_variant(), Slic3r::WipeTower2::extract_wipe_volumes(), Slic3r::GUI::extruder_supports_tpu_high_flow(), Slic3r::GUI::GUI_App::extruders_cnt(), Slic3r::GUI::GUI_App::extruders_edited_cnt(), Slic3r::filter_published_config(), Slic3r::find_fixed_mixed_filament(), Slic3r::find_imex_mode(), Slic3r::CalibPressureAdvance::find_optimal_PA_speed(), Slic3r::anonymous_namespace{PluginResolver.cpp}::find_option_for_capability(), Slic3r::PresetBundle::full_fff_config(), Slic3r::full_print_config_diffs(), Slic3r::PresetBundle::full_sla_config(), Slic3r::GUI::SyncAmsInfoDialog::generate_override_fix_ams_list(), Slic3r::GUI::CreatePrinterPresetDialog::generate_process_presets_data(), get_abs_value(), get_abs_value(), get_abs_value_at(), Slic3r::GUI::NewCalibrationHistoryDialog::get_all_filaments(), Slic3r::GUI::ExtrusionCalibration::get_bed_temp(), Slic3r::anonymous_namespace{SL1.cpp}::get_cfg_value(), Slic3r::GUI::get_config_json(), Slic3r::GUI::GLGizmoBrimEars::get_config_options(), Slic3r::GUI::ConfigOptionsGroup::get_config_value(), Slic3r::ModelObject::get_config_value(), Slic3r::GUI::ConfigOptionsGroup::get_config_value2(), Slic3r::GUI::Plater::get_enable_wrapping_detection(), Slic3r::DynamicPrintConfig::get_extruder_nozzle_volume_count(), Slic3r::get_extruder_supported_nozzle_volume_types(), Slic3r::GUI::Tab::get_extruder_sync_enable_state(), Slic3r::GUI::PartPlate::get_extruders(), Slic3r::GUI::PartPlate::get_extruders_under_cli(), Slic3r::GUI::get_filament_compatible_printer(), Slic3r::GUI::CreateFilamentPresetDialog::get_filament_preset_choices(), Slic3r::GUI::CreateFilamentPresetDialog::get_filament_presets_by_machine(), Slic3r::PresetBundle::get_filament_presets_for_machine(), Slic3r::DynamicPrintConfig::get_filament_type(), Slic3r::DynamicPrintConfig::get_filament_type(), Slic3r::PresetBundle::get_filament_variant_index(), Slic3r::DynamicPrintConfig::get_filament_vendor(), Slic3r::GUI::get_flow_ratio(), Slic3r::GUI::get_formatted_tooltip_text(), Slic3r::GUI::get_full_label(), Slic3r::DynamicPrintConfig::get_index_for_extruder(), Slic3r::get_instance_arrange_poly(), Slic3r::GUI::get_min_flush_volumes(), Slic3r::GUI::PartPlate::get_object_filament_extruders(), Slic3r::GUI::OrientJob::get_orient_mesh(), Slic3r::DynamicPrintConfig::get_parameter_size(), Slic3r::GUI::PartPlate::get_physical_extruder_by_filament_id(), Slic3r::GUI::PartPlate::get_plate_wrapping_detection_area(), Slic3r::PresetCollection::get_preset_differed_for_save(), Slic3r::GUI::get_preset_info(), Slic3r::PrintHost::get_print_host(), Slic3r::PrintHost::get_print_host_webui(), Slic3r::PresetBundle::get_printer_extruder_count(), get_printer_technology(), Slic3r::anonymous_namespace{SL1.cpp}::get_raster_params(), Slic3r::GUI::PartPlate::get_real_filament_map_mode(), Slic3r::GUI::PartPlate::get_real_filament_maps(), Slic3r::GUI::PartPlate::get_real_filament_volume_maps(), Slic3r::get_real_skirt_dist(), Slic3r::GUI::Plater::get_selected_printer_name_in_combox(), Slic3r::GUI::GLGizmoFdmSupports::get_selection_support_threshold_angle(), Slic3r::anonymous_namespace{SL1.cpp}::get_slice_params(), Slic3r::GUI::get_string_from_enum(), Slic3r::GUI::get_string_value(), Slic3r::GUI::PresetComboBox::get_tooltip(), Slic3r::GUI::CreatePresetForPrinterDialog::get_visible_printer_and_compatible_filament_presets(), Slic3r::GUI::ObjectGridTable::get_volume_config_value(), Slic3r::GUI::getExtruderNozzleCount(), Slic3r::GUI::getExtruderNozzleCountTotal(), Slic3r::PrintConfigDef::handle_legacy_composite(), Slic3r::handle_legacy_project_loaded(), Slic3r::PresetBundle::has_errors(), Slic3r::GUI::PartPlate::has_imex_multimaterial_conflict(), Slic3r::DynamicPrintConfig::has_multi_variant_filament(), Slic3r::has_skirt(), Slic3r::imex_cfg_bool(), Slic3r::imex_cfg_enum(), Slic3r::imex_cfg_float(), Slic3r::imex_cfg_int(), Slic3r::imex_mode_table(), Slic3r::GUI::PartPlate::imex_wipe_tower_hull(), Slic3r::PresetBundle::import_json_presets(), Slic3r::Preset::inherits(), Slic3r::GUI::ObjectTablePanel::init_filaments_and_colors(), Slic3r::GUI::init_multi_extruder_params_for_cali(), Slic3r::plugin_hooks::anonymous_namespace{PluginHooks.cpp}::install_slicing_pipeline_hook(), Slic3r::is_compatible_with_parent_printer(), Slic3r::is_compatible_with_print(), Slic3r::is_compatible_with_printer(), Slic3r::is_compatible_with_printer(), Slic3r::GUI::CalibrationPresetPage::is_filament_in_blacklist(), Slic3r::is_printable_filament_changed(), Slic3r::GUI::is_soluble_filament(), Slic3r::GUI::is_support_filament(), Slic3r::DynamicPrintConfig::is_using_different_extruders(), Slic3r::StaticConfig::keys(), legacy_bed_exclude_area_points(), Slic3r::GUI::MainFrame::load_config(), Slic3r::GUI::Tab::load_config(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::GUI::Tab::load_current_preset(), load_default_gcodes_to_config(), Slic3r::PresetCollection::load_external_preset(), Slic3r::GUI::Plater::priv::load_files(), load_from_json(), Slic3r::GUI::MenuFactory::load_handy_model(), Slic3r::load_mixed_filament_settings(), Slic3r::PresetCollection::load_project_embedded_presets(), Slic3r::PresetBundle::load_selections(), Slic3r::GUI::ObjectList::load_shape_object(), Slic3r::PresetCollection::load_user_preset(), Slic3r::GCodeThumbnails::make_and_check_thumbnail_list(), Slic3r::GUI::manuallySetNozzleCount(), Slic3r::GUI::IMEXModesCtrl::matches_config(), Slic3r::min_object_distance(), Slic3r::GUI::mixed_gradient_curve(), Slic3r::GUI::mixed_gradient_ramp(), Slic3r::GUI::anonymous_namespace{GLGizmoTextureDisplacement.cpp}::mixed_slot_signature(), Slic3r::normalize_compatible_field(), Slic3r::DynamicPrintConfig::normalize_fdm(), Slic3r::DynamicPrintConfig::normalize_fdm_1(), Slic3r::DynamicPrintConfig::normalize_fdm_2(), Slic3r::normalize_filament_values_to_variants(), Slic3r::GUI::PartPlateList::notify_instance_update(), Slic3r::GUI::FlowRateWizard::on_cali_start(), Slic3r::GUI::Plater::on_filament_change(), Slic3r::GUI::TabPrinter::on_preset_loaded(), Slic3r::GUI::CalibrationPresetPage::on_recommend_input_value(), Slic3r::GUI::GLGizmoBrimEars::on_render_input_window(), Slic3r::GUI::GLGizmoFuzzySkin::on_render_input_window(), Slic3r::GUI::AMSMaterialsSetting::on_select_filament(), Slic3r::GUI::Plater::priv::on_select_preset(), Slic3r::GUI::Tab::on_value_change(), Slic3r::GUI::Plater::open_filament_map_setting_dialog(), Slic3r::DynamicConfig::opt(), Slic3r::DynamicConfig::opt(), Slic3r::DynamicConfig::opt_bool(), Slic3r::DynamicConfig::opt_bool(), Slic3r::DynamicConfig::opt_bool_nullable(), Slic3r::DynamicConfig::opt_enum(), Slic3r::DynamicConfig::opt_enum(), Slic3r::DynamicConfig::opt_enum_nullable(), Slic3r::DynamicConfig::opt_float(), Slic3r::DynamicConfig::opt_float(), Slic3r::DynamicConfig::opt_float(), Slic3r::DynamicConfig::opt_float(), Slic3r::DynamicConfig::opt_float_nullable(), Slic3r::DynamicConfig::opt_float_nullable(), Slic3r::DynamicConfig::opt_float_or_percent_nullable(), Slic3r::DynamicConfig::opt_float_or_percent_nullable(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_int(), Slic3r::DynamicConfig::opt_int_nullable(), Slic3r::DynamicConfig::opt_int_nullable(), opt_serialize(), Slic3r::DynamicConfig::opt_string(), Slic3r::DynamicConfig::opt_string(), Slic3r::option_of(), Slic3r::opts_equal(), Slic3r::GUI::anonymous_namespace{Plater.cpp}::parse_mixed_gradient_slots(), Slic3r::GUI::ObjectList::paste_settings_into_list(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::place_wipe_tower(), Slic3r::GUI::AMSMaterialsSetting::Popup(), Slic3r::GUI::FillBedJob::prepare(), Slic3r::GUI::ArrangeJob::prepare_all(), Slic3r::GUI::ArrangeJob::prepare_partplate(), Slic3r::BackgroundSlicingProcess::prepare_upload(), Slic3r::GUI::ArrangeJob::prepare_wipe_tower(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::preset_templates(), Slic3r::prime_tower_is_printed(), Slic3r::print_config_diffs(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::printable_area_center(), Slic3r::PhysicalPrinter::printer_technology(), Slic3r::Preset::printer_technology(), Slic3r::Preset::printer_technology_ref(), Slic3r::GUI::ArrangeJob::process(), Slic3r::GUI::CalibUtils::process_and_store_3mf(), Slic3r::BackgroundSlicingProcess::process_sla(), Slic3r::anonymous_namespace{PrintConfig.cpp}::project_bed_material_keepouts(), Slic3r::prune_stale_plugin_overrides(), Slic3r::DynamicConfig::read_cli(), Slic3r::ImexArrangeInput::read_config(), Slic3r::GUI::recompute_mixed_slot_colors(), Slic3r::referenced_capabilities(), Slic3r::GUI::PartPlate::refresh_imex_icon(), Slic3r::refresh_missing_plugins(), Slic3r::GUI::PartPlate::register_raycasters_for_picking(), Slic3r::PresetBundle::reload_local_bundle(), Slic3r::GUI::ObjectGridTable::reload_object_data(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::GUI::PartPlate::render_icons(), Slic3r::GUI::SelectMachineDialog::reset_and_sync_ams_list(), Slic3r::GUI::SyncAmsInfoDialog::reset_and_sync_ams_list(), Slic3r::PresetBundle::reset_default_nozzle_volume_type(), Slic3r::PresetBundle::reset_project_embedded_presets(), Slic3r::GUI::IMEXModesCtrl::reset_row_to_parent(), Slic3r::resize_mixed_filament_metadata(), Slic3r::GUI::PartPlate::resolve_active_mode_tools(), Slic3r::PresetCollection::resolve_user_preset(), Slic3r::PresetBundle::resolve_vendor_preset(), Slic3r::resolve_wipe_tower_type(), Slic3r::GUI::IMEXModesCtrl::row_differs_from_parent(), Slic3r::GUI::IMEXModesCtrl::row_has_parent_counterpart(), Slic3r::CLI::run(), Slic3r::GUI::s_get_slicing_extuder_nozzles(), Slic3r::anonymous_namespace{Flashforge.cpp}::safe_config_string(), Slic3r::Preset::save(), Slic3r::GUI::CalibrationWizard::save_preset_with_index(), save_to_json(), Slic3r::GUI::Selection::scale_to_fit_print_volume(), Slic3r::GUI::sCheckFilamentInfo(), Slic3r::GUI::seedExtruderNozzleStats(), Slic3r::GUI::Tab::select_preset(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::select_printer_default_presets(), Slic3r::GUI::Plater::send_gcode_legacy(), Slic3r::PresetBundle::set_calibrate_printer(), Slic3r::GUI::set_config_values(), Slic3r::GUI::PartPlateList::set_default_wipe_tower_pos_for_plate(), Slic3r::StaticConfig::set_defaults(), set_deserialize_raw(), Slic3r::set_filament_dev_options(), Slic3r::GUI::CalibUtils::set_for_auto_pa_model_and_config(), Slic3r::DynamicPrintConfig::set_num_extruders(), Slic3r::DynamicPrintConfig::set_num_filaments(), Slic3r::GUI::PartPlate::set_shape(), Slic3r::GUI::PartPlate::set_vase_mode_related_object_config(), anonymous_namespace{OrcaSlicer_profile_validator.cpp}::slice_config(), Slic3r::DynamicPrintConfig::support_different_extruders(), Slic3r::GUI::support_nozzle_volume(), Slic3r::GUI::Sidebar::priv::switch_diameter(), Slic3r::GUI::Sidebar::priv::switch_diameter_to(), Slic3r::GUI::Tab::switch_excluder(), Slic3r::GUI::SendMultiMachinePage::sync_ams_list(), Slic3r::GUI::Sidebar::sync_ams_list(), Slic3r::GUI::PlaterPresetComboBox::sync_colour_config(), Slic3r::GUI::Tab::sync_excluder(), Slic3r::GUI::Sidebar::priv::sync_extruder_list(), Slic3r::GUI::Plater::priv::take_snapshot(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), Slic3r::GUI::Plater::priv::undo_redo_to(), Slic3r::GUI::PlaterPresetComboBox::update(), Slic3r::GUI::PresetComboBox::update_ams_color(), Slic3r::GLVolumeCollection::update_colors_by_extruder(), Slic3r::GUI::CalibrationPresetPage::update_combobox_filaments(), Slic3r::PresetBundle::update_compatible(), Slic3r::PresetCollection::update_compatible_internal(), Slic3r::GUI::ObjectTableSettings::update_config_values(), Slic3r::GUI::update_custom_filaments(), Slic3r::DynamicPrintConfig::update_diff_values_to_child_config(), Slic3r::GUI::Plater::update_filament_colors_in_full_config(), Slic3r::DynamicPrintConfig::update_filament_config_values_for_multiple_extruders(), Slic3r::GUI::TabFilament::update_filament_overrides_page(), Slic3r::GUI::Plater::update_flush_volume_matrix(), Slic3r::GUI::TabPrintModel::update_model_config(), Slic3r::DynamicPrintConfig::update_non_diff_values_to_base_config(), update_plugin_manifest(), Slic3r::GUI::Tab::update_preset_description_line(), Slic3r::GUI::Sidebar::update_presets(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), Slic3r::update_static_print_config_from_dynamic(), Slic3r::GUI::UnsavedChangesDialog::update_tree(), Slic3r::GUI::UnsavedChangesDialog::update_tree(), Slic3r::DynamicPrintConfig::update_values_from_multi_to_multi(), Slic3r::DynamicPrintConfig::update_values_from_multi_to_multi_2(), Slic3r::DynamicPrintConfig::update_values_from_single_to_multi(), Slic3r::DynamicPrintConfig::update_values_to_printer_extruders(), Slic3r::DynamicPrintConfig::update_values_to_printer_extruders_for_multiple_filaments(), Slic3r::GUI::updateNozzleCountDisplay(), Slic3r::DynamicPrintConfig::validate(), Slic3r::GUI::Tab::validate_filament_temperature_pairs(), Slic3r::PresetBundle::validate_presets(), Slic3r::GUI::variant_keys(), and Slic3r::GUI::zero_pressure_advance_where_disabled().

Here is the call graph for this function:

◆ option_throw() [1/2]

const ConfigOption * Slic3r::ConfigOptionResolver::option_throw ( const t_config_option_key & opt_key) const
inlineinherited
2709 {
2710 const ConfigOption* opt = this->optptr(opt_key);
2711 if (opt == nullptr)
2712 throw UnknownOptionException(opt_key);
2713 return opt;
2714 }

◆ option_throw() [2/2]

ConfigOption * Slic3r::ConfigBase::option_throw ( const t_config_option_key & opt_key,
bool create = false )
inlineinherited
2783 {
2784 ConfigOption *opt = this->optptr(opt_key, create);
2785 if (opt == nullptr)
2786 throw UnknownOptionException(opt_key);
2787 return opt;
2788 }

References optptr().

Referenced by option_throw(), set(), set(), set(), set(), and set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ optptr() [1/2]

virtual const ConfigOption * Slic3r::ConfigOptionResolver::optptr ( const t_config_option_key & opt_key) const
virtualinherited

Implements Slic3r::ConfigOptionResolver.

Reimplemented in Slic3r::DynamicConfig.

◆ optptr() [2/2]

virtual ConfigOption * Slic3r::ConfigBase::optptr ( const t_config_option_key & opt_key,
bool create = false )
pure virtualinherited

Implemented in Slic3r::DynamicConfig.

Referenced by null_nullables(), option(), and option_throw().

Here is the caller graph for this function:

◆ save()

void Slic3r::ConfigBase::save ( const std::string & file) const
inherited
1604{
1605 boost::nowide::ofstream c;
1606 c.open(file, std::ios::out | std::ios::trunc);
1607 c << "# " << Slic3r::header_slic3r_generated() << std::endl;
1608 for (const std::string &opt_key : this->keys())
1609 c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
1610 c.close();
1611
1612 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(", saved config to %1%\n")%file;
1613}
std::string opt_serialize(const t_config_option_key &opt_key) const
Definition Config.cpp:566
std::string header_slic3r_generated()
Definition utils.cpp:1470

References Slic3r::header_slic3r_generated(), keys(), and opt_serialize().

Here is the call graph for this function:

◆ save_to_json() [1/2]

void Slic3r::ConfigBase::save_to_json ( const std::string & file,
const std::string & name,
const std::string & from,
const std::string & version ) const
inherited
1543{
1544 // Serialize first: if that throws (invalid UTF-8), the existing file stays untouched.
1545 std::ostringstream ss;
1546 this->save_to_json(ss, name, from, version);
1547 if (const std::error_code ec = write_file_atomically(file, ss.str()))
1548 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": failed to save config to %1%: %2%") % file % ec.message();
1549 else
1550 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" <<__LINE__ << boost::format(", saved config to %1%\n")%file;
1551}
void save_to_json(const std::string &file, const std::string &name, const std::string &from, const std::string &version) const
Definition Config.cpp:1542
std::error_code write_file_atomically(const std::string &path, std::initializer_list< std::string_view > chunks, bool binary)
Definition utils.cpp:796

References save_to_json(), and Slic3r::write_file_atomically().

Referenced by Slic3r::_BBS_3MF_Exporter::_add_project_config_file_to_archive(), Slic3r::_BBS_3MF_Exporter::_add_project_embedded_presets_to_archive(), Slic3r::PresetBundle::export_current_configs(), Slic3r::Preset::save(), and save_to_json().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_to_json() [2/2]

void Slic3r::ConfigBase::save_to_json ( std::ostream & os,
const std::string & name,
const std::string & from,
const std::string & version,
bool replace_invalid_utf8 = false ) const
inherited
1554{
1555 json j;
1556 //record the headers
1557 j[BBL_JSON_KEY_VERSION] = version;
1558 j[BBL_JSON_KEY_NAME] = name;
1559 j[BBL_JSON_KEY_FROM] = from;
1560
1561 //record all the key-values
1562 for (const std::string &opt_key : this->keys())
1563 {
1564 const ConfigOption* opt = this->option(opt_key);
1565 if ( opt->is_scalar() ) {
1566 if (opt->type() == coString && (opt_key != "bed_custom_texture" && opt_key != "bed_custom_model"))
1567 //keep \n, \r, \t
1568 j[opt_key] = (dynamic_cast<const ConfigOptionString *>(opt))->value;
1569 else
1570 j[opt_key] = opt->serialize();
1571 }
1572 else {
1573 const ConfigOptionVectorBase* vec = static_cast<const ConfigOptionVectorBase*>(opt);
1574 //if (!vec->empty())
1575 std::vector<std::string> string_values = vec->vserialize();
1576
1577 /*for (int i = 0; i < string_values.size(); i++)
1578 {
1579 std::string string_value = escape_string_cstyle(string_values[i]);
1580 j[opt_key][i] = string_value;
1581 }*/
1582
1583 json j_array(string_values);
1584 j[opt_key] = j_array;
1585 }
1586 }
1587
1588 // Serialize the top-level "plugins" manifest: the individual plugin-backed options keep bare
1589 // capability names; the full "name;uuid;capability" references are derived here (same helper as
1590 // update_plugin_manifest). Only with a resolver (GUI); without one (CLI/headless) leave whatever
1591 // the "plugins" option already serialized above, so a round-trip never drops the manifest.
1593 std::vector<std::string> unique_refs = this->collect_plugin_manifest();
1594 if (unique_refs.empty())
1595 j.erase("plugins");
1596 else
1597 j["plugins"] = unique_refs;
1598 }
1599
1600 os << j.dump(1, '\t', false, replace_invalid_utf8 ? json::error_handler_t::replace : json::error_handler_t::strict) << std::endl;
1601}
std::vector< std::string > collect_plugin_manifest() const
Definition Config.cpp:1662
static std::function< std::string(std::string, std::string)> resolve_capability_fn
Definition Config.hpp:2904
zaa_minimize_perimeter_height ConfigOptionString
Definition PrintConfig.hpp:1702
@ coString
Definition Config.hpp:192

References BBL_JSON_KEY_FROM, BBL_JSON_KEY_NAME, BBL_JSON_KEY_VERSION, collect_plugin_manifest(), Slic3r::coString, keys(), option(), resolve_capability_fn, and Slic3r::ConfigOptionVectorBase::vserialize().

Here is the call graph for this function:

◆ set() [1/5]

void Slic3r::ConfigBase::set ( const std::string & opt_key,
bool value,
bool create = false )
inlineinherited
2823 { this->option_throw<ConfigOptionBool>(opt_key, create)->value = value; }
ConfigOption * option_throw(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2782

References option_throw().

Referenced by Slic3r::Print::apply(), Slic3r::extract_profile(), Slic3r::import_sla_archive(), Slic3r::CLI::run(), and Slic3r::GUI::CreatePrinterPresetDialog::save_printable_area_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [2/5]

void Slic3r::ConfigBase::set ( const std::string & opt_key,
const char * value,
bool create = false )
inlineinherited
2827 { this->option_throw<ConfigOptionString>(opt_key, create)->value = value; }

References option_throw().

Here is the call graph for this function:

◆ set() [3/5]

void Slic3r::ConfigBase::set ( const std::string & opt_key,
const std::string & value,
bool create = false )
inlineinherited
2829 { this->option_throw<ConfigOptionString>(opt_key, create)->value = value; }

References option_throw().

Here is the call graph for this function:

◆ set() [4/5]

void Slic3r::ConfigBase::set ( const std::string & opt_key,
double value,
bool create = false )
inherited
586{
587 ConfigOption *opt = this->option_throw(opt_key, create);
588 switch (opt->type()) {
589 case coFloat: static_cast<ConfigOptionFloat*>(opt)->value = value; break;
590 case coFloatOrPercent: static_cast<ConfigOptionFloatOrPercent*>(opt)->value = value; static_cast<ConfigOptionFloatOrPercent*>(opt)->percent = false; break;
591 case coString: static_cast<ConfigOptionString*>(opt)->value = float_to_string_decimal_point(value); break;
592 default: throw BadOptionTypeException("Configbase::set() - conversion from float not possible");
593 }
594}
std::string float_to_string_decimal_point(double value, int precision)
Definition LocalesUtils.cpp:108

References Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coString, Slic3r::float_to_string_decimal_point(), and option_throw().

Here is the call graph for this function:

◆ set() [5/5]

void Slic3r::ConfigBase::set ( const std::string & opt_key,
int value,
bool create = false )
inherited
574{
575 ConfigOption *opt = this->option_throw(opt_key, create);
576 switch (opt->type()) {
577 case coInt: static_cast<ConfigOptionInt*>(opt)->value = value; break;
578 case coFloat: static_cast<ConfigOptionFloat*>(opt)->value = value; break;
579 case coFloatOrPercent: static_cast<ConfigOptionFloatOrPercent*>(opt)->value = value; static_cast<ConfigOptionFloatOrPercent*>(opt)->percent = false; break;
580 case coString: static_cast<ConfigOptionString*>(opt)->value = std::to_string(value); break;
581 default: throw BadOptionTypeException("Configbase::set() - conversion from int not possible");
582 }
583}

References Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coString, and option_throw().

Here is the call graph for this function:

◆ set_defaults()

void Slic3r::StaticConfig::set_defaults ( )
protectedinherited

Set all statically defined config options to their defaults defined by this->def().

2004{
2005 // use defaults from definition
2006 auto *defs = this->def();
2007 if (defs != nullptr) {
2008 for (const std::string &key : this->keys()) {
2009 const ConfigOptionDef *def = defs->get(key);
2010 ConfigOption *opt = this->option(key);
2011 if (def != nullptr && opt != nullptr && def->default_value)
2012 opt->set(def->default_value.get());
2013 }
2014 }
2015}

References Slic3r::ConfigBase::def(), keys(), and Slic3r::ConfigBase::option().

Here is the call graph for this function:

◆ set_deserialize() [1/2]

void Slic3r::ConfigBase::set_deserialize ( const t_config_option_key & opt_key,
const std::string & str,
ConfigSubstitutionContext & config_substitutions,
bool append = false )
inherited
615{
616 if (! this->set_deserialize_nothrow(opt_key_src, value_src, substitutions_ctxt, append))
617 throw BadOptionValueException(format(_u8L("Invalid value provided for parameter %1%: %2%"), opt_key_src, value_src));
618}
bool set_deserialize_nothrow(const t_config_option_key &opt_key_src, const std::string &value_src, ConfigSubstitutionContext &substitutions, bool append=false)
Definition Config.cpp:596
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:157

References _u8L, Slic3r::append(), Slic3r::format(), and set_deserialize_nothrow().

Referenced by construct_assemble_list(), load(), load_from_gcode_file(), load_from_gcode_string_legacy(), load_from_json(), load_string_map(), set_deserialize(), set_deserialize_strict(), and set_deserialize_strict().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_deserialize() [2/2]

void Slic3r::ConfigBase::set_deserialize ( std::initializer_list< SetDeserializeItem > items,
ConfigSubstitutionContext & substitutions )
inherited
621{
622 for (const SetDeserializeItem &item : items)
623 this->set_deserialize(item.opt_key, item.opt_value, substitutions_ctxt, item.append);
624}
Definition Config.hpp:2838

References set_deserialize().

Here is the call graph for this function:

◆ set_deserialize_nothrow()

bool Slic3r::ConfigBase::set_deserialize_nothrow ( const t_config_option_key & opt_key_src,
const std::string & value_src,
ConfigSubstitutionContext & substitutions,
bool append = false )
inherited
597{
598 t_config_option_key opt_key = opt_key_src;
599 std::string value = value_src;
600 // Both opt_key and value may be modified by handle_legacy().
601 // If the opt_key is no more valid in this version of Slic3r, opt_key is cleared by handle_legacy().
602 this->handle_legacy(opt_key, value);
603 if (opt_key.empty()) {
604 // Ignore the option.
605 //BBS: record these options, keep only one repeated opt_key
606 auto iter = std::find(substitutions_ctxt.unrecogized_keys.begin(), substitutions_ctxt.unrecogized_keys.end(), opt_key_src);
607 if (iter == substitutions_ctxt.unrecogized_keys.end())
608 substitutions_ctxt.unrecogized_keys.push_back(opt_key_src);
609 return true;
610 }
611 return this->set_deserialize_raw(opt_key, value, substitutions_ctxt, append);
612}
bool set_deserialize_raw(const t_config_option_key &opt_key_src, const std::string &value, ConfigSubstitutionContext &substitutions, bool append)
Definition Config.cpp:626

References Slic3r::append(), handle_legacy(), set_deserialize_raw(), and Slic3r::ConfigSubstitutionContext::unrecogized_keys.

Referenced by Slic3r::DynamicConfig::read_cli(), and set_deserialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_deserialize_strict() [1/2]

void Slic3r::ConfigBase::set_deserialize_strict ( const t_config_option_key & opt_key,
const std::string & str,
bool append = false )
inlineinherited
2837 { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(opt_key, str, ctxt, append); }

References Slic3r::append(), Slic3r::Disable, and set_deserialize().

Referenced by Slic3r::GUI::Tab::apply_preset_config_values().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_deserialize_strict() [2/2]

void Slic3r::ConfigBase::set_deserialize_strict ( std::initializer_list< SetDeserializeItem > items)
inlineinherited
2854 { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(items, ctxt); }

References Slic3r::Disable, and set_deserialize().

Here is the call graph for this function:

◆ set_resolve_capability_fn()

void Slic3r::ConfigBase::set_resolve_capability_fn ( std::function< std::string(std::string, std::string)> fn)
inlinestaticinherited
2893{ resolve_capability_fn = fn; }

References resolve_capability_fn.

Referenced by Slic3r::plugin_hooks::anonymous_namespace{PluginHooks.cpp}::install_capability_resolver(), and Slic3r::plugin_hooks::uninstall().

Here is the caller graph for this function:

◆ setenv_()

void Slic3r::ConfigBase::setenv_ ( ) const
inherited
808{
809 t_config_option_keys opt_keys = this->keys();
810 for (t_config_option_keys::const_iterator it = opt_keys.begin(); it != opt_keys.end(); ++it) {
811 // prepend the SLIC3R_ prefix
812 std::ostringstream ss;
813 ss << "SLIC3R_";
814 ss << *it;
815 std::string envname = ss.str();
816
817 // capitalize environment variable name
818 for (size_t i = 0; i < envname.size(); ++i)
819 envname[i] = (envname[i] <= 'z' && envname[i] >= 'a') ? envname[i]-('a'-'A') : envname[i];
820
821 boost::nowide::setenv(envname.c_str(), this->opt_serialize(*it).c_str(), 1);
822 }
823}

References keys().

Referenced by Slic3r::run_post_process_scripts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_plugin_manifest()

void Slic3r::ConfigBase::update_plugin_manifest ( )
inherited
1678{
1679 // Writes the derived manifest back into this config's "plugins" option (save_to_json writes the
1680 // same manifest into a JSON document instead), so an in-memory backend config carries a resolved
1681 // manifest even when the source preset was never serialized (picked-but-unsaved). Without a
1682 // resolver (CLI/headless) leave whatever manifest was loaded from disk untouched.
1684 return;
1685 if (auto* manifest = this->option<ConfigOptionStrings>("plugins", true))
1686 manifest->values = this->collect_plugin_manifest();
1687}

References collect_plugin_manifest(), option(), and resolve_capability_fn.

Here is the call graph for this function:

The documentation for this class was generated from the following file: