Skip to content

Commit

Permalink
ENH:display the euler angle of rotation plane
Browse files Browse the repository at this point in the history
Jira: STUDIO-5268
Change-Id: I6b7b431931d60f1a9a832908400417781798c472
  • Loading branch information
Haidiye00 authored and lanewei120 committed Nov 22, 2023
1 parent e21cbc0 commit 6677018
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ GLGizmoAdvancedCut::GLGizmoAdvancedCut(GLCanvas3D& parent, const std::string& ic
, m_connector_shape_id(size_t(CutConnectorShape::Circle))
{
set_group_id(m_gizmos.size());
m_rotation.setZero();
m_buffered_rotation.setZero();
}

Expand Down Expand Up @@ -388,7 +387,7 @@ void GLGizmoAdvancedCut::reset_cut_plane()

m_movement = 0.0;
m_height = box.size()[2] / 2.0;
m_rotation.setZero();
m_rotation = Geometry::extract_euler_angles(m_rotate_matrix);

m_buffered_movement = 0.0;
m_buffered_height = m_height;
Expand Down Expand Up @@ -567,7 +566,6 @@ void GLGizmoAdvancedCut::on_start_dragging()
}
}
m_rotate_angle = 0;
m_start_dragging_m = m_rotate_matrix;
} else if (m_hover_id >= c_cube_z_move_id && c_connectors_group_id) {
const Selection & selection = m_parent.get_selection();
const BoundingBoxf3 &box = selection.get_bounding_box();
Expand All @@ -581,8 +579,8 @@ void GLGizmoAdvancedCut::on_start_dragging()
} else if (m_hover_id == c_plate_move_id) {
m_drag_pos_start = m_plane_drag_start;
}
m_start_dragging_m = m_rotate_matrix;
}
m_start_dragging_m = m_rotate_matrix;
}

void GLGizmoAdvancedCut::on_stop_dragging()
Expand All @@ -600,7 +598,7 @@ void GLGizmoAdvancedCut::on_stop_dragging()
reset_cut_by_contours();
}
m_movement = 0.0;
m_rotation.setZero();
m_rotation = Geometry::extract_euler_angles(m_rotate_matrix);
}

void GLGizmoAdvancedCut::update_plate_center(Axis axis_type, double projection, bool is_abs_move) {
Expand All @@ -615,13 +613,14 @@ void GLGizmoAdvancedCut::update_plate_center(Axis axis_type, double projection,
}
}

void GLGizmoAdvancedCut::update_plate_normal_boundingbox_clipper(Vec3d rotation)
void GLGizmoAdvancedCut::update_plate_normal_boundingbox_clipper(const Transform3d &rotation_tmp)
{
const Transform3d rotation_tmp = Geometry::rotation_transform(rotation) * m_start_dragging_m;
const bool update_tbb = !m_rotate_matrix.rotation().isApprox(rotation_tmp.rotation());
m_rotate_matrix = rotation_tmp;
if (update_tbb) m_transformed_bounding_box = transformed_bounding_box(m_plane_center, m_rotate_matrix);
update_clipper();
if (update_tbb) {
m_rotate_matrix = rotation_tmp;
m_transformed_bounding_box = transformed_bounding_box(m_plane_center, m_rotate_matrix);
update_clipper();
}
}

void GLGizmoAdvancedCut::on_update(const UpdateData& data)
Expand All @@ -637,9 +636,11 @@ void GLGizmoAdvancedCut::on_update(const UpdateData& data)
if (rotation(i) < 0) rotation(i) = 2 * PI + rotation(i);
if (rotation(i) != 0) { m_rotate_angle = rotation(i); }
}
m_rotation = rotation;
const Transform3d rotation_tmp = Geometry::rotation_transform(rotation) * m_start_dragging_m;
// deal rotate
if (!is_approx(rotation, Vec3d(0, 0, 0))) { update_plate_normal_boundingbox_clipper(rotation); }
if (!is_approx(rotation, Vec3d(0, 0, 0))) {
update_plate_normal_boundingbox_clipper(rotation_tmp);
}
} // move plane
else if (m_hover_id == c_cube_z_move_id || m_hover_id == c_plate_move_id) {
double move = calc_projection(m_drag_pos_start, data.mouse_ray, m_plane_normal);
Expand Down Expand Up @@ -1872,9 +1873,11 @@ void GLGizmoAdvancedCut::render_cut_plane_input_window(float x, float y, float b
m_rotation(0) = Geometry::deg2rad(m_buffered_rotation(0));
m_rotation(1) = Geometry::deg2rad(m_buffered_rotation(1));
m_rotation(2) = Geometry::deg2rad(m_buffered_rotation(2));
update_plate_normal_boundingbox_clipper(m_rotation);

Geometry::Transformation tran;
tran.set_rotation(m_rotation);
update_plate_normal_boundingbox_clipper(tran.get_matrix());
reset_cut_by_contours();
m_rotation.setZero();
}

ImGui::Separator();
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class GLGizmoAdvancedCut : public GLGizmoRotate3D
virtual void on_start_dragging() override;
virtual void on_stop_dragging() override;
virtual void update_plate_center(Axis axis_type, double projection, bool is_abs_move); // old name:dragging_grabber_move
virtual void update_plate_normal_boundingbox_clipper(Vec3d rotation); // old name:dragging_grabber_rotation
virtual void update_plate_normal_boundingbox_clipper(const Transform3d &rotation_tmp); // old name:dragging_grabber_rotation
virtual void on_update(const UpdateData& data);
virtual void on_render();
virtual void on_render_for_picking();
Expand Down

0 comments on commit 6677018

Please sign in to comment.