Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::DynamicConfig Class Reference

#include <src/libslic3r/Config.hpp>

+ Inheritance diagram for Slic3r::DynamicConfig:
+ Collaboration diagram for Slic3r::DynamicConfig:

Public Member Functions

 DynamicConfig ()=default
 
 DynamicConfig (const DynamicConfig &rhs)
 
 DynamicConfig (DynamicConfig &&rhs) noexcept
 
 DynamicConfig (const ConfigBase &rhs, const t_config_option_keys &keys)
 
 DynamicConfig (const ConfigBase &rhs)
 
virtual ~DynamicConfig () override=default
 
DynamicConfigoperator= (const DynamicConfig &rhs)
 
DynamicConfigoperator= (DynamicConfig &&rhs) noexcept
 
DynamicConfigoperator+= (const DynamicConfig &rhs)
 
DynamicConfigoperator+= (DynamicConfig &&rhs)
 
bool operator== (const DynamicConfig &rhs) const
 
bool operator!= (const DynamicConfig &rhs) const
 
void swap (DynamicConfig &other)
 
void clear ()
 
bool erase (const t_config_option_key &opt_key)
 
size_t remove_nil_options ()
 
const ConfigDefdef () const override
 
const ConfigOptionoptptr (const t_config_option_key &opt_key) const override
 
ConfigOptionoptptr (const t_config_option_key &opt_key, bool create=false) override
 
t_config_option_keys keys () const override
 
bool empty () const
 
bool set_key_value (const std::string &opt_key, ConfigOption *opt)
 
bool equals (const DynamicConfig &other) const
 
t_config_option_keys diff (const DynamicConfig &other) const
 
t_config_option_keys equal (const DynamicConfig &other) const
 
bool read_cli (int argc, const char *const argv[], t_config_option_keys *extra, t_config_option_keys *keys=nullptr)
 
std::map< t_config_option_key, std::unique_ptr< ConfigOption > >::const_iterator cbegin () const
 
std::map< t_config_option_key, std::unique_ptr< ConfigOption > >::const_iterator cend () const
 
size_t size () const
 
ConfigOptionoption (const t_config_option_key &opt_key, bool create=false)
 
template<typename TYPE >
TYPE * option (const t_config_option_key &opt_key, bool create=false)
 
const ConfigOptionoption (const t_config_option_key &opt_key) const
 
template<typename TYPE >
const TYPE * option (const t_config_option_key &opt_key) const
 
ConfigOptionoption_throw (const t_config_option_key &opt_key, bool create=false)
 
template<typename TYPE >
TYPE * option_throw (const t_config_option_key &opt_key, bool create=false)
 
const ConfigOptionoption_throw (const t_config_option_key &opt_key) const
 
template<typename TYPE >
const TYPE * option_throw (const t_config_option_key &opt_key) const
 
template<class T >
T * opt (const t_config_option_key &opt_key, bool create=false)
 
template<class T >
const T * opt (const t_config_option_key &opt_key) const
 
const ConfigOptionDefoption_def (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
 
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 (const t_config_option_key &opt_key) const
 
double get_abs_value (const t_config_option_key &opt_key, double ratio_over) const
 
std::string & opt_string (const t_config_option_key &opt_key, bool create=false)
 
const std::string & opt_string (const t_config_option_key &opt_key) const
 
std::string & opt_string (const t_config_option_key &opt_key, unsigned int idx)
 
const std::string & opt_string (const t_config_option_key &opt_key, unsigned int idx) const
 
double & opt_float (const t_config_option_key &opt_key)
 
const double & opt_float (const t_config_option_key &opt_key) const
 
double & opt_float (const t_config_option_key &opt_key, unsigned int idx)
 
const double & opt_float (const t_config_option_key &opt_key, unsigned int idx) const
 
int & opt_int (const t_config_option_key &opt_key)
 
int opt_int (const t_config_option_key &opt_key) const
 
int & opt_int (const t_config_option_key &opt_key, unsigned int idx)
 
int opt_int (const t_config_option_key &opt_key, unsigned int idx) const
 
template<typename ENUM >
ENUM opt_enum (const t_config_option_key &opt_key) const
 
bool opt_bool (const t_config_option_key &opt_key) const
 
bool opt_bool (const t_config_option_key &opt_key, unsigned int idx) 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_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 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)
 

Protected Member Functions

virtual void handle_legacy (t_config_option_key &, std::string &) const
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar)
 
bool set_deserialize_raw (const t_config_option_key &opt_key_src, const std::string &value, ConfigSubstitutionContext &substitutions, bool append)
 

Private Attributes

std::map< t_config_option_key, std::unique_ptr< ConfigOption > > options
 

Friends

class cereal::access
 

Detailed Description

Constructor & Destructor Documentation

◆ DynamicConfig() [1/5]

Slic3r::DynamicConfig::DynamicConfig ( )
default

◆ DynamicConfig() [2/5]

Slic3r::DynamicConfig::DynamicConfig ( const DynamicConfig rhs)
inline
2326{ *this = rhs; }

◆ DynamicConfig() [3/5]

Slic3r::DynamicConfig::DynamicConfig ( DynamicConfig &&  rhs)
inlinenoexcept
2327: options(std::move(rhs.options)) { rhs.options.clear(); }
std::map< t_config_option_key, std::unique_ptr< ConfigOption > > options
Definition Config.hpp:2458

◆ DynamicConfig() [4/5]

Slic3r::DynamicConfig::DynamicConfig ( const ConfigBase rhs,
const t_config_option_keys keys 
)
explicit
1052{
1053 for (const t_config_option_key& opt_key : keys)
1054 this->options[opt_key] = std::unique_ptr<ConfigOption>(rhs.option(opt_key)->clone());
1055}
t_config_option_keys keys() const override
Definition Config.cpp:1233
Definition getopt.h:102
VoxelGridPtr clone(const VoxelGrid &grid)
Definition OpenVDBUtils.cpp:285
std::string t_config_option_key
Definition Config.hpp:76
STL namespace.

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

+ Here is the call graph for this function:

◆ DynamicConfig() [5/5]

Slic3r::DynamicConfig::DynamicConfig ( const ConfigBase rhs)
inlineexplicit
2329: DynamicConfig(rhs, rhs.keys()) {}

◆ ~DynamicConfig()

virtual Slic3r::DynamicConfig::~DynamicConfig ( )
overridevirtualdefault

Member Function Documentation

◆ apply()

void Slic3r::ConfigBase::apply ( const ConfigBase other,
bool  ignore_nonexistent = false 
)
inlineinherited
2209{ 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:466

References Slic3r::ConfigBase::apply_only(), and Slic3r::ConfigBase::keys().

Referenced by Slic3r::PresetCollection::PresetCollection(), Slic3r::GCodeProcessor::apply_config_superslicer(), Slic3r::GUI::SLAImportJob::finalize(), Slic3r::PresetBundle::full_fff_config(), Slic3r::PresetBundle::full_sla_config(), Slic3r::PresetBundle::load_config_file(), Slic3r::PresetBundle::load_configbundle(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::PresetCollection::load_presets(), Slic3r::GCodeProcessor::process_file(), Slic3r::CLI::run(), and Slic3r::GUI::ObjectSettings::update_config_values().

+ 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
467{
468 // loop through options and apply them
469 for (const t_config_option_key &opt_key : keys) {
470 // Create a new option with default value for the key.
471 // If the key is not in the parameter definition, or this ConfigBase is a static type and it does not support the parameter,
472 // an exception is thrown if not ignore_nonexistent.
473 ConfigOption *my_opt = this->option(opt_key, true);
474 if (my_opt == nullptr) {
475 // opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def().
476 // This is only possible if other is of DynamicConfig type.
477 if (ignore_nonexistent)
478 continue;
479 throw UnknownOptionException(opt_key);
480 }
481 const ConfigOption *other_opt = other.option(opt_key);
482 if (other_opt == nullptr) {
483 // The key was not found in the source config, therefore it will not be initialized!
484// printf("Not found, therefore not initialized: %s\n", opt_key.c_str());
485 } else
486 my_opt->set(other_opt);
487 }
488}
virtual t_config_option_keys keys() const =0

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

Referenced by Slic3r::PresetBundle::PresetBundle(), Slic3r::ConfigBase::apply(), Slic3r::ModelConfig::apply(), Slic3r::ModelConfig::apply_only(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::PresetCollection::load_external_preset(), Slic3r::PresetCollection::load_preset(), Slic3r::GUI::Tab::may_discard_current_dirty_preset(), Slic3r::PresetBundle::save_changes_for_preset(), Slic3r::PresetBundle::transfer_and_save(), Slic3r::PhysicalPrinter::update_from_config(), and Slic3r::PhysicalPrinter::update_from_preset().

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

◆ cbegin()

std::map< t_config_option_key, std::unique_ptr< ConfigOption > >::const_iterator Slic3r::DynamicConfig::cbegin ( ) const
inline
2453{ return options.cbegin(); }

References options.

Referenced by Slic3r::apply_to_print_region_config(), Slic3r::ModelConfig::cbegin(), Slic3r::dynamic_config_iterate(), and cereal::save().

+ Here is the caller graph for this function:

◆ cend()

std::map< t_config_option_key, std::unique_ptr< ConfigOption > >::const_iterator Slic3r::DynamicConfig::cend ( ) const
inline
2454{ return options.cend(); }

References options.

Referenced by Slic3r::apply_to_print_region_config(), Slic3r::ModelConfig::cend(), Slic3r::dynamic_config_iterate(), and cereal::save().

+ Here is the caller graph for this function:

◆ clear()

void Slic3r::DynamicConfig::clear ( )
inline
2401 {
2402 this->options.clear();
2403 }

Referenced by Slic3r::PlaceholderParser::clear_config(), cereal::load(), Slic3r::PresetBundle::load_configbundle(), operator=(), operator=(), Slic3r::GCode::PlaceholderParserIntegration::reset(), Slic3r::ModelConfig::reset(), Slic3r::GUI::ObjectList::Clipboard::reset(), and Slic3r::GUI::GLCanvas3D::LayersEditing::set_config().

+ Here is the caller graph for this function:

◆ def()

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

Implements Slic3r::ConfigBase.

Reimplemented in Slic3r::DynamicPrintConfig, and Slic3r::DynamicPrintAndCLIConfig.

2419{ return nullptr; }

Referenced by operator+=(), operator+=(), operator=(), and operator=().

+ Here is the caller graph for this function:

◆ diff() [1/2]

t_config_option_keys Slic3r::ConfigBase::diff ( const ConfigBase other) const
inherited
504{
506 for (const t_config_option_key &opt_key : this->keys()) {
507 const ConfigOption *this_opt = this->option(opt_key);
508 const ConfigOption *other_opt = other.option(opt_key);
509 if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
510 diff.emplace_back(opt_key);
511 }
512 return diff;
513}
t_config_option_keys diff(const ConfigBase &other) const
Definition Config.cpp:503
std::vector< std::string > t_config_option_keys
Definition Config.hpp:77

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

Referenced by Slic3r::ConfigBase::diff(), and diff().

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

◆ diff() [2/2]

t_config_option_keys Slic3r::DynamicConfig::diff ( const DynamicConfig other) const
1299{
1301 dynamic_config_iterate(*this, other,
1302 [&diff](const t_config_option_key &key, const ConfigOption *l, const ConfigOption *r) {
1303 if (*l != *r)
1304 diff.emplace_back(key);
1305 // Continue iterating.
1306 return false;
1307 });
1308 return diff;
1309}
t_config_option_keys diff(const DynamicConfig &other) const
Definition Config.cpp:1298
static bool dynamic_config_iterate(const DynamicConfig &lhs, const DynamicConfig &rhs, Fn fn)
Definition Config.cpp:1269

References Slic3r::ConfigBase::diff(), and Slic3r::dynamic_config_iterate().

Referenced by Slic3r::GUI::ObjectSettings::add_missed_options(), Slic3r::GUI::ConfigManipulation::apply(), Slic3r::PresetCollection::dirty_options(), Slic3r::profile_print_params_same(), and Slic3r::Preset::set_dirty().

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

◆ empty()

bool Slic3r::DynamicConfig::empty ( ) const
inline
2426{ return options.empty(); }

References options.

Referenced by Slic3r::ModelConfig::empty(), Slic3r::extract_profile(), Slic3r::load_3mf(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::ObjectList::paste_settings_into_list(), and Slic3r::GUI::GUI_App::post_init().

+ Here is the caller graph for this function:

◆ equal() [1/2]

t_config_option_keys Slic3r::ConfigBase::equal ( const ConfigBase other) const
inherited
517{
519 for (const t_config_option_key &opt_key : this->keys()) {
520 const ConfigOption *this_opt = this->option(opt_key);
521 const ConfigOption *other_opt = other.option(opt_key);
522 if (this_opt != nullptr && other_opt != nullptr && *this_opt == *other_opt)
523 equal.emplace_back(opt_key);
524 }
525 return equal;
526}
t_config_option_keys equal(const ConfigBase &other) const
Definition Config.cpp:516

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

Referenced by Slic3r::ConfigBase::equal(), and equal().

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

◆ equal() [2/2]

t_config_option_keys Slic3r::DynamicConfig::equal ( const DynamicConfig other) const
1313{
1315 dynamic_config_iterate(*this, other,
1316 [&equal](const t_config_option_key &key, const ConfigOption *l, const ConfigOption *r) {
1317 if (*l == *r)
1318 equal.emplace_back(key);
1319 // Continue iterating.
1320 return false;
1321 });
1322 return equal;
1323}
t_config_option_keys equal(const DynamicConfig &other) const
Definition Config.cpp:1312

References Slic3r::dynamic_config_iterate(), and Slic3r::ConfigBase::equal().

+ Here is the call graph for this function:

◆ equals() [1/2]

bool Slic3r::ConfigBase::equals ( const ConfigBase other) const
inherited
492{
493 for (const t_config_option_key &opt_key : this->keys()) {
494 const ConfigOption *this_opt = this->option(opt_key);
495 const ConfigOption *other_opt = other.option(opt_key);
496 if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
497 return false;
498 }
499 return true;
500}

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

+ Here is the call graph for this function:

◆ equals() [2/2]

bool Slic3r::DynamicConfig::equals ( const DynamicConfig other) const
1292{
1293 return ! dynamic_config_iterate(*this, other,
1294 [](const t_config_option_key & /* key */, const ConfigOption *l, const ConfigOption *r) { return *l != *r; });
1295}

References Slic3r::dynamic_config_iterate().

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

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

◆ erase()

bool Slic3r::DynamicConfig::erase ( const t_config_option_key opt_key)
inline
2406 {
2407 auto it = this->options.find(opt_key);
2408 if (it == this->options.end())
2409 return false;
2410 this->options.erase(it);
2411 return true;
2412 }

Referenced by Slic3r::ModelConfig::erase(), Slic3r::PresetBundle::full_config_secure(), Slic3r::PresetBundle::full_fff_config(), Slic3r::PresetBundle::full_sla_config(), Slic3r::DynamicPrintConfig::normalize_fdm(), and Slic3r::Preset::remove_invalid_keys().

+ Here is the caller graph for this function:

◆ get_abs_value() [1/2]

double Slic3r::ConfigBase::get_abs_value ( const t_config_option_key opt_key) const
inherited
670{
671 // Get stored option value.
672 const ConfigOption *raw_opt = this->option(opt_key);
673 assert(raw_opt != nullptr);
674 if (raw_opt->type() == coFloat)
675 return static_cast<const ConfigOptionFloat*>(raw_opt)->value;
676 if (raw_opt->type() == coFloatOrPercent) {
677 // Get option definition.
678 const ConfigDef *def = this->def();
679 if (def == nullptr)
680 throw NoDefinitionException(opt_key);
681 const ConfigOptionDef *opt_def = def->get(opt_key);
682 assert(opt_def != nullptr);
683 // Compute absolute value over the absolute value of the base option.
684 //FIXME there are some ratio_over chains, which end with empty ratio_with.
685 // For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
686 return opt_def->ratio_over.empty() ? 0. :
687 static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->get_abs_value(this->get_abs_value(opt_def->ratio_over));
688 }
689 throw ConfigurationError("ConfigBase::get_abs_value(): Not a valid option type for get_abs_value()");
690}
virtual const ConfigDef * def() const =0
double get_abs_value(const t_config_option_key &opt_key) const
Definition Config.cpp:669
const ConfigOptionDef * get(const t_config_option_key &opt_key) const
Definition Config.hpp:2069
ConfigOptionFloat
Definition PrintConfig.hpp:570
@ coFloat
Definition Config.hpp:164
@ coFloatOrPercent
Definition Config.hpp:180

References Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::ConfigBase::def(), Slic3r::ConfigDef::get(), Slic3r::ConfigBase::get_abs_value(), Slic3r::ConfigOptionDef::ratio_over, and Slic3r::ConfigOption::type().

Referenced by Slic3r::ConfigBase::get_abs_value(), Slic3r::ConfigBase::get_abs_value(), Slic3r::PresetHints::maximum_volumetric_flow_description(), and Slic3r::CLI::run().

+ 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
695{
696 // Get stored option value.
697 const ConfigOption *raw_opt = this->option(opt_key);
698 assert(raw_opt != nullptr);
699 if (raw_opt->type() != coFloatOrPercent)
700 throw ConfigurationError("ConfigBase::get_abs_value(): opt_key is not of coFloatOrPercent");
701 // Compute absolute value.
702 return static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->get_abs_value(ratio_over);
703}

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

+ Here is the call graph for this function:

◆ handle_legacy()

virtual void Slic3r::ConfigBase::handle_legacy ( t_config_option_key ,
std::string &   
) const
inlineprotectedvirtualinherited

Reimplemented in Slic3r::DynamicPrintConfig, Slic3r::StaticPrintConfig, and Slic3r::DynamicPrintAndCLIConfig.

2162{}

Referenced by Slic3r::ConfigBase::set_deserialize_nothrow().

+ Here is the caller graph for this function:

◆ has()

◆ keys()

t_config_option_keys Slic3r::DynamicConfig::keys ( ) const
overridevirtual

Implements Slic3r::ConfigBase.

1234{
1236 keys.reserve(this->options.size());
1237 for (const auto &opt : this->options)
1238 keys.emplace_back(opt.first);
1239 return keys;
1240}
T * opt(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2196

References Slic3r::ConfigBase::keys(), and Slic3r::ConfigBase::opt().

Referenced by Slic3r::_3MF_Exporter::_add_print_config_file_to_archive(), Slic3r::GCode::append_full_config(), Slic3r::Search::OptionsSearcher::append_options(), Slic3r::PlaceholderParser::apply_config(), Slic3r::PlaceholderParser::config_diff(), Slic3r::PresetBundle::full_fff_config(), Slic3r::full_print_config_diffs(), Slic3r::GUI::SettingsFactory::get_bundle(), Slic3r::ModelConfig::keys(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::PresetCollection::load_external_preset(), Slic3r::PresetCollection::load_preset(), Slic3r::DynamicPrintConfig::new_from_defaults_keys(), Slic3r::GUI::ObjectList::paste_settings_into_list(), Slic3r::Preset::remove_invalid_keys(), and Slic3r::store_amf().

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

◆ load() [1/2]

ConfigSubstitutions Slic3r::ConfigBase::load ( const boost::property_tree::ptree &  tree,
ForwardCompatibilitySubstitutionRule  compatibility_rule 
)
inherited
790{
791 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
792 for (const boost::property_tree::ptree::value_type &v : tree) {
793 try {
794 t_config_option_key opt_key = v.first;
795 this->set_deserialize(opt_key, v.second.get_value<std::string>(), substitutions_ctxt);
796 } catch (UnknownOptionException & /* e */) {
797 // ignore
798 }
799 }
800 return std::move(substitutions_ctxt.substitutions);
801}
void set_deserialize(const t_config_option_key &opt_key, const std::string &str, ConfigSubstitutionContext &config_substitutions, bool append=false)
Definition Config.cpp:571

References Slic3r::ConfigBase::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
724{
725 return is_gcode_file(file) ?
726 this->load_from_gcode_file(file, compatibility_rule) :
727 this->load_from_ini(file, compatibility_rule);
728}
ConfigSubstitutions load_from_ini(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:730
ConfigSubstitutions load_from_gcode_file(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:928
bool is_gcode_file(const std::string &path)
Definition utils.cpp:783

References Slic3r::is_gcode_file(), Slic3r::ConfigBase::load_from_gcode_file(), and Slic3r::ConfigBase::load_from_ini().

Referenced by Slic3r::extract_profile(), Slic3r::PresetBundle::load_config_file(), Slic3r::ConfigBase::load_from_ini(), Slic3r::ConfigBase::load_from_ini_string(), Slic3r::SL1Reader::read(), Slic3r::SL1_SVGReader::read(), and Slic3r::CLI::run().

+ 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
929{
930 // Read a 64k block from the end of the G-code.
931 boost::nowide::ifstream ifs(file, std::ifstream::binary);
932 // Look for Slic3r or PrusaSlicer header.
933 // 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.
934 bool has_delimiters = false;
935 {
936 static constexpr const char slic3r_gcode_header[] = "; generated by Slic3r ";
937 static constexpr const char prusaslicer_gcode_header[] = "; generated by PrusaSlicer ";
938 std::string header;
939 bool header_found = false;
940 while (std::getline(ifs, header)) {
941 if (strncmp(slic3r_gcode_header, header.c_str(), strlen(slic3r_gcode_header)) == 0) {
942 header_found = true;
943 break;
944 } else if (strncmp(prusaslicer_gcode_header, header.c_str(), strlen(prusaslicer_gcode_header)) == 0) {
945 // Parse PrusaSlicer version.
946 size_t i = strlen(prusaslicer_gcode_header);
947 for (; i < header.size() && header[i] == ' '; ++ i) ;
948 size_t j = i;
949 for (; j < header.size() && header[j] != ' '; ++ j) ;
950 try {
951 Semver semver(header.substr(i, j - i));
952 has_delimiters = semver >= Semver(2, 4, 0, nullptr, "alpha0");
953 } catch (const RuntimeError &) {
954 }
955 header_found = true;
956 break;
957 }
958 }
959 if (! header_found)
960 throw Slic3r::RuntimeError("Not a PrusaSlicer / Slic3r PE generated g-code.");
961 }
962
963 auto header_end_pos = ifs.tellg();
964 ConfigSubstitutionContext substitutions_ctxt(compatibility_rule);
965 size_t key_value_pairs = 0;
966
967 if (has_delimiters)
968 {
969 // PrusaSlicer starting with 2.4.0-alpha0 delimits the config section stored into G-code with
970 // ; prusaslicer_config = begin
971 // ...
972 // ; prusaslicer_config = end
973 // The begin / end tags look like any other key / value pairs on purpose to be compatible with older G-code viewer.
974 // Read the file in reverse line by line.
975 ReverseLineReader reader(ifs, header_end_pos);
976 // Read the G-code file by 64k blocks back to front.
977 bool begin_found = false;
978 bool end_found = false;
979 std::string line;
980 while (reader.getline(line))
981 if (line == "; prusaslicer_config = end") {
982 end_found = true;
983 break;
984 }
985 if (! end_found)
986 throw Slic3r::RuntimeError(format("Configuration block closing tag \"; prusaslicer_config = end\" not found when reading %1%", file));
987 std::string key, value;
988 while (reader.getline(line)) {
989 if (line == "; prusaslicer_config = begin") {
990 begin_found = true;
991 break;
992 }
993 // line should be a valid key = value pair.
994 auto pos = line.find('=');
995 if (pos != std::string::npos && pos > 1 && line.front() == ';') {
996 key = line.substr(1, pos - 1);
997 value = line.substr(pos + 1);
998 boost::trim(key);
999 boost::trim(value);
1000 try {
1001 this->set_deserialize(key, value, substitutions_ctxt);
1002 ++ key_value_pairs;
1003 } catch (UnknownOptionException & /* e */) {
1004 // ignore
1005 }
1006 }
1007 }
1008 if (! begin_found)
1009 throw Slic3r::RuntimeError(format("Configuration block opening tag \"; prusaslicer_config = begin\" not found when reading %1%", file));
1010 }
1011 else
1012 {
1013 // Slic3r or PrusaSlicer older than 2.4.0-alpha0 do not emit any delimiter.
1014 // Try a heuristics reading the G-code from back.
1015 ifs.seekg(0, ifs.end);
1016 auto file_length = ifs.tellg();
1017 auto data_length = std::min<std::fstream::pos_type>(65535, file_length - header_end_pos);
1018 ifs.seekg(file_length - data_length, ifs.beg);
1019 std::vector<char> data(size_t(data_length) + 1, 0);
1020 ifs.read(data.data(), data_length);
1021 ifs.close();
1022 key_value_pairs = load_from_gcode_string_legacy(*this, data.data(), substitutions_ctxt);
1023 }
1024
1025 if (key_value_pairs < 80)
1026 throw Slic3r::RuntimeError(format("Suspiciously low number of configuration values extracted from %1%: %2%", file, key_value_pairs));
1027 return std::move(substitutions_ctxt.substitutions);
1028}
static size_t load_from_gcode_string_legacy(ConfigBase &config, const char *str, ConfigSubstitutionContext &substitutions)
Definition Config.cpp:804
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:44
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195

References Slic3r::format(), Slic3r::ReverseLineReader::getline(), Slic3r::ConfigBase::load_from_gcode_string_legacy(), Slic3r::ConfigBase::set_deserialize(), and Slic3r::ConfigSubstitutionContext::substitutions.

Referenced by Slic3r::ConfigBase::load(), Slic3r::PresetBundle::load_config_file(), 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
805{
806 if (str == nullptr)
807 return 0;
808
809 // Walk line by line in reverse until a non-configuration key appears.
810 const char *data_start = str;
811 // boost::nowide::ifstream seems to cook the text data somehow, so less then the 64k of characters may be retrieved.
812 const char *end = data_start + strlen(str);
813 size_t num_key_value_pairs = 0;
814 for (;;) {
815 // Extract next line.
816 for (--end; end > data_start && (*end == '\r' || *end == '\n'); --end);
817 if (end == data_start)
818 break;
819 const char *start = end ++;
820 for (; start > data_start && *start != '\r' && *start != '\n'; --start);
821 if (start == data_start)
822 break;
823 // Extracted a line from start to end. Extract the key = value pair.
824 if (end - (++ start) < 10 || start[0] != ';' || start[1] != ' ')
825 break;
826 const char *key = start + 2;
827 if (!((*key >= 'a' && *key <= 'z') || (*key >= 'A' && *key <= 'Z')))
828 // A key must start with a letter.
829 break;
830 const char *sep = key;
831 for (; sep != end && *sep != '='; ++ sep) ;
832 if (sep == end || sep[-1] != ' ' || sep[1] != ' ')
833 break;
834 const char *value = sep + 2;
835 if (value > end)
836 break;
837 const char *key_end = sep - 1;
838 if (key_end - key < 3)
839 break;
840 // The key may contain letters, digits and underscores.
841 for (const char *c = key; c != key_end; ++ c)
842 if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_')) {
843 key = nullptr;
844 break;
845 }
846 if (key == nullptr)
847 break;
848 try {
849 config.set_deserialize(std::string(key, key_end), std::string(value, end), substitutions);
850 ++num_key_value_pairs;
851 }
852 catch (UnknownOptionException & /* e */) {
853 // ignore
854 }
855 end = start;
856 }
857
858 return num_key_value_pairs;
859}
S::iterator end(S &sh, const PathTag &)
Definition geometry_traits.hpp:620

References Slic3r::ConfigBase::set_deserialize().

Referenced by Slic3r::AMFParserContext::endElement(), Slic3r::ConfigBase::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
731{
732 try {
733 boost::property_tree::ptree tree;
734 boost::nowide::ifstream ifs(file);
735 boost::property_tree::read_ini(ifs, tree);
736 return this->load(tree, compatibility_rule);
737 } catch (const ConfigurationError &e) {
738 throw ConfigurationError(format("Failed loading configuration file \"%1%\": %2%", file, e.what()));
739 }
740}
ConfigSubstitutions load(const std::string &file, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:723

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

Referenced by Slic3r::ConfigBase::load(), Slic3r::PresetCollection::load_presets(), and Slic3r::PhysicalPrinterCollection::load_printers().

+ 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
743{
744 boost::property_tree::ptree tree;
745 std::istringstream iss(data);
746 boost::property_tree::read_ini(iss, tree);
747 return this->load(tree, compatibility_rule);
748}

References Slic3r::ConfigBase::load().

Referenced by Slic3r::anonymous_namespace{AnycubicSLA.cpp}::fill_header(), and Slic3r::ConfigBase::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
753{
754 // Convert the "data" string into INI format by removing the semi-colons at the start of a line.
755 // Also the "; generated by PrusaSlicer ..." comment line will be removed.
756 size_t j = 0;
757 for (size_t i = 0; i < data.size();)
758 if (i == 0 || data[i] == '\n') {
759 // Start of a line.
760 if (data[i] == '\n') {
761 // Consume LF, don't keep empty lines.
762 if (j > 0 && data[j - 1] != '\n')
763 data[j ++] = data[i];
764 ++ i;
765 }
766 // Skip all leading spaces;
767 for (; i < data.size() && (data[i] == ' ' || data[i] == '\t'); ++ i) ;
768 // Skip the semicolon (comment indicator).
769 if (i < data.size() && data[i] == ';')
770 ++ i;
771 // Skip all leading spaces after semicolon.
772 for (; i < data.size() && (data[i] == ' ' || data[i] == '\t'); ++ i) ;
773 if (strncmp(data.data() + i, "generated by ", 13) == 0) {
774 // Skip the "; generated by ..." line.
775 for (; i < data.size() && data[i] != '\n'; ++ i);
776 }
777 } else if (data[i] == '\r' && i + 1 < data.size() && data[i + 1] == '\n') {
778 // Skip CR.
779 ++ i;
780 } else {
781 // Consume the rest of the data.
782 data[j ++] = data[i ++];
783 }
784 data.erase(data.begin() + j, data.end());
785
786 return this->load_from_ini_string(data, compatibility_rule);
787}
ConfigSubstitutions load_from_ini_string(const std::string &data, ForwardCompatibilitySubstitutionRule compatibility_rule)
Definition Config.cpp:742

References Slic3r::ConfigBase::load_from_ini_string().

+ Here is the call graph for this function:

◆ null_nullables()

void Slic3r::ConfigBase::null_nullables ( )
inherited
1042{
1043 for (const std::string &opt_key : this->keys()) {
1044 ConfigOption *opt = this->optptr(opt_key, false);
1045 assert(opt != nullptr);
1046 if (opt->nullable())
1047 opt->deserialize("nil", ForwardCompatibilitySubstitutionRule::Disable);
1048 }
1049}
virtual ConfigOption * optptr(const t_config_option_key &opt_key, bool create=false)=0
@ Disable
Definition Config.hpp:219

References Slic3r::ConfigOption::deserialize(), Slic3r::Disable, Slic3r::ConfigBase::keys(), Slic3r::ConfigOption::nullable(), Slic3r::ConfigBase::opt(), and Slic3r::ConfigBase::optptr().

Referenced by Slic3r::PresetBundle::PresetBundle().

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

◆ operator!=()

bool Slic3r::DynamicConfig::operator!= ( const DynamicConfig rhs) const
inline
2393{ return ! (*this == rhs); }

◆ operator+=() [1/2]

DynamicConfig & Slic3r::DynamicConfig::operator+= ( const DynamicConfig rhs)
inline
2357 {
2358 assert(this->def() == nullptr || this->def() == rhs.def());
2359 for (const auto &kvp : rhs.options) {
2360 auto it = this->options.find(kvp.first);
2361 if (it == this->options.end())
2362 this->options[kvp.first].reset(kvp.second->clone());
2363 else {
2364 assert(it->second->type() == kvp.second->type());
2365 if (it->second->type() == kvp.second->type())
2366 *it->second = *kvp.second;
2367 else
2368 it->second.reset(kvp.second->clone());
2369 }
2370 }
2371 return *this;
2372 }
const ConfigDef * def() const override
Definition Config.hpp:2419

References def(), and options.

+ Here is the call graph for this function:

◆ operator+=() [2/2]

DynamicConfig & Slic3r::DynamicConfig::operator+= ( DynamicConfig &&  rhs)
inline
2377 {
2378 assert(this->def() == nullptr || this->def() == rhs.def());
2379 for (auto &kvp : rhs.options) {
2380 auto it = this->options.find(kvp.first);
2381 if (it == this->options.end()) {
2382 this->options.insert(std::make_pair(kvp.first, std::move(kvp.second)));
2383 } else {
2384 assert(it->second->type() == kvp.second->type());
2385 it->second = std::move(kvp.second);
2386 }
2387 }
2388 rhs.options.clear();
2389 return *this;
2390 }

References def().

+ Here is the call graph for this function:

◆ operator=() [1/2]

DynamicConfig & Slic3r::DynamicConfig::operator= ( const DynamicConfig rhs)
inline
2335 {
2336 assert(this->def() == nullptr || this->def() == rhs.def());
2337 this->clear();
2338 for (const auto &kvp : rhs.options)
2339 this->options[kvp.first].reset(kvp.second->clone());
2340 return *this;
2341 }
void clear()
Definition Config.hpp:2400

References clear(), def(), and options.

Referenced by Slic3r::DynamicPrintConfig::operator=(), and Slic3r::DynamicPrintConfig::operator=().

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

◆ operator=() [2/2]

DynamicConfig & Slic3r::DynamicConfig::operator= ( DynamicConfig &&  rhs)
inlinenoexcept
2346 {
2347 assert(this->def() == nullptr || this->def() == rhs.def());
2348 this->clear();
2349 this->options = std::move(rhs.options);
2350 rhs.options.clear();
2351 return *this;
2352 }

References clear(), and def().

+ Here is the call graph for this function:

◆ operator==()

bool Slic3r::DynamicConfig::operator== ( const DynamicConfig rhs) const
1058{
1059 auto it1 = this->options.begin();
1060 auto it1_end = this->options.end();
1061 auto it2 = rhs.options.begin();
1062 auto it2_end = rhs.options.end();
1063 for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2)
1064 if (it1->first != it2->first || *it1->second != *it2->second)
1065 // key or value differ
1066 return false;
1067 return it1 == it1_end && it2 == it2_end;
1068}

References options.

◆ opt() [1/2]

template<class T >
const T * Slic3r::ConfigBase::opt ( const t_config_option_key opt_key) const
inlineinherited
2199 { return dynamic_cast<const T*>(this->optptr(opt_key)); }

References Slic3r::ConfigBase::optptr().

+ Here is the call graph for this function:

◆ opt() [2/2]

template<class T >
T * Slic3r::ConfigBase::opt ( const t_config_option_key opt_key,
bool  create = false 
)
inlineinherited
2197 { return dynamic_cast<T*>(this->optptr(opt_key, create)); }

References Slic3r::ConfigBase::optptr().

Referenced by Slic3r::apply_to_print_region_config(), Slic3r::GUI::GLCanvas3D::WipeTowerInfo::apply_wipe_tower(), Slic3r::PrinterPresetCollection::default_preset_for(), Slic3r::get_bed_shape(), Slic3r::GUI::Materials::get_filament_type(), Slic3r::GUI::Materials::get_filament_vendor(), Slic3r::GUI::Materials::get_material_type(), Slic3r::GUI::Materials::get_material_vendor(), Slic3r::GUI::get_string_value(), Slic3r::handle_legacy_sla(), Slic3r::is_XL_printer(), keys(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::Plater::priv::load_model_objects(), Slic3r::DynamicPrintConfig::normalize_fdm(), Slic3r::ConfigBase::null_nullables(), Slic3r::GUI::Plater::priv::on_wipetower_moved(), Slic3r::GUI::Plater::priv::on_wipetower_rotated(), Slic3r::ConfigBase::opt_serialize(), Slic3r::ConfigBase::option(), Slic3r::ConfigBase::option_throw(), optptr(), Slic3r::PresetHints::recommended_thin_wall_thickness(), Slic3r::CLI::run(), Slic3r::run_post_process_scripts(), Slic3r::ConfigBase::set(), Slic3r::ConfigBase::set(), Slic3r::StaticConfig::set_defaults(), Slic3r::ConfigBase::set_deserialize_raw(), Slic3r::DynamicPrintConfig::set_num_extruders(), Slic3r::CLI::setup(), Slic3r::PresetUtils::system_printer_model(), Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tag_check_material(), Slic3r::GUI::DiffPresetDialog::update_tree(), Slic3r::GUI::UnsavedChangesDialog::update_tree(), and Slic3r::DynamicPrintConfig::validate().

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

◆ opt_bool() [1/2]

◆ opt_bool() [2/2]

bool Slic3r::ConfigBase::opt_bool ( const t_config_option_key opt_key,
unsigned int  idx 
) const
inlineinherited
2297{ return this->option<ConfigOptionBools>(opt_key)->get_at(idx) != 0; }

◆ opt_enum()

template<typename ENUM >
ENUM Slic3r::ConfigBase::opt_enum ( const t_config_option_key opt_key) const
inlineinherited
2294{ return static_cast<ENUM>(this->option(opt_key)->getInt()); }

Referenced by Slic3r::BackgroundSlicingProcess::apply(), Slic3r::GUI::Plater::on_config_change(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), Slic3r::GUI::ConfigManipulation::toggle_print_sla_options(), and Slic3r::GUI::ConfigManipulation::update_print_fff_config().

+ Here is the caller graph for this function:

◆ opt_float() [1/4]

◆ opt_float() [2/4]

const double & Slic3r::ConfigBase::opt_float ( const t_config_option_key opt_key) const
inlineinherited
2282{ return dynamic_cast<const ConfigOptionFloat*>(this->option(opt_key))->value; }

◆ opt_float() [3/4]

double & Slic3r::ConfigBase::opt_float ( const t_config_option_key opt_key,
unsigned int  idx 
)
inlineinherited
2283{ return this->option<ConfigOptionFloats>(opt_key)->get_at(idx); }

◆ opt_float() [4/4]

const double & Slic3r::ConfigBase::opt_float ( const t_config_option_key opt_key,
unsigned int  idx 
) const
inlineinherited
2284{ return dynamic_cast<const ConfigOptionFloats*>(this->option(opt_key))->get_at(idx); }
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:716

◆ opt_int() [1/4]

◆ opt_int() [2/4]

int Slic3r::ConfigBase::opt_int ( const t_config_option_key opt_key) const
inlineinherited
2287{ return dynamic_cast<const ConfigOptionInt*>(this->option(opt_key))->value; }

◆ opt_int() [3/4]

int & Slic3r::ConfigBase::opt_int ( const t_config_option_key opt_key,
unsigned int  idx 
)
inlineinherited
2288{ return this->option<ConfigOptionInts>(opt_key)->get_at(idx); }

◆ opt_int() [4/4]

int Slic3r::ConfigBase::opt_int ( const t_config_option_key opt_key,
unsigned int  idx 
) const
inlineinherited
2289{ return dynamic_cast<const ConfigOptionInts*>(this->option(opt_key))->get_at(idx); }
ConfigOptionIntsTempl< false > ConfigOptionInts
Definition Config.hpp:844

◆ opt_serialize()

std::string Slic3r::ConfigBase::opt_serialize ( const t_config_option_key opt_key) const
inherited
529{
530 const ConfigOption* opt = this->option(opt_key);
531 assert(opt != nullptr);
532 return opt->serialize();
533}

References Slic3r::ConfigBase::opt(), and Slic3r::ConfigOption::serialize().

Referenced by Slic3r::_3MF_Exporter::_add_print_config_file_to_archive(), Slic3r::GCode::append_full_config(), Slic3r::anonymous_namespace{SL1.cpp}::fill_slicerconf(), Slic3r::ModelConfig::opt_serialize(), Slic3r::ConfigBase::save(), and Slic3r::store_amf().

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

◆ opt_string() [1/4]

const std::string & Slic3r::ConfigBase::opt_string ( const t_config_option_key opt_key) const
inlineinherited
2277{ return const_cast<ConfigBase*>(this)->opt_string(opt_key); }
ConfigBase()=default
std::string & opt_string(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2276

References Slic3r::ConfigBase::opt_string().

Referenced by Slic3r::ConfigBase::opt_string().

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

◆ opt_string() [2/4]

std::string & Slic3r::ConfigBase::opt_string ( const t_config_option_key opt_key,
bool  create = false 
)
inlineinherited
2276{ return this->option<ConfigOptionString>(opt_key, create)->value; }

Referenced by Slic3r::PresetBundle::PresetBundle(), Slic3r::_3MF_Exporter::_add_custom_gcode_per_print_z_file_to_archive(), Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), Slic3r::GUI::PhysicalPrinterDialog::build_printhost_settings(), Slic3r::PhysicalPrinterCollection::find_printer_with_same_config(), Slic3r::PrinterPresetCollection::find_system_preset_by_model_and_variant(), Slic3r::GUI::ConfigOptionsGroup::get_config_value(), Slic3r::GUI::get_string_value(), Slic3r::PhysicalPrinter::has_empty_config(), Slic3r::PhysicalPrinter::has_print_host_information(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::PresetBundle::load_configbundle(), Slic3r::PhysicalPrinterCollection::load_printers_from_presets(), Slic3r::GUI::PresetComboBox::open_physical_printer_url(), Slic3r::PrintBase::output_filename(), Slic3r::CLI::output_filepath(), Slic3r::CLI::run(), Slic3r::GUI::Tab::save_preset(), Slic3r::Preset::set_visible_from_appconfig(), Slic3r::CLI::setup(), Slic3r::GUI::PlaterPresetComboBox::show_edit_menu(), Slic3r::store_amf(), Slic3r::GUI::TabSLAMaterial::toggle_options(), Slic3r::GUI::PlaterPresetComboBox::update(), Slic3r::GLVolumeCollection::update_colors_by_extruder(), Slic3r::PresetBundle::update_compatible(), Slic3r::GUI::Plater::update_filament_colors_in_full_config(), Slic3r::PresetBundle::update_filaments_compatible(), Slic3r::GUI::PhysicalPrinterDialog::update_host_type(), Slic3r::GUI::Tab::update_preset_description_line(), and Slic3r::GUI::PhysicalPrinterDialog::update_printhost_buttons().

+ Here is the caller graph for this function:

◆ opt_string() [3/4]

std::string & Slic3r::ConfigBase::opt_string ( const t_config_option_key opt_key,
unsigned int  idx 
)
inlineinherited
2278{ return this->option<ConfigOptionStrings>(opt_key)->get_at(idx); }

◆ opt_string() [4/4]

const std::string & Slic3r::ConfigBase::opt_string ( const t_config_option_key opt_key,
unsigned int  idx 
) const
inlineinherited
2279{ return const_cast<ConfigBase*>(this)->opt_string(opt_key, idx); }

References Slic3r::ConfigBase::opt_string().

Referenced by Slic3r::ConfigBase::opt_string().

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

◆ option() [1/4]

template<typename TYPE >
const TYPE * Slic3r::ConfigOptionResolver::option ( const t_config_option_key opt_key) const
inlineinherited
2111 {
2112 const ConfigOption* opt = this->optptr(opt_key);
2113 return (opt == nullptr || opt->type() != TYPE::static_type()) ? nullptr : static_cast<const TYPE*>(opt);
2114 }

◆ option() [2/4]

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

◆ option() [3/4]

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

References Slic3r::ConfigBase::optptr().

Referenced by DynamicConfig(), Slic3r::PresetBundle::PresetBundle(), Slic3r::GCode::_do_export(), Slic3r::GUI::GLCanvas3D::_render_arrange_menu(), 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::add_correct_opts_to_options_list(), Slic3r::GUI::ObjectSettings::add_missed_options(), Slic3r::GCode::append_full_config(), Slic3r::Search::OptionsSearcher::append_options(), Slic3r::Print::apply(), Slic3r::SLAPrint::apply(), Slic3r::GUI::ConfigManipulation::apply(), Slic3r::GCodeProcessor::apply_config(), Slic3r::PlaceholderParser::apply_config(), Slic3r::ConfigBase::apply_only(), Slic3r::PlaceholderParser::apply_only(), Slic3r::GUI::ConfigOptionsGroup::back_to_config_value(), Slic3r::GUI::TabSLAMaterial::build(), Slic3r::GUI::TabPrinter::build_extruder_pages(), Slic3r::GUI::TabPrinter::build_fff(), Slic3r::GUI::TabPrinter::cache_extruder_cnt(), Slic3r::GUI::PlaterPresetComboBox::change_extruder_color(), Slic3r::Search::change_opt_key(), Slic3r::GUI::change_opt_value(), Slic3r::Preset::compatible_printers_condition(), Slic3r::Preset::compatible_prints_condition(), Slic3r::copy_bed_model_and_texture_if_needed(), Slic3r::deep_diff(), Slic3r::GUI::Bed3D::detect_type(), Slic3r::ConfigBase::diff(), Slic3r::ConfigBase::equal(), Slic3r::ConfigBase::equals(), Slic3r::GUI::GUI_App::extruders_cnt(), Slic3r::GUI::GUI_App::extruders_edited_cnt(), Slic3r::anonymous_namespace{AnycubicSLA.cpp}::fill_header(), Slic3r::GUI::Plater::force_filament_colors_update(), Slic3r::PresetBundle::full_fff_config(), Slic3r::full_print_config_diffs(), Slic3r::PresetBundle::full_sla_config(), Slic3r::anonymous_namespace{SL1.cpp}::get_cfg_value(), Slic3r::anonymous_namespace{AnycubicSLA.cpp}::get_cfg_value_f(), Slic3r::anonymous_namespace{AnycubicSLA.cpp}::get_cfg_value_i(), Slic3r::GUI::GLGizmoHollow::get_config_options(), Slic3r::GUI::GLGizmoSlaSupports::get_config_options(), Slic3r::GUI::ConfigOptionsGroup::get_config_value(), Slic3r::GUI::Plater::get_extruder_colors_from_plater_config(), Slic3r::GUI::get_full_label(), Slic3r::PrintHost::get_print_host(), get_printer_technology(), Slic3r::get_raster_params(), Slic3r::get_sla_suptree_prefix(), Slic3r::get_slice_params(), Slic3r::GUI::get_string_value(), Slic3r::handle_legacy_project_loaded(), Slic3r::Preset::inherits(), Slic3r::is_compatible_with_print(), Slic3r::is_compatible_with_printer(), Slic3r::is_compatible_with_printer(), Slic3r::GUI::MainFrame::load_config(), Slic3r::GUI::Tab::load_config(), Slic3r::GUI::Tab::load_current_preset(), Slic3r::PresetHints::maximum_volumetric_flow_description(), Slic3r::min_object_distance(), Slic3r::Preset::normalize(), Slic3r::GUI::Plater::on_config_change(), Slic3r::GUI::GLGizmoSlaSupports::on_set_state(), Slic3r::PlaceholderParser::option(), Slic3r::ModelConfig::option(), Slic3r::client::MyContext::optptr(), Slic3r::opts_equal(), Slic3r::GUI::ObjectList::paste_settings_into_list(), Slic3r::BackgroundSlicingProcess::prepare_upload(), Slic3r::print_config_diffs(), Slic3r::Preset::printer_technology(), Slic3r::PhysicalPrinter::printer_technology(), Slic3r::Preset::printer_technology_ref(), Slic3r::BackgroundSlicingProcess::process_sla(), Slic3r::GUI::GLCanvas3D::reload_scene(), Slic3r::CLI::run(), Slic3r::CLI::setup(), Slic3r::GUI::Plater::priv::show_action_buttons(), Slic3r::GUI::ConfigManipulation::toggle_print_fff_options(), Slic3r::GUI::PhysicalPrinterDialog::update(), Slic3r::GLVolumeCollection::update_colors_by_extruder(), Slic3r::PresetCollection::update_compatible_internal(), Slic3r::ExtruderFilaments::update_compatible_internal(), Slic3r::CustomGCode::update_custom_gcode_per_print_z_from_config(), Slic3r::PresetBundle::update_filaments_compatible(), Slic3r::PhysicalPrinter::update_from_config(), Slic3r::GUI::PhysicalPrinterDialog::update_host_type(), Slic3r::GUI::Tab::update_preset_description_line(), Slic3r::PhysicalPrinter::update_preset_names_in_config(), Slic3r::GUI::Sidebar::update_presets(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), and Slic3r::GUI::Sidebar::update_sliced_info_sizer().

+ Here is the call graph for this function:

◆ option() [4/4]

template<typename TYPE >
TYPE * Slic3r::ConfigBase::option ( const t_config_option_key opt_key,
bool  create = false 
)
inlineinherited
2174 {
2175 ConfigOption *opt = this->optptr(opt_key, create);
2176 return (opt == nullptr || opt->type() != TYPE::static_type()) ? nullptr : static_cast<TYPE*>(opt);
2177 }

References Slic3r::ConfigBase::opt(), Slic3r::ConfigBase::optptr(), and Slic3r::ConfigOption::type().

+ Here is the call graph for this function:

◆ option_def()

const ConfigOptionDef * Slic3r::ConfigBase::option_def ( const t_config_option_key opt_key) const
inlineinherited
2204 { return this->def()->get(opt_key); }

References Slic3r::ConfigBase::def(), and Slic3r::ConfigDef::get().

Referenced by Slic3r::Search::OptionsSearcher::append_options(), Slic3r::GUI::GLGizmoHollow::get_config_options(), Slic3r::GUI::get_string_value(), read_cli(), and Slic3r::GUI::ConfigManipulation::update_print_fff_config().

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

◆ option_throw() [1/4]

const ConfigOption * Slic3r::ConfigOptionResolver::option_throw ( const t_config_option_key opt_key) const
inlineinherited
2117 {
2118 const ConfigOption* opt = this->optptr(opt_key);
2119 if (opt == nullptr)
2120 throw UnknownOptionException(opt_key);
2121 return opt;
2122 }

◆ option_throw() [2/4]

template<typename TYPE >
const TYPE * Slic3r::ConfigOptionResolver::option_throw ( const t_config_option_key opt_key) const
inlineinherited
2126 {
2127 const ConfigOption* opt = this->option_throw(opt_key);
2128 if (opt->type() != TYPE::static_type())
2129 throw BadOptionTypeException("Conversion to a wrong type");
2130 return static_cast<TYPE*>(opt);
2131 }
ConfigOption * option_throw(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2179

◆ option_throw() [3/4]

ConfigOption * Slic3r::ConfigBase::option_throw ( const t_config_option_key opt_key,
bool  create = false 
)
inlineinherited
2180 {
2181 ConfigOption *opt = this->optptr(opt_key, create);
2182 if (opt == nullptr)
2183 throw UnknownOptionException(opt_key);
2184 return opt;
2185 }

References Slic3r::ConfigBase::opt(), and Slic3r::ConfigBase::optptr().

Referenced by Slic3r::ConfigBase::option_throw(), Slic3r::ConfigBase::set(), and Slic3r::ConfigBase::set().

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

◆ option_throw() [4/4]

template<typename TYPE >
TYPE * Slic3r::ConfigBase::option_throw ( const t_config_option_key opt_key,
bool  create = false 
)
inlineinherited
2189 {
2190 ConfigOption *opt = this->option_throw(opt_key, create);
2191 if (opt->type() != TYPE::static_type())
2192 throw BadOptionTypeException("Conversion to a wrong type");
2193 return static_cast<TYPE*>(opt);
2194 }

References Slic3r::ConfigBase::opt(), Slic3r::ConfigBase::option_throw(), and Slic3r::ConfigOption::type().

+ Here is the call graph for this function:

◆ optptr() [1/2]

const ConfigOption * Slic3r::DynamicConfig::optptr ( const t_config_option_key opt_key) const
overridevirtual

Reimplemented from Slic3r::ConfigBase.

1107{
1108 auto it = options.find(opt_key);
1109 return (it == options.end()) ? nullptr : it->second.get();
1110}

Referenced by Slic3r::PresetBundle::PresetBundle(), Slic3r::GUI::get_string_value(), Slic3r::PresetBundle::load_config_file_config_bundle(), Slic3r::client::MyContext::new_old_variable(), and Slic3r::client::MyContext::resolve_output_symbol().

+ Here is the caller graph for this function:

◆ optptr() [2/2]

ConfigOption * Slic3r::DynamicConfig::optptr ( const t_config_option_key opt_key,
bool  create = false 
)
overridevirtual

Implements Slic3r::ConfigBase.

1084{
1085 auto it = options.find(opt_key);
1086 if (it != options.end())
1087 // Option was found.
1088 return it->second.get();
1089 if (! create)
1090 // Option was not found and a new option shall not be created.
1091 return nullptr;
1092 // Try to create a new ConfigOption.
1093 const ConfigDef *def = this->def();
1094 if (def == nullptr)
1095 throw NoDefinitionException(opt_key);
1096 const ConfigOptionDef *optdef = def->get(opt_key);
1097 if (optdef == nullptr)
1098// throw ConfigurationError(std::string("Invalid option name: ") + opt_key);
1099 // Let the parent decide what to do if the opt_key is not defined by this->def().
1100 return nullptr;
1101 ConfigOption *opt = optdef->create_default_option();
1102 this->options.emplace_hint(it, opt_key, std::unique_ptr<ConfigOption>(opt));
1103 return opt;
1104}

References Slic3r::ConfigOptionDef::create_default_option(), Slic3r::ConfigBase::def(), Slic3r::ConfigDef::get(), and Slic3r::ConfigBase::opt().

+ Here is the call graph for this function:

◆ read_cli()

bool Slic3r::DynamicConfig::read_cli ( int  argc,
const char *const  argv[],
t_config_option_keys extra,
t_config_option_keys keys = nullptr 
)
1113{
1114 // cache the CLI option => opt_key mapping
1115 std::map<std::string,std::string> opts;
1116 for (const auto &oit : this->def()->options)
1117 for (const std::string &t : oit.second.cli_args(oit.first))
1118 opts[t] = oit.first;
1119
1120 bool parse_options = true;
1121 for (int i = 1; i < argc; ++ i) {
1122 std::string token = argv[i];
1123 // Store non-option arguments in the provided vector.
1124 if (! parse_options || ! boost::starts_with(token, "-")) {
1125 extra->push_back(token);
1126 continue;
1127 }
1128#ifdef __APPLE__
1129 if (boost::starts_with(token, "-psn_"))
1130 // OSX launcher may add a "process serial number", for example "-psn_0_989382" to the command line.
1131 // While it is supposed to be dropped since OSX 10.9, we will rather ignore it.
1132 continue;
1133#endif /* __APPLE__ */
1134 // Stop parsing tokens as options when -- is supplied.
1135 if (token == "--") {
1136 parse_options = false;
1137 continue;
1138 }
1139 // Remove leading dashes (one or two).
1140 token.erase(token.begin(), token.begin() + (boost::starts_with(token, "--") ? 2 : 1));
1141 // Read value when supplied in the --key=value form.
1142 std::string value;
1143 {
1144 size_t equals_pos = token.find("=");
1145 if (equals_pos != std::string::npos) {
1146 value = token.substr(equals_pos+1);
1147 token.erase(equals_pos);
1148 }
1149 }
1150 // Look for the cli -> option mapping.
1151 auto it = opts.find(token);
1152 bool no = false;
1153 if (it == opts.end()) {
1154 // Remove the "no-" prefix used to negate boolean options.
1155 std::string yes_token;
1156 if (boost::starts_with(token, "no-")) {
1157 yes_token = token.substr(3);
1158 it = opts.find(yes_token);
1159 no = true;
1160 }
1161 if (it == opts.end()) {
1162 boost::nowide::cerr << "Unknown option --" << token.c_str() << std::endl;
1163 return false;
1164 }
1165 if (no)
1166 token = yes_token;
1167 }
1168
1169 const t_config_option_key &opt_key = it->second;
1170 const ConfigOptionDef &optdef = *this->option_def(opt_key);
1171
1172 // If the option type expects a value and it was not already provided,
1173 // look for it in the next token.
1174 if (value.empty() && optdef.type != coBool && optdef.type != coBools) {
1175 if (i == argc-1) {
1176 boost::nowide::cerr << "No value supplied for --" << token.c_str() << std::endl;
1177 return false;
1178 }
1179 value = argv[++ i];
1180 }
1181
1182 if (no) {
1183 assert(optdef.type == coBool || optdef.type == coBools);
1184 if (! value.empty()) {
1185 boost::nowide::cerr << "Boolean options negated by the --no- prefix cannot have a value." << std::endl;
1186 return false;
1187 }
1188 }
1189
1190 // Store the option value.
1191 const bool existing = this->has(opt_key);
1192 if (keys != nullptr && ! existing) {
1193 // Save the order of detected keys.
1194 keys->push_back(opt_key);
1195 }
1196 ConfigOption *opt_base = this->option(opt_key, true);
1197 ConfigOptionVectorBase *opt_vector = opt_base->is_vector() ? static_cast<ConfigOptionVectorBase*>(opt_base) : nullptr;
1198 if (opt_vector) {
1199 if (! existing)
1200 // remove the default values
1201 opt_vector->clear();
1202 // Vector values will be chained. Repeated use of a parameter will append the parameter or parameters
1203 // to the end of the value.
1204 if (opt_base->type() == coBools && value.empty())
1205 static_cast<ConfigOptionBools*>(opt_base)->values.push_back(!no);
1206 else
1207 // Deserialize any other vector value (ConfigOptionInts, Floats, Percents, Points) the same way
1208 // they get deserialized from an .ini file. For ConfigOptionStrings, that means that the C-style unescape
1209 // will be applied for values enclosed in quotes, while values non-enclosed in quotes are left to be
1210 // unescaped by the calling shell.
1211 opt_vector->deserialize(value, true);
1212 } else if (opt_base->type() == coBool) {
1213 if (value.empty())
1214 static_cast<ConfigOptionBool*>(opt_base)->value = !no;
1215 else
1216 opt_base->deserialize(value);
1217 } else if (opt_base->type() == coString) {
1218 // Do not unescape single string values, the unescaping is left to the calling shell.
1219 static_cast<ConfigOptionString*>(opt_base)->value = value;
1220 } else {
1221 // Just bail out if the configuration value is not understood.
1222 ConfigSubstitutionContext context(ForwardCompatibilitySubstitutionRule::Disable);
1223 // Any scalar value of a type different from Bool and String.
1224 if (! this->set_deserialize_nothrow(opt_key, value, context, false)) {
1225 boost::nowide::cerr << "Invalid value supplied for --" << token.c_str() << std::endl;
1226 return false;
1227 }
1228 }
1229 }
1230 return true;
1231}
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:558
const ConfigOptionDef * option_def(const t_config_option_key &opt_key) const
Definition Config.hpp:2203
bool has(const t_config_option_key &opt_key) const
Definition Config.hpp:2105
TOKEN * string(char *text)
Definition config.c:233
#define const
Definition getopt.c:38
ConfigOptionBool
Definition PrintConfig.hpp:665
ConfigOptionBoolsTempl< false > ConfigOptionBools
Definition Config.hpp:1491
@ coString
Definition Config.hpp:172
@ coBools
Definition Config.hpp:192
@ coBool
Definition Config.hpp:190

References Slic3r::ConfigOptionVectorBase::clear(), Slic3r::coBool, Slic3r::coBools, Slic3r::coString, Slic3r::ConfigBase::def(), Slic3r::ConfigOption::deserialize(), Slic3r::Disable, Slic3r::ConfigOptionResolver::has(), Slic3r::ConfigOption::is_vector(), Slic3r::ConfigBase::keys(), Slic3r::ConfigBase::option_def(), Slic3r::ConfigDef::options, Slic3r::ConfigBase::set_deserialize_nothrow(), Slic3r::ConfigOption::type(), Slic3r::ConfigOptionDef::type, and Slic3r::ConfigOptionSingle< T >::value.

Referenced by Slic3r::CLI::setup().

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

◆ remove_nil_options()

size_t Slic3r::DynamicConfig::remove_nil_options ( )
1072{
1073 size_t cnt_removed = 0;
1074 for (auto it = options.begin(); it != options.end();)
1075 if (it->second->is_nil()) {
1076 it = options.erase(it);
1077 ++ cnt_removed;
1078 } else
1079 ++ it;
1080 return cnt_removed;
1081}

◆ save()

void Slic3r::ConfigBase::save ( const std::string &  file) const
inherited
1031{
1032 boost::nowide::ofstream c;
1033 c.open(file, std::ios::out | std::ios::trunc);
1034 c << "# " << Slic3r::header_slic3r_generated() << std::endl;
1035 for (const std::string &opt_key : this->keys())
1036 c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
1037 c.close();
1038}
std::string opt_serialize(const t_config_option_key &opt_key) const
Definition Config.cpp:528
std::string header_slic3r_generated()
Definition utils.cpp:914

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

Referenced by Slic3r::CLI::run(), Slic3r::Preset::save(), Slic3r::PhysicalPrinter::save(), and Slic3r::PhysicalPrinter::save().

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

◆ serialize()

template<class Archive >
void Slic3r::DynamicConfig::serialize ( Archive &  ar)
inlineprivate
2461{ ar(options); }

References options.

◆ set() [1/5]

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

Referenced by Slic3r::extract_profile(), and Slic3r::ModelConfig::set().

+ 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
2231 { this->option_throw<ConfigOptionString>(opt_key, create)->value = value; }

◆ set() [3/5]

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

◆ set() [4/5]

void Slic3r::ConfigBase::set ( const std::string &  opt_key,
double  value,
bool  create = false 
)
inherited
548{
549 ConfigOption *opt = this->option_throw(opt_key, create);
550 switch (opt->type()) {
551 case coFloat: static_cast<ConfigOptionFloat*>(opt)->value = value; break;
552 case coFloatOrPercent: static_cast<ConfigOptionFloatOrPercent*>(opt)->value = value; static_cast<ConfigOptionFloatOrPercent*>(opt)->percent = false; break;
553 case coString: static_cast<ConfigOptionString*>(opt)->value = float_to_string_decimal_point(value); break;
554 default: throw BadOptionTypeException("Configbase::set() - conversion from float not possible");
555 }
556}
std::string float_to_string_decimal_point(double value, int precision)
Definition LocalesUtils.cpp:74

References Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coString, Slic3r::float_to_string_decimal_point(), Slic3r::ConfigBase::opt(), Slic3r::ConfigBase::option_throw(), and Slic3r::ConfigOption::type().

+ 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
536{
537 ConfigOption *opt = this->option_throw(opt_key, create);
538 switch (opt->type()) {
539 case coInt: static_cast<ConfigOptionInt*>(opt)->value = value; break;
540 case coFloat: static_cast<ConfigOptionFloat*>(opt)->value = value; break;
541 case coFloatOrPercent: static_cast<ConfigOptionFloatOrPercent*>(opt)->value = value; static_cast<ConfigOptionFloatOrPercent*>(opt)->percent = false; break;
542 case coString: static_cast<ConfigOptionString*>(opt)->value = std::to_string(value); break;
543 default: throw BadOptionTypeException("Configbase::set() - conversion from int not possible");
544 }
545}
@ coInt
Definition Config.hpp:168

References Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coString, Slic3r::ConfigBase::opt(), Slic3r::ConfigBase::option_throw(), and Slic3r::ConfigOption::type().

+ 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
572{
573 if (! this->set_deserialize_nothrow(opt_key_src, value_src, substitutions_ctxt, append))
574 throw BadOptionValueException(format("Invalid value provided for parameter %1%: %2%", opt_key_src, value_src));
575}
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:110

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

Referenced by Slic3r::ConfigBase::load(), Slic3r::PresetBundle::load_configbundle(), Slic3r::ConfigBase::load_from_gcode_file(), Slic3r::ConfigBase::load_from_gcode_string_legacy(), Slic3r::ModelConfig::set_deserialize(), Slic3r::ConfigBase::set_deserialize(), Slic3r::ConfigBase::set_deserialize_strict(), and Slic3r::ConfigBase::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
578{
579 for (const SetDeserializeItem &item : items)
580 this->set_deserialize(item.opt_key, item.opt_value, substitutions_ctxt, item.append);
581}

References Slic3r::ConfigBase::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
559{
560 t_config_option_key opt_key = opt_key_src;
561 std::string value = value_src;
562 // Both opt_key and value may be modified by handle_legacy().
563 // If the opt_key is no more valid in this version of Slic3r, opt_key is cleared by handle_legacy().
564 this->handle_legacy(opt_key, value);
565 if (opt_key.empty())
566 // Ignore the option.
567 return true;
568 return this->set_deserialize_raw(opt_key, value, substitutions_ctxt, append);
569}
virtual void handle_legacy(t_config_option_key &, std::string &) const
Definition Config.hpp:2162
bool set_deserialize_raw(const t_config_option_key &opt_key_src, const std::string &value, ConfigSubstitutionContext &substitutions, bool append)
Definition Config.cpp:583

References Slic3r::append(), Slic3r::ConfigBase::handle_legacy(), and Slic3r::ConfigBase::set_deserialize_raw().

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

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

◆ set_deserialize_raw()

bool Slic3r::ConfigBase::set_deserialize_raw ( const t_config_option_key opt_key_src,
const std::string &  value,
ConfigSubstitutionContext substitutions,
bool  append 
)
privateinherited
584{
585 t_config_option_key opt_key = opt_key_src;
586 // Try to deserialize the option by its name.
587 const ConfigDef *def = this->def();
588 if (def == nullptr)
589 throw NoDefinitionException(opt_key);
590 const ConfigOptionDef *optdef = def->get(opt_key);
591 if (optdef == nullptr) {
592 // If we didn't find an option, look for any other option having this as an alias.
593 for (const auto &opt : def->options) {
594 for (const t_config_option_key &opt_key2 : opt.second.aliases) {
595 if (opt_key2 == opt_key) {
596 opt_key = opt.first;
597 optdef = &opt.second;
598 break;
599 }
600 }
601 if (optdef != nullptr)
602 break;
603 }
604 if (optdef == nullptr)
605 throw UnknownOptionException(opt_key);
606 }
607
608 if (! optdef->shortcut.empty()) {
609 // Aliasing for example "solid_layers" to "top_solid_layers" and "bottom_solid_layers".
610 for (const t_config_option_key &shortcut : optdef->shortcut)
611 // Recursive call.
612 if (! this->set_deserialize_raw(shortcut, value, substitutions_ctxt, append))
613 return false;
614 return true;
615 }
616
617 ConfigOption *opt = this->option(opt_key, true);
618 assert(opt != nullptr);
619 bool success = false;
620 bool substituted = false;
621 if (optdef->type == coBools && substitutions_ctxt.rule != ForwardCompatibilitySubstitutionRule::Disable) {
622 //FIXME Special handling of vectors of bools, quick and not so dirty solution before PrusaSlicer 2.3.2 release.
623 bool nullable = opt->nullable();
625 if (optdef->default_value) {
626 // Default value for vectors of booleans used in a "per extruder" context, thus the default contains just a single value.
627 assert(dynamic_cast<const ConfigOptionVector<unsigned char>*>(optdef->default_value.get()));
628 auto &values = static_cast<const ConfigOptionVector<unsigned char>*>(optdef->default_value.get())->values;
629 if (values.size() == 1 && values.front() == 1)
631 }
632 auto result = nullable ?
633 static_cast<ConfigOptionBoolsNullable*>(opt)->deserialize_with_substitutions(value, append, default_value) :
634 static_cast<ConfigOptionBools*>(opt)->deserialize_with_substitutions(value, append, default_value);
637 } else {
638 success = opt->deserialize(value, append);
639 if (! success && substitutions_ctxt.rule != ForwardCompatibilitySubstitutionRule::Disable &&
640 // Only allow substitutions of an enum value by another enum value or a boolean value with an enum value.
641 // That means, we expect enum values being added in the future and possibly booleans being converted to enums.
642 (optdef->type == coEnum || optdef->type == coBool) && ConfigHelpers::looks_like_enum_value(value)) {
643 // Deserialize failed, try to substitute with a default value.
644 assert(substitutions_ctxt.rule == ForwardCompatibilitySubstitutionRule::Enable || substitutions_ctxt.rule == ForwardCompatibilitySubstitutionRule::EnableSilent);
645 if (optdef->type == coBool)
646 static_cast<ConfigOptionBool*>(opt)->value = ConfigHelpers::enum_looks_like_true_value(value);
647 else
648 // Just use the default of the option.
649 opt->set(optdef->default_value.get());
650 success = true;
651 substituted = true;
652 }
653 }
654
655 if (substituted && (substitutions_ctxt.rule == ForwardCompatibilitySubstitutionRule::Enable ||
657 // Log the substitution.
658 ConfigSubstitution config_substitution;
659 config_substitution.opt_def = optdef;
660 config_substitution.old_value = value;
661 config_substitution.new_value = ConfigOptionUniquePtr(opt->clone());
662 substitutions_ctxt.substitutions.emplace_back(std::move(config_substitution));
663 }
664 return success;
665}
if(!(yy_init))
Definition lexer.c:1190
bool looks_like_enum_value(std::string value)
Definition Config.hpp:87
DeserializationSubstitution
Definition Config.hpp:103
bool enum_looks_like_true_value(std::string value)
Definition Config.hpp:98
@ EnableSystemSilent
Definition Config.hpp:225
@ EnableSilent
Definition Config.hpp:223
@ Enable
Definition Config.hpp:221
ConfigOptionBoolsTempl< true > ConfigOptionBoolsNullable
Definition Config.hpp:1492
std::unique_ptr< ConfigOption, ConfigOptionDeleter > ConfigOptionUniquePtr
Definition Config.hpp:235
@ coEnum
Definition Config.hpp:194

References Slic3r::append(), Slic3r::ConfigOption::clone(), Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::ConfigBase::def(), Slic3r::ConfigOptionDef::default_value, Slic3r::ConfigHelpers::DefaultsToFalse, Slic3r::ConfigHelpers::DefaultsToTrue, Slic3r::ConfigOption::deserialize(), Slic3r::Disable, Slic3r::Enable, Slic3r::EnableSilent, Slic3r::EnableSystemSilent, Slic3r::ConfigHelpers::enum_looks_like_true_value(), Slic3r::ConfigHelpers::Failed, Slic3r::ConfigDef::get(), Slic3r::ConfigHelpers::looks_like_enum_value(), Slic3r::ConfigSubstitution::new_value, Slic3r::ConfigOption::nullable(), Slic3r::ConfigSubstitution::old_value, Slic3r::ConfigBase::opt(), Slic3r::ConfigSubstitution::opt_def, Slic3r::ConfigDef::options, Slic3r::ConfigSubstitutionContext::rule, Slic3r::ConfigOption::set(), Slic3r::ConfigBase::set_deserialize_raw(), Slic3r::ConfigOptionDef::shortcut, Slic3r::ConfigHelpers::Substituted, Slic3r::ConfigSubstitutionContext::substitutions, and Slic3r::ConfigOptionDef::type.

Referenced by Slic3r::ConfigBase::set_deserialize_nothrow(), and Slic3r::ConfigBase::set_deserialize_raw().

+ 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
2241 { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(opt_key, str, ctxt, append); }

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

Referenced by Slic3r::DynamicPrintConfig::new_with(), Slic3r::DynamicPrintConfig::new_with(), and Slic3r::ModelConfig::set_deserialize_strict().

+ 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
2271 { ConfigSubstitutionContext ctxt{ ForwardCompatibilitySubstitutionRule::Disable }; this->set_deserialize(items, ctxt); }

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

+ Here is the call graph for this function:

◆ set_key_value()

bool Slic3r::DynamicConfig::set_key_value ( const std::string &  opt_key,
ConfigOption opt 
)
inline
2432 {
2433 auto it = this->options.find(opt_key);
2434 if (it == this->options.end()) {
2435 this->options[opt_key].reset(opt);
2436 return true;
2437 } else {
2438 it->second.reset(opt);
2439 return false;
2440 }
2441 }

Referenced by Slic3r::GUI::FreqChangedParams::FreqChangedParams(), Slic3r::PhysicalPrinterCollection::PhysicalPrinterCollection(), Slic3r::WipeTowerIntegration::append_tcr(), Slic3r::GUI::ConfigManipulation::apply(), Slic3r::GUI::PageFirmware::apply_custom_config(), Slic3r::GUI::PageBedShape::apply_custom_config(), Slic3r::GUI::PageBuildVolume::apply_custom_config(), Slic3r::GUI::PageDiameters::apply_custom_config(), Slic3r::GUI::PageTemperatures::apply_custom_config(), Slic3r::GUI::TabSLAMaterial::build(), Slic3r::GUI::TabPrinter::build_extruder_pages(), Slic3r::GUI::TabPrinter::build_fff(), Slic3r::GUI::TabPrinter::build_kinematics_page(), Slic3r::GUI::PlaterPresetComboBox::change_extruder_color(), Slic3r::GUI::change_opt_value(), Slic3r::PrintStatistics::config(), Slic3r::ProcessLayer::emit_custom_gcode_per_print_z(), Slic3r::PresetBundle::full_fff_config(), Slic3r::PresetBundle::full_sla_config(), Slic3r::is_compatible_with_printer(), cereal::load(), Slic3r::Print::output_filename(), Slic3r::SLAPrint::output_filename(), Slic3r::PrintBase::output_filename(), Slic3r::PrintStatistics::placeholders(), Slic3r::print_config_diffs(), Slic3r::GUI::Plater::priv::process_validation_warning(), Slic3r::PlaceholderParser::set(), Slic3r::ModelConfig::set_key_value(), Slic3r::GUI::PhysicalPrinterDialog::set_printer_technology(), Slic3r::client::MyContext::store_new_variable(), Slic3r::GUI::TabPrinter::toggle_options(), Slic3r::GUI::Plater::priv::undo_redo_to(), Slic3r::PresetCollection::update_compatible_internal(), Slic3r::ExtruderFilaments::update_compatible_internal(), Slic3r::GUI::PhysicalPrinterDialog::update_host_type(), Slic3r::PrintBase::update_object_placeholders(), Slic3r::update_preset_name_option(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), Slic3r::GUI::ConfigManipulation::update_print_sla_config(), and Slic3r::PlaceholderParser::update_timestamp().

+ Here is the caller graph for this function:

◆ setenv_()

void Slic3r::ConfigBase::setenv_ ( ) const
inherited
706{
707 t_config_option_keys opt_keys = this->keys();
708 for (t_config_option_keys::const_iterator it = opt_keys.begin(); it != opt_keys.end(); ++it) {
709 // prepend the SLIC3R_ prefix
710 std::ostringstream ss;
711 ss << "SLIC3R_";
712 ss << *it;
713 std::string envname = ss.str();
714
715 // capitalize environment variable name
716 for (size_t i = 0; i < envname.size(); ++i)
717 envname[i] = (envname[i] <= 'z' && envname[i] >= 'a') ? envname[i]-('a'-'A') : envname[i];
718
719 boost::nowide::setenv(envname.c_str(), this->opt_serialize(*it).c_str(), 1);
720 }
721}

References Slic3r::ConfigBase::keys().

Referenced by Slic3r::run_post_process_scripts().

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

◆ size()

size_t Slic3r::DynamicConfig::size ( ) const
inline
2455{ return options.size(); }

References options.

Referenced by cereal::save(), and Slic3r::ModelConfig::size().

+ Here is the caller graph for this function:

◆ swap()

void Slic3r::DynamicConfig::swap ( DynamicConfig other)
inline
2396 {
2397 std::swap(this->options, other.options);
2398 }

References options.

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

Member Data Documentation

◆ options

std::map<t_config_option_key, std::unique_ptr<ConfigOption> > Slic3r::DynamicConfig::options
private

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