Partial revert of 1bffc2b99b

(deriving the printer technology from the merged configs).
This commit is contained in:
Vojtech Bubnik 2021-01-19 15:17:47 +01:00
parent 7cd218a4ee
commit 2bc6679a62
3 changed files with 26 additions and 26 deletions

View File

@ -57,6 +57,12 @@
using namespace Slic3r; using namespace Slic3r;
static PrinterTechnology get_printer_technology(const DynamicConfig &config)
{
const ConfigOptionEnum<PrinterTechnology> *opt = config.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
return (opt == nullptr) ? ptUnknown : opt->value;
}
int CLI::run(int argc, char **argv) int CLI::run(int argc, char **argv)
{ {
// Mark the main thread for the debugger and for runtime checks. // Mark the main thread for the debugger and for runtime checks.
@ -95,7 +101,7 @@ int CLI::run(int argc, char **argv)
m_extra_config.apply(m_config, true); m_extra_config.apply(m_config, true);
m_extra_config.normalize_fdm(); m_extra_config.normalize_fdm();
PrinterTechnology printer_technology = Slic3r::printer_technology(m_config); PrinterTechnology printer_technology = get_printer_technology(m_config);
bool start_gui = m_actions.empty() && bool start_gui = m_actions.empty() &&
// cutting transformations are setting an "export" action. // cutting transformations are setting an "export" action.
@ -130,7 +136,7 @@ int CLI::run(int argc, char **argv)
return 1; return 1;
} }
config.normalize_fdm(); config.normalize_fdm();
PrinterTechnology other_printer_technology = Slic3r::printer_technology(config); PrinterTechnology other_printer_technology = get_printer_technology(config);
if (printer_technology == ptUnknown) { if (printer_technology == ptUnknown) {
printer_technology = other_printer_technology; printer_technology = other_printer_technology;
} else if (printer_technology != other_printer_technology && other_printer_technology != ptUnknown) { } else if (printer_technology != other_printer_technology && other_printer_technology != ptUnknown) {
@ -167,7 +173,7 @@ int CLI::run(int argc, char **argv)
// When loading an AMF or 3MF, config is imported as well, including the printer technology. // When loading an AMF or 3MF, config is imported as well, including the printer technology.
DynamicPrintConfig config; DynamicPrintConfig config;
model = Model::read_from_file(file, &config, true); model = Model::read_from_file(file, &config, true);
PrinterTechnology other_printer_technology = Slic3r::printer_technology(config); PrinterTechnology other_printer_technology = get_printer_technology(config);
if (printer_technology == ptUnknown) { if (printer_technology == ptUnknown) {
printer_technology = other_printer_technology; printer_technology = other_printer_technology;
} }
@ -224,10 +230,12 @@ int CLI::run(int argc, char **argv)
m_print_config.apply(sla_print_config, true); m_print_config.apply(sla_print_config, true);
} }
std::string validity = m_print_config.validate(); {
if (!validity.empty()) { std::string validity = m_print_config.validate();
boost::nowide::cerr << "error: " << validity << std::endl; if (! validity.empty()) {
return 1; boost::nowide::cerr << "Error: The composite configation is not valid: " << validity << std::endl;
return 1;
}
} }
// Loop through transform options. // Loop through transform options.
@ -645,6 +653,7 @@ bool CLI::setup(int argc, char **argv)
set_logging_level(opt_loglevel->value); set_logging_level(opt_loglevel->value);
} }
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
std::string validity = m_config.validate(); std::string validity = m_config.validate();
// Initialize with defaults. // Initialize with defaults.
@ -654,6 +663,7 @@ bool CLI::setup(int argc, char **argv)
set_data_dir(m_config.opt_string("datadir")); set_data_dir(m_config.opt_string("datadir"));
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
if (!validity.empty()) { if (!validity.empty()) {
boost::nowide::cerr << "error: " << validity << std::endl; boost::nowide::cerr << "error: " << validity << std::endl;
return false; return false;

View File

@ -3299,15 +3299,20 @@ DynamicPrintConfig* DynamicPrintConfig::new_from_defaults_keys(const std::vector
double min_object_distance(const ConfigBase &cfg) double min_object_distance(const ConfigBase &cfg)
{ {
const ConfigOptionEnum<PrinterTechnology> *opt_printer_technology = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
auto printer_technology = opt_printer_technology ? opt_printer_technology->value : ptUnknown;
double ret = 0.; double ret = 0.;
if (printer_technology(cfg) == ptSLA) ret = 6.; if (printer_technology == ptSLA)
ret = 6.;
else { else {
auto ecr_opt = cfg.option<ConfigOptionFloat>("extruder_clearance_radius"); auto ecr_opt = cfg.option<ConfigOptionFloat>("extruder_clearance_radius");
auto dd_opt = cfg.option<ConfigOptionFloat>("duplicate_distance"); auto dd_opt = cfg.option<ConfigOptionFloat>("duplicate_distance");
auto co_opt = cfg.option<ConfigOptionBool>("complete_objects"); auto co_opt = cfg.option<ConfigOptionBool>("complete_objects");
if (!ecr_opt || !dd_opt || !co_opt) ret = 0.; if (!ecr_opt || !dd_opt || !co_opt)
ret = 0.;
else { else {
// min object distance is max(duplicate_distance, clearance_radius) // min object distance is max(duplicate_distance, clearance_radius)
ret = (co_opt->value && ecr_opt->value > dd_opt->value) ? ret = (co_opt->value && ecr_opt->value > dd_opt->value) ?
@ -3318,21 +3323,6 @@ double min_object_distance(const ConfigBase &cfg)
return ret; return ret;
} }
PrinterTechnology printer_technology(const ConfigBase &cfg)
{
const ConfigOptionEnum<PrinterTechnology> *opt = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
if (opt) return opt->value;
const ConfigOptionBool *export_opt = cfg.option<ConfigOptionBool>("export_sla");
if (export_opt && export_opt->getBool()) return ptSLA;
export_opt = cfg.option<ConfigOptionBool>("export_gcode");
if (export_opt && export_opt->getBool()) return ptFFF;
return ptUnknown;
}
void DynamicPrintConfig::normalize_fdm() void DynamicPrintConfig::normalize_fdm()
{ {
if (this->has("extruder")) { if (this->has("extruder")) {

View File

@ -246,7 +246,7 @@ extern const PrintConfigDef print_config_def;
class StaticPrintConfig; class StaticPrintConfig;
PrinterTechnology printer_technology(const ConfigBase &cfg); // Minimum object distance for arrangement, based on printer technology.
double min_object_distance(const ConfigBase &cfg); double min_object_distance(const ConfigBase &cfg);
// Slic3r dynamic configuration, used to override the configuration // Slic3r dynamic configuration, used to override the configuration