Ported test_skirt_brim from upstream Slic3r, thanks @lordofhyphens

This commit is contained in:
bubnikv 2019-10-15 16:31:20 +02:00
parent c99e7cb0df
commit 1964ac2e89
8 changed files with 308 additions and 32 deletions

View file

@ -29,6 +29,8 @@ public:
float value(Axis axis) const { return m_axis[axis]; }
bool has(char axis) const;
bool has_value(char axis, float &value) const;
float new_X(const GCodeReader &reader) const { return this->has(X) ? this->x() : reader.x(); }
float new_Y(const GCodeReader &reader) const { return this->has(Y) ? this->y() : reader.y(); }
float new_Z(const GCodeReader &reader) const { return this->has(Z) ? this->z() : reader.z(); }
float new_E(const GCodeReader &reader) const { return this->has(E) ? this->e() : reader.e(); }
float new_F(const GCodeReader &reader) const { return this->has(F) ? this->f() : reader.f(); }

View file

@ -29,7 +29,7 @@ PrintConfigDef::PrintConfigDef()
this->init_common_params();
assign_printer_technology_to_unknown(this->options, ptAny);
this->init_fff_params();
this->init_extruder_retract_keys();
this->init_extruder_option_keys();
assign_printer_technology_to_unknown(this->options, ptFFF);
this->init_sla_params();
assign_printer_technology_to_unknown(this->options, ptSLA);
@ -2270,8 +2270,17 @@ void PrintConfigDef::init_fff_params()
}
}
void PrintConfigDef::init_extruder_retract_keys()
void PrintConfigDef::init_extruder_option_keys()
{
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
m_extruder_option_keys = {
"nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset",
"retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed",
"retract_before_wipe", "retract_restart_extra", "retract_before_travel", "wipe",
"retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
"default_filament_profile"
};
m_extruder_retract_keys = {
"deretract_speed",
"retract_before_travel",
@ -2938,6 +2947,20 @@ void DynamicPrintConfig::normalize()
}
}
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
{
const auto &defaults = FullPrintConfig::defaults();
for (const std::string &key : print_config_def.extruder_option_keys()) {
if (key == "default_filament_profile")
continue;
auto *opt = this->option(key, false);
assert(opt != nullptr);
assert(opt->is_vector());
if (opt != nullptr && opt->is_vector())
static_cast<ConfigOptionVectorBase*>(opt)->resize(num_extruders, defaults.option(key));
}
}
std::string DynamicPrintConfig::validate()
{
// Full print config is initialized from the defaults.

View file

@ -193,6 +193,8 @@ public:
static void handle_legacy(t_config_option_key &opt_key, std::string &value);
// Array options growing with the number of extruders
const std::vector<std::string>& extruder_option_keys() const { return m_extruder_option_keys; }
// Options defining the extruder retract properties. These keys are sorted lexicographically.
// The extruder retract keys could be overidden by the same values defined at the Filament level
// (then the key is further prefixed with the "filament_" prefix).
@ -201,9 +203,10 @@ public:
private:
void init_common_params();
void init_fff_params();
void init_extruder_retract_keys();
void init_extruder_option_keys();
void init_sla_params();
std::vector<std::string> m_extruder_option_keys;
std::vector<std::string> m_extruder_retract_keys;
};
@ -231,6 +234,8 @@ public:
void normalize();
void set_num_extruders(unsigned int num_extruders);
// Validate the PrintConfig. Returns an empty string on success, otherwise an error message is returned.
std::string validate();