OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::ConfigOptionFloatOrPercent Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/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
ConfigOption * clone () const override
ConfigOptionFloatOrPercent & operator= (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 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, std::vector< int > &default_index)

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
1341: ConfigOptionPercent(0), percent(false) {}
bool percent
Definition Config.hpp:1340
ConfigOptionPercent()
Definition Config.hpp:1240

References Slic3r::ConfigOptionPercent::ConfigOptionPercent(), and percent.

Referenced by clone(), operator<(), operator=(), operator==(), operator==(), and set().

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

◆ ConfigOptionFloatOrPercent() [2/2]

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

References Slic3r::ConfigOptionPercent::ConfigOptionPercent(), and percent.

Here is the call graph for this function:

Member Function Documentation

◆ apply_override()

virtual bool Slic3r::ConfigOption::apply_override ( const ConfigOption * rhs,
std::vector< int > & default_index )
inlinevirtualinherited
314 {
315 if (*this == *rhs)
316 return false;
317 *this = *rhs;
318 return true;
319 }
Definition Config.hpp:327

◆ clone()

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

Reimplemented from Slic3r::ConfigOptionFloat.

1346{ return new ConfigOptionFloatOrPercent(*this); }
ConfigOptionFloatOrPercent()
Definition Config.hpp:1341

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.

1382 {
1383 UNUSED(append);
1384 std::istringstream iss(str);
1385 double value;
1386 iss >> value;
1387 if (iss.fail())
1388 return false;
1389 this->value = value;
1390 this->percent = str.find_first_of("%") != std::string::npos;
1391 return true;
1392 }
double value
Definition Config.hpp:329
#define UNUSED(x)
Definition libslic3r.h:112
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:157

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
1363 { return this->percent ? (ratio_over * this->value / 100) : this->value; }

Referenced by Slic3r::LayerRegion::bridging_flow().

Here is the caller graph for this function:

◆ getBool()

virtual bool Slic3r::ConfigOption::getBool ( ) const
inlinevirtualinherited
296{ throw BadOptionTypeException("Calling ConfigOption::getBool on a non-boolean ConfigOption"); }

◆ getFloat()

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

Reimplemented from Slic3r::ConfigOption.

832{ return this->value; }

Referenced by Slic3r::anonymous_namespace{SL1.cpp}::get_slice_params(), and Slic3r::GUI::ObjectGridTable::GetValueAsDouble().

Here is the caller graph for this function:

◆ getInt()

virtual int Slic3r::ConfigOption::getInt ( ) const
inlinevirtualinherited
294{ throw BadOptionTypeException("Calling ConfigOption::getInt on a non-int ConfigOption"); }

◆ hash()

size_t Slic3r::ConfigOptionFloatOrPercent::hash ( ) const
throw ( )
inlineoverridevirtual

Implements Slic3r::ConfigOption.

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

◆ is_nil()

virtual bool Slic3r::ConfigOption::is_nil ( ) const
inlinevirtualinherited
306{ return false; }

◆ is_scalar()

bool Slic3r::ConfigOption::is_scalar ( ) const
inlineinherited
301{ return (int(this->type()) & int(coVectorType)) == 0; }
virtual ConfigOptionType type() const=0

◆ is_vector()

bool Slic3r::ConfigOption::is_vector ( ) const
inlineinherited
302{ return ! this->is_scalar(); }
bool is_scalar() const
Definition Config.hpp:301

◆ nullable()

virtual bool Slic3r::ConfigOption::nullable ( ) const
inlinevirtualinherited
304{ return false; }

◆ operator double()

Slic3r::ConfigOptionSingle< double >::operator double ( ) const
inlineinherited
331{ return this->value; }

◆ operator!=() [1/2]

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

◆ operator!=() [2/2]

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

◆ operator<() [1/4]

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

References ConfigOptionFloat().

Here is the call graph for this function:

◆ operator<() [2/4]

bool Slic3r::ConfigOptionFloatOrPercent::operator< ( const ConfigOptionFloatOrPercent & rhs) const
throw ( )
inline
1360 { return this->value < rhs.value || (is_approx(this->value, rhs.value) && int(this->percent) < int(rhs.percent)); }
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320

References ConfigOptionFloatOrPercent(), and Slic3r::is_approx().

Here is the call graph for this function:

◆ operator<() [3/4]

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

References ConfigOptionPercent().

Here is the call graph for this function:

◆ operator<() [4/4]

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

◆ operator=()

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

References ConfigOptionFloatOrPercent(), and set().

Here is the call graph for this function:

◆ operator==() [1/4]

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

Reimplemented from Slic3r::ConfigOptionFloat.

1349 {
1350 if (rhs.type() != this->type())
1351 throw ConfigurationError("ConfigOptionFloatOrPercent: Comparing incompatible types");
1352 assert(dynamic_cast<const ConfigOptionFloatOrPercent*>(&rhs));
1353 return *this == *static_cast<const ConfigOptionFloatOrPercent*>(&rhs);
1354 }

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

Here is the call graph for this function:

◆ operator==() [2/4]

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

References ConfigOptionFloatOrPercent(), and Slic3r::is_approx().

Here is the call graph for this function:

◆ operator==() [3/4]

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

◆ operator==() [4/4]

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

References ConfigOptionPercent().

Here is the call graph for this function:

◆ overriden_by()

virtual bool Slic3r::ConfigOption::overriden_by ( const ConfigOption * rhs) const
inlinevirtualinherited
309 {
310 assert(! this->nullable() && ! rhs->nullable());
311 return *this != *rhs;
312 }
virtual bool nullable() const
Definition Config.hpp:304

◆ serialize() [1/2]

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

Reimplemented from Slic3r::ConfigOptionFloat.

1373 {
1374 std::ostringstream ss;
1375 ss << this->value;
1376 std::string s(ss.str());
1377 if (this->percent) s += "%";
1378 return s;
1379 }

◆ serialize() [2/2]

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

References percent.

◆ set()

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

Implements Slic3r::ConfigOption.

1365 {
1366 if (rhs->type() != this->type())
1367 throw ConfigurationError("ConfigOptionFloatOrPercent: Assigning an incompatible type");
1368 assert(dynamic_cast<const ConfigOptionFloatOrPercent*>(rhs));
1369 *this = *static_cast<const ConfigOptionFloatOrPercent*>(rhs);
1370 }

References ConfigOptionFloatOrPercent(), and 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
297{ throw BadOptionTypeException("Calling ConfigOption::setInt on a non-int ConfigOption"); }

◆ static_type()

ConfigOptionType Slic3r::ConfigOptionFloatOrPercent::static_type ( )
inlinestatic
1344{ return coFloatOrPercent; }
@ coFloatOrPercent
Definition Config.hpp:200

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.

1345{ return static_type(); }
static ConfigOptionType static_type()
Definition Config.hpp:1344

References static_type().

Here is the call graph for this function:

◆ cereal::access

friend class cereal::access
friend

References cereal::access.

Referenced by cereal::access.

Member Data Documentation

◆ percent

◆ value


The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Config.hpp