ENH: optimize error notification when slicing

support error notification if max_z_layer height exceed max print height

Change-Id: I02d3f479f09df7ca01c85c97aa471f50b3cf9b46
This commit is contained in:
xun.zhang 2023-06-29 18:12:26 +08:00 committed by Lane.Wei
parent c5de582fbd
commit 8cf98f10a4
3 changed files with 17 additions and 7 deletions

View File

@ -830,10 +830,12 @@ public:
bool can_export_toolpaths() const;
std::vector<int> get_plater_extruder();
const float get_max_print_height() const { return m_max_print_height; }
const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; }
const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; }
const BoundingBoxf3& get_shell_bounding_box() const { return m_shell_bounding_box; }
const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
const std::array<unsigned int,2> &get_layers_z_range() const { return m_layers_z_range; }
const SequentialView& get_sequential_view() const { return m_sequential_view; }
void update_sequential_view_current(unsigned int first, unsigned int last);

View File

@ -2758,6 +2758,7 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
if (wxGetApp().is_editor()) {
//BBS: always load shell at preview, do this in load_shells
//m_gcode_viewer.update_shells_color_by_extruder(m_config);
_set_warning_notification_if_needed(EWarning::ToolHeightOutside);
_set_warning_notification_if_needed(EWarning::ToolpathOutside);
_set_warning_notification_if_needed(EWarning::GCodeConflict);
}
@ -8870,14 +8871,19 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning)
if (!m_volumes.empty()) {
show = _is_any_volume_outside();
show &= m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.m_conflict_result.has_value();
}
else {
} else {
if (wxGetApp().is_editor()) {
if (current_printer_technology() != ptSLA)
if (warning == EWarning::ToolpathOutside)
show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
else if (warning==EWarning::GCodeConflict)
if (current_printer_technology() != ptSLA) {
unsigned int max_z_layer = m_gcode_viewer.get_layers_z_range().back();
if (warning == EWarning::ToolHeightOutside) // check if max z_layer height exceed max print height
show = m_gcode_viewer.has_data() && (m_gcode_viewer.get_layers_zs()[max_z_layer] - m_gcode_viewer.get_max_print_height() >= 1e-6);
else if (warning == EWarning::ToolpathOutside) { // check if max x,y coords exceed bed area
show = m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed() &&
(m_gcode_viewer.get_max_print_height() -m_gcode_viewer.get_layers_zs()[max_z_layer] >= 1e-6);
}
else if (warning == EWarning::GCodeConflict)
show = m_gcode_viewer.has_data() && m_gcode_viewer.is_contained_in_bed() && m_gcode_viewer.m_conflict_result.has_value();
}
}
}
@ -8936,6 +8942,7 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
break;
}
case EWarning::ObjectOutside: text = _u8L("An object is layed over the boundary of plate."); break;
case EWarning::ToolHeightOutside: text = _u8L("A G-code path goes beyond the max print height."); error = ErrorType::SLICING_ERROR; break;
case EWarning::ToolpathOutside: text = _u8L("A G-code path goes beyond the boundary of plate."); error = ErrorType::SLICING_ERROR; break;
// BBS: remove _u8L() for SLA
case EWarning::SlaSupportsOutside: text = ("SLA supports outside the print area were detected."); error = ErrorType::PLATER_ERROR; break;

View File

@ -374,7 +374,8 @@ class GLCanvas3D
SlaSupportsOutside,
SomethingNotShown,
ObjectClashed,
GCodeConflict
GCodeConflict,
ToolHeightOutside
};
class RenderStats