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

#include <src/libslic3r/PrintConfig.hpp>

+ Inheritance diagram for Slic3r::CLIMiscConfigDef:
+ Collaboration diagram for Slic3r::CLIMiscConfigDef:

Public Member Functions

 CLIMiscConfigDef ()
 
bool has (const t_config_option_key &opt_key) const
 
const ConfigOptionDefget (const t_config_option_key &opt_key) const
 
std::vector< std::string > keys () const
 
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

ConfigOptionDefadd (const t_config_option_key &opt_key, ConfigOptionType type)
 
ConfigOptionDefadd_nullable (const t_config_option_key &opt_key, ConfigOptionType type)
 
void finalize ()
 

Detailed Description

Constructor & Destructor Documentation

◆ CLIMiscConfigDef()

Slic3r::CLIMiscConfigDef::CLIMiscConfigDef ( )
4859{
4860 ConfigOptionDef* def;
4861
4862 def = this->add("ignore_nonexistent_config", coBool);
4863 def->label = L("Ignore non-existent config files");
4864 def->tooltip = L("Do not fail if a file supplied to --load does not exist.");
4865
4866 def = this->add("config_compatibility", coEnum);
4867 def->label = L("Forward-compatibility rule when loading configurations from config files and project files (3MF, AMF).");
4868 def->tooltip = L("This version of PrusaSlicer may not understand configurations produced by the newest PrusaSlicer versions. "
4869 "For example, newer PrusaSlicer may extend the list of supported firmware flavors. One may decide to "
4870 "bail out or to substitute an unknown value with a default silently or verbosely.");
4872 { "disable", L("Bail out on unknown configuration values") },
4873 { "enable", L("Enable reading unknown configuration values by verbosely substituting them with defaults.") },
4874 { "enable_silent", L("Enable reading unknown configuration values by silently substituting them with defaults.") }
4875 });
4876 def->set_default_value(new ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>(ForwardCompatibilitySubstitutionRule::Enable));
4877
4878 def = this->add("load", coStrings);
4879 def->label = L("Load config file");
4880 def->tooltip = L("Load configuration from the specified file. It can be used more than once to load options from multiple files.");
4881
4882 def = this->add("output", coString);
4883 def->label = L("Output File");
4884 def->tooltip = L("The file where the output will be written (if not specified, it will be based on the input file).");
4885 def->cli = "output|o";
4886
4887 def = this->add("single_instance", coBool);
4888 def->label = L("Single instance mode");
4889 def->tooltip = L("If enabled, the command line arguments are sent to an existing instance of GUI PrusaSlicer, "
4890 "or an existing PrusaSlicer window is activated. "
4891 "Overrides the \"single_instance\" configuration value from application preferences.");
4892
4893 def = this->add("datadir", coString);
4894 def->label = L("Data directory");
4895 def->tooltip = L("Load and store settings at the given directory. This is useful for maintaining different profiles or including configurations from a network storage.");
4896
4897 def = this->add("loglevel", coInt);
4898 def->label = L("Logging level");
4899 def->tooltip = L("Sets logging sensitivity. 0:fatal, 1:error, 2:warning, 3:info, 4:debug, 5:trace\n"
4900 "For example. loglevel=2 logs fatal, error and warning level messages.");
4901 def->min = 0;
4902
4903#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(SLIC3R_GUI)
4904 def = this->add("sw_renderer", coBool);
4905 def->label = L("Render with a software renderer");
4906 def->tooltip = L("Render with a software renderer. The bundled MESA software renderer is loaded instead of the default OpenGL driver.");
4907 def->min = 0;
4908#endif /* _MSC_VER */
4909}
ConfigOptionDef * add(const t_config_option_key &opt_key, ConfigOptionType type)
Definition Config.cpp:288
ForwardCompatibilitySubstitutionRule
Definition Config.hpp:217
@ Enable
Definition Config.hpp:221
@ coString
Definition Config.hpp:172
@ coEnum
Definition Config.hpp:194
@ coInt
Definition Config.hpp:168
@ coBool
Definition Config.hpp:190
@ coStrings
Definition Config.hpp:174
#define L(s)
Definition I18N.hpp:18

References Slic3r::ConfigDef::add(), Slic3r::ConfigOptionDef::cli, Slic3r::coBool, Slic3r::coEnum, Slic3r::coInt, Slic3r::coString, Slic3r::coStrings, Slic3r::Enable, L, Slic3r::ConfigOptionDef::label, Slic3r::ConfigOptionDef::min, Slic3r::ConfigOptionDef::set_default_value(), Slic3r::ConfigOptionDef::set_enum(), and Slic3r::ConfigOptionDef::tooltip.

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ConfigOptionDef * Slic3r::ConfigDef::add ( const t_config_option_key opt_key,
ConfigOptionType  type 
)
protectedinherited
289{
290 static size_t serialization_key_ordinal_last = 0;
291 ConfigOptionDef *opt = &this->options[opt_key];
292 opt->opt_key = opt_key;
293 opt->type = type;
294 opt->serialization_key_ordinal = ++ serialization_key_ordinal_last;
295 this->by_serialization_key_ordinal[opt->serialization_key_ordinal] = opt;
296 return opt;
297}
std::map< size_t, const ConfigOptionDef * > by_serialization_key_ordinal
Definition Config.hpp:2066
t_optiondef_map options
Definition Config.hpp:2065

References Slic3r::ConfigDef::by_serialization_key_ordinal, Slic3r::ConfigOptionDef::opt_key, Slic3r::ConfigDef::options, Slic3r::ConfigOptionDef::serialization_key_ordinal, and Slic3r::ConfigOptionDef::type.

Referenced by Slic3r::AnycubicSLAFormatConfigDef::AnycubicSLAFormatConfigDef(), Slic3r::CLIActionsConfigDef::CLIActionsConfigDef(), CLIMiscConfigDef(), Slic3r::CLITransformConfigDef::CLITransformConfigDef(), Slic3r::ConfigDef::add_nullable(), Slic3r::PrintConfigDef::init_common_params(), Slic3r::PrintConfigDef::init_fff_params(), Slic3r::PrintConfigDef::init_sla_params(), and Slic3r::PrintConfigDef::init_sla_support_params().

+ Here is the caller graph for this function:

◆ add_nullable()

ConfigOptionDef * Slic3r::ConfigDef::add_nullable ( const t_config_option_key opt_key,
ConfigOptionType  type 
)
protectedinherited
300{
301 ConfigOptionDef *def = this->add(opt_key, type);
302 def->nullable = true;
303 return def;
304}

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

Referenced by Slic3r::PrintConfigDef::init_fff_params(), and Slic3r::PrintConfigDef::init_sla_params().

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

◆ finalize()

void Slic3r::ConfigDef::finalize ( )
protectedinherited
307{
308 // Validate & finalize open & closed enums.
309 for (std::pair<const t_config_option_key, ConfigOptionDef> &kvp : options) {
310 ConfigOptionDef& def = kvp.second;
311 if (def.type == coEnum) {
312 assert(def.enum_def);
313 assert(def.enum_def->is_valid_closed_enum());
314 assert(def.gui_type != ConfigOptionDef::GUIType::i_enum_open &&
315 def.gui_type != ConfigOptionDef::GUIType::f_enum_open &&
317 def.enum_def->finalize_closed_enum();
318 } else if (def.gui_type == ConfigOptionDef::GUIType::i_enum_open || def.gui_type == ConfigOptionDef::GUIType::f_enum_open ||
320 assert(def.enum_def);
321 assert(def.enum_def->is_valid_open_enum());
322 assert(def.gui_type != ConfigOptionDef::GUIType::i_enum_open || def.type == coInt || def.type == coInts);
323 assert(def.gui_type != ConfigOptionDef::GUIType::f_enum_open || def.type == coFloat || def.type == coPercent || def.type == coFloatOrPercent);
324 assert(def.gui_type != ConfigOptionDef::GUIType::select_open || def.type == coString || def.type == coStrings);
325 } else {
326 assert(! def.enum_def);
327 }
328 }
329}
@ coInts
Definition Config.hpp:170
@ coFloat
Definition Config.hpp:164
@ coFloatOrPercent
Definition Config.hpp:180
@ coPercent
Definition Config.hpp:176

References Slic3r::coEnum, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coInt, Slic3r::coInts, Slic3r::coPercent, Slic3r::coString, Slic3r::coStrings, Slic3r::ConfigOptionDef::enum_def, Slic3r::ConfigOptionDef::f_enum_open, Slic3r::ConfigOptionDef::gui_type, Slic3r::ConfigOptionDef::i_enum_open, Slic3r::ConfigDef::options, Slic3r::ConfigOptionDef::select_open, and Slic3r::ConfigOptionDef::type.

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

+ Here is the caller graph for this function:

◆ get()

◆ has()

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

Referenced by Slic3r::PrintConfigDef::handle_legacy(), and Slic3r::CLI::setup().

+ Here is the caller graph for this function:

◆ keys()

std::vector< std::string > Slic3r::ConfigDef::keys ( ) const
inlineinherited
2073 {
2074 std::vector<std::string> out;
2075 out.reserve(options.size());
2076 for(auto const& kvp : options)
2077 out.push_back(kvp.first);
2078 return out;
2079 }

References Slic3r::ConfigDef::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
332{
333 // prepare a function for wrapping text
334 auto wrap = [](const std::string& text, size_t line_length) -> std::string {
335 std::istringstream words(text);
336 std::ostringstream wrapped;
337 std::string word;
338
339 if (words >> word) {
340 wrapped << word;
341 size_t space_left = line_length - word.length();
342 while (words >> word) {
343 if (space_left < word.length() + 1) {
344 wrapped << '\n' << word;
345 space_left = line_length - word.length();
346 } else {
347 wrapped << ' ' << word;
348 space_left -= word.length() + 1;
349 }
350 }
351 }
352 return wrapped.str();
353 };
354
355 // get the unique categories
356 std::set<std::string> categories;
357 for (const auto& opt : this->options) {
358 const ConfigOptionDef& def = opt.second;
359 if (filter(def))
360 categories.insert(def.category);
361 }
362
363 for (const std::string& category : categories) {
364 if (category != "") {
365 out << category << ":" << std::endl;
366 } else if (categories.size() > 1) {
367 out << "Misc options:" << std::endl;
368 }
369
370 for (const auto& opt : this->options) {
371 const ConfigOptionDef& def = opt.second;
372 if (def.category != category || def.cli == ConfigOptionDef::nocli || !filter(def))
373 continue;
374
375 // get all possible variations: --foo, --foobar, -f...
376 std::vector<std::string> cli_args = def.cli_args(opt.first);
377 if (cli_args.empty())
378 continue;
379
380 for (auto& arg : cli_args) {
381 arg.insert(0, (arg.size() == 1) ? "-" : "--");
382 if (def.type == coFloat || def.type == coInt || def.type == coFloatOrPercent
383 || def.type == coFloats || def.type == coInts) {
384 arg += " N";
385 } else if (def.type == coPoint) {
386 arg += " X,Y";
387 } else if (def.type == coPoint3) {
388 arg += " X,Y,Z";
389 } else if (def.type == coString || def.type == coStrings) {
390 arg += " ABCD";
391 }
392 }
393
394 // left: command line options
395 const std::string cli = boost::algorithm::join(cli_args, ", ");
396 out << " " << std::left << std::setw(20) << cli;
397
398 // right: option description
399 std::string descr = def.tooltip;
400 bool show_defaults_this = show_defaults || def.opt_key == "config_compatibility";
401 if (show_defaults_this && def.default_value && def.type != coBool
402 && (def.type != coString || !def.default_value->serialize().empty())) {
403 descr += " (";
404 if (!def.sidetext.empty()) {
405 descr += def.sidetext + ", ";
406 } else if (def.enum_def->has_values()) {
407 descr += boost::algorithm::join(def.enum_def->values(), ", ") + "; ";
408 }
409 descr += "default: " + def.default_value->serialize() + ")";
410 }
411
412 // wrap lines of description
413 descr = wrap(descr, 80);
414 std::vector<std::string> lines;
415 boost::split(lines, descr, boost::is_any_of("\n"));
416
417 // if command line options are too long, print description in new line
418 for (size_t i = 0; i < lines.size(); ++i) {
419 if (i == 0 && cli.size() > 19)
420 out << std::endl;
421 if (i > 0 || cli.size() > 19)
422 out << std::string(21, ' ');
423 out << lines[i] << std::endl;
424 }
425 }
426 }
427 return out;
428}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition ArrayCwiseUnaryOps.h:57
static const constexpr char * nocli
Definition Config.hpp:2035
@ coPoint
Definition Config.hpp:184
@ coPoint3
Definition Config.hpp:187
@ coFloats
Definition Config.hpp:166

References arg(), Slic3r::ConfigOptionDef::category, Slic3r::ConfigOptionDef::cli, Slic3r::ConfigOptionDef::cli_args(), Slic3r::coBool, Slic3r::coFloat, Slic3r::coFloatOrPercent, Slic3r::coFloats, Slic3r::coInt, Slic3r::coInts, Slic3r::coPoint, Slic3r::coPoint3, Slic3r::coString, Slic3r::coStrings, Slic3r::ConfigOptionDef::default_value, Slic3r::ConfigOptionDef::enum_def, Slic3r::ConfigOptionDef::nocli, Slic3r::ConfigOptionDef::opt_key, Slic3r::ConfigDef::options, Slic3r::ConfigOptionDef::sidetext, Slic3r::ConfigOptionDef::tooltip, and Slic3r::ConfigOptionDef::type.

Referenced by Slic3r::CLI::print_help().

+ Here is the call graph for this function:
+ Here is the caller 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 files: