ENH: config: add filament_maps in partplate
Change-Id: I1183830788e703f1d33a8a4b620b58b822283dd4
This commit is contained in:
parent
f3d67a98ac
commit
b0e3ab037e
|
@ -354,6 +354,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.
|
||||
|
@ -441,6 +444,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());
|
||||
|
|
|
@ -296,6 +296,8 @@ static constexpr const char* FIRST_LAYER_PRINT_SEQUENCE_ATTR = "first_layer_prin
|
|||
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_ATTR = "other_layers_print_sequence";
|
||||
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR = "other_layers_print_sequence_nums";
|
||||
static constexpr const char* SPIRAL_VASE_MODE = "spiral_mode";
|
||||
static constexpr const char* FILAMENT_MAP_MODE_ATTR = "filament_map_mode";
|
||||
static constexpr const char* FILAMENT_MAP_ATTR = "filament_maps";
|
||||
static constexpr const char* GCODE_FILE_ATTR = "gcode_file";
|
||||
static constexpr const char* THUMBNAIL_FILE_ATTR = "thumbnail_file";
|
||||
static constexpr const char* NO_LIGHT_THUMBNAIL_FILE_ATTR = "thumbnail_no_light_file";
|
||||
|
@ -4063,6 +4065,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);
|
||||
|
@ -4104,25 +4116,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) {
|
||||
|
@ -4133,6 +4129,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;
|
||||
|
@ -7512,7 +7518,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 << "=\"";
|
||||
|
@ -7534,6 +7539,24 @@ 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";
|
||||
|
||||
//filament map related
|
||||
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";
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
if (save_gcode)
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << GCODE_FILE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha << xml_escape(plate_data->gcode_file) << "\"/>\n";
|
||||
if (!plate_data->gcode_file.empty()) {
|
||||
|
|
|
@ -331,6 +331,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());*/
|
||||
|
@ -820,6 +822,7 @@ static std::vector<std::string> s_Preset_print_options {
|
|||
"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",
|
||||
|
@ -877,6 +880,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",
|
||||
//OrcaSlicer
|
||||
"enable_pressure_advance", "pressure_advance", "chamber_temperatures","filament_notes",
|
||||
"filament_long_retractions_when_cut","filament_retraction_distances_when_cut","filament_shrink"
|
||||
|
@ -894,7 +898,8 @@ static std::vector<std::string> s_Preset_printer_options {
|
|||
"printer_technology",
|
||||
"printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor",
|
||||
"single_extruder_multi_material", "machine_start_gcode", "machine_end_gcode","printing_by_object_gcode","before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode",
|
||||
"printer_model", "printer_variant", "printable_height", "extruder_clearance_dist_to_rod", "extruder_clearance_max_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_max_radius","extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
|
||||
"nozzle_height",
|
||||
"default_print_profile", "inherits",
|
||||
"silent_mode",
|
||||
|
|
|
@ -1980,16 +1980,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);
|
||||
//BBS example: config.erase("print_host");
|
||||
config.erase("print_host_webui");
|
||||
config.erase("printhost_apikey");
|
||||
|
@ -2005,7 +2023,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());
|
||||
|
@ -2018,9 +2036,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"));
|
||||
|
@ -2051,15 +2068,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());
|
||||
|
@ -2148,10 +2168,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;
|
||||
|
@ -2166,11 +2188,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2210,7 +2259,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.
|
||||
|
@ -2418,6 +2467,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;
|
||||
|
@ -2529,8 +2608,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.
|
||||
|
@ -3661,7 +3746,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
|
||||
|
|
|
@ -153,9 +153,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.
|
||||
|
@ -268,7 +272,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;
|
||||
};
|
||||
|
||||
|
|
|
@ -375,17 +375,24 @@ static const t_config_enum_values s_keys_map_ZHopType = {
|
|||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ZHopType)
|
||||
|
||||
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)
|
||||
|
||||
static const t_config_enum_values s_keys_map_NozzleVolumeType = {
|
||||
{ "Normal", evtNormal },
|
||||
{ "Big Traffic", evtBigTraffic }
|
||||
{ "Normal", nvtNormal },
|
||||
{ "Big Traffic", nvtBigTraffic }
|
||||
};
|
||||
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)
|
||||
{
|
||||
|
@ -396,7 +403,7 @@ std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolume
|
|||
//extruder_type = etDirectDrive;
|
||||
return variant_string;
|
||||
}
|
||||
if (nozzle_volume_type > evtMaxNozzleVolumeType) {
|
||||
if (nozzle_volume_type > nvtMaxNozzleVolumeType) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(", unsupported NozzleVolumeType=%1%")%nozzle_volume_type;
|
||||
//extruder_type = etDirectDrive;
|
||||
return variant_string;
|
||||
|
@ -1543,6 +1550,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. "
|
||||
|
@ -2976,9 +2994,9 @@ void PrintConfigDef::init_fff_params()
|
|||
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("DirectDrive");
|
||||
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("Direct Drive"));
|
||||
def->enum_labels.push_back(L("Bowden"));
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionEnumsGeneric{ ExtruderType::etDirectDrive });
|
||||
|
@ -2989,16 +3007,16 @@ void PrintConfigDef::init_fff_params()
|
|||
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;
|
||||
def->set_default_value(new ConfigOptionEnumsGeneric{ NozzleVolumeType::evtNormal });
|
||||
def->set_default_value(new ConfigOptionEnumsGeneric{ NozzleVolumeType::nvtNormal });
|
||||
|
||||
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);
|
||||
|
@ -3010,7 +3028,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);
|
||||
|
@ -3022,7 +3040,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);
|
||||
|
@ -3034,7 +3052,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);
|
||||
|
@ -4153,7 +4177,7 @@ void PrintConfigDef::init_extruder_option_keys()
|
|||
{
|
||||
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
|
||||
m_extruder_option_keys = {
|
||||
"extruder_type", "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", "retraction_speed", "retract_lift_above", "retract_lift_below","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",
|
||||
|
@ -4971,21 +4995,84 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
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()
|
||||
|
@ -5422,21 +5509,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)(opt_extruder_type->get_at(extruder_id - 1));
|
||||
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType)(opt_nozzle_volume_type->get_at(extruder_id - 1));
|
||||
|
@ -5444,6 +5531,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 {
|
||||
|
@ -5456,6 +5549,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5464,7 +5562,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) {
|
||||
|
|
|
@ -289,9 +289,14 @@ enum ExtruderType {
|
|||
};
|
||||
|
||||
enum NozzleVolumeType {
|
||||
evtNormal = 0,
|
||||
evtBigTraffic,
|
||||
evtMaxNozzleVolumeType = evtBigTraffic
|
||||
nvtNormal = 0,
|
||||
nvtBigTraffic,
|
||||
nvtMaxNozzleVolumeType = nvtBigTraffic
|
||||
};
|
||||
|
||||
enum FilamentMapMode {
|
||||
fmmAuto,
|
||||
fmmManual
|
||||
};
|
||||
|
||||
extern std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type);
|
||||
|
@ -494,14 +499,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);
|
||||
|
||||
|
|
|
@ -2906,6 +2906,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:
|
||||
|
|
|
@ -139,6 +139,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
|
||||
|
@ -2827,6 +2829,53 @@ std::map<std::string, std::string> PartPlate::get_diff_plate_setting()
|
|||
return out;
|
||||
}
|
||||
|
||||
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),
|
||||
|
@ -3521,8 +3570,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;
|
||||
}
|
||||
|
@ -3534,6 +3585,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);
|
||||
|
@ -3579,6 +3632,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);
|
||||
|
@ -5493,7 +5548,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;
|
||||
|
||||
|
@ -5503,6 +5558,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);
|
||||
|
@ -5854,5 +5910,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
|
||||
|
|
|
@ -476,6 +476,16 @@ public:
|
|||
std::map<std::string, std::string> get_diff_object_setting();
|
||||
std::map<std::string, std::string> get_diff_plate_setting();
|
||||
|
||||
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;
|
||||
|
||||
|
@ -567,6 +577,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);
|
||||
|
@ -881,7 +893,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();
|
||||
|
||||
|
@ -902,6 +914,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];
|
||||
|
|
|
@ -1043,7 +1043,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
|
||||
|
@ -1056,7 +1056,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);
|
||||
|
@ -1921,6 +1921,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);
|
||||
|
@ -1932,6 +1933,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);
|
||||
|
@ -2299,22 +2301,22 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
|||
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
||||
auto& ams_filament_list = preset_bundle->filament_ams_list;
|
||||
|
||||
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;
|
||||
|
@ -2328,11 +2330,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
|
||||
|
@ -2359,7 +2361,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) {
|
||||
|
@ -2381,7 +2383,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;
|
||||
}
|
||||
}
|
||||
|
@ -3797,7 +3799,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, current_depth, current_height;
|
||||
int current_width, current_depth, current_height, project_filament_count = 1;
|
||||
|
||||
if (input_files.empty()) { return std::vector<size_t>(); }
|
||||
|
||||
|
@ -4074,7 +4076,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);
|
||||
|
@ -4293,6 +4296,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, &makerlab_region, &makerlab_name, &makerlab_id](std::vector<RGBA> &input_colors, bool is_single_color, std::vector<unsigned char> &filament_ids,
|
||||
unsigned char& first_extruder_id, std::string ml_origin, std::string ml_name, std::string ml_id) {
|
||||
|
@ -4382,7 +4386,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
if (obj->name.empty()) obj->name = fs::path(obj->input_file).filename().string();
|
||||
|
||||
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);
|
||||
|
@ -5461,7 +5465,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
|
||||
|
@ -13206,11 +13218,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) {
|
||||
|
@ -13227,7 +13240,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);
|
||||
|
||||
|
@ -13381,7 +13394,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);
|
||||
|
@ -13986,7 +13999,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)
|
||||
|
@ -14025,7 +14044,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;
|
||||
|
@ -14328,7 +14352,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…
Reference in New Issue