Reworked the command line interface based on the current state

of the upstream.
Thanks @alexrj, @lordofhyphens for the original code of slic3r.cpp
This commit is contained in:
bubnikv 2019-03-13 15:44:50 +01:00
parent 75cf1cde92
commit 18025cc669
22 changed files with 1131 additions and 530 deletions

View file

@ -30,6 +30,8 @@ enum PrinterTechnology
ptFFF,
// Stereolitography
ptSLA,
// Unknown, useful for command line processing
ptUnknown,
};
enum GCodeFlavor {
@ -1145,72 +1147,32 @@ protected:
#undef STATIC_PRINT_CONFIG_CACHE_DERIVED
#undef OPT_PTR
class CLIConfigDef : public ConfigDef
class CLIActionsConfigDef : public ConfigDef
{
public:
CLIConfigDef();
CLIActionsConfigDef();
};
extern const CLIConfigDef cli_config_def;
#define OPT_PTR(KEY) if (opt_key == #KEY) return &this->KEY
class CLIConfig : public virtual ConfigBase, public StaticConfig
class CLITransformConfigDef : public ConfigDef
{
public:
ConfigOptionFloat cut;
ConfigOptionString datadir;
ConfigOptionBool dont_arrange;
ConfigOptionBool export_3mf;
ConfigOptionBool gui;
ConfigOptionBool info;
ConfigOptionBool help;
ConfigOptionStrings load;
ConfigOptionBool no_gui;
ConfigOptionString output;
ConfigOptionPoint print_center;
ConfigOptionFloat rotate;
ConfigOptionFloat rotate_x;
ConfigOptionFloat rotate_y;
ConfigOptionString save;
ConfigOptionFloat scale;
// ConfigOptionPoint3 scale_to_fit;
ConfigOptionBool slice;
CLIConfig() : ConfigBase(), StaticConfig()
{
this->set_defaults();
};
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
const ConfigDef* def() const override { return &cli_config_def; }
t_config_option_keys keys() const override { return cli_config_def.keys(); }
ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) override
{
OPT_PTR(cut);
OPT_PTR(datadir);
OPT_PTR(dont_arrange);
OPT_PTR(export_3mf);
OPT_PTR(gui);
OPT_PTR(help);
OPT_PTR(info);
OPT_PTR(load);
OPT_PTR(no_gui);
OPT_PTR(output);
OPT_PTR(print_center);
OPT_PTR(rotate);
OPT_PTR(rotate_x);
OPT_PTR(rotate_y);
OPT_PTR(save);
OPT_PTR(scale);
// OPT_PTR(scale_to_fit);
OPT_PTR(slice);
return NULL;
}
CLITransformConfigDef();
};
#undef OPT_PTR
class CLIMiscConfigDef : public ConfigDef
{
public:
CLIMiscConfigDef();
};
// This class defines the command line options representing actions.
extern const CLIActionsConfigDef cli_actions_config_def;
// This class defines the command line options representing transforms.
extern const CLITransformConfigDef cli_transform_config_def;
// This class defines all command line options that are not actions or transforms.
extern const CLIMiscConfigDef cli_misc_config_def;
class DynamicPrintAndCLIConfig : public DynamicPrintConfig
{
@ -1233,19 +1195,16 @@ private:
public:
PrintAndCLIConfigDef() {
this->options.insert(print_config_def.options.begin(), print_config_def.options.end());
this->options.insert(cli_config_def.options.begin(), cli_config_def.options.end());
this->options.insert(cli_actions_config_def.options.begin(), cli_actions_config_def.options.end());
this->options.insert(cli_transform_config_def.options.begin(), cli_transform_config_def.options.end());
this->options.insert(cli_misc_config_def.options.begin(), cli_misc_config_def.options.end());
}
// Do not release the default values, they are handled by print_config_def & cli_config_def.
// Do not release the default values, they are handled by print_config_def & cli_actions_config_def / cli_transform_config_def / cli_misc_config_def.
~PrintAndCLIConfigDef() { this->options.clear(); }
};
static PrintAndCLIConfigDef s_def;
};
/// Iterate through all of the print options and write them to a stream.
std::ostream& print_print_options(std::ostream& out);
/// Iterate through all of the CLI options and write them to a stream.
std::ostream& print_cli_options(std::ostream& out);
} // namespace Slic3r
#endif