mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-25 17:18:49 -07:00
ENH: config: add filament_maps in partplate
Change-Id: I1183830788e703f1d33a8a4b620b58b822283dd4 (cherry picked from commit b0e3ab037e3f5af0851539af5ac15b8f96daf548)
This commit is contained in:
parent
fe09c20725
commit
141af16fa2
11 changed files with 490 additions and 105 deletions
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -2661,6 +2661,7 @@ bool GUI_App::on_init_inner()
|
|||
if (plater_ != nullptr) {
|
||||
plater_->reset_project_dirty_initial_presets();
|
||||
plater_->update_project_dirty_from_presets();
|
||||
plater_->get_partplate_list().set_filament_count(preset_bundle->filament_presets.size());
|
||||
}
|
||||
|
||||
// BBS:
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ void PartPlate::init()
|
|||
|
||||
m_print_index = -1;
|
||||
m_print = nullptr;
|
||||
|
||||
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true);
|
||||
}
|
||||
|
||||
BedType PartPlate::get_bed_type(bool load_from_project) const
|
||||
|
|
@ -3172,6 +3174,53 @@ void PartPlate::print() const
|
|||
return;
|
||||
}
|
||||
|
||||
FilamentMapMode PartPlate::get_filament_map_mode()
|
||||
{
|
||||
return m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value;
|
||||
}
|
||||
|
||||
void PartPlate::set_filament_map_mode(FilamentMapMode& mode)
|
||||
{
|
||||
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
|
||||
}
|
||||
|
||||
std::vector<int> PartPlate::get_filament_maps()
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
return filament_maps;
|
||||
}
|
||||
|
||||
void PartPlate::set_filament_maps(std::vector<int>& f_maps)
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
filament_maps = f_maps;
|
||||
}
|
||||
|
||||
void PartPlate::set_filament_count(int filament_count)
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
filament_maps.resize(filament_count, 1);
|
||||
}
|
||||
|
||||
void PartPlate::on_filament_added()
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
filament_maps.push_back(1);
|
||||
}
|
||||
|
||||
|
||||
void PartPlate::on_filament_deleted(int filament_count, int filament_id)
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
||||
filament_maps.erase(filament_maps.begin()+filament_id);
|
||||
|
||||
update_first_layer_print_sequence_when_delete_filament(filament_id);
|
||||
}
|
||||
|
||||
|
||||
/* PartPlate List related functions*/
|
||||
PartPlateList::PartPlateList(int width, int depth, int height, Plater* platerObj, Model* modelObj, PrinterTechnology tech)
|
||||
:m_plate_width(width), m_plate_depth(depth), m_plate_height(height), m_plater(platerObj), m_model(modelObj), printer_technology(tech),
|
||||
|
|
@ -3607,8 +3656,10 @@ void PartPlateList::reset(bool do_init)
|
|||
|
||||
//m_plate_list.clear();
|
||||
|
||||
if (do_init)
|
||||
if (do_init) {
|
||||
init();
|
||||
m_plate_list[0]->set_filament_count(m_filament_count);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -3620,6 +3671,8 @@ void PartPlateList::reinit()
|
|||
|
||||
init();
|
||||
|
||||
m_plate_list[0]->set_filament_count(m_filament_count);
|
||||
|
||||
//reset plate 0's position
|
||||
Vec2d pos = compute_shape_position(0, m_plate_cols);
|
||||
m_plate_list[0]->set_shape(m_shape, m_exclude_areas, pos, m_height_to_lid, m_height_to_rod);
|
||||
|
|
@ -3668,6 +3721,8 @@ int PartPlateList::create_plate(bool adjust_position)
|
|||
m_print_index++;
|
||||
}
|
||||
|
||||
plate->set_filament_count(m_filament_count);
|
||||
|
||||
plate->set_index(new_index);
|
||||
Vec2d pos = compute_shape_position(new_index, cols);
|
||||
plate->set_shape(m_shape, m_exclude_areas, pos, m_height_to_lid, m_height_to_rod);
|
||||
|
|
@ -5385,7 +5440,7 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
|
|||
return ret;
|
||||
}
|
||||
|
||||
int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
|
||||
int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list, int filament_count)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
|
@ -5395,6 +5450,7 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
|
|||
return -1;
|
||||
}
|
||||
clear(true, true);
|
||||
set_filament_count(filament_count);
|
||||
for (unsigned int i = 0; i < (unsigned int)plate_data_list.size(); ++i)
|
||||
{
|
||||
int index = create_plate(false);
|
||||
|
|
@ -5736,5 +5792,35 @@ void PartPlateList::load_cali_textures()
|
|||
PartPlateList::is_load_cali_texture = true;
|
||||
}
|
||||
|
||||
void PartPlateList::set_filament_count(int filament_count)
|
||||
{
|
||||
m_filament_count = filament_count;
|
||||
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
|
||||
{
|
||||
m_plate_list[i]->set_filament_count(filament_count);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: filament_count=%2%")% __FUNCTION__ %filament_count;
|
||||
}
|
||||
|
||||
void PartPlateList::on_filament_added(int filament_count)
|
||||
{
|
||||
m_filament_count++;
|
||||
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
|
||||
{
|
||||
m_plate_list[i]->on_filament_added();
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: filament_count=%2%")% __FUNCTION__ %filament_count;
|
||||
}
|
||||
|
||||
void PartPlateList::on_filament_deleted(int filament_count, int filament_id)
|
||||
{
|
||||
m_filament_count--;
|
||||
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
|
||||
{
|
||||
m_plate_list[i]->on_filament_deleted(filament_count, filament_id);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: filament_count=%2%, filament_id=%3%")% __FUNCTION__ %filament_count %filament_id;
|
||||
}
|
||||
|
||||
}//end namespace GUI
|
||||
}//end namespace slic3r
|
||||
|
|
|
|||
|
|
@ -481,6 +481,16 @@ public:
|
|||
|
||||
void print() const;
|
||||
|
||||
FilamentMapMode get_filament_map_mode();
|
||||
void set_filament_map_mode(FilamentMapMode& mode);
|
||||
|
||||
std::vector<int> get_filament_maps();
|
||||
void set_filament_maps(std::vector<int>& f_maps);
|
||||
|
||||
void set_filament_count(int filament_count);
|
||||
void on_filament_added();
|
||||
void on_filament_deleted(int filament_count, int filament_id);
|
||||
|
||||
friend class cereal::access;
|
||||
friend class UndoRedo::StackImpl;
|
||||
|
||||
|
|
@ -573,6 +583,8 @@ class PartPlateList : public ObjectBase
|
|||
|
||||
bool m_is_dark = false;
|
||||
|
||||
int m_filament_count = 1;
|
||||
|
||||
void init();
|
||||
//compute the origin for printable plate with index i
|
||||
Vec3d compute_origin(int index, int column_count);
|
||||
|
|
@ -839,7 +851,7 @@ public:
|
|||
* if with_gcode = true and specify plate_idx, export plate_idx gcode only
|
||||
*/
|
||||
int store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool with_slice_info = true, int plate_idx = -1);
|
||||
int load_from_3mf_structure(PlateDataPtrs& plate_data_list);
|
||||
int load_from_3mf_structure(PlateDataPtrs& plate_data_list, int filament_count = 1);
|
||||
//load gcode files
|
||||
int load_gcode_files();
|
||||
|
||||
|
|
@ -860,6 +872,10 @@ public:
|
|||
void init_cali_texture_info();
|
||||
void load_cali_textures();
|
||||
|
||||
void set_filament_count(int filament_count);
|
||||
void on_filament_deleted(int filament_count, int filament_id);
|
||||
void on_filament_added(int filament_count);
|
||||
|
||||
BedTextureInfo bed_texture_info[btCount];
|
||||
BedTextureInfo cali_texture_info;
|
||||
BedTextureInfo extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::btAreaCount];
|
||||
|
|
|
|||
|
|
@ -1063,7 +1063,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
auto& project_config = wxGetApp().preset_bundle->project_config;
|
||||
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
|
||||
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
|
||||
|
||||
|
||||
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
const auto& extra_flush_volumes = get_min_flush_volumes(full_config, 0); // todo multi_extruder: always display nozzle 1
|
||||
|
|
@ -1076,7 +1076,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
flush_multiplier = cast<float>(flush_multi_opt->values);
|
||||
else {
|
||||
for (size_t nozzle_id = 0; nozzle_id < nozzle_nums; ++nozzle_id) {
|
||||
flush_multiplier.push_back(1.f);
|
||||
flush_multiplier.push_back(1.f);
|
||||
}
|
||||
}
|
||||
WipingDialog dlg(parent, cast<float>(init_matrix), cast<float>(init_extruders), extruder_colours, extra_flush_volumes, flush_multiplier, nozzle_nums);
|
||||
|
|
@ -1930,6 +1930,7 @@ void Sidebar::delete_filament(size_t filament_id) {
|
|||
}
|
||||
|
||||
wxGetApp().preset_bundle->update_num_filaments(filament_id);
|
||||
wxGetApp().plater()->get_partplate_list().on_filament_deleted(filament_count, filament_id);
|
||||
wxGetApp().plater()->on_filaments_delete(filament_count, filament_id);
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update();
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
|
|
@ -1941,6 +1942,7 @@ void Sidebar::add_custom_filament(wxColour new_col) {
|
|||
int filament_count = p->combos_filament.size() + 1;
|
||||
std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
|
||||
wxGetApp().preset_bundle->set_num_filaments(filament_count, new_color);
|
||||
wxGetApp().plater()->get_partplate_list().on_filament_added(filament_count);
|
||||
wxGetApp().plater()->on_filaments_change(filament_count);
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update();
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
|
|
@ -2306,22 +2308,22 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
|||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
||||
|
||||
size_t nozzle_nums = preset_bundle->full_config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
||||
size_t nozzle_nums = preset_bundle->get_printer_extruder_count();
|
||||
for (size_t nozzle_id = 0; nozzle_id < nozzle_nums; ++nozzle_id)
|
||||
{
|
||||
std::vector<double> init_matrix = get_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, nozzle_id, nozzle_nums);
|
||||
|
||||
const std::vector<int>& min_flush_volumes= get_min_flush_volumes(full_config, nozzle_id);
|
||||
|
||||
|
||||
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
|
||||
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
||||
std::vector<double> matrix = init_matrix;
|
||||
int m_max_flush_volume = Slic3r::g_max_flush_volume;
|
||||
unsigned int m_number_of_extruders = (int)(sqrt(init_matrix.size()) + 0.001);
|
||||
|
||||
|
||||
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
std::vector<std::vector<wxColour>> multi_colours;
|
||||
|
||||
|
||||
// Support for multi-color filament
|
||||
for (int i = 0; i < extruder_colours.size(); ++i) {
|
||||
std::vector<wxColour> single_filament;
|
||||
|
|
@ -2335,11 +2337,11 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
single_filament.push_back(wxColour(extruder_colours[i]));
|
||||
multi_colours.push_back(single_filament);
|
||||
}
|
||||
|
||||
|
||||
if (modify_id >= 0 && modify_id < multi_colours.size()) {
|
||||
for (int i = 0; i < multi_colours.size(); ++i) {
|
||||
// from to modify
|
||||
|
|
@ -2366,7 +2368,7 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
|||
}
|
||||
matrix[m_number_of_extruders * from_idx + modify_id] = flushing_volume;
|
||||
}
|
||||
|
||||
|
||||
// modify to to
|
||||
int to_idx = i;
|
||||
if (to_idx != modify_id) {
|
||||
|
|
@ -2388,7 +2390,7 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
|||
}
|
||||
if (is_from_support)
|
||||
flushing_volume = std::max(flushing_volume, Slic3r::g_min_flush_volume_from_support);
|
||||
|
||||
|
||||
matrix[m_number_of_extruders * modify_id + to_idx] = flushing_volume;
|
||||
}
|
||||
}
|
||||
|
|
@ -3896,7 +3898,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
bool dlg_cont = true;
|
||||
bool is_user_cancel = false;
|
||||
bool translate_old = false;
|
||||
int current_width = 0, current_depth = 0, current_height = 0;
|
||||
int current_width = 0, current_depth = 0, current_height = 0, project_filament_count = 1;
|
||||
|
||||
if (input_files.empty()) { return std::vector<size_t>(); }
|
||||
|
||||
|
|
@ -4177,7 +4179,8 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
//set the size back
|
||||
partplate_list.reset_size(current_width + Bed3D::Axes::DefaultTipRadius, current_depth + Bed3D::Axes::DefaultTipRadius, current_height, false);
|
||||
}
|
||||
partplate_list.load_from_3mf_structure(plate_data);
|
||||
project_filament_count = config_loaded.option<ConfigOptionStrings>("filament_colour")->size();
|
||||
partplate_list.load_from_3mf_structure(plate_data, project_filament_count);
|
||||
partplate_list.update_slice_context_to_current_plate(background_process);
|
||||
this->preview->update_gcode_result(partplate_list.get_current_slice_result());
|
||||
release_PlateData_list(plate_data);
|
||||
|
|
@ -4392,7 +4395,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
std::vector<Preset *> project_presets;
|
||||
bool is_xxx;
|
||||
Semver file_version;
|
||||
|
||||
|
||||
//ObjImportColorFn obj_color_fun=nullptr;
|
||||
auto obj_color_fun = [this, &path](std::vector<RGBA> &input_colors, bool is_single_color, std::vector<unsigned char> &filament_ids,
|
||||
unsigned char &first_extruder_id) {
|
||||
|
|
@ -4486,7 +4489,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
}
|
||||
|
||||
if (plate_data.size() > 0) {
|
||||
partplate_list.load_from_3mf_structure(plate_data);
|
||||
partplate_list.load_from_3mf_structure(plate_data, project_filament_count);
|
||||
partplate_list.update_slice_context_to_current_plate(background_process);
|
||||
this->preview->update_gcode_result(partplate_list.get_current_slice_result());
|
||||
release_PlateData_list(plate_data);
|
||||
|
|
@ -5536,7 +5539,15 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
|||
this->partplate_list.update_slice_context_to_current_plate(background_process);
|
||||
this->preview->update_gcode_result(partplate_list.get_current_slice_result());
|
||||
}
|
||||
Print::ApplyStatus invalidated = background_process.apply(this->model, wxGetApp().preset_bundle->full_config());
|
||||
|
||||
Print::ApplyStatus invalidated;
|
||||
if (wxGetApp().preset_bundle->get_printer_extruder_count() > 1) {
|
||||
PartPlate* cur_plate = background_process.get_current_plate();
|
||||
std::vector<int> f_maps = cur_plate->get_filament_maps();
|
||||
invalidated = background_process.apply(this->model, wxGetApp().preset_bundle->full_config(f_maps));
|
||||
}
|
||||
else
|
||||
invalidated = background_process.apply(this->model, wxGetApp().preset_bundle->full_config());
|
||||
|
||||
if ((invalidated == Print::APPLY_STATUS_CHANGED) || (invalidated == Print::APPLY_STATUS_INVALIDATED))
|
||||
// BBS: add only gcode mode
|
||||
|
|
@ -13365,11 +13376,12 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id)
|
|||
update_filament_colors_in_full_config();
|
||||
|
||||
// update fisrt print sequence and other layer sequence
|
||||
Slic3r::GUI::PartPlateList &plate_list = get_partplate_list();
|
||||
//move to partplate->on_filament_deleted
|
||||
/*Slic3r::GUI::PartPlateList &plate_list = get_partplate_list();
|
||||
for (int i = 0; i < plate_list.get_plate_count(); ++i) {
|
||||
PartPlate *part_plate = plate_list.get_plate(i);
|
||||
part_plate->update_first_layer_print_sequence_when_delete_filament(filament_id);
|
||||
}
|
||||
}*/
|
||||
|
||||
// update mmu info
|
||||
for (ModelObject *mo : wxGetApp().model().objects) {
|
||||
|
|
@ -13386,7 +13398,7 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id)
|
|||
for (auto key : keys)
|
||||
if (p->config->has(key) && p->config->opt_int(key) == filament_id + 1)
|
||||
(*(p->config)).erase(key);
|
||||
|
||||
|
||||
// update object/volume/support(object and volume) filament id
|
||||
sidebar().obj_list()->update_objects_list_filament_column_when_delete_filament(filament_id, num_filaments);
|
||||
|
||||
|
|
@ -13543,7 +13555,7 @@ void Plater::update_flush_volume_matrix(const Slic3r::DynamicPrintConfig& config
|
|||
|
||||
auto *printer_model = config.opt<ConfigOptionString>("printer_model");
|
||||
if (printer_model != nullptr && !printer_model->value.empty()) {
|
||||
size_t nozzle_nums = wxGetApp().preset_bundle->full_config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
||||
size_t nozzle_nums = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||
if (!is_multi_extruder_printer(old_model_id) && is_multi_extruder_printer(printer_model->value)) {
|
||||
Slic3r::DynamicPrintConfig *project_config = &wxGetApp().preset_bundle->project_config;
|
||||
std::vector<double> flush_volume_mtx = get_flush_volumes_matrix(project_config->option<ConfigOptionFloats>("flush_volumes_matrix")->values, -1, nozzle_nums);
|
||||
|
|
@ -14120,7 +14132,13 @@ void Plater::apply_background_progress()
|
|||
int plate_index = p->partplate_list.get_curr_plate_index();
|
||||
bool result_valid = part_plate->is_slice_result_valid();
|
||||
//always apply the current plate's print
|
||||
Print::ApplyStatus invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
Print::ApplyStatus invalidated;
|
||||
if (wxGetApp().preset_bundle->get_printer_extruder_count() > 1) {
|
||||
std::vector<int> f_maps = part_plate->get_filament_maps();
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config(f_maps));
|
||||
}
|
||||
else
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: plate %2%, after apply, invalidated= %3%, previous result_valid %4% ") % __LINE__ % plate_index % invalidated % result_valid;
|
||||
if (invalidated & PrintBase::APPLY_STATUS_INVALIDATED)
|
||||
|
|
@ -14159,7 +14177,12 @@ int Plater::select_plate(int plate_index, bool need_slice)
|
|||
part_plate->get_print(&print, &gcode_result, NULL);
|
||||
|
||||
//always apply the current plate's print
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
if (wxGetApp().preset_bundle->get_printer_extruder_count() > 1) {
|
||||
std::vector<int> f_maps = part_plate->get_filament_maps();
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config(f_maps));
|
||||
}
|
||||
else
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
bool model_fits, validate_err;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: plate %2%, after apply, invalidated= %3%, previous result_valid %4% ")%__LINE__ %plate_index %invalidated %result_valid;
|
||||
|
|
@ -14465,7 +14488,12 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi
|
|||
|
||||
part_plate->get_print(&print, &gcode_result, NULL);
|
||||
//always apply the current plate's print
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
if (wxGetApp().preset_bundle->get_printer_extruder_count() > 1) {
|
||||
std::vector<int> f_maps = part_plate->get_filament_maps();
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config(f_maps));
|
||||
}
|
||||
else
|
||||
invalidated = p->background_process.apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||
bool model_fits, validate_err;
|
||||
validate_current_plate(model_fits, validate_err);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue