Skip to content

Commit

Permalink
NEW: add slice warning msg to slice_info
Browse files Browse the repository at this point in the history
Change-Id: I145a14b7ab6f4aff2158ca0f86191e57b7efa643
  • Loading branch information
StoneLiBambulab authored and lanewei120 committed Oct 20, 2022
1 parent 2ed7027 commit 82a1a38
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
44 changes: 44 additions & 0 deletions src/libslic3r/Format/bbs_3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ static constexpr const char* BUILD_TAG = "build";
static constexpr const char* ITEM_TAG = "item";
static constexpr const char* METADATA_TAG = "metadata";
static constexpr const char* FILAMENT_TAG = "filament";
static constexpr const char* SLICE_WARNING_TAG = "warning";
static constexpr const char* WARNING_MSG_TAG = "msg";
static constexpr const char *FILAMENT_ID_TAG = "id";
static constexpr const char* FILAMENT_TYPE_TAG = "type";
static constexpr const char *FILAMENT_COLOR_TAG = "color";
Expand Down Expand Up @@ -460,6 +462,14 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
info.used_g = used_filament_g;
slice_filaments_info.push_back(info);
}

/* only for test
GCodeProcessorResult::SliceWarnings sw;
sw.msg = BED_TEMP_TOO_HIGH_THAN_FILAMENT;
sw.level = 1;
result->warnings.push_back(sw);
*/
warnings = result->warnings;
}


Expand Down Expand Up @@ -843,6 +853,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
bool _handle_start_config_filament(const char** attributes, unsigned int num_attributes);
bool _handle_end_config_filament();

bool _handle_start_config_warning(const char** attributes, unsigned int num_attributes);
bool _handle_end_config_warning();

//BBS: add plater config parse functions
bool _handle_start_config_plater(const char** attributes, unsigned int num_attributes);
bool _handle_end_config_plater();
Expand Down Expand Up @@ -1510,6 +1523,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
plate_data_list[it->first-1]->gcode_weight = it->second->gcode_weight;
plate_data_list[it->first-1]->toolpath_outside = it->second->toolpath_outside;
plate_data_list[it->first-1]->slice_filaments_info = it->second->slice_filaments_info;
plate_data_list[it->first-1]->warnings = it->second->warnings;
plate_data_list[it->first-1]->thumbnail_file = (m_load_restore || it->second->thumbnail_file.empty()) ? it->second->thumbnail_file : m_backup_path + "/" + it->second->thumbnail_file;
plate_data_list[it->first-1]->pattern_file = (m_load_restore || it->second->pattern_file.empty()) ? it->second->pattern_file : m_backup_path + "/" + it->second->pattern_file;
plate_data_list[it->first-1]->pattern_bbox_file = (m_load_restore || it->second->pattern_bbox_file.empty()) ? it->second->pattern_bbox_file : m_backup_path + "/" + it->second->pattern_bbox_file;
Expand Down Expand Up @@ -2355,6 +2369,8 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
res = _handle_start_config_plater_instance(attributes, num_attributes);
else if (::strcmp(FILAMENT_TAG, name) == 0)
res = _handle_start_config_filament(attributes, num_attributes);
else if (::strcmp(SLICE_WARNING_TAG, name) == 0)
res = _handle_start_config_warning(attributes, num_attributes);
else if (::strcmp(ASSEMBLE_TAG, name) == 0)
res = _handle_start_assemble(attributes, num_attributes);
else if (::strcmp(ASSEMBLE_ITEM_TAG, name) == 0)
Expand Down Expand Up @@ -3205,6 +3221,30 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
return true;
}

bool _BBS_3MF_Importer::_handle_start_config_warning(const char** attributes, unsigned int num_attributes)
{
if (m_curr_plater) {
std::string msg = bbs_get_attribute_value_string(attributes, num_attributes, WARNING_MSG_TAG);
std::string lvl_str = bbs_get_attribute_value_string(attributes, num_attributes, "level");
GCodeProcessorResult::SliceWarnings sw;
sw.msg = msg;
try {
sw.level = atoi(lvl_str.c_str());
}
catch(...) {
};

m_curr_plater->warnings.push_back(sw);
}
return true;
}

bool _BBS_3MF_Importer::_handle_end_config_warning()
{
// do nothing
return true;
}

bool _BBS_3MF_Importer::_handle_start_config_plater(const char** attributes, unsigned int num_attributes)
{
if (!m_parsing_slice_info) {
Expand Down Expand Up @@ -5639,6 +5679,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
<< FILAMENT_USED_M_TAG << "=\"" << it->used_m << "\" "
<< FILAMENT_USED_G_TAG << "=\"" << it->used_g << "\" />\n";
}

for (auto it = plate_data->warnings.begin(); it != plate_data->warnings.end(); it++) {
stream << " <" << SLICE_WARNING_TAG << " " << "msg=\"" << it->msg << "\" " << "level=\"" << std::to_string(it->level) << "\" />\n";
}
stream << " </" << PLATE_TAG << ">\n";
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Format/bbs_3mf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct PlateData
bool is_sliced_valid = false;
bool toolpath_outside {false};

std::vector<GCodeProcessorResult::SliceWarnings> warnings;

std::string get_gcode_prediction_str() {
return gcode_prediction;
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/PartPlate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4106,7 +4106,7 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
ps.total_used_filament *= 1000; //koef
gcode_result->toolpath_outside = plate_data_list[i]->toolpath_outside;
m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info;

gcode_result->warnings = plate_data_list[i]->warnings;
if (!plate_data_list[i]->thumbnail_file.empty()) {
if (boost::filesystem::exists(plate_data_list[i]->thumbnail_file)) {
m_plate_list[index]->load_thumbnail_data(plate_data_list[i]->thumbnail_file);
Expand Down

0 comments on commit 82a1a38

Please sign in to comment.