Add warning info on spirail lift before slicing

This commit is contained in:
xiaoyeliu
2026-01-24 14:09:42 +08:00
parent b8bf1a8fe1
commit cf4275198c
7 changed files with 339 additions and 1 deletions

View File

@@ -1110,6 +1110,32 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
int64_t comp_id = ((int64_t)volume->composite_id.object_id << 32) | ((int64_t)volume->composite_id.instance_id);
volume->is_outside = state != BuildVolume::ObjectState::Inside;
// Snapmaker: 检测模型是否距离床边界太近(螺旋抬升风险)
volume->near_boundary_for_spiral_lift = false;
// 只对矩形床进行检测Snapmaker U1
if (plate_build_volume.type() == BuildVolume_Type::Rectangle && volume->composite_id.volume_id >= 0) {
constexpr double SPIRAL_LIFT_SAFETY_MARGIN = 3.5; // mm
const BoundingBoxf3& bb = volume_bbox(*volume);
const BoundingBoxf3& bed_bb = plate_build_volume.bounding_volume();
// 计算模型边界框与床边界的最小距离(使用绝对值处理超出边界的情况)
double min_distance_x = std::min({
std::abs(bb.min.x() - bed_bb.min.x()),
std::abs(bed_bb.max.x() - bb.max.x())
});
double min_distance_y = std::min({
std::abs(bb.min.y() - bed_bb.min.y()),
std::abs(bed_bb.max.y() - bb.max.y())
});
double min_distance = std::min({min_distance_x, min_distance_y});
// 如果最小距离小于安全余量,触发警告
if (min_distance < SPIRAL_LIFT_SAFETY_MARGIN) {
volume->near_boundary_for_spiral_lift = true;
}
}
//volume->partly_inside = (state == BuildVolume::ObjectState::Colliding);
if (volume->printable) {
if (overall_state == ModelInstancePVS_Inside && volume->is_outside) {
@@ -1185,10 +1211,22 @@ void GLVolumeCollection::reset_outside_state()
if (volume != nullptr) {
volume->is_outside = false;
volume->partly_inside = false;
volume->near_boundary_for_spiral_lift = false; // Snapmaker: 初始化螺旋抬升边界状态
}
}
}
// Snapmaker: 检查是否有任何 volume 靠近边界(螺旋抬升风险)
bool GLVolumeCollection::is_any_volume_near_boundary_for_spiral_lift() const
{
for (const GLVolume* volume : this->volumes)
{
if (volume != nullptr && volume->near_boundary_for_spiral_lift)
return true;
}
return false;
}
void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig *config, bool is_update_alpha)
{

View File

@@ -185,6 +185,8 @@ public:
// Wheter or not this volume is outside print volume.
bool is_outside : 1;
bool partly_inside : 1;
// Snapmaker: Whether or not this volume is too close to boundary for spiral lift
bool near_boundary_for_spiral_lift : 1;
// Wheter or not this volume has been generated from a modifier
bool is_modifier : 1;
// Wheter or not this volume has been generated from the wipe tower
@@ -516,6 +518,8 @@ public:
// returns the containment state in the given out_state, if non-null
bool check_outside_state(const Slic3r::BuildVolume& build_volume, ModelInstanceEPrintVolumeState* out_state) const;
void reset_outside_state();
// Snapmaker: 检查是否有任何 volume 靠近边界(螺旋抬升风险)
bool is_any_volume_near_boundary_for_spiral_lift() const;
void update_colors_by_extruder(const DynamicPrintConfig *config, bool is_update_alpha = true);

View File

@@ -2823,6 +2823,13 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
if (printer_technology != ptSLA || !contained_min_one)
_set_warning_notification(EWarning::SlaSupportsOutside, false);
// Snapmaker: 螺旋抬升边界警告 - 无论模型是否超出边界都检测
if (contained_min_one) {
_set_warning_notification(EWarning::SpiralLiftNearBoundary, _is_any_volume_near_boundary_for_spiral_lift());
} else {
_set_warning_notification(EWarning::SpiralLiftNearBoundary, false);
}
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS,
contained_min_one && !m_model->objects.empty() && !partlyOut));
}
@@ -2830,6 +2837,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
_set_warning_notification(EWarning::ObjectOutside, false);
_set_warning_notification(EWarning::ObjectClashed, false);
_set_warning_notification(EWarning::SlaSupportsOutside, false);
_set_warning_notification(EWarning::SpiralLiftNearBoundary, false); // Snapmaker: 清空警告
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, false));
}
}
@@ -9696,6 +9704,13 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
"Please solve the problem by moving it totally on or off the plate, and confirming that the height is within the build volume.");
error = ErrorType::PLATER_ERROR;
break;
// Snapmaker: 螺旋抬升靠近边界警告
case EWarning::SpiralLiftNearBoundary:
text = _u8L("An object is too close to the plate boundary. "
"Spiral lift during printing may exceed the bed and cause a crash. "
"Please move the object away from the edge (recommend keeping at least 3mm distance).");
error = ErrorType::SLICING_SERIOUS_WARNING;
break;
}
//BBS: this may happened when exit the app, plater is null
if (!wxGetApp().plater())
@@ -9750,6 +9765,12 @@ bool GLCanvas3D::_is_any_volume_outside() const
return false;
}
// Snapmaker: 检查是否有任何 volume 靠近边界(螺旋抬升风险)
bool GLCanvas3D::_is_any_volume_near_boundary_for_spiral_lift() const
{
return m_volumes.is_any_volume_near_boundary_for_spiral_lift();
}
void GLCanvas3D::_update_selection_from_hover()
{
bool ctrl_pressed = wxGetKeyState(WXK_CONTROL);

View File

@@ -381,7 +381,8 @@ class GLCanvas3D
SomethingNotShown,
ObjectClashed,
GCodeConflict,
ToolHeightOutside
ToolHeightOutside,
SpiralLiftNearBoundary // Snapmaker: 螺旋抬升靠近边界警告
};
class RenderStats
@@ -1238,6 +1239,8 @@ private:
void _set_warning_notification(EWarning warning, bool state);
bool _is_any_volume_outside() const;
// Snapmaker: 检查是否有任何 volume 靠近边界(螺旋抬升风险)
bool _is_any_volume_near_boundary_for_spiral_lift() const;
// updates the selection from the content of m_hover_volume_idxs
void _update_selection_from_hover();