SPE-1667 - Added 'Zoom to mouse cursor' by Shift+Mouse wheel
Successfully enhanced and integrated into PrusaSlicer from 3f2ee4062b
Co-authored-by: liz.li <liz.li@bambulab.com>
Co-authored-by: lane.wei <lane.wei@bambulab.com>
This commit is contained in:
parent
9e56625287
commit
85dd2e486a
@ -2939,8 +2939,21 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
||||
return;
|
||||
|
||||
// Calculate the zoom delta and apply it to the current zoom factor
|
||||
double direction_factor = wxGetApp().app_config->get_bool("reverse_mouse_wheel_zoom") ? -1.0 : 1.0;
|
||||
_update_camera_zoom(direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta());
|
||||
const double direction_factor = wxGetApp().app_config->get_bool("reverse_mouse_wheel_zoom") ? -1.0 : 1.0;
|
||||
const double delta = direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta();
|
||||
if (wxGetKeyState(WXK_SHIFT)) {
|
||||
const auto cnv_size = get_canvas_size();
|
||||
const auto screen_center_3d_pos = _mouse_to_3d({ cnv_size.get_width() * 0.5, cnv_size.get_height() * 0.5 });
|
||||
const auto mouse_3d_pos = _mouse_to_3d({ evt.GetX(), evt.GetY() });
|
||||
const Vec3d displacement = mouse_3d_pos - screen_center_3d_pos;
|
||||
wxGetApp().plater()->get_camera().translate_world(displacement);
|
||||
const double origin_zoom = wxGetApp().plater()->get_camera().get_zoom();
|
||||
_update_camera_zoom(delta);
|
||||
const double new_zoom = wxGetApp().plater()->get_camera().get_zoom();
|
||||
wxGetApp().plater()->get_camera().translate_world((-displacement) / (new_zoom / origin_zoom));
|
||||
}
|
||||
else
|
||||
_update_camera_zoom(delta);
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
||||
|
Loading…
Reference in New Issue
Block a user