Show info about custom supports and seam in ObjectList

Slight refactoring in GLGizmosManager so it is easier to open a gizmo from the ObjectList
This commit is contained in:
Lukas Matena 2021-04-14 07:38:50 +02:00 committed by Vojtech Bubnik
parent 9153874041
commit 61528cbdc8
9 changed files with 190 additions and 32 deletions

View file

@ -7,6 +7,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include <GL/glew.h>
@ -316,8 +317,12 @@ void GLGizmoFdmSupports::update_model_object() const
updated |= mv->supported_facets.set(*m_triangle_selectors[idx].get());
}
if (updated)
if (updated) {
const ModelObjectPtrs& mos = wxGetApp().model().objects;
wxGetApp().obj_list()->update_info_items(std::find(mos.begin(), mos.end(), mo) - mos.begin());
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
}
}

View file

@ -7,7 +7,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include <GL/glew.h>
@ -222,8 +222,12 @@ void GLGizmoSeam::update_model_object() const
updated |= mv->seam_facets.set(*m_triangle_selectors[idx].get());
}
if (updated)
if (updated) {
const ModelObjectPtrs& mos = wxGetApp().model().objects;
wxGetApp().obj_list()->update_info_items(std::find(mos.begin(), mos.end(), mo) - mos.begin());
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
}
}

View file

@ -165,6 +165,17 @@ void GLGizmosManager::reset_all_states()
m_hover = Undefined;
}
bool GLGizmosManager::open_gizmo(EType type)
{
int idx = int(type);
if (m_gizmos[idx]->is_selectable() && m_gizmos[idx]->is_activable()) {
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
update_data();
return true;
}
return false;
}
void GLGizmosManager::set_hover_id(int id)
{
if (!m_enabled || m_current == Undefined)
@ -268,24 +279,21 @@ bool GLGizmosManager::is_running() const
bool GLGizmosManager::handle_shortcut(int key)
{
if (!m_enabled)
if (!m_enabled || m_parent.get_selection().is_empty())
return false;
if (m_parent.get_selection().is_empty())
auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(),
[key](const std::unique_ptr<GLGizmoBase>& gizmo) {
int gizmo_key = gizmo->get_shortcut_key();
return gizmo->is_selectable()
&& ((gizmo_key == key - 64) || (gizmo_key == key - 96));
});
if (it == m_gizmos.end())
return false;
bool handled = false;
for (size_t idx : get_selectable_idxs()) {
int it_key = m_gizmos[idx]->get_shortcut_key();
if (m_gizmos[idx]->is_activable() && ((it_key == key - 64) || (it_key == key - 96))) {
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
handled = true;
}
}
return handled;
EType gizmo_type = EType(it - m_gizmos.begin());
return open_gizmo(gizmo_type);
}
bool GLGizmosManager::is_dragging() const
@ -819,10 +827,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
if (!processed && !evt.HasModifiers())
{
if (handle_shortcut(keyCode))
{
update_data();
processed = true;
}
}
if (processed)
@ -1161,5 +1166,11 @@ bool GLGizmosManager::is_in_editing_mode(bool error_notification) const
return true;
}
int GLGizmosManager::get_shortcut_key(GLGizmosManager::EType type) const
{
return m_gizmos[type]->get_shortcut_key();
}
} // namespace GUI
} // namespace Slic3r

View file

@ -172,6 +172,7 @@ public:
void refresh_on_off_state();
void reset_all_states();
bool is_serializing() const { return m_serializing; }
bool open_gizmo(EType type);
void set_hover_id(int id);
void enable_grabber(EType type, unsigned int id, bool enable);
@ -229,6 +230,7 @@ public:
void update_after_undo_redo(const UndoRedo::Snapshot& snapshot);
int get_selectable_icons_cnt() const { return get_selectable_idxs().size(); }
int get_shortcut_key(GLGizmosManager::EType) const;
private:
void render_background(float left, float top, float right, float bottom, float border) const;