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

#include <src/libslic3r/PrintConfig.hpp>

+ Inheritance diagram for Slic3r::CLIActionsConfigDef:
+ Collaboration diagram for Slic3r::CLIActionsConfigDef:

Public Member Functions

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

◆ CLIActionsConfigDef()

Slic3r::CLIActionsConfigDef::CLIActionsConfigDef ( )
4664{
4665 ConfigOptionDef* def;
4666
4667 // Actions:
4668 def = this->add("export_obj", coBool);
4669 def->label = L("Export OBJ");
4670 def->tooltip = L("Export the model(s) as OBJ.");
4671 def->set_default_value(new ConfigOptionBool(false));
4672
4673/*
4674 def = this->add("export_svg", coBool);
4675 def->label = L("Export SVG");
4676 def->tooltip = L("Slice the model and export solid slices as SVG.");
4677 def->set_default_value(new ConfigOptionBool(false));
4678*/
4679
4680 def = this->add("export_sla", coBool);
4681 def->label = L("Export SLA");
4682 def->tooltip = L("Slice the model and export SLA printing layers as PNG.");
4683 def->cli = "export-sla|sla";
4684 def->set_default_value(new ConfigOptionBool(false));
4685
4686 def = this->add("export_3mf", coBool);
4687 def->label = L("Export 3MF");
4688 def->tooltip = L("Export the model(s) as 3MF.");
4689 def->set_default_value(new ConfigOptionBool(false));
4690
4691 def = this->add("export_amf", coBool);
4692 def->label = L("Export AMF");
4693 def->tooltip = L("Export the model(s) as AMF.");
4694 def->set_default_value(new ConfigOptionBool(false));
4695
4696 def = this->add("export_stl", coBool);
4697 def->label = L("Export STL");
4698 def->tooltip = L("Export the model(s) as STL.");
4699 def->set_default_value(new ConfigOptionBool(false));
4700
4701 def = this->add("export_gcode", coBool);
4702 def->label = L("Export G-code");
4703 def->tooltip = L("Slice the model and export toolpaths as G-code.");
4704 def->cli = "export-gcode|gcode|g";
4705 def->set_default_value(new ConfigOptionBool(false));
4706
4707 def = this->add("gcodeviewer", coBool);
4708 def->label = L("G-code viewer");
4709 def->tooltip = L("Visualize an already sliced and saved G-code");
4710 def->cli = "gcodeviewer";
4711 def->set_default_value(new ConfigOptionBool(false));
4712
4713#if ENABLE_GL_CORE_PROFILE
4714 def = this->add("opengl-version", coString);
4715 def->label = L("OpenGL version");
4716 def->tooltip = L("Select a specific version of OpenGL");
4717 def->cli = "opengl-version";
4718 def->set_default_value(new ConfigOptionString());
4719
4720 def = this->add("opengl-debug", coBool);
4721 def->label = L("OpenGL debug output");
4722 def->tooltip = L("Activate OpenGL debug output on graphic cards which support it");
4723 def->cli = "opengl-debug";
4724 def->set_default_value(new ConfigOptionBool(false));
4725#endif // ENABLE_GL_CORE_PROFILE
4726
4727 def = this->add("slice", coBool);
4728 def->label = L("Slice");
4729 def->tooltip = L("Slice the model as FFF or SLA based on the printer_technology configuration value.");
4730 def->cli = "slice|s";
4731 def->set_default_value(new ConfigOptionBool(false));
4732
4733 def = this->add("help", coBool);
4734 def->label = L("Help");
4735 def->tooltip = L("Show this help.");
4736 def->cli = "help|h";
4737 def->set_default_value(new ConfigOptionBool(false));
4738
4739 def = this->add("help_fff", coBool);
4740 def->label = L("Help (FFF options)");
4741 def->tooltip = L("Show the full list of print/G-code configuration options.");
4742 def->set_default_value(new ConfigOptionBool(false));
4743
4744 def = this->add("help_sla", coBool);
4745 def->label = L("Help (SLA options)");
4746 def->tooltip = L("Show the full list of SLA print configuration options.");
4747 def->set_default_value(new ConfigOptionBool(false));
4748
4749 def = this->add("info", coBool);
4750 def->label = L("Output Model Info");
4751 def->tooltip = L("Write information about the model to the console.");
4752 def->set_default_value(new ConfigOptionBool(false));
4753
4754 def = this->add("save", coString);
4755 def->label = L("Save config file");
4756 def->tooltip = L("Save configuration to the specified file.");
4757 def->set_default_value(new ConfigOptionString());
4758}
ConfigOptionDef * add(const t_config_option_key &opt_key, ConfigOptionType type)
Definition Config.cpp:288
ConfigOptionBool
Definition PrintConfig.hpp:665
@ coString
Definition Config.hpp:172
@ coBool
Definition Config.hpp:190
#define L(s)
Definition I18N.hpp:18

References Slic3r::ConfigDef::add(), Slic3r::ConfigOptionDef::cli, Slic3r::coBool, Slic3r::coString, L, Slic3r::ConfigOptionDef::label, Slic3r::ConfigOptionDef::set_default_value(), 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(), CLIActionsConfigDef(), Slic3r::CLIMiscConfigDef::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}
@ coEnum
Definition Config.hpp:194
@ coInts
Definition Config.hpp:170
@ coInt
Definition Config.hpp:168
@ coFloat
Definition Config.hpp:164
@ coFloatOrPercent
Definition Config.hpp:180
@ coStrings
Definition Config.hpp:174
@ 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: