mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 06:33:57 -06:00
Finished concept of gizmos with no toolbar icon:
on_is_selectable and on_is_activable functions are now completely independent, the former says if there shall be an icon in the left toolbar, the latter says if the gizmo can be activated (by a shortcut or GLGizmoManager::open_gizmo)
This commit is contained in:
parent
01f32e18d6
commit
85c7dea1a9
6 changed files with 19 additions and 19 deletions
|
@ -51,6 +51,11 @@ bool GLGizmoMmuSegmentation::on_is_selectable() const
|
||||||
&& wxGetApp().get_mode() != comSimple && wxGetApp().extruders_edited_cnt() > 1);
|
&& wxGetApp().get_mode() != comSimple && wxGetApp().extruders_edited_cnt() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLGizmoMmuSegmentation::on_is_activable() const
|
||||||
|
{
|
||||||
|
return GLGizmoPainterBase::on_is_activable() && wxGetApp().extruders_edited_cnt() > 1;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::array<float, 4>> get_extruders_colors()
|
static std::vector<std::array<float, 4>> get_extruders_colors()
|
||||||
{
|
{
|
||||||
unsigned char rgb_color[3] = {};
|
unsigned char rgb_color[3] = {};
|
||||||
|
|
|
@ -109,6 +109,7 @@ protected:
|
||||||
std::string on_get_name() const override;
|
std::string on_get_name() const override;
|
||||||
|
|
||||||
bool on_is_selectable() const override;
|
bool on_is_selectable() const override;
|
||||||
|
bool on_is_activable() const override;
|
||||||
|
|
||||||
wxString handle_snapshot_action_name(bool shift_down, Button button_down) const override;
|
wxString handle_snapshot_action_name(bool shift_down, Button button_down) const override;
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ bool GLGizmoPainterBase::on_is_activable() const
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
|
||||||
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptFFF
|
if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptFFF
|
||||||
|| !selection.is_single_full_instance())
|
|| !selection.is_single_full_instance() || wxGetApp().get_mode() == comSimple)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check that none of the selected volumes is outside. Only SLA auxiliaries (supports) are allowed outside.
|
// Check that none of the selected volumes is outside. Only SLA auxiliaries (supports) are allowed outside.
|
||||||
|
|
|
@ -40,7 +40,7 @@ protected:
|
||||||
virtual void on_render_for_picking() override;
|
virtual void on_render_for_picking() override;
|
||||||
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
virtual void on_render_input_window(float x, float y, float bottom_limit) override;
|
||||||
virtual bool on_is_activable() const override;
|
virtual bool on_is_activable() const override;
|
||||||
virtual bool on_is_selectable() const override { return false; };
|
virtual bool on_is_selectable() const override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void close();
|
void close();
|
||||||
|
|
|
@ -51,14 +51,7 @@ std::vector<size_t> GLGizmosManager::get_selectable_idxs() const
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> GLGizmosManager::get_activable_idxs() const
|
|
||||||
{
|
|
||||||
std::vector<size_t> out;
|
|
||||||
for (size_t i=0; i<m_gizmos.size(); ++i)
|
|
||||||
if (m_gizmos[i]->is_activable())
|
|
||||||
out.push_back(i);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t GLGizmosManager::get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const
|
size_t GLGizmosManager::get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const
|
||||||
{
|
{
|
||||||
|
@ -171,7 +164,7 @@ void GLGizmosManager::refresh_on_off_state()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_current != Undefined
|
if (m_current != Undefined
|
||||||
&& (! m_gizmos[m_current]->is_activable() || ! m_gizmos[m_current]->is_selectable())) {
|
&& ! m_gizmos[m_current]->is_activable()) {
|
||||||
activate_gizmo(Undefined);
|
activate_gizmo(Undefined);
|
||||||
update_data();
|
update_data();
|
||||||
}
|
}
|
||||||
|
@ -189,7 +182,7 @@ void GLGizmosManager::reset_all_states()
|
||||||
bool GLGizmosManager::open_gizmo(EType type)
|
bool GLGizmosManager::open_gizmo(EType type)
|
||||||
{
|
{
|
||||||
int idx = int(type);
|
int idx = int(type);
|
||||||
if (/*m_gizmos[idx]->is_selectable() &&*/ m_gizmos[idx]->is_activable()) {
|
if (m_gizmos[idx]->is_activable()) {
|
||||||
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
|
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
|
||||||
update_data();
|
update_data();
|
||||||
return true;
|
return true;
|
||||||
|
@ -306,7 +299,7 @@ bool GLGizmosManager::handle_shortcut(int key)
|
||||||
auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(),
|
auto it = std::find_if(m_gizmos.begin(), m_gizmos.end(),
|
||||||
[key](const std::unique_ptr<GLGizmoBase>& gizmo) {
|
[key](const std::unique_ptr<GLGizmoBase>& gizmo) {
|
||||||
int gizmo_key = gizmo->get_shortcut_key();
|
int gizmo_key = gizmo->get_shortcut_key();
|
||||||
return gizmo->is_selectable()
|
return gizmo->is_activable()
|
||||||
&& ((gizmo_key == key - 64) || (gizmo_key == key - 96));
|
&& ((gizmo_key == key - 64) || (gizmo_key == key - 96));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1079,8 +1072,7 @@ void GLGizmosManager::do_render_overlay() const
|
||||||
float u_offset = 1.0f / (float)tex_width;
|
float u_offset = 1.0f / (float)tex_width;
|
||||||
float v_offset = 1.0f / (float)tex_height;
|
float v_offset = 1.0f / (float)tex_height;
|
||||||
|
|
||||||
float toolbar_top = 0.f;
|
float current_y = FLT_MAX;
|
||||||
float current_y = 0.f;
|
|
||||||
for (size_t idx : selectable_idxs)
|
for (size_t idx : selectable_idxs)
|
||||||
{
|
{
|
||||||
GLGizmoBase* gizmo = m_gizmos[idx].get();
|
GLGizmoBase* gizmo = m_gizmos[idx].get();
|
||||||
|
@ -1094,15 +1086,18 @@ void GLGizmosManager::do_render_overlay() const
|
||||||
float u_right = u_left + du - u_offset;
|
float u_right = u_left + du - u_offset;
|
||||||
|
|
||||||
GLTexture::render_sub_texture(icons_texture_id, zoomed_top_x, zoomed_top_x + zoomed_icons_size, zoomed_top_y - zoomed_icons_size, zoomed_top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
|
GLTexture::render_sub_texture(icons_texture_id, zoomed_top_x, zoomed_top_x + zoomed_icons_size, zoomed_top_y - zoomed_icons_size, zoomed_top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
|
||||||
if (idx == m_current) {
|
if (idx == m_current || current_y == FLT_MAX) {
|
||||||
toolbar_top = cnv_h - wxGetApp().plater()->get_view_toolbar().get_height();
|
// The FLT_MAX trick is here so that even non-selectable but activable
|
||||||
|
// gizmos are passed some meaningful value.
|
||||||
current_y = 0.5f * cnv_h - zoomed_top_y * zoom;
|
current_y = 0.5f * cnv_h - zoomed_top_y * zoom;
|
||||||
}
|
}
|
||||||
zoomed_top_y -= zoomed_stride_y;
|
zoomed_top_y -= zoomed_stride_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current != Undefined)
|
if (m_current != Undefined) {
|
||||||
|
float toolbar_top = cnv_h - wxGetApp().plater()->get_view_toolbar().get_height();
|
||||||
m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top);
|
m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLGizmosManager::get_scaled_total_height() const
|
float GLGizmosManager::get_scaled_total_height() const
|
||||||
|
|
|
@ -102,7 +102,6 @@ private:
|
||||||
std::pair<EType, bool> m_highlight; // bool true = higlightedShown, false = highlightedHidden
|
std::pair<EType, bool> m_highlight; // bool true = higlightedShown, false = highlightedHidden
|
||||||
|
|
||||||
std::vector<size_t> get_selectable_idxs() const;
|
std::vector<size_t> get_selectable_idxs() const;
|
||||||
std::vector<size_t> get_activable_idxs() const;
|
|
||||||
size_t get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const;
|
size_t get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const;
|
||||||
|
|
||||||
void activate_gizmo(EType type);
|
void activate_gizmo(EType type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue