ENH: config: add filament_maps in partplate

Change-Id: I1183830788e703f1d33a8a4b620b58b822283dd4
(cherry picked from commit b0e3ab037e3f5af0851539af5ac15b8f96daf548)
This commit is contained in:
lane.wei
2024-06-20 16:10:16 +08:00
committed by Noisyfox
parent fe09c20725
commit 141af16fa2
11 changed files with 490 additions and 105 deletions

View File

@@ -344,6 +344,9 @@ public:
// Set a single vector item from either a scalar option or the first value of a vector option.vector of ConfigOptions.
// This function is useful to split values from multiple extrder / filament settings into separate configurations.
virtual void set_at(const ConfigOption *rhs, size_t i, size_t j) = 0;
//BBS
virtual void append(const ConfigOption *rhs) = 0;
virtual void set(const ConfigOption* rhs, size_t start, size_t len) = 0;
// Resize the vector of values, copy the newly added values from opt_default if provided.
virtual void resize(size_t n, const ConfigOption *opt_default = nullptr) = 0;
// Clear the values vector.
@@ -431,6 +434,41 @@ public:
throw ConfigurationError("ConfigOptionVector::set_at(): Assigning an incompatible type");
}
//BBS
void append(const ConfigOption *rhs) override
{
if (rhs->type() == this->type()) {
// Assign the first value of the rhs vector.
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);
if (other->values.empty())
throw ConfigurationError("ConfigOptionVector::append(): append an empty vector");
this->values.insert(this->values.end(), other->values.begin(), other->values.end());
} else if (rhs->type() == this->scalar_type())
this->values.push_back(static_cast<const ConfigOptionSingle<T>*>(rhs)->value);
else
throw ConfigurationError("ConfigOptionVector::append(): append an incompatible type");
}
// Set a single vector item from a range of another vector option
// This function is useful to split values from multiple extrder / filament settings into separate configurations.
void set(const ConfigOption* rhs, size_t start, size_t len) override
{
// It is expected that the vector value has at least one value, which is the default, if not overwritten.
assert(!this->values.empty());
T v = this->values.front();
this->values.resize(len, v);
if (rhs->type() == this->type()) {
// Assign the first value of the rhs vector.
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);
if (other->values.size() < (start+len))
throw ConfigurationError("ConfigOptionVector::set_with(): Assigning from an vector with invalid size");
for (size_t i = 0; i < len; i++)
this->values[i] = other->get_at(start+i);
}
else
throw ConfigurationError("ConfigOptionVector::set_with(): Assigning an incompatible type");
}
const T& get_at(size_t i) const
{
assert(! this->values.empty());

View File

@@ -4129,6 +4129,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
std::string key = bbs_get_attribute_value_string(attributes, num_attributes, KEY_ATTR);
std::string value = bbs_get_attribute_value_string(attributes, num_attributes, VALUE_ATTR);
auto get_vector_from_string = [](const std::string& str) -> std::vector<int> {
std::stringstream stream(str);
int value;
std::vector<int> results;
while (stream >> value) {
results.push_back(value);
}
return results;
};
if ((m_curr_plater == nullptr)&&!m_parsing_slice_info)
{
IdToMetadataMap::iterator object = m_objects_metadata.find(m_curr_config.object_id);
@@ -4170,25 +4180,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
m_curr_plater->config.set_key_value("print_sequence", new ConfigOptionEnum<PrintSequence>(print_sequence));
}
else if (key == FIRST_LAYER_PRINT_SEQUENCE_ATTR) {
auto get_vector_from_string = [](const std::string &str) -> std::vector<int> {
std::stringstream stream(str);
int value;
std::vector<int> results;
while (stream >> value) {
results.push_back(value);
}
return results;
};
m_curr_plater->config.set_key_value("first_layer_print_sequence", new ConfigOptionInts(get_vector_from_string(value)));
}
else if (key == OTHER_LAYERS_PRINT_SEQUENCE_ATTR) {
auto get_vector_from_string = [](const std::string &str) -> std::vector<int> {
std::stringstream stream(str);
int value;
std::vector<int> results;
while (stream >> value) { results.push_back(value); }
return results;
};
m_curr_plater->config.set_key_value("other_layers_print_sequence", new ConfigOptionInts(get_vector_from_string(value)));
}
else if (key == OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR) {
@@ -4199,6 +4193,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
std::istringstream(value) >> std::boolalpha >> spiral_mode;
m_curr_plater->config.set_key_value("spiral_mode", new ConfigOptionBool(spiral_mode));
}
else if (key == FILAMENT_MAP_MODE_ATTR)
{
FilamentMapMode map_mode = FilamentMapMode::fmmAuto;
ConfigOptionEnum<FilamentMapMode>::from_string(value, map_mode);
m_curr_plater->config.set_key_value("filament_map_mode", new ConfigOptionEnum<FilamentMapMode>(map_mode));
}
else if (key == FILAMENT_MAP_ATTR) {
m_curr_plater->config.set_key_value("filament_map", new ConfigOptionInts(get_vector_from_string(value)));
}
else if (key == GCODE_FILE_ATTR)
{
m_curr_plater->gcode_file = value;
@@ -7624,7 +7628,6 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << "\"/>\n";
}
ConfigOptionInts *other_layers_print_sequence_opt = plate_data->config.option<ConfigOptionInts>("other_layers_print_sequence");
if (other_layers_print_sequence_opt != nullptr) {
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OTHER_LAYERS_PRINT_SEQUENCE_ATTR << "\" " << VALUE_ATTR << "=\"";
@@ -7646,19 +7649,23 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
if (spiral_mode_opt)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SPIRAL_VASE_MODE << "\" " << VALUE_ATTR << "=\"" << spiral_mode_opt->getBool() << "\"/>\n";
// TODO: Orca: hack
//filament map related
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_MODE_ATTR << "\" " << VALUE_ATTR << "=\"" << "Auto For Flush" << "\"/>\n";
ConfigOption* filament_map_mode_opt = plate_data->config.option("filament_map_mode");
t_config_enum_names filament_map_mode_names = ConfigOptionEnum<FilamentMapMode>::get_enum_names();
if (filament_map_mode_opt != nullptr && filament_map_mode_names.size() > filament_map_mode_opt->getInt())
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_MODE_ATTR << "\" " << VALUE_ATTR << "=\"" << filament_map_mode_names[filament_map_mode_opt->getInt()] << "\"/>\n";
// filament map override global settings only when group mode overrides the global settings
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_ATTR << "\" " << VALUE_ATTR << "=\"";
const size_t filaments_count = dynamic_cast<const ConfigOptionStrings*>(config.option("filament_colour"))->values.size();
for (int i = 0; i < filaments_count; ++i) {
stream << "1"; // Orca hack: for now, all filaments are mapped to extruder 1
if (i != (filaments_count - 1))
stream << " ";
ConfigOptionInts* filament_maps_opt = plate_data->config.option<ConfigOptionInts>("filament_map");
if (filament_maps_opt != nullptr) {
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_ATTR << "\" " << VALUE_ATTR << "=\"";
const std::vector<int>& values = filament_maps_opt->values;
for (int i = 0; i < values.size(); ++i) {
stream << values[i];
if (i != (values.size() - 1))
stream << " ";
}
stream << "\"/>\n";
}
stream << "\"/>\n";
if (save_gcode)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << GCODE_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << xml_escape(plate_data->gcode_file) << "\"/>\n";

View File

@@ -342,6 +342,8 @@ void Preset::normalize(DynamicPrintConfig &config)
for (const std::string &key : Preset::filament_options()) {
if (key == "compatible_prints" || key == "compatible_printers")
continue;
if (filament_options_with_variant.find(key) != filament_options_with_variant.end())
continue;
auto *opt = config.option(key, false);
/*assert(opt != nullptr);
assert(opt->is_vector());*/
@@ -808,6 +810,8 @@ static std::vector<std::string> s_Preset_print_options {
"brim_width", "brim_object_gap", "brim_type", "brim_ears_max_angle", "brim_ears_detection_length", "enable_support", "support_type", "support_threshold_angle", "support_threshold_overlap","enforce_support_layers",
"raft_layers", "raft_first_layer_density", "raft_first_layer_expansion", "raft_contact_distance", "raft_expansion",
"support_base_pattern", "support_base_pattern_spacing", "support_expansion", "support_style",
// BBS
"print_extruder_id", "print_extruder_variant",
"independent_support_layer_height",
"support_angle", "support_interface_top_layers", "support_interface_bottom_layers",
"support_interface_pattern", "support_interface_spacing", "support_interface_loop_pattern",
@@ -872,6 +876,7 @@ static std::vector<std::string> s_Preset_filament_options {
//BBS
"filament_wipe_distance", "additional_cooling_fan_speed",
"nozzle_temperature_range_low", "nozzle_temperature_range_high",
"filament_extruder_id", "filament_extruder_variant",
//SoftFever
"enable_pressure_advance", "pressure_advance","adaptive_pressure_advance","adaptive_pressure_advance_model","adaptive_pressure_advance_overhangs", "adaptive_pressure_advance_bridges","chamber_temperature", "filament_shrink","filament_shrinkage_compensation_z", "support_material_interface_fan_speed","internal_bridge_fan_speed", "filament_notes" /*,"filament_seam_gap"*/,
"ironing_fan_speed",
@@ -898,7 +903,8 @@ static std::vector<std::string> s_Preset_printer_options {
"printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor",
"fan_kickstart", "fan_speedup_time", "fan_speedup_overhangs",
"single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "printing_by_object_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "change_extrusion_role_gcode",
"printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
"printer_model", "printer_variant", "printer_extruder_id", "printer_extruder_variant", "extruder_variant_list", "nozzle_volume_type",
"printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
"nozzle_height",
"default_print_profile", "inherits",
"silent_mode",

View File

@@ -2108,16 +2108,34 @@ bool PresetBundle::is_the_only_edited_filament(unsigned int filament_index)
return true;
}
DynamicPrintConfig PresetBundle::full_config() const
int PresetBundle::get_printer_extruder_count()
{
Preset& printer_preset = this->printers.get_edited_preset();
int count = printer_preset.config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
return count;
}
bool PresetBundle::support_different_extruders()
{
Preset& printer_preset = this->printers.get_edited_preset();
int extruder_count;
bool supported = printer_preset.config.support_different_extruders(extruder_count);
return supported;
}
DynamicPrintConfig PresetBundle::full_config(std::vector<int> filament_maps) const
{
return (this->printers.get_edited_preset().printer_technology() == ptFFF) ?
this->full_fff_config() :
this->full_fff_config(true, filament_maps) :
this->full_sla_config();
}
DynamicPrintConfig PresetBundle::full_config_secure() const
DynamicPrintConfig PresetBundle::full_config_secure(std::vector<int> filament_maps) const
{
DynamicPrintConfig config = this->full_config();
DynamicPrintConfig config = this->full_fff_config(false, filament_maps);
//FIXME legacy, the keys should not be there after conversion to a Physical Printer profile.
config.erase("print_host");
config.erase("print_host_webui");
@@ -2134,7 +2152,7 @@ const std::set<std::string> ignore_settings_list ={
"print_settings_id", "filament_settings_id", "printer_settings_id"
};
DynamicPrintConfig PresetBundle::full_fff_config() const
DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::vector<int> filament_maps) const
{
DynamicPrintConfig out;
out.apply(FullPrintConfig::defaults());
@@ -2147,9 +2165,8 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
// BBS
size_t num_filaments = this->filament_presets.size();
// todo multi_extruders: to delete
for (size_t i = 0; i < num_filaments; ++i) {
this->filament_maps.push_back(1);
if (filament_maps.empty()) {
filament_maps.resize(num_filaments, 1);
}
auto* extruder_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter"));
@@ -2180,15 +2197,18 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
different_settings.emplace_back(different_print_settings);
//BBS: update printer config related with variants
out.update_values_to_printer_extruders(printer_options_with_variant_1, "printer_extruder_id", "printer_extruder_variant");
out.update_values_to_printer_extruders(printer_options_with_variant_2, "printer_extruder_id", "printer_extruder_variant", 2);
//update print config related with variants
out.update_values_to_printer_extruders(print_options_with_variant, "print_extruder_id", "print_extruder_variant");
if (apply_extruder) {
out.update_values_to_printer_extruders(out, printer_options_with_variant_1, "printer_extruder_id", "printer_extruder_variant");
out.update_values_to_printer_extruders(out, printer_options_with_variant_2, "printer_extruder_id", "printer_extruder_variant", 2);
//update print config related with variants
out.update_values_to_printer_extruders(out, print_options_with_variant, "print_extruder_id", "print_extruder_variant");
}
if (num_filaments <= 1) {
//BBS: update filament config related with variants
DynamicPrintConfig filament_config = this->filaments.get_edited_preset().config;
filament_config.update_values_to_printer_extruders(filament_options_with_variant, "filament_extruder_id", "filament_extruder_variant", 1, this->filament_maps[0]);
if (apply_extruder)
filament_config.update_values_to_printer_extruders(out, filament_options_with_variant, "filament_extruder_id", "filament_extruder_variant", 1, filament_maps[0]);
out.apply(filament_config);
compatible_printers_condition.emplace_back(this->filaments.get_edited_preset().compatible_printers_condition());
compatible_prints_condition .emplace_back(this->filaments.get_edited_preset().compatible_prints_condition());
@@ -2277,10 +2297,12 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
filament_temp_configs.resize(num_filaments);
for (size_t i = 0; i < num_filaments; ++i) {
filament_temp_configs[i] = *(filament_configs[i]);
filament_temp_configs[i].update_values_to_printer_extruders(filament_options_with_variant, "filament_extruder_id", "filament_extruder_variant", 1, this->filament_maps[i]);
if (apply_extruder)
filament_temp_configs[i].update_values_to_printer_extruders(out, filament_options_with_variant, "filament_extruder_id", "filament_extruder_variant", 1, filament_maps[i]);
}
// loop through options and apply them to the resulting config.
std::vector<int> filament_variant_count(num_filaments, 1);
for (const t_config_option_key &key : this->filaments.default_preset().config.keys()) {
if (key == "compatible_prints" || key == "compatible_printers")
continue;
@@ -2295,11 +2317,38 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
// BBS
ConfigOptionVectorBase* opt_vec_dst = static_cast<ConfigOptionVectorBase*>(opt_dst);
{
std::vector<const ConfigOption*> filament_opts(num_filaments, nullptr);
// Setting a vector value from all filament_configs.
for (size_t i = 0; i < filament_opts.size(); ++i)
filament_opts[i] = filament_temp_configs[i].option(key);
opt_vec_dst->set(filament_opts);
if (apply_extruder) {
std::vector<const ConfigOption*> filament_opts(num_filaments, nullptr);
// Setting a vector value from all filament_configs.
for (size_t i = 0; i < filament_opts.size(); ++i)
filament_opts[i] = filament_temp_configs[i].option(key);
opt_vec_dst->set(filament_opts);
}
else {
for (size_t i = 0; i < num_filaments; ++i) {
const ConfigOptionVectorBase* filament_option = static_cast<const ConfigOptionVectorBase*>(filament_temp_configs[i].option(key));
if (i == 0)
opt_vec_dst->set(filament_option);
else
opt_vec_dst->append(filament_option);
if (key == "filament_extruder_variant")
filament_variant_count[i] = filament_option->size();
}
}
}
}
}
if (!apply_extruder) {
//append filament_self_index
std::vector<int>& filament_self_indice = out.option<ConfigOptionInts>("filament_self_index", true)->values;
int index_size = out.option<ConfigOptionStrings>("filament_extruder_variant")->size();
filament_self_indice.resize(index_size, 1);
int k = 0;
for (size_t i = 0; i < num_filaments; i++) {
for (size_t j = 0; j < filament_variant_count[i]; j++) {
filament_self_indice[k++] = i + 1;
}
}
}
@@ -2347,7 +2396,7 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
out.option<ConfigOptionStrings>("filament_ids", true)->values = filament_ids;
out.option<ConfigOptionInts>("filament_map", true)->values = this->filament_maps;
out.option<ConfigOptionInts>("filament_map", true)->values = filament_maps;
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
// The vector will not be stored if all fields are empty strings.
@@ -2508,6 +2557,36 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
default: break;
}
bool process_multi_extruder = false;
std::vector<int> filament_variant_index;
size_t extruder_variant_count;
std::vector<int> filament_self_indice = std::move(config.option<ConfigOptionInts>("filament_self_index", true)->values);
if (config.option("extruder_variant_list")) {
//3mf support multiple extruder logic
size_t extruder_count = config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
extruder_variant_count = config.option<ConfigOptionInts>("filament_extruder_id", true)->size();
if ((extruder_variant_count != filament_self_indice.size())
|| (extruder_variant_count < num_filaments)) {
assert(false);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": invalid config file %1%, can not find suitable filament_extruder_id or filament_self_index") % name_or_path;
throw Slic3r::RuntimeError(std::string("invalid configuration file: ") + name_or_path);
}
if (extruder_count != extruder_variant_count) {
process_multi_extruder = true;
filament_variant_index.resize(num_filaments, 0);
size_t cur_filament_id = 1;
for (size_t index = 0; index < filament_self_indice.size(); index++) {
if (filament_self_indice[index] == cur_filament_id) {
filament_variant_index[cur_filament_id - 1] = index;
cur_filament_id++;
if (cur_filament_id > num_filaments)
break;
}
}
}
}
// 1) Create a name from the file name.
// Keep the suffix (.ini, .gcode, .amf, .3mf etc) to differentiate it from the normal profiles.
std::string name = is_external ? boost::filesystem::path(name_or_path).filename().string() : name_or_path;
@@ -2619,8 +2698,14 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
configs[i].option(key, false)->set(other_opt);
}
else if (key != "compatible_printers" && key != "compatible_prints") {
for (size_t i = 0; i < configs.size(); ++i)
static_cast<ConfigOptionVectorBase*>(configs[i].option(key, false))->set_at(other_opt, 0, i);
for (size_t i = 0; i < configs.size(); ++i) {
if (process_multi_extruder && (filament_options_with_variant.find(key) != filament_options_with_variant.end())) {
size_t next_index = (i < (configs.size() - 1)) ? filament_variant_index[i + 1] : extruder_variant_count - 1;
static_cast<ConfigOptionVectorBase*>(configs[i].option(key, false))->set(other_opt, filament_variant_index[i], next_index - filament_variant_index[i]);
}
else
static_cast<ConfigOptionVectorBase*>(configs[i].option(key, false))->set_at(other_opt, 0, i);
}
}
}
// Load the configs into this->filaments and make them active.
@@ -3230,7 +3315,7 @@ void PresetBundle::update_multi_material_filament_presets(size_t to_delete_filam
// Now verify if flush_volumes_matrix has proper size (it is used to deduce number of extruders in wipe tower generator):
std::vector<double> old_matrix = this->project_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
size_t nozzle_nums = full_config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();
size_t nozzle_nums = get_printer_extruder_count();
size_t old_number_of_filaments = size_t(sqrt(old_matrix.size() / nozzle_nums) + EPSILON);
if (num_filaments != old_number_of_filaments) {
// First verify if purging volumes presets for each extruder matches number of extruders

View File

@@ -183,9 +183,13 @@ public:
bool has_defauls_only() const
{ return prints.has_defaults_only() && filaments.has_defaults_only() && printers.has_defaults_only(); }
DynamicPrintConfig full_config() const;
DynamicPrintConfig full_config(std::vector<int> filament_maps = std::vector<int>()) const;
// full_config() with the some "useless" config removed.
DynamicPrintConfig full_config_secure() const;
DynamicPrintConfig full_config_secure(std::vector<int> filament_maps = std::vector<int>()) const;
//BBS: add some functions for multiple extruders
int get_printer_extruder_count();
bool support_different_extruders();
// Load user configuration and store it into the user profiles.
// This method is called by the configuration wizard.
@@ -310,7 +314,7 @@ private:
/*ConfigSubstitutions load_config_file_config_bundle(
const std::string &path, const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule);*/
DynamicPrintConfig full_fff_config() const;
DynamicPrintConfig full_fff_config(bool apply_extruder, std::vector<int> filament_maps) const;
DynamicPrintConfig full_sla_config() const;
// Orca: used for validation only

View File

@@ -472,7 +472,7 @@ static const t_config_enum_values s_keys_map_WipeTowerWallType{
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(WipeTowerWallType)
static const t_config_enum_values s_keys_map_ExtruderType = {
{ "Direct drive", etDirectDrive },
{ "Direct Drive", etDirectDrive },
{ "Bowden", etBowden }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ExtruderType)
@@ -483,6 +483,13 @@ static const t_config_enum_values s_keys_map_NozzleVolumeType = {
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NozzleVolumeType)
static const t_config_enum_values s_keys_map_FilamentMapMode = {
{ "Auto", fmmAuto },
{ "Manual", fmmManual }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FilamentMapMode)
//BBS
std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type)
{
@@ -2065,6 +2072,17 @@ void PrintConfigDef::init_fff_params()
def->mode = comDevelop;
def->set_default_value(new ConfigOptionInts{1});
def = this->add("filament_map_mode", coEnum);
def->label = L("filament mapping mode");
def->tooltip = ("filament mapping mode used as plate param");
def->enum_keys_map = &ConfigOptionEnum<FilamentMapMode>::get_enum_values();
def->enum_values.push_back("Auto");
def->enum_values.push_back("Manual");
def->enum_labels.push_back(L("Auto"));
def->enum_labels.push_back(L("Manual"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<FilamentMapMode>(fmmAuto));
def = this->add("filament_max_volumetric_speed", coFloats);
def->label = L("Max volumetric speed");
def->tooltip = L("This setting stands for how much volume of filament can be melted and extruded per second. "
@@ -4364,13 +4382,24 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnumsGeneric{RetractLiftEnforceType ::rletAllSurfaces});
def = this->add("extruder_type", coEnums);
def->label = L("Type");
def->tooltip = ("This setting is only used for initial value of manual calibration of pressure advance. Bowden extruder usually has larger pa value. This setting doesn't influence normal slicing");
def->enum_keys_map = &ConfigOptionEnum<ExtruderType>::get_enum_values();
def->enum_values.push_back("Direct Drive");
def->enum_values.push_back("Bowden");
def->enum_labels.push_back(L("Direct Drive"));
def->enum_labels.push_back(L("Bowden"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnumsGeneric{ ExtruderType::etDirectDrive });
//BBS
def = this->add("nozzle_volume_type", coEnums);
def->label = L("Nozzle Volume Type");
def->tooltip = ("Nozzle volume type");
def->enum_keys_map = &ConfigOptionEnum<NozzleVolumeType>::get_enum_values();
def->enum_values.push_back("Normal");
def->enum_values.push_back("BigTraffic");
def->enum_values.push_back("Big Traffic");
def->enum_labels.push_back(L("Normal"));
def->enum_labels.push_back(L("Big Traffic"));
def->mode = comAdvanced;
@@ -4379,7 +4408,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("extruder_variant_list", coStrings);
def->label = "Extruder variant list";
def->tooltip = "Extruder variant list";
def->set_default_value(new ConfigOptionStrings { "Direct drive Normal" });
def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" });
def->cli = ConfigOptionDef::nocli;
def = this->add("printer_extruder_id", coInts);
@@ -4391,7 +4420,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("printer_extruder_variant", coStrings);
def->label = "Printer's extruder variant";
def->tooltip = "Printer's extruder variant";
def->set_default_value(new ConfigOptionStrings { "Direct drive Normal" });
def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" });
def->cli = ConfigOptionDef::nocli;
def = this->add("print_extruder_id", coInts);
@@ -4403,7 +4432,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("print_extruder_variant", coStrings);
def->label = "Print's extruder variant";
def->tooltip = "Print's extruder variant";
def->set_default_value(new ConfigOptionStrings { "Direct drive Normal" });
def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" });
def->cli = ConfigOptionDef::nocli;
def = this->add("filament_extruder_id", coInts);
@@ -4415,7 +4444,13 @@ void PrintConfigDef::init_fff_params()
def = this->add("filament_extruder_variant", coStrings);
def->label = "Filament's extruder variant";
def->tooltip = "Filament's extruder variant";
def->set_default_value(new ConfigOptionStrings { "Direct drive Normal" });
def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" });
def->cli = ConfigOptionDef::nocli;
def = this->add("filament_self_index", coInts);
def->label = "Filament self index";
def->tooltip = "Filament self index";
def->set_default_value(new ConfigOptionInts { 1 });
def->cli = ConfigOptionDef::nocli;
def = this->add("retract_restart_extra", coFloats);
@@ -6163,7 +6198,7 @@ void PrintConfigDef::init_extruder_option_keys()
{
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
m_extruder_option_keys = {
"nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset",
"extruder_type", "nozzle_diameter", "nozzle_volume_type", "min_layer_height", "max_layer_height", "extruder_offset",
"retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed",
"retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
@@ -7082,21 +7117,84 @@ void PrintConfigDef::handle_legacy_composite(DynamicPrintConfig &config)
const PrintConfigDef print_config_def;
//todo
std::vector<std::string> print_options_with_variant = {
"outer_wall_speed"
std::set<std::string> print_options_with_variant = {
"outer_wall_speed",
"inner_wall_speed",
"small_perimeter_speed",
"small_perimeter_threshold",
"sparse_infill_speed",
"internal_solid_infill_speed",
"top_surface_speed",
"enable_overhang_speed",
"overhang_1_4_speed",
"overhang_2_4_speed",
"overhang_3_4_speed",
"overhang_4_4_speed",
"bridge_speed",
"gap_infill_speed",
"initial_layer_speed",
"initial_layer_infill_speed",
"travel_speed",
"travel_speed_z",
"default_acceleration",
"initial_layer_acceleration",
"outer_wall_acceleration",
"inner_wall_acceleration",
"sparse_infill_acceleration",
"top_surface_acceleration",
"support_interface_speed",
"support_speed",
"print_extruder_id",
"print_extruder_variant"
};
std::vector<std::string> filament_options_with_variant = {
"filament_max_volumetric_speed"
std::set<std::string> filament_options_with_variant = {
"filament_max_volumetric_speed",
"filament_extruder_id",
"filament_extruder_variant"
};
std::vector<std::string> printer_options_with_variant_1 = {
"retraction_length"
std::set<std::string> printer_options_with_variant_1 = {
/*"extruder_type",
"nozzle_diameter",
"nozzle_volume_type".
"min_layer_height",
"max_layer_height",*/
//"retraction_length",
"z_hop",
//"retract_lift_above",
"retract_lift_below",
"z_hop_types",
"retraction_speed",
"deretraction_speed",
"retraction_minimum_travel",
"retract_when_changing_layer",
"wipe",
//"wipe_distance",
"retract_before_wipe",
"retract_length_toolchange",
//"retraction_distances_when_cut",
"printer_extruder_id",
"printer_extruder_variant"
};
//options with silient mode
std::vector<std::string> printer_options_with_variant_2 = {
"machine_max_acceleration_x"
std::set<std::string> printer_options_with_variant_2 = {
/*"machine_max_acceleration_x",
"machine_max_acceleration_y",
"machine_max_acceleration_z",
"machine_max_acceleration_e",
"machine_max_acceleration_extruding",
"machine_max_acceleration_retracting",
"machine_max_acceleration_travel",
"machine_max_speed_x",
"machine_max_speed_y",
"machine_max_speed_z",
"machine_max_speed_e",
"machine_max_jerk_x",
"machine_max_jerk_y",
"machine_max_jerk_z",
"machine_max_jerk_e",*/
};
DynamicPrintConfig DynamicPrintConfig::full_print_config()
@@ -7530,21 +7628,21 @@ int DynamicPrintConfig::get_index_for_extruder(int extruder_id, std::string id_n
return ret;
}
void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::string>& key_list, std::string id_name, std::string variant_name, unsigned int stride, unsigned int extruder_id)
void DynamicPrintConfig::update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride, unsigned int extruder_id)
{
int extruder_count;
bool different_extruder = support_different_extruders(extruder_count);
bool different_extruder = printer_config.support_different_extruders(extruder_count);
if ((extruder_count > 1) || different_extruder)
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: different extruders processing")%__LINE__;
//apply process settings
//auto opt_nozzle_diameters = this->option<ConfigOptionFloats>("nozzle_diameter");
//int extruder_count = opt_nozzle_diameters->size();
//auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("extruder_type"));
//auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->option("nozzle_volume_type"));
//auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(printer_config.option("extruder_type"));
//auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(printer_config.option("nozzle_volume_type"));
std::vector<int> variant_index;
if (extruder_id > 0 && extruder_id < extruder_count) {
if (extruder_id > 0 && extruder_id <= extruder_count) {
variant_index.resize(1);
ExtruderType extruder_type = ExtruderType::etDirectDrive; // TODO:Orca hack (ExtruderType)(opt_extruder_type->get_at(extruder_id - 1));
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal; // TODO:Orca hack (NozzleVolumeType)(opt_nozzle_volume_type->get_at(extruder_id - 1));
@@ -7552,6 +7650,12 @@ void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::str
//variant index
variant_index[0] = get_index_for_extruder(extruder_id, id_name, extruder_type, nozzle_volume_type, variant_name);
if (variant_index[0] < 0) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", Line %1%: could not found extruder_type %2%, nozzle_volume_type %3%, for filament")
% __LINE__ % s_keys_names_ExtruderType[extruder_type] % s_keys_names_NozzleVolumeType[nozzle_volume_type];
assert(false);
}
extruder_count = 1;
}
else {
@@ -7564,6 +7668,11 @@ void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::str
//variant index
variant_index[e_index] = get_index_for_extruder(e_index+1, id_name, extruder_type, nozzle_volume_type, variant_name);
if (variant_index[e_index] < 0) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", Line %1%: could not found extruder_type %2%, nozzle_volume_type %3%, extruder_index %4%")
%__LINE__ %s_keys_names_ExtruderType[extruder_type] % s_keys_names_NozzleVolumeType[nozzle_volume_type] % (e_index+1);
assert(false);
}
}
}
@@ -7572,7 +7681,7 @@ void DynamicPrintConfig::update_values_to_printer_extruders(std::vector<std::str
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", Line %1%: can not find config define")%__LINE__;
return;
}
for (auto& key: key_list)
for (auto& key: key_set)
{
const ConfigOptionDef *optdef = config_def->get(key);
if (!optdef) {

View File

@@ -378,6 +378,11 @@ enum NozzleVolumeType {
nvtMaxNozzleVolumeType = nvtBigTraffic
};
enum FilamentMapMode {
fmmAuto,
fmmManual
};
extern std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type);
static std::string bed_type_to_gcode_string(const BedType type)
@@ -600,14 +605,14 @@ public:
bool is_using_different_extruders();
bool support_different_extruders(int& extruder_count);
int get_index_for_extruder(int extruder_id, std::string id_name, ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type, std::string variant_name);
void update_values_to_printer_extruders(std::vector<std::string>& key_list, std::string id_name, std::string variant_name, unsigned int stride = 1, unsigned int extruder_id = 0);
void update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride = 1, unsigned int extruder_id = 0);
bool is_custom_defined();
};
extern std::vector<std::string> print_options_with_variant;
extern std::vector<std::string> filament_options_with_variant;
extern std::vector<std::string> printer_options_with_variant_1;
extern std::vector<std::string> printer_options_with_variant_2;
extern std::set<std::string> print_options_with_variant;
extern std::set<std::string> filament_options_with_variant;
extern std::set<std::string> printer_options_with_variant_1;
extern std::set<std::string> printer_options_with_variant_2;
void handle_legacy_sla(DynamicPrintConfig &config);