Fixed gizmos overlay rendering/selection by adding GLGizmoBase::is_selectable() method

This commit is contained in:
Enrico Turri 2018-11-19 14:46:37 +01:00
parent d658d918d7
commit d322fa0fd5
4 changed files with 22 additions and 9 deletions

View file

@ -2317,11 +2317,15 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Flatten, gizmo));
gizmo = new GLGizmoCut(parent);
if (! gizmo->init()) {
if (gizmo == nullptr)
return false;
if (!gizmo->init()) {
_reset();
return false;
}
m_gizmos.insert({ Cut, gizmo });
m_gizmos.insert(GizmosMap::value_type(Cut, gizmo));
gizmo = new GLGizmoSlaSupports(parent);
if (gizmo == nullptr)
@ -2359,7 +2363,7 @@ std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, con
float top_y = 0.5f * (cnv_h - height);
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if (it->second == nullptr)
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
float tex_size = (float)it->second->get_textures_size() * OverlayTexturesScale;
@ -2389,7 +2393,7 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec
float top_y = 0.5f * (cnv_h - height);
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if (it->second == nullptr)
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
float tex_size = (float)it->second->get_textures_size() * OverlayTexturesScale;
@ -2487,7 +2491,7 @@ bool GLCanvas3D::Gizmos::overlay_contains_mouse(const GLCanvas3D& canvas, const
float top_y = 0.5f * (cnv_h - height);
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if (it->second == nullptr)
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
float tex_size = (float)it->second->get_textures_size() * OverlayTexturesScale;
@ -2739,8 +2743,9 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas) const
float scaled_gap_y = OverlayGapY * inv_zoom;
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if (it->first == SlaSupports && wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA)
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
float tex_size = (float)it->second->get_textures_size() * OverlayTexturesScale * inv_zoom;
GLTexture::render_texture(it->second->get_texture_id(), top_x, top_x + tex_size, top_y - tex_size, top_y);
top_y -= (tex_size + scaled_gap_y);

View file

@ -565,8 +565,8 @@ private:
Scale,
Rotate,
Flatten,
SlaSupports,
Cut,
SlaSupports,
Num_Types
};

View file

@ -1779,6 +1779,11 @@ bool GLGizmoSlaSupports::on_is_activable(const GLCanvas3D::Selection& selection)
return (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA);
}
bool GLGizmoSlaSupports::on_is_selectable() const
{
return (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA);
}
std::string GLGizmoSlaSupports::on_get_name() const
{
return L("SLA Support Points");

View file

@ -101,6 +101,7 @@ public:
void set_state(EState state) { m_state = state; on_set_state(); }
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
bool is_selectable() const { return on_is_selectable(); }
unsigned int get_texture_id() const { return m_textures[m_state].get_id(); }
int get_textures_size() const { return m_textures[Off].get_width(); }
@ -134,6 +135,7 @@ protected:
virtual void on_set_state() {}
virtual void on_set_hover_id() {}
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
virtual bool on_is_selectable() const { return true; }
virtual void on_enable_grabber(unsigned int id) {}
virtual void on_disable_grabber(unsigned int id) {}
virtual void on_start_dragging(const GLCanvas3D::Selection& selection) {}
@ -454,8 +456,9 @@ protected:
}
}
std::string on_get_name() const override;
bool on_is_activable(const GLCanvas3D::Selection& selection) const override;
virtual std::string on_get_name() const;
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const;
virtual bool on_is_selectable() const;
};