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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Config.hpp>

Collaboration diagram for Slic3r::ConfigOptionDef:

Public Types

enum class  GUIType {
  undefined , i_enum_open , f_enum_open , color ,
  select_open , slider , legend , one_string ,
  plugin_picker , plugin_config , printer_agent_select
}

Public Member Functions

void set_default_value (const ConfigOption *ptr)
template<typename T>
const T * get_default_value () const
ConfigOption * create_empty_option () const
ConfigOption * create_default_option () const
bool is_scalar () const
template<class Archive>
ConfigOption * load_option_from_archive (Archive &archive) const
template<class Archive>
ConfigOption * save_option_to_archive (Archive &archive, const ConfigOption *opt) const
bool is_plugin_backed () const
bool is_value_valid (const double value, const int max_precision=4) const
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 ConfigOption > default_value
GUIType gui_type { GUIType::undefined }
std::string gui_flags
std::string plugin_type
std::string label
std::string full_label
PrinterTechnology printer_technology = ptUnknown
std::string category
std::string tooltip
std::string sidetext
std::string cli
std::string cli_params
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_key > aliases
std::vector< t_config_option_key > shortcut
std::vector< std::string > enum_values
std::vector< std::string > enum_labels
const t_config_enum_values * enum_keys_map = nullptr
size_t serialization_key_ordinal = 0

Static Public Attributes

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

Detailed Description

Member Enumeration Documentation

◆ GUIType

Enumerator
undefined 
i_enum_open 
f_enum_open 
color 
select_open 
slider 
legend 
one_string 
plugin_picker 
plugin_config 
printer_agent_select 
2318 {
2319 undefined,
2320 // Open enums, integer value could be one of the enumerated values or something else.
2321 i_enum_open,
2322 // Open enums, float value could be one of the enumerated values or something else.
2323 f_enum_open,
2324 // Color picker, string value.
2325 color,
2326 // ???
2327 select_open,
2328 // Currently unused.
2329 slider,
2330 // Static text
2331 legend,
2332 // Vector value, but edited as a single string.
2333 one_string,
2334 plugin_picker,
2335 // Raw JSON string value, edited through a dialog behind a button rather than in the row.
2336 plugin_config,
2337 // PrinterAgentChoice
2338 printer_agent_select,
2339 };

Member Function Documentation

◆ cli_args()

std::vector< std::string > Slic3r::ConfigOptionDef::cli_args ( const std::string & key) const
266{
267 std::vector<std::string> args;
268 if (this->cli != ConfigOptionDef::nocli) {
269 const std::string &cli = this->cli;
270 //FIXME What was that for? Check the "readline" documentation.
271 // Neither '=' nor '!' is used in any of the cli parameters currently defined by PrusaSlicer.
272// std::string cli = this->cli.substr(0, this->cli.find("="));
273// boost::trim_right_if(cli, boost::is_any_of("!"));
274 if (cli.empty()) {
275 // Convert an option key to CLI argument by replacing underscores with dashes.
276 std::string opt = key;
277 boost::replace_all(opt, "_", "-");
278 args.emplace_back(std::move(opt));
279 } else
280 boost::split(args, cli, boost::is_any_of("|"));
281 }
282 return args;
283}
std::string cli
Definition Config.hpp:2578
static const constexpr char * nocli
Definition Config.hpp:2636

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
323{
324 if (this->default_value) {
325 ConfigOptionType type = this->default_value->type();
326 if (type == coEnum)
327 return new ConfigOptionEnumGeneric(this->enum_keys_map, this->default_value->getInt());
328
329 if (type == coEnums) {
330 // Enum list defaults are built without a keys map, which the copy needs to deserialize and serialize names.
331 ConfigOption *opt = this->default_value->clone();
332 if (auto *nullable_enums = dynamic_cast<ConfigOptionEnumsGenericNullable *>(opt))
333 nullable_enums->keys_map = this->enum_keys_map;
334 else if (auto *enums = dynamic_cast<ConfigOptionEnumsGeneric *>(opt))
335 enums->keys_map = this->enum_keys_map;
336 return opt;
337 }
338
339 return this->default_value->clone();
340 }
341 return this->create_empty_option();
342}
ConfigOption * create_empty_option() const
Definition Config.cpp:285
ConfigOptionType type
Definition Config.hpp:2344
Slic3r::clonable_ptr< const ConfigOption > default_value
Definition Config.hpp:2348
const t_config_enum_values * enum_keys_map
Definition Config.hpp:2619
ConfigOptionEnumsGenericTempl< false > ConfigOptionEnumsGeneric
Definition Config.hpp:2311
ConfigOptionEnumsGenericTempl< true > ConfigOptionEnumsGenericNullable
Definition Config.hpp:2312
ConfigOptionType
Definition Config.hpp:180
@ coEnum
Definition Config.hpp:214
@ coEnums
Definition Config.hpp:216

References Slic3r::coEnum, Slic3r::coEnums, create_empty_option(), default_value, enum_keys_map, and type.

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
286{
287 if (this->nullable) {
288 switch (this->type) {
289 case coFloats: return new ConfigOptionFloatsNullable();
290 case coInts: return new ConfigOptionIntsNullable();
291 case coPercents: return new ConfigOptionPercentsNullable();
293 case coBools: return new ConfigOptionBoolsNullable();
294 default: throw ConfigurationError(std::string("Unknown option type for nullable option ") + this->label);
295 }
296 } else {
297 switch (this->type) {
298 case coFloat: return new ConfigOptionFloat();
299 case coFloats: return new ConfigOptionFloats();
300 case coInt: return new ConfigOptionInt();
301 case coInts: return new ConfigOptionInts();
302 case coString: return new ConfigOptionString();
303 case coStrings: return new ConfigOptionStrings();
304 case coPercent: return new ConfigOptionPercent();
305 case coPercents: return new ConfigOptionPercents();
306 case coFloatOrPercent: return new ConfigOptionFloatOrPercent();
308 case coPoint: return new ConfigOptionPoint();
309 case coPoints: return new ConfigOptionPoints();
310 case coPoint3: return new ConfigOptionPoint3();
311 // case coPoint3s: return new ConfigOptionPoint3s();
312 case coBool: return new ConfigOptionBool();
313 case coBools: return new ConfigOptionBools();
314 case coEnum: return new ConfigOptionEnumGeneric(this->enum_keys_map);
315 // BBS
316 case coEnums: return new ConfigOptionEnumsGeneric(this->enum_keys_map);
317 default: throw ConfigurationError(std::string("Unknown option type for option ") + this->label);
318 }
319 }
320}
std::string label
Definition Config.hpp:2566
bool nullable
Definition Config.hpp:2346
zaa_minimize_perimeter_height ConfigOptionFloat
Definition PrintConfig.hpp:1954
ConfigOptionBoolsTempl< true > ConfigOptionBoolsNullable
Definition Config.hpp:2067
ConfigOptionPercentsTempl< true > ConfigOptionPercentsNullable
Definition Config.hpp:1335
ConfigOptionIntsTempl< true > ConfigOptionIntsNullable
Definition Config.hpp:1155
ConfigOptionFloatsTempl< true > ConfigOptionFloatsNullable
Definition Config.hpp:1016
ConfigOptionIntsTempl< false > ConfigOptionInts
Definition Config.hpp:1154
ConfigOptionBoolsTempl< false > ConfigOptionBools
Definition Config.hpp:2066
ConfigOptionFloatsOrPercentsTempl< true > ConfigOptionFloatsOrPercentsNullable
Definition Config.hpp:1532
ConfigOptionPercentsTempl< false > ConfigOptionPercents
Definition Config.hpp:1334
zaa_minimize_perimeter_height ConfigOptionString
Definition PrintConfig.hpp:1702
@ coFloatsOrPercents
Definition Config.hpp:202
@ coString
Definition Config.hpp:192
@ coPoint
Definition Config.hpp:204
@ coBools
Definition Config.hpp:212
@ coPoint3
Definition Config.hpp:207
@ coPercents
Definition Config.hpp:198
@ coInts
Definition Config.hpp:190
@ coPoints
Definition Config.hpp:206
@ coInt
Definition Config.hpp:188
@ coBool
Definition Config.hpp:210
@ coFloat
Definition Config.hpp:184
@ coFloatOrPercent
Definition Config.hpp:200
@ coStrings
Definition Config.hpp:194
@ coFloats
Definition Config.hpp:186
@ coPercent
Definition Config.hpp:196
ConfigOptionFloatsOrPercentsTempl< false > ConfigOptionFloatsOrPercents
Definition Config.hpp:1531
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

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

Referenced by create_default_option().

Here is the caller graph for this function:

◆ get_default_value()

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

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

Referenced by Slic3r::CalibPressureAdvance::find_optimal_PA_speed().

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
2621 {
2622 for (const std::string &v : enum_values)
2623 if (v == value)
2624 return true;
2625 return false;
2626 }
std::vector< std::string > enum_values
Definition Config.hpp:2615

References enum_values.

◆ is_plugin_backed()

bool Slic3r::ConfigOptionDef::is_plugin_backed ( ) const
inline
2561{ return !plugin_type.empty(); }
std::string plugin_type
Definition Config.hpp:2558

References plugin_type.

Referenced by Slic3r::anonymous_namespace{PluginResolver.cpp}::find_option_for_capability(), Slic3r::prune_stale_plugin_overrides(), and Slic3r::ConfigBase::save_plugin_collection().

Here is the caller graph for this function:

◆ is_scalar()

bool Slic3r::ConfigOptionDef::is_scalar ( ) const
inline
2357{ return (int(this->type) & int(coVectorType)) == 0; }
@ coVectorType
Definition Config.hpp:181

References Slic3r::coVectorType.

Referenced by Slic3r::GUI::get_type(), and Slic3r::GUI::EditGCodeDialog::selection_changed().

Here is the caller graph for this function:

◆ is_value_valid()

bool Slic3r::ConfigOptionDef::is_value_valid ( const double value,
const int max_precision = 4 ) const
345{
346 // Special handling for the nil values
347 // The nil value is a valid one only for nullable options
348 if (std::isnan(value))
349 return this->nullable;
350
351 // Special handling of 0
352 if (this->min == 0.f && value < 0)
353 return false;
354
355 const double ep = std::pow(0.1, max_precision);
356 if (is_approx(value, (double) this->min, ep) || is_approx(value, (double) this->max, ep))
357 return true;
358
359 return this->min <= value && value <= this->max;
360}
float min
Definition Config.hpp:2601
float max
Definition Config.hpp:2602
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320

References Slic3r::is_approx(), max, min, and nullable.

Referenced by Slic3r::validate().

Here is the call graph for this function:
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
2360 {
2361 if (this->nullable) {
2362 switch (this->type) {
2363 case coFloats: {
2364 auto opt = new ConfigOptionFloatsNullable();
2365 archive(*opt);
2366 return opt;
2367 }
2368 case coInts: {
2369 auto opt = new ConfigOptionIntsNullable();
2370 archive(*opt);
2371 return opt;
2372 }
2373 case coPercents: {
2374 auto opt = new ConfigOptionPercentsNullable();
2375 archive(*opt);
2376 return opt;
2377 }
2378 case coBools: {
2379 auto opt = new ConfigOptionBoolsNullable();
2380 archive(*opt);
2381 return opt;
2382 }
2383 case coFloatsOrPercents: {
2384 auto opt = new ConfigOptionFloatsOrPercentsNullable();
2385 archive(*opt);
2386 return opt;
2387 }
2388 case coEnums: {
2389 auto opt = new ConfigOptionEnumsGenericNullable(this->enum_keys_map);
2390 archive(*opt);
2391 return opt;
2392 }
2393 default:
2394 throw ConfigurationError(
2395 std::string("ConfigOptionDef::load_option_from_archive(): Unknown nullable option type for option ") + this->opt_key);
2396 }
2397 } else {
2398 switch (this->type) {
2399 case coFloat: {
2400 auto opt = new ConfigOptionFloat();
2401 archive(*opt);
2402 return opt;
2403 }
2404 case coFloats: {
2405 auto opt = new ConfigOptionFloats();
2406 archive(*opt);
2407 return opt;
2408 }
2409 case coInt: {
2410 auto opt = new ConfigOptionInt();
2411 archive(*opt);
2412 return opt;
2413 }
2414 case coInts: {
2415 auto opt = new ConfigOptionInts();
2416 archive(*opt);
2417 return opt;
2418 }
2419 case coString: {
2420 auto opt = new ConfigOptionString();
2421 archive(*opt);
2422 return opt;
2423 }
2424 case coStrings: {
2425 auto opt = new ConfigOptionStrings();
2426 archive(*opt);
2427 return opt;
2428 }
2429 case coPercent: {
2430 auto opt = new ConfigOptionPercent();
2431 archive(*opt);
2432 return opt;
2433 }
2434 case coPercents: {
2435 auto opt = new ConfigOptionPercents();
2436 archive(*opt);
2437 return opt;
2438 }
2439 case coFloatOrPercent: {
2440 auto opt = new ConfigOptionFloatOrPercent();
2441 archive(*opt);
2442 return opt;
2443 }
2444 case coFloatsOrPercents: {
2445 auto opt = new ConfigOptionFloatsOrPercents();
2446 archive(*opt);
2447 return opt;
2448 }
2449 case coPoint: {
2450 auto opt = new ConfigOptionPoint();
2451 archive(*opt);
2452 return opt;
2453 }
2454 case coPoints: {
2455 auto opt = new ConfigOptionPoints();
2456 archive(*opt);
2457 return opt;
2458 }
2459 case coPoint3: {
2460 auto opt = new ConfigOptionPoint3();
2461 archive(*opt);
2462 return opt;
2463 }
2464 case coBool: {
2465 auto opt = new ConfigOptionBool();
2466 archive(*opt);
2467 return opt;
2468 }
2469 case coBools: {
2470 auto opt = new ConfigOptionBools();
2471 archive(*opt);
2472 return opt;
2473 }
2474 case coEnum: {
2475 auto opt = new ConfigOptionEnumGeneric(this->enum_keys_map);
2476 archive(*opt);
2477 return opt;
2478 }
2479 // BBS
2480 case coEnums: {
2481 auto opt = new ConfigOptionEnumsGeneric(this->enum_keys_map);
2482 archive(*opt);
2483 return opt;
2484 }
2485 case coIntsGroups: {
2486 auto opt = new ConfigOptionIntsGroups();
2487 archive(*opt);
2488 return opt;
2489 }
2490 case coPointsGroups: {
2491 auto opt = new ConfigOptionPointsGroups();
2492 archive(*opt);
2493 return opt;
2494 }
2495 default:
2496 throw ConfigurationError(std::string("ConfigOptionDef::load_option_from_archive(): Unknown option type for option ") +
2497 this->opt_key);
2498 }
2499 }
2500 }
t_config_option_key opt_key
Definition Config.hpp:2342
@ coPointsGroups
Definition Config.hpp:217
@ coIntsGroups
Definition Config.hpp:218

References Slic3r::coBool, Slic3r::coBools, Slic3r::coEnum, Slic3r::coEnums, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coFloatsOrPercents, Slic3r::coInt, Slic3r::coInts, Slic3r::coIntsGroups, Slic3r::ConfigOptionFloat, Slic3r::ConfigOptionString, Slic3r::coPercent, Slic3r::coPercents, Slic3r::coPoint, Slic3r::coPoint3, Slic3r::coPoints, Slic3r::coPointsGroups, Slic3r::coString, Slic3r::coStrings, and enum_keys_map.

Referenced by Slic3r::read_config().

Here is the caller graph for this function:

◆ save_option_to_archive()

template<class Archive>
ConfigOption * Slic3r::ConfigOptionDef::save_option_to_archive ( Archive & archive,
const ConfigOption * opt ) const
inline
2502 {
2503 if (this->nullable) {
2504 switch (this->type) {
2505 case coFloats: archive(*static_cast<const ConfigOptionFloatsNullable*>(opt)); break;
2506 case coInts: archive(*static_cast<const ConfigOptionIntsNullable*>(opt)); break;
2507 case coPercents: archive(*static_cast<const ConfigOptionPercentsNullable*>(opt));break;
2508 case coBools: archive(*static_cast<const ConfigOptionBoolsNullable*>(opt)); break;
2509 case coFloatsOrPercents: archive(*static_cast<const ConfigOptionFloatsOrPercentsNullable*>(opt)); break;
2510 case coEnums: archive(*static_cast<const ConfigOptionEnumsGenericNullable*>(opt)); break;
2511 default:
2512 throw ConfigurationError(
2513 std::string("ConfigOptionDef::save_option_to_archive(): Unknown nullable option type for option ") + this->opt_key);
2514 }
2515 } else {
2516 switch (this->type) {
2517 case coFloat: archive(*static_cast<const ConfigOptionFloat*>(opt)); break;
2518 case coFloats: archive(*static_cast<const ConfigOptionFloats*>(opt)); break;
2519 case coInt: archive(*static_cast<const ConfigOptionInt*>(opt)); break;
2520 case coInts: archive(*static_cast<const ConfigOptionInts*>(opt)); break;
2521 case coString: archive(*static_cast<const ConfigOptionString*>(opt)); break;
2522 case coStrings: archive(*static_cast<const ConfigOptionStrings*>(opt)); break;
2523 case coPercent: archive(*static_cast<const ConfigOptionPercent*>(opt)); break;
2524 case coPercents: archive(*static_cast<const ConfigOptionPercents*>(opt)); break;
2525 case coFloatOrPercent: archive(*static_cast<const ConfigOptionFloatOrPercent*>(opt)); break;
2526 case coFloatsOrPercents: archive(*static_cast<const ConfigOptionFloatsOrPercents*>(opt)); break;
2527 case coPoint: archive(*static_cast<const ConfigOptionPoint*>(opt)); break;
2528 case coPoints: archive(*static_cast<const ConfigOptionPoints*>(opt)); break;
2529 case coPoint3: archive(*static_cast<const ConfigOptionPoint3*>(opt)); break;
2530 case coBool: archive(*static_cast<const ConfigOptionBool*>(opt)); break;
2531 case coBools: archive(*static_cast<const ConfigOptionBools*>(opt)); break;
2532 case coEnum: archive(*static_cast<const ConfigOptionEnumGeneric*>(opt)); break;
2533 // BBS
2534 case coEnums: archive(*static_cast<const ConfigOptionEnumsGeneric*>(opt)); break;
2535 case coIntsGroups: archive(*static_cast<const ConfigOptionIntsGroups*>(opt)); break;
2536 case coPointsGroups: archive(*static_cast<const ConfigOptionPointsGroups*>(opt)); break;
2537 default:
2538 throw ConfigurationError(std::string("ConfigOptionDef::save_option_to_archive(): Unknown option type for option ") +
2539 this->opt_key);
2540 }
2541 }
2542 // Make the compiler happy, shut up the warnings.
2543 return nullptr;
2544 }

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

Referenced by cereal::save().

Here is the caller graph for this function:

◆ set_default_value()

void Slic3r::ConfigOptionDef::set_default_value ( const ConfigOption * ptr)
inline

Member Data Documentation

◆ aliases

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

◆ category

◆ cli

◆ cli_params

◆ default_value

◆ enum_keys_map

◆ enum_labels

◆ enum_values

◆ full_label

◆ full_width

◆ gui_flags

◆ gui_type

◆ height

◆ 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

◆ plugin_type

◆ printer_technology

PrinterTechnology Slic3r::ConfigOptionDef::printer_technology = ptUnknown

◆ ratio_over

◆ readonly

bool Slic3r::ConfigOptionDef::readonly = false

◆ serialization_key_ordinal

size_t Slic3r::ConfigOptionDef::serialization_key_ordinal = 0

Referenced by cereal::save().

◆ shortcut

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

◆ sidetext

◆ tooltip

◆ type

◆ width


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