diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 9c074ef1e9..ca4b355d80 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1305,7 +1305,9 @@ void ModelObject::synchronize_model_after_cut() void ModelObject::apply_cut_attributes(ModelObjectCutAttributes attributes) { // we don't save cut information, if result will not contains all parts of initial object - if (!attributes.has(ModelObjectCutAttribute::KeepUpper) || !attributes.has(ModelObjectCutAttribute::KeepLower)) + if (!attributes.has(ModelObjectCutAttribute::KeepUpper) || + !attributes.has(ModelObjectCutAttribute::KeepLower) || + attributes.has(ModelObjectCutAttribute::InvalidateCutInfo)) return; if (cut_id.id().invalid()) @@ -1425,7 +1427,7 @@ void ModelObject::process_modifier_cut(ModelVolume* volume, const Transform3d& i lower->add_volume(*volume); } -static void add_cut_volume(TriangleMesh& mesh, ModelObject* object, const ModelVolume* src_volume, const Transform3d& cut_matrix) +static void add_cut_volume(TriangleMesh& mesh, ModelObject* object, const ModelVolume* src_volume, const Transform3d& cut_matrix, const std::string& suffix = {}) { if (mesh.empty()) return; @@ -1433,7 +1435,7 @@ static void add_cut_volume(TriangleMesh& mesh, ModelObject* object, const ModelV mesh.transform(cut_matrix); ModelVolume* vol = object->add_volume(mesh); - vol->name = src_volume->name; + vol->name = src_volume->name + suffix; // Don't copy the config's ID. vol->config.assign_config(src_volume->config); assert(vol->config.id().valid()); @@ -1478,8 +1480,8 @@ void ModelObject::process_solid_part_cut(ModelVolume* volume, const Transform3d& // Add required cut parts to the objects if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) { - add_cut_volume(lower_mesh, lower, volume, cut_matrix); - add_cut_volume(upper_mesh, lower, volume, cut_matrix); + add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A"); + add_cut_volume(lower_mesh, upper, volume, cut_matrix, "_B"); return; } @@ -1566,7 +1568,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Transform3d& cut_matrix, clone_for_cut(&upper); ModelObject* lower{ nullptr }; - if (attributes.has(ModelObjectCutAttribute::KeepLower)) + if (attributes.has(ModelObjectCutAttribute::KeepLower) && !attributes.has(ModelObjectCutAttribute::KeepAsParts)) clone_for_cut(&lower); std::vector dowels; @@ -1614,8 +1616,9 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Transform3d& cut_matrix, ModelObjectPtrs res; - if (attributes.has(ModelObjectCutAttribute::KeepAsParts) && !lower->volumes.empty()) { - res.push_back(lower); + if (attributes.has(ModelObjectCutAttribute::KeepAsParts) && !upper->volumes.empty()) { + reset_instance_transformation(upper, instance, cut_matrix); + res.push_back(upper); } else { if (attributes.has(ModelObjectCutAttribute::KeepUpper) && !upper->volumes.empty()) { diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index a1ae950d18..0e47cbe5c5 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -316,7 +316,7 @@ enum class ModelVolumeType : int { SUPPORT_ENFORCER, }; -enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, KeepAsParts, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels }; +enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, KeepAsParts, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels, InvalidateCutInfo }; using ModelObjectCutAttributes = enum_bitmask; ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 8b49ca6d3b..fa2df0c617 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -277,6 +277,8 @@ bool GLGizmoCut3D::on_mouse(const wxMouseEvent &mouse_event) if (mouse_event.ShiftDown() && mouse_event.LeftDown()) return gizmo_event(SLAGizmoEventType::LeftDown, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), mouse_event.CmdDown()); + if (mouse_event.CmdDown() && mouse_event.LeftDown()) + return false; if (cut_line_processing()) { if (mouse_event.ShiftDown()) { if (mouse_event.Moving()|| mouse_event.Dragging()) @@ -682,8 +684,12 @@ void GLGizmoCut3D::render_cut_plane() shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); - if (can_perform_cut() && has_valid_contour()) - m_plane.model.set_color({ 0.8f, 0.8f, 0.8f, 0.5f }); + if (can_perform_cut() && has_valid_contour()) { + if (m_hover_id == CutPlane) + m_plane.model.set_color({ 0.9f, 0.9f, 0.9f, 0.5f }); + else + m_plane.model.set_color({ 0.8f, 0.8f, 0.8f, 0.5f }); + } else m_plane.model.set_color({ 1.0f, 0.8f, 0.8f, 0.5f }); m_plane.model.render(); @@ -1677,8 +1683,7 @@ void GLGizmoCut3D::set_connectors_editing(bool connectors_editing) void GLGizmoCut3D::flip_cut_plane() { - m_rotation_m = m_start_dragging_m * rotation_transform(PI * Vec3d::UnitX()); - + m_rotation_m = m_rotation_m * rotation_transform(PI * Vec3d::UnitX()); Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Flip cut plane"), UndoRedo::SnapshotType::GizmoAction); m_start_dragging_m = m_rotation_m; @@ -1760,7 +1765,7 @@ void GLGizmoCut3D::render_cut_plane_input_window(CutConnectors &connectors) add_vertical_scaled_interval(0.75f); - m_imgui->disabled_begin(!m_keep_upper || !m_keep_lower); + m_imgui->disabled_begin(!m_keep_upper || !m_keep_lower || m_keep_as_parts); if (m_imgui->button(has_connectors ? _L("Edit connectors") : _L("Add connectors"))) set_connectors_editing(true); m_imgui->disabled_end(); @@ -2247,7 +2252,8 @@ void GLGizmoCut3D::perform_cut(const Selection& selection) only_if(m_place_on_cut_lower, ModelObjectCutAttribute::PlaceOnCutLower) | only_if(m_rotate_upper, ModelObjectCutAttribute::FlipUpper) | only_if(m_rotate_lower, ModelObjectCutAttribute::FlipLower) | - only_if(create_dowels_as_separate_object, ModelObjectCutAttribute::CreateDowels)); + only_if(create_dowels_as_separate_object, ModelObjectCutAttribute::CreateDowels) | + only_if(!has_connectors, ModelObjectCutAttribute::InvalidateCutInfo)); } } @@ -2482,7 +2488,7 @@ bool GLGizmoCut3D::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_posi if (is_dragging() || m_connector_mode == CutConnectorMode::Auto) return false; - if ( m_hover_id < 0 && shift_down && ! m_connectors_editing && + if ( (m_hover_id < 0 || m_hover_id == CutPlane) && shift_down && ! m_connectors_editing && (action == SLAGizmoEventType::LeftDown || action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::Moving) ) return process_cut_line(action, mouse_position);