Rectangle selection in 3D scene -> refactored GLVolume member varialbe for hovering
This commit is contained in:
parent
51e1f5cd97
commit
d2d06c9f73
4 changed files with 18 additions and 15 deletions
|
@ -252,8 +252,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
||||||
, zoom_to_volumes(true)
|
, zoom_to_volumes(true)
|
||||||
, shader_outside_printer_detection_enabled(false)
|
, shader_outside_printer_detection_enabled(false)
|
||||||
, is_outside(false)
|
, is_outside(false)
|
||||||
, hover_select(false)
|
, hover(None)
|
||||||
, hover_deselect(false)
|
|
||||||
, is_modifier(false)
|
, is_modifier(false)
|
||||||
, is_wipe_tower(false)
|
, is_wipe_tower(false)
|
||||||
, is_extrusion_path(false)
|
, is_extrusion_path(false)
|
||||||
|
@ -293,9 +292,9 @@ void GLVolume::set_render_color()
|
||||||
if (force_native_color)
|
if (force_native_color)
|
||||||
set_render_color(color, 4);
|
set_render_color(color, 4);
|
||||||
else {
|
else {
|
||||||
if (hover_select)
|
if (hover == Select)
|
||||||
set_render_color(HOVER_SELECT_COLOR, 4);
|
set_render_color(HOVER_SELECT_COLOR, 4);
|
||||||
else if (hover_deselect)
|
else if (hover == Deselect)
|
||||||
set_render_color(HOVER_DESELECT_COLOR, 4);
|
set_render_color(HOVER_DESELECT_COLOR, 4);
|
||||||
else if (selected)
|
else if (selected)
|
||||||
set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
|
set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
|
||||||
|
|
|
@ -234,6 +234,13 @@ public:
|
||||||
static const float SLA_SUPPORT_COLOR[4];
|
static const float SLA_SUPPORT_COLOR[4];
|
||||||
static const float SLA_PAD_COLOR[4];
|
static const float SLA_PAD_COLOR[4];
|
||||||
|
|
||||||
|
enum EHoverState : unsigned char
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Select,
|
||||||
|
Deselect
|
||||||
|
};
|
||||||
|
|
||||||
GLVolume(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f);
|
GLVolume(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f);
|
||||||
GLVolume(const float *rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
|
GLVolume(const float *rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
|
||||||
~GLVolume();
|
~GLVolume();
|
||||||
|
@ -297,10 +304,8 @@ public:
|
||||||
bool shader_outside_printer_detection_enabled;
|
bool shader_outside_printer_detection_enabled;
|
||||||
// Wheter or not this volume is outside print volume.
|
// Wheter or not this volume is outside print volume.
|
||||||
bool is_outside;
|
bool is_outside;
|
||||||
// Boolean: Is mouse over this object to select it ?
|
// Is mouse or rectangle selection over this object to select/deselect it ?
|
||||||
bool hover_select;
|
EHoverState hover;
|
||||||
// Boolean: Is mouse over this object to deselect it ?
|
|
||||||
bool hover_deselect;
|
|
||||||
// Wheter or not this volume has been generated from a modifier
|
// Wheter or not this volume has been generated from a modifier
|
||||||
bool is_modifier;
|
bool is_modifier;
|
||||||
// Wheter or not this volume has been generated from the wipe tower
|
// Wheter or not this volume has been generated from the wipe tower
|
||||||
|
|
|
@ -4246,8 +4246,7 @@ void GLCanvas3D::_update_volumes_hover_state() const
|
||||||
{
|
{
|
||||||
for (GLVolume* v : m_volumes.volumes)
|
for (GLVolume* v : m_volumes.volumes)
|
||||||
{
|
{
|
||||||
v->hover_select = false;
|
v->hover = GLVolume::None;
|
||||||
v->hover_deselect = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_hover_volume_idxs.empty())
|
if (m_hover_volume_idxs.empty())
|
||||||
|
@ -4268,9 +4267,9 @@ void GLCanvas3D::_update_volumes_hover_state() const
|
||||||
if (volume->is_modifier && (!deselect || ((volume->object_idx() == m_selection.get_object_idx()) && (volume->instance_idx() == m_selection.get_instance_idx()))))
|
if (volume->is_modifier && (!deselect || ((volume->object_idx() == m_selection.get_object_idx()) && (volume->instance_idx() == m_selection.get_instance_idx()))))
|
||||||
{
|
{
|
||||||
if (deselect)
|
if (deselect)
|
||||||
volume->hover_deselect = true;
|
volume->hover = GLVolume::Deselect;
|
||||||
else
|
else
|
||||||
volume->hover_select = true;
|
volume->hover = GLVolume::Select;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4282,9 +4281,9 @@ void GLCanvas3D::_update_volumes_hover_state() const
|
||||||
if ((v->object_idx() == object_idx) && (v->instance_idx() == instance_idx))
|
if ((v->object_idx() == object_idx) && (v->instance_idx() == instance_idx))
|
||||||
{
|
{
|
||||||
if (deselect)
|
if (deselect)
|
||||||
v->hover_deselect = true;
|
v->hover = GLVolume::Deselect;
|
||||||
else
|
else
|
||||||
v->hover_select = true;
|
v->hover = GLVolume::Select;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
bool is_dragging() const { return m_state != Off; }
|
bool is_dragging() const { return m_state != Off; }
|
||||||
EState get_state() const { return m_state; }
|
EState get_state() const { return m_state; }
|
||||||
|
|
||||||
float get_width() const { return std::abs(m_start_corner(0) - m_end_corner(0)); }
|
float get_width() const { return std::abs(m_start_corner(0) - m_end_corner(0)); }
|
||||||
float get_height() const { return std::abs(m_start_corner(1) - m_end_corner(1)); }
|
float get_height() const { return std::abs(m_start_corner(1) - m_end_corner(1)); }
|
||||||
float get_left() const { return std::min(m_start_corner(0), m_end_corner(0)); }
|
float get_left() const { return std::min(m_start_corner(0), m_end_corner(0)); }
|
||||||
|
|
Loading…
Reference in a new issue