mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 03:12:04 +08:00
Cut bug fixing:
* Disable "Add/Edit connectors" button then cut to parts * Fixed flip_cut_plane() * Fixed cut by Line, when draw line over the cut plane * Fixed apply of the transformations, when cut to parts Cut improvements: * Process "Ctrl" * Change color of the cut plane when it's hovered * Don't apply Cut information for result object(s), if cut doesn't have any connector or is cut to parts (partially related to #9633 - Add option to Invalidate Cut Info at the time of cutting)
This commit is contained in:
parent
8c28b60125
commit
ffd484eb04
@ -1305,7 +1305,9 @@ void ModelObject::synchronize_model_after_cut()
|
|||||||
void ModelObject::apply_cut_attributes(ModelObjectCutAttributes attributes)
|
void ModelObject::apply_cut_attributes(ModelObjectCutAttributes attributes)
|
||||||
{
|
{
|
||||||
// we don't save cut information, if result will not contains all parts of initial object
|
// 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;
|
return;
|
||||||
|
|
||||||
if (cut_id.id().invalid())
|
if (cut_id.id().invalid())
|
||||||
@ -1425,7 +1427,7 @@ void ModelObject::process_modifier_cut(ModelVolume* volume, const Transform3d& i
|
|||||||
lower->add_volume(*volume);
|
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())
|
if (mesh.empty())
|
||||||
return;
|
return;
|
||||||
@ -1433,7 +1435,7 @@ static void add_cut_volume(TriangleMesh& mesh, ModelObject* object, const ModelV
|
|||||||
mesh.transform(cut_matrix);
|
mesh.transform(cut_matrix);
|
||||||
ModelVolume* vol = object->add_volume(mesh);
|
ModelVolume* vol = object->add_volume(mesh);
|
||||||
|
|
||||||
vol->name = src_volume->name;
|
vol->name = src_volume->name + suffix;
|
||||||
// Don't copy the config's ID.
|
// Don't copy the config's ID.
|
||||||
vol->config.assign_config(src_volume->config);
|
vol->config.assign_config(src_volume->config);
|
||||||
assert(vol->config.id().valid());
|
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
|
// Add required cut parts to the objects
|
||||||
|
|
||||||
if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
|
if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
|
||||||
add_cut_volume(lower_mesh, lower, volume, cut_matrix);
|
add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A");
|
||||||
add_cut_volume(upper_mesh, lower, volume, cut_matrix);
|
add_cut_volume(lower_mesh, upper, volume, cut_matrix, "_B");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1566,7 +1568,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Transform3d& cut_matrix,
|
|||||||
clone_for_cut(&upper);
|
clone_for_cut(&upper);
|
||||||
|
|
||||||
ModelObject* lower{ nullptr };
|
ModelObject* lower{ nullptr };
|
||||||
if (attributes.has(ModelObjectCutAttribute::KeepLower))
|
if (attributes.has(ModelObjectCutAttribute::KeepLower) && !attributes.has(ModelObjectCutAttribute::KeepAsParts))
|
||||||
clone_for_cut(&lower);
|
clone_for_cut(&lower);
|
||||||
|
|
||||||
std::vector<ModelObject*> dowels;
|
std::vector<ModelObject*> dowels;
|
||||||
@ -1614,8 +1616,9 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Transform3d& cut_matrix,
|
|||||||
|
|
||||||
ModelObjectPtrs res;
|
ModelObjectPtrs res;
|
||||||
|
|
||||||
if (attributes.has(ModelObjectCutAttribute::KeepAsParts) && !lower->volumes.empty()) {
|
if (attributes.has(ModelObjectCutAttribute::KeepAsParts) && !upper->volumes.empty()) {
|
||||||
res.push_back(lower);
|
reset_instance_transformation(upper, instance, cut_matrix);
|
||||||
|
res.push_back(upper);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper) && !upper->volumes.empty()) {
|
if (attributes.has(ModelObjectCutAttribute::KeepUpper) && !upper->volumes.empty()) {
|
||||||
|
@ -316,7 +316,7 @@ enum class ModelVolumeType : int {
|
|||||||
SUPPORT_ENFORCER,
|
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<ModelObjectCutAttribute>;
|
using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
|
||||||
ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
|
ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
|
||||||
|
|
||||||
|
@ -277,6 +277,8 @@ bool GLGizmoCut3D::on_mouse(const wxMouseEvent &mouse_event)
|
|||||||
|
|
||||||
if (mouse_event.ShiftDown() && mouse_event.LeftDown())
|
if (mouse_event.ShiftDown() && mouse_event.LeftDown())
|
||||||
return gizmo_event(SLAGizmoEventType::LeftDown, mouse_pos, mouse_event.ShiftDown(), mouse_event.AltDown(), mouse_event.CmdDown());
|
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 (cut_line_processing()) {
|
||||||
if (mouse_event.ShiftDown()) {
|
if (mouse_event.ShiftDown()) {
|
||||||
if (mouse_event.Moving()|| mouse_event.Dragging())
|
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("view_model_matrix", view_model_matrix);
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
|
||||||
if (can_perform_cut() && has_valid_contour())
|
if (can_perform_cut() && has_valid_contour()) {
|
||||||
m_plane.model.set_color({ 0.8f, 0.8f, 0.8f, 0.5f });
|
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
|
else
|
||||||
m_plane.model.set_color({ 1.0f, 0.8f, 0.8f, 0.5f });
|
m_plane.model.set_color({ 1.0f, 0.8f, 0.8f, 0.5f });
|
||||||
m_plane.model.render();
|
m_plane.model.render();
|
||||||
@ -1677,8 +1683,7 @@ void GLGizmoCut3D::set_connectors_editing(bool connectors_editing)
|
|||||||
|
|
||||||
void GLGizmoCut3D::flip_cut_plane()
|
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);
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Flip cut plane"), UndoRedo::SnapshotType::GizmoAction);
|
||||||
m_start_dragging_m = m_rotation_m;
|
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);
|
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")))
|
if (m_imgui->button(has_connectors ? _L("Edit connectors") : _L("Add connectors")))
|
||||||
set_connectors_editing(true);
|
set_connectors_editing(true);
|
||||||
m_imgui->disabled_end();
|
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_place_on_cut_lower, ModelObjectCutAttribute::PlaceOnCutLower) |
|
||||||
only_if(m_rotate_upper, ModelObjectCutAttribute::FlipUpper) |
|
only_if(m_rotate_upper, ModelObjectCutAttribute::FlipUpper) |
|
||||||
only_if(m_rotate_lower, ModelObjectCutAttribute::FlipLower) |
|
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)
|
if (is_dragging() || m_connector_mode == CutConnectorMode::Auto)
|
||||||
return false;
|
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) )
|
(action == SLAGizmoEventType::LeftDown || action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::Moving) )
|
||||||
return process_cut_line(action, mouse_position);
|
return process_cut_line(action, mouse_position);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user