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

#include <src/libslic3r/Config.hpp>

+ Collaboration diagram for Slic3r::ConfigOptionDef:

Public Types

enum class  GUIType {
  undefined , i_enum_open , f_enum_open , select_open ,
  color , slider , legend , one_string ,
  select_close
}
 

Public Member Functions

void set_default_value (const ConfigOption *ptr)
 
template<typename T >
const T * get_default_value () const
 
ConfigOptioncreate_empty_option () const
 
ConfigOptioncreate_default_option () const
 
template<class Archive >
ConfigOptionload_option_from_archive (Archive &archive) const
 
template<class Archive >
ConfigOptionsave_option_to_archive (Archive &archive, const ConfigOption *opt) const
 
void set_enum_values (const std::initializer_list< std::string_view > il)
 
void set_enum_values (GUIType gui_type, const std::initializer_list< std::string_view > il)
 
void set_enum_values (const std::initializer_list< std::pair< std::string_view, std::string_view > > il)
 
void set_enum_values (GUIType gui_type, const std::initializer_list< std::pair< std::string_view, std::string_view > > il)
 
template<typename Values , typename Labels >
void set_enum_values (Values &&values, Labels &&labels)
 
void set_enum_labels (GUIType gui_type, const std::initializer_list< std::string_view > il)
 
template<typename EnumType >
void set_enum (std::initializer_list< std::string_view > il)
 
template<typename EnumType >
void set_enum (std::initializer_list< std::pair< std::string_view, std::string_view > > il)
 
template<typename EnumType , typename Values , typename Labels >
void set_enum (Values &&values, Labels &&labels)
 
template<typename EnumType , typename Values >
void set_enum (Values &&values, const std::initializer_list< std::string_view > labels)
 
bool has_enum_value (const std::string &value) const
 
std::vector< std::string > cli_args (const std::string &key) const
 

Public Attributes

t_config_option_key opt_key
 
ConfigOptionType type = coNone
 
bool nullable = false
 
Slic3r::clonable_ptr< const ConfigOptiondefault_value
 
GUIType gui_type { GUIType::undefined }
 
std::string gui_flags
 
std::string label
 
std::string full_label
 
PrinterTechnology printer_technology = ptUnknown
 
std::string category
 
std::string tooltip
 
std::string sidetext
 
std::string cli
 
t_config_option_key ratio_over
 
bool multiline = false
 
bool full_width = false
 
bool is_code = false
 
bool readonly = false
 
int height = -1
 
int width = -1
 
float min = -FLT_MAX
 
float max = FLT_MAX
 
double max_literal = 1
 
ConfigOptionMode mode = comSimple
 
std::vector< t_config_option_keyaliases
 
std::vector< t_config_option_keyshortcut
 
Slic3r::clonable_ptr< ConfigOptionEnumDefenum_def
 
size_t serialization_key_ordinal = 0
 

Static Public Attributes

static const constexpr char * nocli = "~~~noCLI"
 

Private Member Functions

void enum_def_new ()
 

Detailed Description

Member Enumeration Documentation

◆ GUIType

Enumerator
undefined 
i_enum_open 
f_enum_open 
select_open 
color 
slider 
legend 
one_string 
select_close 
1799 {
1800 undefined,
1801 // Open enums, integer value could be one of the enumerated values or something else.
1803 // Open enums, float value could be one of the enumerated values or something else.
1805 // Open enums, string value could be one of the enumerated values or something else.
1807 // Color picker, string value.
1808 color,
1809 // Currently unused.
1810 slider,
1811 // Static text
1812 legend,
1813 // Vector value, but edited as a single string.
1814 one_string,
1815 // Close parameter, string value could be one of the list values.
1817 };

Member Function Documentation

◆ cli_args()

std::vector< std::string > Slic3r::ConfigOptionDef::cli_args ( const std::string &  key) const
223{
224 std::vector<std::string> args;
225 if (this->cli != ConfigOptionDef::nocli) {
226 const std::string &cli = this->cli;
227 //FIXME What was that for? Check the "readline" documentation.
228 // Neither '=' nor '!' is used in any of the cli parameters currently defined by PrusaSlicer.
229// std::string cli = this->cli.substr(0, this->cli.find("="));
230// boost::trim_right_if(cli, boost::is_any_of("!"));
231 if (cli.empty()) {
232 // Convert an option key to CLI argument by replacing underscores with dashes.
233 std::string opt = key;
234 boost::replace_all(opt, "_", "-");
235 args.emplace_back(std::move(opt));
236 } else
237 boost::split(args, cli, boost::is_any_of("|"));
238 }
239 return args;
240}
std::string cli
Definition Config.hpp:1926
static const constexpr char * nocli
Definition Config.hpp:2035

References cli, and nocli.

Referenced by Slic3r::ConfigDef::print_cli_help().

+ Here is the caller graph for this function:

◆ create_default_option()

ConfigOption * Slic3r::ConfigOptionDef::create_default_option ( ) const
278{
279 if (this->default_value)
280 return (this->default_value->type() == coEnum) ?
281 // Special case: For a DynamicConfig, convert a templated enum to a generic enum.
282 new ConfigOptionEnumGeneric(this->enum_def->m_enum_keys_map, this->default_value->getInt()) :
283 this->default_value->clone();
284 return this->create_empty_option();
285}
ConfigOption * create_empty_option() const
Definition Config.cpp:242
Slic3r::clonable_ptr< ConfigOptionEnumDef > enum_def
Definition Config.hpp:1959
Slic3r::clonable_ptr< const ConfigOption > default_value
Definition Config.hpp:1826
VoxelGridPtr clone(const VoxelGrid &grid)
Definition OpenVDBUtils.cpp:285
@ coEnum
Definition Config.hpp:194

References Slic3r::coEnum, create_empty_option(), default_value, and enum_def.

Referenced by Slic3r::DynamicConfig::optptr().

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

◆ create_empty_option()

ConfigOption * Slic3r::ConfigOptionDef::create_empty_option ( ) const
243{
244 if (this->nullable) {
245 switch (this->type) {
246 case coFloats: return new ConfigOptionFloatsNullable();
247 case coInts: return new ConfigOptionIntsNullable();
248 case coPercents: return new ConfigOptionPercentsNullable();
250 case coBools: return new ConfigOptionBoolsNullable();
251 default: throw ConfigurationError(std::string("Unknown option type for nullable option ") + this->label);
252 }
253 } else {
254 switch (this->type) {
255 case coFloat: return new ConfigOptionFloat();
256 case coFloats: return new ConfigOptionFloats();
257 case coInt: return new ConfigOptionInt();
258 case coInts: return new ConfigOptionInts();
259 case coString: return new ConfigOptionString();
260 case coStrings: return new ConfigOptionStrings();
261 case coPercent: return new ConfigOptionPercent();
262 case coPercents: return new ConfigOptionPercents();
263 case coFloatOrPercent: return new ConfigOptionFloatOrPercent();
265 case coPoint: return new ConfigOptionPoint();
266 case coPoints: return new ConfigOptionPoints();
267 case coPoint3: return new ConfigOptionPoint3();
268 // case coPoint3s: return new ConfigOptionPoint3s();
269 case coBool: return new ConfigOptionBool();
270 case coBools: return new ConfigOptionBools();
271 case coEnum: return new ConfigOptionEnumGeneric(this->enum_def->m_enum_keys_map);
272 default: throw ConfigurationError(std::string("Unknown option type for option ") + this->label);
273 }
274 }
275}
ConfigOptionType type
Definition Config.hpp:1822
std::string label
Definition Config.hpp:1914
bool nullable
Definition Config.hpp:1824
ConfigOptionFloat
Definition PrintConfig.hpp:570
ConfigOptionFloatsOrPercentsTempl< false > ConfigOptionFloatsOrPercents
Definition Config.hpp:1196
ConfigOptionPercentsTempl< true > ConfigOptionPercentsNullable
Definition Config.hpp:1009
ConfigOptionBool
Definition PrintConfig.hpp:665
ConfigOptionPercentsTempl< false > ConfigOptionPercents
Definition Config.hpp:1008
ConfigOptionFloatsTempl< true > ConfigOptionFloatsNullable
Definition Config.hpp:717
ConfigOptionBoolsTempl< true > ConfigOptionBoolsNullable
Definition Config.hpp:1492
ConfigOptionBoolsTempl< false > ConfigOptionBools
Definition Config.hpp:1491
ConfigOptionFloatsOrPercentsTempl< true > ConfigOptionFloatsOrPercentsNullable
Definition Config.hpp:1197
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:716
ConfigOptionIntsTempl< false > ConfigOptionInts
Definition Config.hpp:844
@ coFloatsOrPercents
Definition Config.hpp:182
@ coString
Definition Config.hpp:172
@ coPoint
Definition Config.hpp:184
@ coBools
Definition Config.hpp:192
@ coPoint3
Definition Config.hpp:187
@ coPercents
Definition Config.hpp:178
@ coInts
Definition Config.hpp:170
@ coPoints
Definition Config.hpp:186
@ coInt
Definition Config.hpp:168
@ coBool
Definition Config.hpp:190
@ coFloat
Definition Config.hpp:164
@ coFloatOrPercent
Definition Config.hpp:180
@ coStrings
Definition Config.hpp:174
@ coFloats
Definition Config.hpp:166
@ coPercent
Definition Config.hpp:176
ConfigOptionIntsTempl< true > ConfigOptionIntsNullable
Definition Config.hpp:845

References Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoint3, Slic3r::coPoints, Slic3r::coString, Slic3r::coStrings, enum_def, label, nullable, and type.

Referenced by create_default_option().

+ Here is the caller graph for this function:

◆ enum_def_new()

void Slic3r::ConfigOptionDef::enum_def_new ( )
inlineprivate
2038 {
2039 if (enum_def)
2040 enum_def->clear();
2041 else
2042 enum_def = Slic3r::clonable_ptr<ConfigOptionEnumDef>(new ConfigOptionEnumDef{});
2043 }
Definition clonable_ptr.hpp:28

References enum_def.

Referenced by set_enum_labels(), set_enum_values(), set_enum_values(), set_enum_values(), set_enum_values(), and set_enum_values().

+ Here is the caller graph for this function:

◆ get_default_value()

template<typename T >
const T * Slic3r::ConfigOptionDef::get_default_value ( ) const
inline
1828{ return static_cast<const T*>(this->default_value.get()); }

References Slic3r::clonable_ptr< T >::get().

Referenced by Slic3r::GUI::PageDiameters::PageDiameters(), Slic3r::GUI::PlaterPresetComboBox::update(), and Slic3r::GLVolumeCollection::update_colors_by_extruder().

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

◆ has_enum_value()

bool Slic3r::ConfigOptionDef::has_enum_value ( const std::string &  value) const
inline
2023 {
2024 return enum_def && enum_def->value_to_index(value).has_value();
2025 }

References enum_def.

Referenced by Slic3r::validate().

+ Here is the caller graph for this function:

◆ load_option_from_archive()

template<class Archive >
ConfigOption * Slic3r::ConfigOptionDef::load_option_from_archive ( Archive &  archive) const
inline
1835 {
1836 if (this->nullable) {
1837 switch (this->type) {
1838 case coFloats: { auto opt = new ConfigOptionFloatsNullable(); archive(*opt); return opt; }
1839 case coInts: { auto opt = new ConfigOptionIntsNullable(); archive(*opt); return opt; }
1840 case coPercents: { auto opt = new ConfigOptionPercentsNullable();archive(*opt); return opt; }
1841 case coBools: { auto opt = new ConfigOptionBoolsNullable(); archive(*opt); return opt; }
1842 default: throw ConfigurationError(std::string("ConfigOptionDef::load_option_from_archive(): Unknown nullable option type for option ") + this->opt_key);
1843 }
1844 } else {
1845 switch (this->type) {
1846 case coFloat: { auto opt = new ConfigOptionFloat(); archive(*opt); return opt; }
1847 case coFloats: { auto opt = new ConfigOptionFloats(); archive(*opt); return opt; }
1848 case coInt: { auto opt = new ConfigOptionInt(); archive(*opt); return opt; }
1849 case coInts: { auto opt = new ConfigOptionInts(); archive(*opt); return opt; }
1850 case coString: { auto opt = new ConfigOptionString(); archive(*opt); return opt; }
1851 case coStrings: { auto opt = new ConfigOptionStrings(); archive(*opt); return opt; }
1852 case coPercent: { auto opt = new ConfigOptionPercent(); archive(*opt); return opt; }
1853 case coPercents: { auto opt = new ConfigOptionPercents(); archive(*opt); return opt; }
1854 case coFloatOrPercent: { auto opt = new ConfigOptionFloatOrPercent(); archive(*opt); return opt; }
1855 case coFloatsOrPercents:{ auto opt = new ConfigOptionFloatsOrPercents();archive(*opt); return opt; }
1856 case coPoint: { auto opt = new ConfigOptionPoint(); archive(*opt); return opt; }
1857 case coPoints: { auto opt = new ConfigOptionPoints(); archive(*opt); return opt; }
1858 case coPoint3: { auto opt = new ConfigOptionPoint3(); archive(*opt); return opt; }
1859 case coBool: { auto opt = new ConfigOptionBool(); archive(*opt); return opt; }
1860 case coBools: { auto opt = new ConfigOptionBools(); archive(*opt); return opt; }
1861 case coEnum: { auto opt = new ConfigOptionEnumGeneric(this->enum_def->m_enum_keys_map); archive(*opt); return opt; }
1862 default: throw ConfigurationError(std::string("ConfigOptionDef::load_option_from_archive(): Unknown option type for option ") + this->opt_key);
1863 }
1864 }
1865 }
t_config_option_key opt_key
Definition Config.hpp:1820

References Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoint3, Slic3r::coPoints, Slic3r::coString, Slic3r::coStrings, and enum_def.

◆ save_option_to_archive()

template<class Archive >
ConfigOption * Slic3r::ConfigOptionDef::save_option_to_archive ( Archive &  archive,
const ConfigOption opt 
) const
inline
1867 {
1868 if (this->nullable) {
1869 switch (this->type) {
1870 case coFloats: archive(*static_cast<const ConfigOptionFloatsNullable*>(opt)); break;
1871 case coInts: archive(*static_cast<const ConfigOptionIntsNullable*>(opt)); break;
1872 case coPercents: archive(*static_cast<const ConfigOptionPercentsNullable*>(opt));break;
1873 case coBools: archive(*static_cast<const ConfigOptionBoolsNullable*>(opt)); break;
1874 default: throw ConfigurationError(std::string("ConfigOptionDef::save_option_to_archive(): Unknown nullable option type for option ") + this->opt_key);
1875 }
1876 } else {
1877 switch (this->type) {
1878 case coFloat: archive(*static_cast<const ConfigOptionFloat*>(opt)); break;
1879 case coFloats: archive(*static_cast<const ConfigOptionFloats*>(opt)); break;
1880 case coInt: archive(*static_cast<const ConfigOptionInt*>(opt)); break;
1881 case coInts: archive(*static_cast<const ConfigOptionInts*>(opt)); break;
1882 case coString: archive(*static_cast<const ConfigOptionString*>(opt)); break;
1883 case coStrings: archive(*static_cast<const ConfigOptionStrings*>(opt)); break;
1884 case coPercent: archive(*static_cast<const ConfigOptionPercent*>(opt)); break;
1885 case coPercents: archive(*static_cast<const ConfigOptionPercents*>(opt)); break;
1886 case coFloatOrPercent: archive(*static_cast<const ConfigOptionFloatOrPercent*>(opt)); break;
1887 case coFloatsOrPercents:archive(*static_cast<const ConfigOptionFloatsOrPercents*>(opt));break;
1888 case coPoint: archive(*static_cast<const ConfigOptionPoint*>(opt)); break;
1889 case coPoints: archive(*static_cast<const ConfigOptionPoints*>(opt)); break;
1890 case coPoint3: archive(*static_cast<const ConfigOptionPoint3*>(opt)); break;
1891 case coBool: archive(*static_cast<const ConfigOptionBool*>(opt)); break;
1892 case coBools: archive(*static_cast<const ConfigOptionBools*>(opt)); break;
1893 case coEnum: archive(*static_cast<const ConfigOptionEnumGeneric*>(opt)); break;
1894 default: throw ConfigurationError(std::string("ConfigOptionDef::save_option_to_archive(): Unknown option type for option ") + this->opt_key);
1895 }
1896 }
1897 // Make the compiler happy, shut up the warnings.
1898 return nullptr;
1899 }

References Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoint3, Slic3r::coPoints, Slic3r::coString, and Slic3r::coStrings.

Referenced by cereal::save().

+ Here is the caller graph for this function:

◆ set_default_value()

◆ set_enum() [1/4]

template<typename EnumType >
void Slic3r::ConfigOptionDef::set_enum ( std::initializer_list< std::pair< std::string_view, std::string_view > >  il)
inline
2006 {
2007 this->set_enum_values(il);
2008 enum_def->set_enum_map<EnumType>();
2009 }
void set_enum_values(const std::initializer_list< std::string_view > il)
Definition Config.hpp:1961

References enum_def, and set_enum_values().

+ Here is the call graph for this function:

◆ set_enum() [2/4]

template<typename EnumType >
void Slic3r::ConfigOptionDef::set_enum ( std::initializer_list< std::string_view >  il)
inline
2000 {
2001 this->set_enum_values(il);
2002 enum_def->set_enum_map<EnumType>();
2003 }

References enum_def, and set_enum_values().

Referenced by Slic3r::CLIMiscConfigDef::CLIMiscConfigDef(), Slic3r::GUI::append_enum_option(), Slic3r::PrintConfigDef::init_common_params(), Slic3r::PrintConfigDef::init_fff_params(), Slic3r::PrintConfigDef::init_sla_params(), and Slic3r::PrintConfigDef::init_sla_support_params().

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

◆ set_enum() [3/4]

template<typename EnumType , typename Values >
void Slic3r::ConfigOptionDef::set_enum ( Values &&  values,
const std::initializer_list< std::string_view >  labels 
)
inline
2018 {
2019 this->set_enum_values(std::move(values), labels);
2020 enum_def->set_enum_map<EnumType>();
2021 }

References enum_def, and set_enum_values().

+ Here is the call graph for this function:

◆ set_enum() [4/4]

template<typename EnumType , typename Values , typename Labels >
void Slic3r::ConfigOptionDef::set_enum ( Values &&  values,
Labels &&  labels 
)
inline
2012 {
2013 this->set_enum_values(std::move(values), std::move(labels));
2014 enum_def->set_enum_map<EnumType>();
2015 }

References enum_def, and set_enum_values().

+ Here is the call graph for this function:

◆ set_enum_labels()

void Slic3r::ConfigOptionDef::set_enum_labels ( GUIType  gui_type,
const std::initializer_list< std::string_view >  il 
)
inline
1992 {
1993 this->enum_def_new();
1995 this->gui_type = gui_type;
1996 enum_def->set_labels(il);
1997 }
GUIType gui_type
Definition Config.hpp:1904
void enum_def_new()
Definition Config.hpp:2038

References enum_def, enum_def_new(), f_enum_open, gui_type, i_enum_open, and select_close.

Referenced by Slic3r::GUI::FreqChangedParams::FreqChangedParams(), and Slic3r::PrintConfigDef::init_fff_params().

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

◆ set_enum_values() [1/5]

void Slic3r::ConfigOptionDef::set_enum_values ( const std::initializer_list< std::pair< std::string_view, std::string_view > >  il)
inline
1973 {
1974 this->enum_def_new();
1975 enum_def->set_values(il);
1976 }

References enum_def_new().

+ Here is the call graph for this function:

◆ set_enum_values() [2/5]

void Slic3r::ConfigOptionDef::set_enum_values ( const std::initializer_list< std::string_view >  il)
inline
1961 {
1962 this->enum_def_new();
1963 enum_def->set_values(il);
1964 }

References enum_def_new().

Referenced by Slic3r::PrintConfigDef::init_fff_params(), Slic3r::PrintConfigDef::init_sla_params(), set_enum(), set_enum(), set_enum(), and set_enum().

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

◆ set_enum_values() [3/5]

void Slic3r::ConfigOptionDef::set_enum_values ( GUIType  gui_type,
const std::initializer_list< std::pair< std::string_view, std::string_view > >  il 
)
inline
1978 {
1979 this->enum_def_new();
1981 this->gui_type = gui_type;
1982 enum_def->set_values(il);
1983 }

References enum_def, enum_def_new(), f_enum_open, gui_type, and i_enum_open.

+ Here is the call graph for this function:

◆ set_enum_values() [4/5]

void Slic3r::ConfigOptionDef::set_enum_values ( GUIType  gui_type,
const std::initializer_list< std::string_view >  il 
)
inline
1966 {
1967 this->enum_def_new();
1969 this->gui_type = gui_type;
1970 enum_def->set_values(il);
1971 }

References enum_def, enum_def_new(), f_enum_open, gui_type, i_enum_open, and select_open.

+ Here is the call graph for this function:

◆ set_enum_values() [5/5]

template<typename Values , typename Labels >
void Slic3r::ConfigOptionDef::set_enum_values ( Values &&  values,
Labels &&  labels 
)
inline
1986 {
1987 this->enum_def_new();
1988 enum_def->set_values(std::move(values));
1989 enum_def->set_labels(std::move(labels));
1990 }

References enum_def, and enum_def_new().

+ Here is the call graph for this function:

Member Data Documentation

◆ aliases

std::vector<t_config_option_key> Slic3r::ConfigOptionDef::aliases

◆ category

◆ cli

◆ default_value

◆ enum_def

◆ full_label

◆ full_width

bool Slic3r::ConfigOptionDef::full_width = false

◆ gui_flags

◆ gui_type

◆ height

int Slic3r::ConfigOptionDef::height = -1

◆ is_code

bool Slic3r::ConfigOptionDef::is_code = false

◆ label

◆ max

◆ max_literal

double Slic3r::ConfigOptionDef::max_literal = 1

◆ min

◆ mode

◆ multiline

bool Slic3r::ConfigOptionDef::multiline = false

◆ nocli

◆ nullable

◆ opt_key

◆ printer_technology

PrinterTechnology Slic3r::ConfigOptionDef::printer_technology = ptUnknown

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

◆ ratio_over

◆ readonly

bool Slic3r::ConfigOptionDef::readonly = false

◆ serialization_key_ordinal

size_t Slic3r::ConfigOptionDef::serialization_key_ordinal = 0

◆ shortcut

std::vector<t_config_option_key> Slic3r::ConfigOptionDef::shortcut

◆ sidetext

◆ tooltip

◆ type

◆ width

int Slic3r::ConfigOptionDef::width = -1

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