FIX: save filament_maps to slice_info

and fix bug when switching printer preset between single-nozzle and double-nozzle, prompt the modification of extruder_count
jira:none

Change-Id: I1d5f0b2f002493378d2f482d08cfd5a72b35b99f
This commit is contained in:
zhimin.zeng 2024-07-12 14:08:42 +08:00 committed by lane.wei
parent 3179fd416e
commit ed98163973
4 changed files with 32 additions and 2 deletions

View File

@ -312,6 +312,9 @@ static constexpr const char* PLATERID_ATTR = "plater_id";
static constexpr const char* PLATER_NAME_ATTR = "plater_name";
static constexpr const char* PLATE_IDX_ATTR = "index";
static constexpr const char* PRINTER_MODEL_ID_ATTR = "printer_model_id";
static constexpr const char* EXTRUDER_TYPE_ATTR = "extruder_type";
static constexpr const char* NOZZLE_VOLUME_TYPE_ATTR = "nozzle_volume_type";
static constexpr const char* NOZZLE_TYPE_ATTR = "nozzle_types";
static constexpr const char* NOZZLE_DIAMETERS_ATTR = "nozzle_diameters";
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
static constexpr const char* SLICE_WEIGHT_ATTR = "weight";
@ -473,6 +476,16 @@ void add_vec3(std::stringstream &stream, const Slic3r::Vec3f &tr)
}
}
template<typename T>
void add_vector(std::stringstream &stream, const std::vector<T> &values)
{
for (size_t i = 0; i < values.size(); ++i) {
stream << values[i];
if (i != (values.size() - 1))
stream << " ";
}
}
Slic3r::Vec3f get_vec3_from_string(const std::string &pos_str)
{
Slic3r::Vec3f pos(0, 0, 0);
@ -7783,6 +7796,18 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
break;
}
}
std::vector<int> extruder_types = config.option<ConfigOptionEnumsGeneric>("extruder_type")->values;
std::vector<int> nozzle_volume_types = config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << EXTRUDER_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"";
add_vector(stream, extruder_types);
stream << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << NOZZLE_VOLUME_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"";
add_vector(stream, nozzle_volume_types);
stream << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PRINTER_MODEL_ID_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->printer_model_id << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << NOZZLE_DIAMETERS_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->nozzle_diameters << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"" << timelapse_type << "\"/>\n";
@ -7793,6 +7818,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SUPPORT_USED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_support_used << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LABEL_OBJECT_ENABLED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_label_object_enabled << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FILAMENT_MAP_ATTR << "\" " << VALUE_ATTR << "=\"";
add_vector<int>(stream, plate_data->filament_maps);
stream << "\"/>\n";
for (auto it = plate_data->objects_and_instances.begin(); it != plate_data->objects_and_instances.end(); it++)
{
int obj_id = it->first;

View File

@ -94,6 +94,7 @@ struct PlateData
bool toolpath_outside {false};
bool is_label_object_enabled {false};
int timelapse_warning_code = 0; // 1<<0 sprial vase, 1<<1 by object
std::vector<int> filament_maps;
std::vector<GCodeProcessorResult::SliceWarning> warnings;

View File

@ -208,7 +208,6 @@ private:
void fill_wipe_tower_partitions(const PrintConfig &config, coordf_t object_bottom_z, coordf_t max_layer_height);
void mark_skirt_layers(const PrintConfig &config, coordf_t max_layer_height);
void collect_extruder_statistics(bool prime_multi_material);
//std::vector<int> get_recommended_filament_maps();
void reorder_extruders_for_minimum_flush_volume();
// BBS

View File

@ -5477,9 +5477,10 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i)
{
PlateData* plate_data_item = new PlateData();
plate_data_item->filament_maps = m_plate_list[i]->get_filament_maps();
plate_data_item->locked = m_plate_list[i]->m_locked;
plate_data_item->plate_index = m_plate_list[i]->m_plate_index;
plate_data_item->plate_name = m_plate_list[i]->get_plate_name();
plate_data_item->plate_name = m_plate_list[i]->get_plate_name();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": plate %1% before load, width %2%, height %3%, size %4%!")
%(i+1) %m_plate_list[i]->thumbnail_data.width %m_plate_list[i]->thumbnail_data.height %m_plate_list[i]->thumbnail_data.pixels.size();
plate_data_item->plate_thumbnail.load_from(m_plate_list[i]->thumbnail_data);