mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Handling of gizmos related char events moved into new method GLGizmosManager::on_char()
This commit is contained in:
parent
c1d74d2943
commit
d18208458b
3 changed files with 98 additions and 45 deletions
|
@ -2240,6 +2240,9 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_gizmos.on_char(evt, *this))
|
||||||
|
return;
|
||||||
|
|
||||||
//#ifdef __APPLE__
|
//#ifdef __APPLE__
|
||||||
// ctrlMask |= wxMOD_RAW_CONTROL;
|
// ctrlMask |= wxMOD_RAW_CONTROL;
|
||||||
//#endif /* __APPLE__ */
|
//#endif /* __APPLE__ */
|
||||||
|
@ -2248,9 +2251,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
case WXK_CONTROL_A:
|
case WXK_CONTROL_A:
|
||||||
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::SelectAll)) // Sla gizmo selects all support points
|
|
||||||
m_dirty = true;
|
|
||||||
else
|
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_SELECT_ALL));
|
post_event(SimpleEvent(EVT_GLCANVAS_SELECT_ALL));
|
||||||
break;
|
break;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -2266,29 +2266,12 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
} else {
|
} else {
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
// key ESC
|
|
||||||
case WXK_ESCAPE: {
|
|
||||||
if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports || !m_gizmos.gizmo_event(SLAGizmoEventType::DiscardChanges))
|
|
||||||
m_gizmos.reset_all_states();
|
|
||||||
m_dirty = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WXK_RETURN: {
|
|
||||||
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::ApplyChanges))
|
|
||||||
m_dirty = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
|
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
|
||||||
#else /* __APPLE__ */
|
#else /* __APPLE__ */
|
||||||
case WXK_DELETE:
|
case WXK_DELETE:
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::Delete))
|
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE));
|
||||||
m_dirty = true;
|
|
||||||
else
|
|
||||||
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '0': { select_view("iso"); break; }
|
case '0': { select_view("iso"); break; }
|
||||||
|
@ -2302,15 +2285,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
case '-': { post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, -1)); break; }
|
case '-': { post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, -1)); break; }
|
||||||
case '?': { post_event(SimpleEvent(EVT_GLCANVAS_QUESTION_MARK)); break; }
|
case '?': { post_event(SimpleEvent(EVT_GLCANVAS_QUESTION_MARK)); break; }
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'a': {
|
case 'a': { post_event(SimpleEvent(EVT_GLCANVAS_ARRANGE)); break; }
|
||||||
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports) {
|
|
||||||
if (m_gizmos.gizmo_event(SLAGizmoEventType::AutomaticGeneration))
|
|
||||||
m_dirty = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_ARRANGE));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'B':
|
case 'B':
|
||||||
case 'b': { zoom_to_bed(); break; }
|
case 'b': { zoom_to_bed(); break; }
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -2319,23 +2294,9 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
case 'o': { set_camera_zoom(-1.0f); break; }
|
case 'o': { set_camera_zoom(-1.0f); break; }
|
||||||
case 'Z':
|
case 'Z':
|
||||||
case 'z': { m_selection.is_empty() ? zoom_to_volumes() : zoom_to_selection(); break; }
|
case 'z': { m_selection.is_empty() ? zoom_to_volumes() : zoom_to_selection(); break; }
|
||||||
case 'M':
|
|
||||||
case 'm': {
|
|
||||||
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::ManualEditing)) {
|
|
||||||
m_dirty = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // intentional fallthrough
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (m_gizmos.handle_shortcut(keyCode, m_selection))
|
evt.Skip();
|
||||||
{
|
|
||||||
update_gizmos_data();
|
|
||||||
m_dirty = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
evt.Skip();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,6 +654,97 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas)
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
||||||
|
{
|
||||||
|
// see include/wx/defs.h enum wxKeyCode
|
||||||
|
int keyCode = evt.GetKeyCode();
|
||||||
|
int ctrlMask = wxMOD_CONTROL;
|
||||||
|
|
||||||
|
const Selection& selection = canvas.get_selection();
|
||||||
|
bool processed = false;
|
||||||
|
|
||||||
|
if ((evt.GetModifiers() & ctrlMask) != 0)
|
||||||
|
{
|
||||||
|
switch (keyCode)
|
||||||
|
{
|
||||||
|
case WXK_CONTROL_A:
|
||||||
|
{
|
||||||
|
// Sla gizmo selects all support points
|
||||||
|
if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::SelectAll))
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!evt.HasModifiers())
|
||||||
|
{
|
||||||
|
switch (keyCode)
|
||||||
|
{
|
||||||
|
// key ESC
|
||||||
|
case WXK_ESCAPE:
|
||||||
|
{
|
||||||
|
if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges))
|
||||||
|
reset_all_states();
|
||||||
|
|
||||||
|
processed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WXK_RETURN:
|
||||||
|
{
|
||||||
|
if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ApplyChanges))
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef __APPLE__
|
||||||
|
case WXK_BACK: // the low cost Apple solutions are not equipped with a Delete key, use Backspace instead.
|
||||||
|
#else /* __APPLE__ */
|
||||||
|
case WXK_DELETE:
|
||||||
|
#endif /* __APPLE__ */
|
||||||
|
{
|
||||||
|
if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::Delete))
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'A':
|
||||||
|
case 'a':
|
||||||
|
{
|
||||||
|
if (m_current == SlaSupports)
|
||||||
|
{
|
||||||
|
gizmo_event(SLAGizmoEventType::AutomaticGeneration);
|
||||||
|
// set as processed no matter what's returned by gizmo_event() to avoid the calling canvas to process 'A' as arrange
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'M':
|
||||||
|
case 'm':
|
||||||
|
{
|
||||||
|
if ((m_current == SlaSupports) && gizmo_event(SLAGizmoEventType::ManualEditing))
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
if (handle_shortcut(keyCode, selection))
|
||||||
|
{
|
||||||
|
canvas.update_gizmos_data();
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processed)
|
||||||
|
canvas.set_as_dirty();
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmosManager::reset()
|
void GLGizmosManager::reset()
|
||||||
{
|
{
|
||||||
for (GizmosMap::value_type& gizmo : m_gizmos)
|
for (GizmosMap::value_type& gizmo : m_gizmos)
|
||||||
|
|
|
@ -153,6 +153,7 @@ public:
|
||||||
const std::string& get_tooltip() const { return m_tooltip; }
|
const std::string& get_tooltip() const { return m_tooltip; }
|
||||||
|
|
||||||
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas);
|
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas);
|
||||||
|
bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue