Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ConfigOptionEnum< T > Class Template Reference

#include <src/libslic3r/Config.hpp>

+ Inheritance diagram for Slic3r::ConfigOptionEnum< T >:
+ Collaboration diagram for Slic3r::ConfigOptionEnum< T >:

Public Member Functions

 ConfigOptionEnum ()
 
 ConfigOptionEnum (T _value)
 
ConfigOptionType type () const override
 
ConfigOptionclone () const override
 
ConfigOptionEnum< T > & operator= (const ConfigOption *opt)
 
bool operator== (const ConfigOptionEnum< T > &rhs) const throw ()
 
bool operator< (const ConfigOptionEnum< T > &rhs) const throw ()
 
int getInt () const override
 
void setInt (int val) override
 
bool operator== (const ConfigOption &rhs) const override
 
void set (const ConfigOption *rhs) override
 
std::string serialize () const override
 
bool deserialize (const std::string &str, bool append=false) override
 
 operator T () const
 
bool operator== (const T &rhs) const throw ()
 
bool operator!= (const T &rhs) const throw ()
 
bool operator!= (const ConfigOption &rhs) const
 
bool operator< (const T &rhs) const throw ()
 
size_t hash () const override throw ()
 
virtual double getFloat () const
 
virtual bool getBool () const
 
bool is_scalar () const
 
bool is_vector () const
 
virtual bool nullable () const
 
virtual bool is_nil () const
 
virtual bool overriden_by (const ConfigOption *rhs) const
 
virtual bool apply_override (const ConfigOption *rhs)
 

Static Public Member Functions

static ConfigOptionType static_type ()
 
static bool has (T value)
 
static const t_config_enum_namesget_enum_names ()
 
static const t_config_enum_valuesget_enum_values ()
 
static bool from_string (const std::string &str, T &value)
 

Public Attributes

value
 

Detailed Description

template<class T>
class Slic3r::ConfigOptionEnum< T >

Constructor & Destructor Documentation

◆ ConfigOptionEnum() [1/2]

template<class T >
Slic3r::ConfigOptionEnum< T >::ConfigOptionEnum ( )
inline
1504: ConfigOptionSingle<T>(static_cast<T>(0)) {}

◆ ConfigOptionEnum() [2/2]

template<class T >
Slic3r::ConfigOptionEnum< T >::ConfigOptionEnum ( _value)
inlineexplicit
1505: ConfigOptionSingle<T>(_value) {}

Member Function Documentation

◆ apply_override()

virtual bool Slic3r::ConfigOption::apply_override ( const ConfigOption rhs)
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionVector< T >, Slic3r::ConfigOptionVector< double >, Slic3r::ConfigOptionVector< FloatOrPercent >, Slic3r::ConfigOptionVector< int >, Slic3r::ConfigOptionVector< std::string >, Slic3r::ConfigOptionVector< unsigned char >, and Slic3r::ConfigOptionVector< Vec2d >.

290 {
291 if (*this == *rhs)
292 return false;
293 *this = *rhs;
294 return true;
295 }

Referenced by Slic3r::print_config_diffs().

+ Here is the caller graph for this function:

◆ clone()

template<class T >
ConfigOption * Slic3r::ConfigOptionEnum< T >::clone ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1509{ return new ConfigOptionEnum<T>(*this); }

◆ deserialize()

template<class T >
bool Slic3r::ConfigOptionEnum< T >::deserialize ( const std::string &  str,
bool  append = false 
)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1539 {
1540 UNUSED(append);
1541 return from_string(str, this->value);
1542 }
static bool from_string(const std::string &str, T &value)
Definition Config.hpp:1557
T value
Definition Config.hpp:305
#define UNUSED(x)
Definition libslic3r.h:74
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:110

References Slic3r::append(), Slic3r::ConfigOptionEnum< T >::from_string(), and UNUSED.

+ Here is the call graph for this function:

◆ from_string()

template<class T >
static bool Slic3r::ConfigOptionEnum< T >::from_string ( const std::string &  str,
T &  value 
)
inlinestatic
1558 {
1560 auto it = enum_keys_map.find(str);
1561 if (it == enum_keys_map.end())
1562 return false;
1563 value = static_cast<T>(it->second);
1564 return true;
1565 }
static const t_config_enum_values & get_enum_values()
std::map< std::string, int > t_config_enum_values
Definition Config.hpp:1497

References Slic3r::ConfigOptionEnum< T >::get_enum_values(), and Slic3r::ConfigOptionSingle< T >::value.

Referenced by Slic3r::ConfigOptionEnum< T >::deserialize().

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

◆ get_enum_names()

template<class T >
static const t_config_enum_names & Slic3r::ConfigOptionEnum< T >::get_enum_names ( )
static

Referenced by Slic3r::PrintConfigDef::init_sla_params(), Slic3r::PrintConfigDef::init_sla_support_params(), Slic3r::ConfigOptionEnum< T >::serialize(), and Slic3r::ConfigOptionEnumDef::set_enum_map().

+ Here is the caller graph for this function:

◆ get_enum_values()

template<class T >
static const t_config_enum_values & Slic3r::ConfigOptionEnum< T >::get_enum_values ( )
static

Referenced by Slic3r::ConfigOptionEnum< T >::from_string(), Slic3r::ConfigOptionEnum< T >::has(), Slic3r::Fill::new_from_type(), and Slic3r::ConfigOptionEnumDef::set_enum_map().

+ Here is the caller graph for this function:

◆ getBool()

virtual bool Slic3r::ConfigOption::getBool ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionBool.

272{ throw BadOptionTypeException("Calling ConfigOption::getBool on a non-boolean ConfigOption"); }

Referenced by Slic3r::client::MyContext::scalar_variable_to_expr().

+ Here is the caller graph for this function:

◆ getFloat()

virtual double Slic3r::ConfigOption::getFloat ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionFloat.

271{ throw BadOptionTypeException("Calling ConfigOption::getFloat on a non-float ConfigOption"); }

Referenced by Slic3r::GUI::TabSLAMaterial::build(), Slic3r::GUI::get_string_value(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::GUI::Sidebar::update_sliced_info_sizer().

+ Here is the caller graph for this function:

◆ getInt()

template<class T >
int Slic3r::ConfigOptionEnum< T >::getInt ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOption.

1513{ return (int)this->value; }

References Slic3r::ConfigOptionSingle< T >::value.

◆ has()

template<class T >
static bool Slic3r::ConfigOptionEnum< T >::has ( value)
inlinestatic
1545 {
1546 for (const auto &kvp : ConfigOptionEnum<T>::get_enum_values())
1547 if (kvp.second == value)
1548 return true;
1549 return false;
1550 }
ConfigOptionEnum()
Definition Config.hpp:1504
if(!(yy_init))
Definition lexer.c:1190

References Slic3r::ConfigOptionEnum< T >::get_enum_values(), and Slic3r::ConfigOptionSingle< T >::value.

+ Here is the call graph for this function:

◆ hash()

template<class T >
size_t Slic3r::ConfigOptionSingle< T >::hash ( ) const
throw (
)
inlineoverridevirtualinherited

Implements Slic3r::ConfigOption.

329{ return std::hash<T>{}(this->value); }

References Slic3r::ConfigOptionSingle< T >::value.

◆ is_nil()

◆ is_scalar()

bool Slic3r::ConfigOption::is_scalar ( ) const
inlineinherited
277{ return (int(this->type()) & int(coVectorType)) == 0; }
virtual ConfigOptionType type() const =0
@ coVectorType
Definition Config.hpp:161

References Slic3r::coVectorType, and Slic3r::ConfigOption::type().

Referenced by Slic3r::PresetBundle::full_fff_config(), Slic3r::client::MyContext::is_nil_test(), Slic3r::ConfigOption::is_vector(), Slic3r::client::MyContext::legacy_variable_expansion(), Slic3r::PresetBundle::load_config_file_config(), Slic3r::client::MyContext::scalar_variable_assign_scalar(), Slic3r::client::MyContext::scalar_variable_to_expr(), Slic3r::client::MyContext::vector_variable_assign_array(), Slic3r::client::MyContext::vector_variable_assign_initializer_list(), and Slic3r::client::MyContext::vector_variable_new_from_array().

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

◆ is_vector()

◆ nullable()

virtual bool Slic3r::ConfigOption::nullable ( ) const
inlinevirtualinherited

◆ operator T()

template<class T >
Slic3r::ConfigOptionSingle< T >::operator T ( ) const
inlineinherited
307{ return this->value; }

◆ operator!=() [1/2]

bool Slic3r::ConfigOption::operator!= ( const ConfigOption rhs) const
inlineinherited
275{ return ! (*this == rhs); }

◆ operator!=() [2/2]

template<class T >
bool Slic3r::ConfigOptionSingle< T >::operator!= ( const T &  rhs) const
throw (
)
inlineinherited
326{ return this->value != rhs; }

◆ operator<() [1/2]

template<class T >
bool Slic3r::ConfigOptionEnum< T >::operator< ( const ConfigOptionEnum< T > &  rhs) const
throw (
)
inline
1512{ return int(this->value) < int(rhs.value); }

◆ operator<() [2/2]

template<class T >
bool Slic3r::ConfigOptionSingle< T >::operator< ( const T &  rhs) const
throw (
)
inlineinherited
327{ return this->value < rhs; }

◆ operator=()

template<class T >
ConfigOptionEnum< T > & Slic3r::ConfigOptionEnum< T >::operator= ( const ConfigOption opt)
inline
1510{ this->set(opt); return *this; }
void set(const ConfigOption *rhs) override
Definition Config.hpp:1524

References Slic3r::ConfigOptionEnum< T >::set().

+ Here is the call graph for this function:

◆ operator==() [1/3]

template<class T >
bool Slic3r::ConfigOptionEnum< T >::operator== ( const ConfigOption rhs) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1517 {
1518 if (rhs.type() != this->type())
1519 throw ConfigurationError("ConfigOptionEnum<T>: Comparing incompatible types");
1520 // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
1521 return this->value == (T)rhs.getInt();
1522 }

References Slic3r::ConfigOption::getInt(), and Slic3r::ConfigOption::type().

+ Here is the call graph for this function:

◆ operator==() [2/3]

template<class T >
bool Slic3r::ConfigOptionEnum< T >::operator== ( const ConfigOptionEnum< T > &  rhs) const
throw (
)
inline
1511{ return this->value == rhs.value; }

◆ operator==() [3/3]

template<class T >
bool Slic3r::ConfigOptionSingle< T >::operator== ( const T &  rhs) const
throw (
)
inlineinherited
325{ return this->value == rhs; }

◆ overriden_by()

virtual bool Slic3r::ConfigOption::overriden_by ( const ConfigOption rhs) const
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionVector< T >, Slic3r::ConfigOptionVector< double >, Slic3r::ConfigOptionVector< FloatOrPercent >, Slic3r::ConfigOptionVector< int >, Slic3r::ConfigOptionVector< std::string >, Slic3r::ConfigOptionVector< unsigned char >, and Slic3r::ConfigOptionVector< Vec2d >.

285 {
286 assert(! this->nullable() && ! rhs->nullable());
287 return *this != *rhs;
288 }
virtual bool nullable() const
Definition Config.hpp:280

References Slic3r::ConfigOption::nullable().

Referenced by Slic3r::print_config_diffs().

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

◆ serialize()

template<class T >
std::string Slic3r::ConfigOptionEnum< T >::serialize ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1532 {
1534 assert(static_cast<int>(this->value) < int(names.size()));
1535 return names[static_cast<int>(this->value)];
1536 }
static const t_config_enum_names & get_enum_names()
std::vector< std::string > t_config_enum_names
Definition Config.hpp:1495

References Slic3r::ConfigOptionEnum< T >::get_enum_names(), and Slic3r::ConfigOptionSingle< T >::value.

+ Here is the call graph for this function:

◆ set()

template<class T >
void Slic3r::ConfigOptionEnum< T >::set ( const ConfigOption rhs)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1524 {
1525 if (rhs->type() != this->type())
1526 throw ConfigurationError("ConfigOptionEnum<T>: Assigning an incompatible type");
1527 // rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
1528 this->value = (T)rhs->getInt();
1529 }

References Slic3r::ConfigOption::getInt(), and Slic3r::ConfigOption::type().

Referenced by Slic3r::ConfigOptionEnum< T >::operator=().

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

◆ setInt()

template<class T >
void Slic3r::ConfigOptionEnum< T >::setInt ( int  val)
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOption.

1514{ this->value = T(val); }

◆ static_type()

template<class T >
static ConfigOptionType Slic3r::ConfigOptionEnum< T >::static_type ( )
inlinestatic
1507{ return coEnum; }
@ coEnum
Definition Config.hpp:194

References Slic3r::coEnum.

Referenced by Slic3r::ConfigOptionEnum< T >::type().

+ Here is the caller graph for this function:

◆ type()

template<class T >
ConfigOptionType Slic3r::ConfigOptionEnum< T >::type ( ) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1508{ return static_type(); }
static ConfigOptionType static_type()
Definition Config.hpp:1507

References Slic3r::ConfigOptionEnum< T >::static_type().

+ Here is the call graph for this function:

Member Data Documentation

◆ value

template<class T >
T Slic3r::ConfigOptionSingle< T >::value
inherited

Referenced by Slic3r::GUI::GLCanvas3D::_render_overlays(), Slic3r::GCodeProcessor::apply_config(), Slic3r::GCodeProcessor::apply_config(), Slic3r::apply_to_print_region_config(), Slic3r::GUI::ColourPicker::BUILD(), Slic3r::GUI::StaticText::BUILD(), Slic3r::GUI::BedShapePanel::build_panel(), Slic3r::clamp_exturder_to_default(), Slic3r::PrinterPresetCollection::default_preset_for(), Slic3r::Flow::extrusion_width(), Slic3r::first_positive(), Slic3r::PrintRegion::flow(), Slic3r::ConfigOptionEnum< T >::from_string(), Slic3r::GUI::Materials::get_filament_vendor(), Slic3r::GUI::Materials::get_material_type(), Slic3r::GUI::Materials::get_material_vendor(), Slic3r::PrintHost::get_print_host(), get_printer_technology(), Slic3r::get_raster_params(), Slic3r::GUI::get_string_value(), Slic3r::ConfigOptionEnum< T >::getInt(), Slic3r::PrintConfigDef::handle_legacy(), Slic3r::handle_legacy_project_loaded(), Slic3r::handle_legacy_sla(), Slic3r::ConfigOptionEnum< T >::has(), Slic3r::ConfigOptionSingle< T >::hash(), Slic3r::PrintObject::invalidate_state_by_config_options(), Slic3r::PresetHints::maximum_volumetric_flow_description(), Slic3r::min_object_distance(), Slic3r::GUI::GLGizmoHollow::on_render_input_window(), Slic3r::ConfigOptionSingle< bool >::operator bool(), Slic3r::ConfigOptionSingle< T >::operator==(), Slic3r::DynamicConfig::read_cli(), Slic3r::CLI::run(), Slic3r::client::MyContext::scalar_variable_to_expr(), Slic3r::ConfigOptionEnum< T >::serialize(), Slic3r::ConfigOptionSingle< T >::set(), Slic3r::ConfigOptionVector< T >::set(), Slic3r::ConfigOptionVector< T >::set_at(), Slic3r::GUI::Plater::set_bed_shape(), Slic3r::CLI::setup(), Slic3r::AvoidCrossingPerimeters::travel_to(), Slic3r::GUI::ConfigManipulation::update_print_fff_config(), and Slic3r::validate().


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