OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::DynamicPrintAndCLIConfig::PrintAndCLIConfigDef Class Reference
Inheritance diagram for Slic3r::DynamicPrintAndCLIConfig::PrintAndCLIConfigDef:
Collaboration diagram for Slic3r::DynamicPrintAndCLIConfig::PrintAndCLIConfigDef:

Public Member Functions

 PrintAndCLIConfigDef ()
 ~PrintAndCLIConfigDef ()
bool has (const t_config_option_key &opt_key) const
const ConfigOptionDef * get (const t_config_option_key &opt_key) const
std::vector< std::string > keys () const
bool empty ()
std::ostream & print_cli_help (std::ostream &out, bool show_defaults, std::function< bool(const ConfigOptionDef &)> filter=[](const ConfigOptionDef &){ return true;}) const

Public Attributes

t_optiondef_map options
std::map< size_t, const ConfigOptionDef * > by_serialization_key_ordinal

Protected Member Functions

ConfigOptionDef * add (const t_config_option_key &opt_key, ConfigOptionType type)
ConfigOptionDef * add_nullable (const t_config_option_key &opt_key, ConfigOptionType type)

Detailed Description

Constructor & Destructor Documentation

◆ PrintAndCLIConfigDef()

Slic3r::DynamicPrintAndCLIConfig::PrintAndCLIConfigDef::PrintAndCLIConfigDef ( )
inline
2524 {
2525 this->options.insert(print_config_def.options.begin(), print_config_def.options.end());
2526 this->options.insert(cli_actions_config_def.options.begin(), cli_actions_config_def.options.end());
2528 this->options.insert(cli_misc_config_def.options.begin(), cli_misc_config_def.options.end());
2529 for (const auto &kvp : this->options)
2530 this->by_serialization_key_ordinal[kvp.second.serialization_key_ordinal] = &kvp.second;
2531 }
std::map< size_t, const ConfigOptionDef * > by_serialization_key_ordinal
Definition Config.hpp:2659
t_optiondef_map options
Definition Config.hpp:2658
const CLIActionsConfigDef cli_actions_config_def
Definition PrintConfig.cpp:13288
const PrintConfigDef print_config_def
Definition PrintConfig.cpp:10099
const CLITransformConfigDef cli_transform_config_def
Definition PrintConfig.cpp:13289
const CLIMiscConfigDef cli_misc_config_def
Definition PrintConfig.cpp:13290

References Slic3r::ConfigDef::by_serialization_key_ordinal, Slic3r::cli_actions_config_def, Slic3r::cli_misc_config_def, Slic3r::cli_transform_config_def, Slic3r::ConfigDef::options, and Slic3r::print_config_def.

◆ ~PrintAndCLIConfigDef()

Slic3r::DynamicPrintAndCLIConfig::PrintAndCLIConfigDef::~PrintAndCLIConfigDef ( )
inline
2533{ this->options.clear(); }

References Slic3r::ConfigDef::options.

Member Function Documentation

◆ add()

◆ add_nullable()

ConfigOptionDef * Slic3r::ConfigDef::add_nullable ( const t_config_option_key & opt_key,
ConfigOptionType type )
protectedinherited
375{
376 ConfigOptionDef *def = this->add(opt_key, type);
377 def->nullable = true;
378 return def;
379}
ConfigOptionDef * add(const t_config_option_key &opt_key, ConfigOptionType type)
Definition Config.cpp:363

References add(), and Slic3r::ConfigOptionDef::nullable.

Referenced by Slic3r::PrintConfigDef::init_fff_params().

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

◆ empty()

bool Slic3r::ConfigDef::empty ( )
inlineinherited
2673{ return options.empty(); }

References options.

◆ get()

const ConfigOptionDef * Slic3r::ConfigDef::get ( const t_config_option_key & opt_key) const
inlineinherited

◆ has()

bool Slic3r::ConfigDef::has ( const t_config_option_key & opt_key) const
inlineinherited
2661{ return this->options.count(opt_key) > 0; }

Referenced by Slic3r::GUI::EditGCodeDialog::selection_changed().

Here is the caller graph for this function:

◆ keys()

std::vector< std::string > Slic3r::ConfigDef::keys ( ) const
inlineinherited
2666 {
2667 std::vector<std::string> out;
2668 out.reserve(options.size());
2669 for(auto const& kvp : options)
2670 out.push_back(kvp.first);
2671 return out;
2672 }

References options.

◆ print_cli_help()

std::ostream & Slic3r::ConfigDef::print_cli_help ( std::ostream & out,
bool show_defaults,
std::function< bool(const ConfigOptionDef &)> filter = [](const ConfigOptionDef &){ return true; } ) const
inherited
382{
383 // prepare a function for wrapping text
384 auto wrap = [](std::string text, size_t line_length) -> std::string {
385 std::istringstream words(text);
386 std::ostringstream wrapped;
387 std::string word;
388
389 if (words >> word) {
390 wrapped << word;
391 size_t space_left = line_length - word.length();
392 while (words >> word) {
393 if (space_left < word.length() + 1) {
394 wrapped << '\n' << word;
395 space_left = line_length - word.length();
396 } else {
397 wrapped << ' ' << word;
398 space_left -= word.length() + 1;
399 }
400 }
401 }
402 return wrapped.str();
403 };
404
405 // get the unique categories
406 std::set<std::string> categories;
407 for (const auto& opt : this->options) {
408 const ConfigOptionDef& def = opt.second;
409 if (filter(def))
410 categories.insert(def.category);
411 }
412
413 for (auto category : categories) {
414 if (category != "") {
415 out << category << ":" << std::endl;
416 } else if (categories.size() > 1) {
417 out << "Misc options:" << std::endl;
418 }
419
420 for (const auto& opt : this->options) {
421 const ConfigOptionDef& def = opt.second;
422 if (def.category != category || def.cli == ConfigOptionDef::nocli || !filter(def))
423 continue;
424
425 // get all possible variations: --foo, --foobar, -f...
426 std::vector<std::string> cli_args = def.cli_args(opt.first);
427 if (cli_args.empty())
428 continue;
429
430 for (auto& arg : cli_args) {
431 arg.insert(0, (arg.size() == 1) ? "-" : "--");
432 //BBS: refine the print help format
433 if (!def.cli_params.empty())
434 arg += " " + def.cli_params;
435 /*if ( def.type == coInt || def.type == coInts) {
436 arg += " int_value";
437 } else if (def.type == coFloat || def.type == coFloatOrPercent || def.type == coFloats) {
438 arg += " float_value";
439 } else if (def.type == coPoint) {
440 arg += " X,Y";
441 } else if (def.type == coPoint3) {
442 arg += " X,Y,Z";
443 } else if (def.type == coString || def.type == coStrings) {
444 arg += " filename_lists";
445 }*/
446 }
447
448 // left: command line options
449 const std::string cli = boost::algorithm::join(cli_args, ", ");
450 out << " " << std::left << std::setw(20) << cli;
451
452 // right: option description
453 std::string descr = def.tooltip;
454 bool show_defaults_this = show_defaults || def.opt_key == "config_compatibility";
455 if (show_defaults_this && def.default_value && def.type != coBool
456 && (def.type != coString || !def.default_value->serialize().empty())) {
457 descr += " (";
458 if (!def.sidetext.empty()) {
459 descr += def.sidetext + ", ";
460 } else if (!def.enum_values.empty()) {
461 descr += boost::algorithm::join(def.enum_values, ", ") + "; ";
462 }
463 descr += "default: " + def.default_value->serialize() + ")";
464 }
465
466 // wrap lines of description
467 descr = wrap(descr, 80);
468 std::vector<std::string> lines;
469 boost::split(lines, descr, boost::is_any_of("\n"));
470
471 // if command line options are too long, print description in new line
472 for (size_t i = 0; i < lines.size(); ++i) {
473 if (i == 0 && cli.size() > 19)
474 out << std::endl;
475 if (i > 0 || cli.size() > 19)
476 out << std::string(21, ' ');
477 out << lines[i] << std::endl;
478 }
479 }
480 }
481 return out;
482}
static const constexpr char * nocli
Definition Config.hpp:2636
@ coString
Definition Config.hpp:192
@ coBool
Definition Config.hpp:210

References Slic3r::ConfigOptionDef::category, Slic3r::ConfigOptionDef::cli, Slic3r::ConfigOptionDef::cli_args(), Slic3r::ConfigOptionDef::cli_params, Slic3r::coBool, Slic3r::coString, Slic3r::ConfigOptionDef::default_value, Slic3r::ConfigOptionDef::enum_values, Slic3r::ConfigOptionDef::nocli, Slic3r::ConfigOptionDef::opt_key, options, Slic3r::ConfigOptionDef::sidetext, Slic3r::ConfigOptionDef::tooltip, and Slic3r::ConfigOptionDef::type.

Here is the call graph for this function:

Member Data Documentation

◆ by_serialization_key_ordinal

std::map<size_t, const ConfigOptionDef*> Slic3r::ConfigDef::by_serialization_key_ordinal
inherited

◆ options


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