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

#include <src/libslic3r/Config.hpp>

+ Inheritance diagram for Slic3r::ConfigOptionPercent:
+ Collaboration diagram for Slic3r::ConfigOptionPercent:

Public Member Functions

 ConfigOptionPercent ()
 
 ConfigOptionPercent (double _value)
 
ConfigOptionType type () const override
 
ConfigOptionclone () const override
 
ConfigOptionPercentoperator= (const ConfigOption *opt)
 
bool operator== (const ConfigOptionPercent &rhs) const throw ()
 
bool operator< (const ConfigOptionPercent &rhs) const throw ()
 
double get_abs_value (double ratio_over) const
 
std::string serialize () const override
 
bool deserialize (const std::string &str, bool append=false) override
 
double getFloat () const override
 
bool operator== (const ConfigOptionFloat &rhs) const throw ()
 
bool operator== (const ConfigOption &rhs) const override
 
bool operator== (const double &rhs) const throw ()
 
bool operator< (const ConfigOptionFloat &rhs) const throw ()
 
bool operator< (const double &rhs) const throw ()
 
 operator double () const
 
void set (const ConfigOption *rhs) override
 
bool operator!= (const double &rhs) const throw ()
 
bool operator!= (const ConfigOption &rhs) const
 
size_t hash () const override throw ()
 
virtual int getInt () const
 
virtual bool getBool () const
 
virtual void setInt (int)
 
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 ()
 

Public Attributes

double value
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar)
 

Friends

class cereal::access
 

Detailed Description

Constructor & Destructor Documentation

◆ ConfigOptionPercent() [1/2]

Slic3r::ConfigOptionPercent::ConfigOptionPercent ( )
inline
920: ConfigOptionFloat(0) {}
ConfigOptionFloat()
Definition Config.hpp:557

Referenced by clone().

+ Here is the caller graph for this function:

◆ ConfigOptionPercent() [2/2]

Slic3r::ConfigOptionPercent::ConfigOptionPercent ( double  _value)
inlineexplicit
921: ConfigOptionFloat(_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()

ConfigOption * Slic3r::ConfigOptionPercent::clone ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

925{ return new ConfigOptionPercent(*this); }
ConfigOptionPercent()
Definition Config.hpp:920

References ConfigOptionPercent().

+ Here is the call graph for this function:

◆ deserialize()

bool Slic3r::ConfigOptionPercent::deserialize ( const std::string &  str,
bool  append = false 
)
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

942 {
943 UNUSED(append);
944 // don't try to parse the trailing % since it's optional
945 std::istringstream iss(str);
946 iss >> this->value;
947 return !iss.fail();
948 }
double 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(), UNUSED, and Slic3r::ConfigOptionSingle< double >::value.

+ Here is the call graph for this function:

◆ get_abs_value()

double Slic3r::ConfigOptionPercent::get_abs_value ( double  ratio_over) const
inline
930{ return ratio_over * this->value / 100; }

◆ 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()

double Slic3r::ConfigOptionFloat::getFloat ( ) const
inlineoverridevirtualinherited

Reimplemented from Slic3r::ConfigOption.

562{ return this->value; }

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

Referenced by Slic3r::get_slice_params().

+ Here is the caller graph for this function:

◆ getInt()

virtual int Slic3r::ConfigOption::getInt ( ) const
inlinevirtualinherited

◆ hash()

size_t Slic3r::ConfigOptionSingle< double >::hash ( ) const
throw (
)
inlineoverridevirtualinherited

Implements Slic3r::ConfigOption.

329{ return std::hash<T>{}(this->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 double()

Slic3r::ConfigOptionSingle< double >::operator double ( ) 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]

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

◆ operator<() [1/3]

bool Slic3r::ConfigOptionFloat::operator< ( const ConfigOptionFloat rhs) const
throw (
)
inlineinherited
565{ return this->value < rhs.value; }

◆ operator<() [2/3]

bool Slic3r::ConfigOptionPercent::operator< ( const ConfigOptionPercent rhs) const
throw (
)
inline
928{ return this->value < rhs.value; }

◆ operator<() [3/3]

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

◆ operator=()

ConfigOptionPercent & Slic3r::ConfigOptionPercent::operator= ( const ConfigOption opt)
inline
926{ this->set(opt); return *this; }
void set(const ConfigOption *rhs) override
Definition Config.hpp:309

References Slic3r::ConfigOptionSingle< double >::set().

+ Here is the call graph for this function:

◆ operator==() [1/4]

bool Slic3r::ConfigOptionSingle< double >::operator== ( const ConfigOption rhs) const
inlineoverridevirtualinherited

Implements Slic3r::ConfigOption.

318 {
319 if (rhs.type() != this->type())
320 throw ConfigurationError("ConfigOptionSingle: Comparing incompatible types");
321 assert(dynamic_cast<const ConfigOptionSingle<T>*>(&rhs));
322 return this->value == static_cast<const ConfigOptionSingle<T>*>(&rhs)->value;
323 }

◆ operator==() [2/4]

bool Slic3r::ConfigOptionFloat::operator== ( const ConfigOptionFloat rhs) const
throw (
)
inlineinherited
564{ return this->value == rhs.value; }

◆ operator==() [3/4]

bool Slic3r::ConfigOptionPercent::operator== ( const ConfigOptionPercent rhs) const
throw (
)
inline
927{ return this->value == rhs.value; }

◆ operator==() [4/4]

bool Slic3r::ConfigOptionSingle< double >::operator== ( const double &  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() [1/2]

std::string Slic3r::ConfigOptionPercent::serialize ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

933 {
934 std::ostringstream ss;
935 ss << this->value;
936 std::string s(ss.str());
937 s += "%";
938 return s;
939 }

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

◆ serialize() [2/2]

template<class Archive >
void Slic3r::ConfigOptionPercent::serialize ( Archive &  ar)
inlineprivate
952{ ar(cereal::base_class<ConfigOptionFloat>(this)); }

◆ set()

void Slic3r::ConfigOptionSingle< double >::set ( const ConfigOption rhs)
inlineoverridevirtualinherited

Implements Slic3r::ConfigOption.

310 {
311 if (rhs->type() != this->type())
312 throw ConfigurationError("ConfigOptionSingle: Assigning an incompatible type");
313 assert(dynamic_cast<const ConfigOptionSingle<T>*>(rhs));
314 this->value = static_cast<const ConfigOptionSingle<T>*>(rhs)->value;
315 }

◆ setInt()

virtual void Slic3r::ConfigOption::setInt ( int  )
inlinevirtualinherited

Reimplemented in Slic3r::ConfigOptionInt, and Slic3r::ConfigOptionEnum< T >.

273{ throw BadOptionTypeException("Calling ConfigOption::setInt on a non-int ConfigOption"); }

◆ static_type()

static ConfigOptionType Slic3r::ConfigOptionPercent::static_type ( )
inlinestatic
923{ return coPercent; }
@ coPercent
Definition Config.hpp:176

References Slic3r::coPercent.

Referenced by type().

+ Here is the caller graph for this function:

◆ type()

ConfigOptionType Slic3r::ConfigOptionPercent::type ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

924{ return static_type(); }
static ConfigOptionType static_type()
Definition Config.hpp:923

References static_type().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

Member Data Documentation

◆ value

double Slic3r::ConfigOptionSingle< double >::value
inherited

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