Fix: collision warnings (#12122)
* Fix: Enable instance collision detection in GCode and Print clearance Squashed commit containing: - Fix gcode path conflict detection in ConflictChecker.cpp by iterating all instances. - Improve clearance validation in Print.cpp by calculating convex hulls per instance (fixes scaling/mirroring issues). - Added // Orca: comments to mark changes. * Fix Wipe Tower G-code conflict detection for WipeTower2 * Fix: Improve object/instance selection for collision and validation warnings - Updated validation logic in Print.cpp to report specific ModelInstance instead of ModelObject for collision/clearance warnings. - Updated NotificationManager and Plater to handle ModelInstance selection in 'Jump to' links. - Added fallback to object selection if specific instance cannot be selected. - Included fixes for G-code conflict detection (ConflictChecker, GLCanvas3D) to also report instances. - Improved GUI_ObjectList to update canvas selection when items are selected via API. * Fix: Prevent crash when loading .3mf projects Moved update_selections_on_canvas() out of ObjectList::select_items() to avoid premature UI updates during loading. Canvas updates are now explicitly called in NotificationManager and Plater callbacks where needed. * Fix: Address code review comments - Fix memory allocation for extrusion layers deep copy - Remove unused variable in GLCanvas3D - Fix string formatting crash risk in NotificationManager - Remove dead code in Plater --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
@@ -9496,6 +9496,7 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
std::string text;
|
||||
ErrorType error = ErrorType::PLATER_WARNING;
|
||||
const ModelObject* conflictObj=nullptr;
|
||||
const ModelInstance* conflictInst=nullptr;
|
||||
switch (warning) {
|
||||
case EWarning::GCodeConflict: {
|
||||
static std::string prevConflictText;
|
||||
@@ -9506,12 +9507,17 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
std::string objName2 = m_gcode_viewer.m_conflict_result.value()._objName2;
|
||||
double height = m_gcode_viewer.m_conflict_result.value()._height;
|
||||
int layer = m_gcode_viewer.m_conflict_result.value().layer;
|
||||
const PrintInstance *inst2 = reinterpret_cast<const PrintInstance *>(m_gcode_viewer.m_conflict_result.value()._obj2);
|
||||
|
||||
text = (boost::format(_u8L("Conflicts of G-code paths have been found at layer %d, Z = %.2lfmm. Please separate the conflicted objects farther (%s <-> %s).")) % layer %
|
||||
height % objName1 % objName2)
|
||||
.str();
|
||||
prevConflictText = text;
|
||||
const PrintObject *obj2 = reinterpret_cast<const PrintObject *>(m_gcode_viewer.m_conflict_result.value()._obj2);
|
||||
conflictObj = obj2->model_object();
|
||||
|
||||
if (inst2) {
|
||||
if (inst2->model_instance) conflictInst = inst2->model_instance;
|
||||
else if (inst2->print_object) conflictObj = inst2->print_object->model_object();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EWarning::ObjectOutside: text = _u8L("An object is laid over the plate boundaries."); break;
|
||||
@@ -9759,8 +9765,13 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state)
|
||||
}
|
||||
break;
|
||||
case SLICING_SERIOUS_WARNING:
|
||||
if (state)
|
||||
notification_manager.push_slicing_serious_warning_notification(text, conflictObj ? std::vector<ModelObject const*>{conflictObj} : std::vector<ModelObject const*>{});
|
||||
if (state) {
|
||||
if (conflictInst) {
|
||||
notification_manager.push_slicing_serious_warning_notification(text, std::vector<ModelInstance const*>{conflictInst});
|
||||
} else {
|
||||
notification_manager.push_slicing_serious_warning_notification(text, conflictObj ? std::vector<ModelObject const*>{conflictObj} : std::vector<ModelObject const*>{});
|
||||
}
|
||||
}
|
||||
else
|
||||
notification_manager.close_slicing_serious_warning_notification(text);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user