SLA clipping plane can now be controlled by Ctrl + mouse wheel rotation

This commit is contained in:
Lukas Matena 2019-04-17 10:16:39 +02:00
parent 00ed0de815
commit 8df2a19974
5 changed files with 37 additions and 1 deletions

View File

@ -2374,6 +2374,10 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
}
}
// Inform gizmos about the event so they have the opportunity to react.
if (m_gizmos.on_mouse_wheel(evt, *this))
return;
// Calculate the zoom delta and apply it to the current zoom factor
float zoom = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta();
set_camera_zoom(zoom);

View File

@ -708,6 +708,18 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
}
}
if (action == SLAGizmoEventType::MouseWheelUp && control_down) {
m_clipping_plane_distance = std::min(1.f, m_clipping_plane_distance + 0.01f);
m_parent.set_as_dirty();
return true;
}
if (action == SLAGizmoEventType::MouseWheelDown && control_down) {
m_clipping_plane_distance = std::max(0.f, m_clipping_plane_distance - 0.01f);
m_parent.set_as_dirty();
return true;
}
return false;
}

View File

@ -14,7 +14,9 @@ enum class SLAGizmoEventType {
ApplyChanges,
DiscardChanges,
AutomaticGeneration,
ManualEditing
ManualEditing,
MouseWheelUp,
MouseWheelDown
};
#include "slic3r/GUI/Gizmos/GLGizmoMove.hpp"

View File

@ -520,6 +520,23 @@ void GLGizmosManager::render_overlay(const GLCanvas3D& canvas, const Selection&
glsafe(::glPopMatrix());
}
bool GLGizmosManager::on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas)
{
bool processed = false;
if (m_current == SlaSupports) {
float rot = (float)evt.GetWheelRotation() / (float)evt.GetWheelDelta();
if (gizmo_event((rot > 0.f ? SLAGizmoEventType::MouseWheelUp : SLAGizmoEventType::MouseWheelDown), Vec2d::Zero(), evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
processed = true;
}
return processed;
}
bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
{
Point pos(evt.GetX(), evt.GetY());

View File

@ -157,6 +157,7 @@ public:
const std::string& get_tooltip() const { return m_tooltip; }
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas);
bool on_mouse_wheel(wxMouseEvent& evt, GLCanvas3D& canvas);
bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas);
bool on_key(wxKeyEvent& evt, GLCanvas3D& canvas);