mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 15:37:30 -06:00
ENH: zooming at mouse position
https://github.com/bambulab/BambuStudio/issues/1321 Change-Id: Ifa5c2b2931a5d80c3e5e5cc05eda76263a5ac570
This commit is contained in:
parent
01bb20e4e1
commit
3f2ee4062b
3 changed files with 25 additions and 2 deletions
|
@ -3585,7 +3585,21 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
|||
#else
|
||||
double direction_factor = 1.0;
|
||||
#endif
|
||||
_update_camera_zoom(direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta());
|
||||
auto delta = direction_factor * (double)evt.GetWheelRotation() / (double)evt.GetWheelDelta();
|
||||
if (evt.CmdDown()) {
|
||||
_update_camera_zoom(delta);
|
||||
}
|
||||
else {
|
||||
auto cnv_size = get_canvas_size();
|
||||
auto screen_center_3d_pos = _mouse_to_3d({ cnv_size.get_width() * 0.5, cnv_size.get_height() * 0.5 });
|
||||
auto mouse_3d_pos = _mouse_to_3d({evt.GetX(), evt.GetY()});
|
||||
Vec3d displacement = mouse_3d_pos - screen_center_3d_pos;
|
||||
wxGetApp().plater()->get_camera().translate(displacement);
|
||||
auto origin_zoom = wxGetApp().plater()->get_camera().get_zoom();
|
||||
_update_camera_zoom(delta);
|
||||
auto new_zoom = wxGetApp().plater()->get_camera().get_zoom();
|
||||
wxGetApp().plater()->get_camera().translate((-displacement) / (new_zoom / origin_zoom));
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue