mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' of https://github.com/prusa3d/Slic3r into svg_icons
This commit is contained in:
commit
e1eff8fa5c
5 changed files with 74 additions and 47 deletions
|
@ -5071,6 +5071,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
#endif // ENABLE_IMGUI
|
||||
|
||||
#ifdef __WXMSW__
|
||||
bool on_enter_workaround = false;
|
||||
if (! evt.Entering() && ! evt.Leaving() && m_mouse.position.x() == -1.0) {
|
||||
// Workaround for SPE-832: There seems to be a mouse event sent to the window before evt.Entering()
|
||||
|
@ -5080,7 +5081,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
printf((format_mouse_event_debug_message(evt) + " - OnEnter workaround\n").c_str());
|
||||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||
on_enter_workaround = true;
|
||||
} else {
|
||||
} else
|
||||
#endif /* __WXMSW__ */
|
||||
{
|
||||
#ifdef SLIC3R_DEBUG_MOUSE_EVENTS
|
||||
printf((format_mouse_event_debug_message(evt) + " - other\n").c_str());
|
||||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||
|
@ -5104,6 +5107,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
||||
|
||||
if (evt.ButtonDown() && wxWindow::FindFocus() != this->m_canvas)
|
||||
// Grab keyboard focus on any mouse click event.
|
||||
m_canvas->SetFocus();
|
||||
|
||||
if (evt.Entering())
|
||||
{
|
||||
//#if defined(__WXMSW__) || defined(__linux__)
|
||||
|
@ -5116,15 +5123,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
p = p->GetParent();
|
||||
auto *top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p);
|
||||
if (top_level_wnd && top_level_wnd->IsActive())
|
||||
{
|
||||
m_canvas->SetFocus();
|
||||
|
||||
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
|
||||
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
|
||||
// change the volume hover state if any is under the mouse
|
||||
m_mouse.position = pos.cast<double>();
|
||||
render();
|
||||
}
|
||||
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
|
||||
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
|
||||
// change the volume hover state if any is under the mouse
|
||||
m_mouse.position = pos.cast<double>();
|
||||
render();
|
||||
}
|
||||
m_mouse.set_start_position_2D_as_invalid();
|
||||
//#endif
|
||||
|
@ -5312,11 +5316,42 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
||||
m_mouse.dragging = true;
|
||||
|
||||
// Get new position at the same Z of the initial click point.
|
||||
float z0 = 0.0f;
|
||||
float z1 = 1.0f;
|
||||
Vec3d cur_pos = m_mouse.drag.start_position_3D;
|
||||
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
|
||||
Vec3d cur_pos = m_selection.contains_volume(m_hover_volume_id) ? Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)) : m_mouse.drag.start_position_3D;
|
||||
if (m_selection.contains_volume(m_hover_volume_id))
|
||||
{
|
||||
if (m_camera.get_theta() == 90.0f)
|
||||
{
|
||||
// side view -> move selected volumes orthogonally to camera view direction
|
||||
Linef3 ray = mouse_ray(pos);
|
||||
Vec3d dir = ray.unit_vector();
|
||||
// finds the intersection of the mouse ray with the plane parallel to the camera viewport and passing throught the starting position
|
||||
// use ray-plane intersection see i.e. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection algebric form
|
||||
// in our case plane normal and ray direction are the same (orthogonal view)
|
||||
// when moving to perspective camera the negative z unit axis of the camera needs to be transformed in world space and used as plane normal
|
||||
Vec3d inters = ray.a + (m_mouse.drag.start_position_3D - ray.a).dot(dir) / dir.squaredNorm() * dir;
|
||||
// vector from the starting position to the found intersection
|
||||
Vec3d inters_vec = inters - m_mouse.drag.start_position_3D;
|
||||
|
||||
// get the view matrix back from opengl
|
||||
GLfloat matrix[16];
|
||||
::glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
|
||||
Vec3d camera_right((double)matrix[0], (double)matrix[4], (double)matrix[8]);
|
||||
|
||||
// finds projection of the vector along the camera right axis
|
||||
double projection = inters_vec.dot(camera_right);
|
||||
|
||||
cur_pos = m_mouse.drag.start_position_3D + projection * camera_right;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generic view
|
||||
// Get new position at the same Z of the initial click point.
|
||||
float z0 = 0.0f;
|
||||
float z1 = 1.0f;
|
||||
cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2));
|
||||
}
|
||||
}
|
||||
|
||||
m_regenerate_volumes = false;
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D);
|
||||
|
@ -5533,8 +5568,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else
|
||||
evt.Skip();
|
||||
|
||||
#ifdef __WXMSW__
|
||||
if (on_enter_workaround)
|
||||
m_mouse.position = Vec2d(-1., -1.);
|
||||
#endif /* __WXMSW__ */
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_paint(wxPaintEvent& evt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue