Skip to content

Commit

Permalink
FIX:ban move glvolume when at cut and
Browse files Browse the repository at this point in the history
so on gizmo
jira:STUDIO-8408
part code is from OrcaSlicer,thanks for OrcaSlicer and Filip Sykala
commit 9dbb2dfe0d5395577a1f86fad7954771d7c77910
Author: Filip Sykala <[email protected]>
Date:   Sun Oct 29 23:11:10 2023 +0800

    Various gizmos refactoring

Change-Id: I7173e997bab1611c96643628fde9b147c54df5e6
  • Loading branch information
Haidiye00 authored and lanewei120 committed Oct 15, 2024
1 parent a26a7f1 commit 72245ed
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3475,7 +3475,10 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
m_dirty = true;
},
[this](const Vec3d& direction, bool slow, bool camera_space) {
m_selection.start_dragging();
if (m_gizmos.is_ban_move_glvolume()) {
return;
}
m_selection.setup_cache();
double multiplier = slow ? 1.0 : 10.0;

Vec3d displacement;
Expand All @@ -3490,7 +3493,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
TransformationType trafo_type;
trafo_type.set_relative();
m_selection.translate(displacement, trafo_type);
m_selection.stop_dragging();
m_dirty = true;
}
);}
Expand Down Expand Up @@ -3647,12 +3649,14 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
} else if (m_gizmos.is_enabled() && !m_selection.is_empty() && m_canvas_type != CanvasAssembleView) {
auto _do_rotate = [this](double angle_z_rad) {
if (m_gizmos.is_ban_move_glvolume()) {
return;
}
if (!m_gizmos.get_gizmo_active_condition(GLGizmosManager::EType::Rotate)) {
return;
}
m_selection.start_dragging();
m_selection.setup_cache();
m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint));
m_selection.stop_dragging();
m_dirty = true;
// wxGetApp().obj_manipul()->set_dirty();
};
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ void GLGizmoRotate3D::data_changed(bool is_serializing) {
}
m_object_manipulation->set_init_rotation(tran);
}
for (GLGizmoRotate &g : m_gizmos)
g.init_data_from_selection(m_parent.get_selection());
}

bool GLGizmoRotate3D::on_is_activable() const
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class GLGizmoRotate : public GLGizmoBase

void set_center(const Vec3d &point) { m_custom_center = point; }
void set_force_local_coordinate(bool use) { m_force_local_coordinate = use; }
void init_data_from_selection(const Selection &selection);

protected:
bool on_init() override;
Expand All @@ -80,7 +81,6 @@ class GLGizmoRotate : public GLGizmoBase
void transform_to_local(const Selection& selection) const;
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const;
void init_data_from_selection(const Selection &selection);
};

class GLGizmoRotate3D : public GLGizmoBase
Expand Down
12 changes: 12 additions & 0 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,18 @@ bool GLGizmosManager::is_show_only_active_plate()
return false;
}

bool GLGizmosManager::is_ban_move_glvolume()
{
auto current_type = get_current_type();
if (current_type == GLGizmosManager::EType::Undefined ||
current_type == GLGizmosManager::EType::Move ||
current_type == GLGizmosManager::EType::Rotate ||
current_type == GLGizmosManager::EType::Scale) {
return false;
}
return true;
}

bool GLGizmosManager::get_gizmo_active_condition(GLGizmosManager::EType type) {
if (auto cur_gizmo = get_gizmo(type)) {
return cur_gizmo->is_activable();
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class GLGizmosManager : public Slic3r::ObjectBase
bool is_gizmo_activable_when_single_full_instance();
bool is_gizmo_click_empty_not_exit();
bool is_show_only_active_plate();
bool is_ban_move_glvolume();
bool get_gizmo_active_condition(GLGizmosManager::EType type);
void check_object_located_outside_plate(bool change_plate =true);
bool get_object_located_outside_plate() { return m_object_located_outside_plate; }
Expand Down

0 comments on commit 72245ed

Please sign in to comment.