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

#include <src/libslic3r/Config.hpp>

+ Inheritance diagram for Slic3r::ConfigOptionFloatOrPercent:
+ Collaboration diagram for Slic3r::ConfigOptionFloatOrPercent:

Public Member Functions

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

bool percent
 
double value
 

Private Member Functions

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

Friends

class cereal::access
 

Detailed Description

Constructor & Destructor Documentation

◆ ConfigOptionFloatOrPercent() [1/2]

Slic3r::ConfigOptionFloatOrPercent::ConfigOptionFloatOrPercent ( )
inline
1015: ConfigOptionPercent(0), percent(false) {}
bool percent
Definition Config.hpp:1014
ConfigOptionPercent()
Definition Config.hpp:920

Referenced by clone().

+ Here is the caller graph for this function:

◆ ConfigOptionFloatOrPercent() [2/2]

Slic3r::ConfigOptionFloatOrPercent::ConfigOptionFloatOrPercent ( double  _value,
bool  _percent 
)
inlineexplicit
1016: ConfigOptionPercent(_value), percent(_percent) {}

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::ConfigOptionFloatOrPercent::clone ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

1020{ return new ConfigOptionFloatOrPercent(*this); }
ConfigOptionFloatOrPercent()
Definition Config.hpp:1015

References ConfigOptionFloatOrPercent().

+ Here is the call graph for this function:

◆ deserialize()

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

Reimplemented from Slic3r::ConfigOptionFloat.

1056 {
1057 UNUSED(append);
1058 this->percent = str.find_first_of("%") != std::string::npos;
1059 std::istringstream iss(str);
1060 iss >> this->value;
1061 return !iss.fail();
1062 }
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::ConfigOptionFloatOrPercent::get_abs_value ( double  ratio_over) const
inline
1037 { return this->percent ? (ratio_over * this->value / 100) : this->value; }

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

Referenced by Slic3r::Flow::extrusion_width(), and Slic3r::PresetHints::maximum_volumetric_flow_description().

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

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::ConfigOptionFloatOrPercent::hash ( ) const
throw (
)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1032 { size_t seed = std::hash<double>{}(this->value); return this->percent ? seed ^ 0x9e3779b9 : seed; }

References Slic3r::ConfigOptionSingle< double >::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/4]

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

◆ operator<() [2/4]

bool Slic3r::ConfigOptionFloatOrPercent::operator< ( const ConfigOptionFloatOrPercent rhs) const
throw (
)
inline
1034 { return this->value < rhs.value || (this->value == rhs.value && int(this->percent) < int(rhs.percent)); }

◆ operator<() [3/4]

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

◆ operator<() [4/4]

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

◆ operator=()

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

References set().

+ Here is the call graph for this function:

◆ operator==() [1/5]

bool Slic3r::ConfigOptionFloatOrPercent::operator== ( const ConfigOption rhs) const
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1023 {
1024 if (rhs.type() != this->type())
1025 throw ConfigurationError("ConfigOptionFloatOrPercent: Comparing incompatible types");
1026 assert(dynamic_cast<const ConfigOptionFloatOrPercent*>(&rhs));
1027 return *this == *static_cast<const ConfigOptionFloatOrPercent*>(&rhs);
1028 }

References Slic3r::ConfigOption::type().

+ Here is the call graph for this function:

◆ operator==() [2/5]

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

◆ operator==() [3/5]

bool Slic3r::ConfigOptionFloatOrPercent::operator== ( const ConfigOptionFloatOrPercent rhs) const
throw (
)
inline
1030 { return this->value == rhs.value && this->percent == rhs.percent; }

◆ operator==() [4/5]

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

◆ operator==() [5/5]

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::ConfigOptionFloatOrPercent::serialize ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::ConfigOptionFloat.

1047 {
1048 std::ostringstream ss;
1049 ss << this->value;
1050 std::string s(ss.str());
1051 if (this->percent) s += "%";
1052 return s;
1053 }

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

◆ serialize() [2/2]

template<class Archive >
void Slic3r::ConfigOptionFloatOrPercent::serialize ( Archive &  ar)
inlineprivate
1066{ ar(cereal::base_class<ConfigOptionPercent>(this), percent); }

References percent.

◆ set()

void Slic3r::ConfigOptionFloatOrPercent::set ( const ConfigOption rhs)
inlineoverridevirtual

Implements Slic3r::ConfigOption.

1039 {
1040 if (rhs->type() != this->type())
1041 throw ConfigurationError("ConfigOptionFloatOrPercent: Assigning an incompatible type");
1042 assert(dynamic_cast<const ConfigOptionFloatOrPercent*>(rhs));
1043 *this = *static_cast<const ConfigOptionFloatOrPercent*>(rhs);
1044 }

References Slic3r::ConfigOption::type().

Referenced by operator=().

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

◆ 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::ConfigOptionFloatOrPercent::static_type ( )
inlinestatic
1018{ return coFloatOrPercent; }
@ coFloatOrPercent
Definition Config.hpp:180

References Slic3r::coFloatOrPercent.

Referenced by type().

+ Here is the caller graph for this function:

◆ type()

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

Reimplemented from Slic3r::ConfigOptionFloat.

1019{ return static_type(); }
static ConfigOptionType static_type()
Definition Config.hpp:1018

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

◆ percent

◆ value

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

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