Synch with branch et_selection_rectangle

This commit is contained in:
Enrico Turri 2019-04-26 13:39:33 +02:00
parent c850fb434b
commit 18db983900
7 changed files with 128 additions and 134 deletions

View file

@ -12,10 +12,7 @@
// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active // Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active
#define ENABLE_RENDER_SELECTION_CENTER 0 #define ENABLE_RENDER_SELECTION_CENTER 0
// Shows an imgui dialog with render related data // Shows an imgui dialog with render related data
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #define ENABLE_RENDER_STATISTICS 0
#define ENABLE_RENDER_STATISTICS 1
//#define ENABLE_RENDER_STATISTICS 0
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//==================== //====================

View file

@ -223,11 +223,8 @@ void GLIndexedVertexArray::render(
} }
const float GLVolume::SELECTED_COLOR[4] = { 0.0f, 1.0f, 0.0f, 1.0f }; const float GLVolume::SELECTED_COLOR[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const float GLVolume::HOVER_SELECT_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f }; const float GLVolume::HOVER_SELECT_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f };
const float GLVolume::HOVER_DESELECT_COLOR[4] = { 0.9f, 0.4f, 0.1f, 1.0f }; const float GLVolume::HOVER_DESELECT_COLOR[4] = { 0.9f, 0.4f, 0.1f, 1.0f };
//const float GLVolume::HOVER_COLOR[4] = { 0.4f, 0.9f, 0.1f, 1.0f };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f }; const float GLVolume::OUTSIDE_COLOR[4] = { 0.0f, 0.38f, 0.8f, 1.0f };
const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f }; const float GLVolume::SELECTED_OUTSIDE_COLOR[4] = { 0.19f, 0.58f, 1.0f, 1.0f };
const float GLVolume::DISABLED_COLOR[4] = { 0.25f, 0.25f, 0.25f, 1.0f }; const float GLVolume::DISABLED_COLOR[4] = { 0.25f, 0.25f, 0.25f, 1.0f };
@ -255,11 +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(HS_None)
, hover_select(false)
, hover_deselect(false)
// , hover(false)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
, is_modifier(false) , is_modifier(false)
, is_wipe_tower(false) , is_wipe_tower(false)
, is_extrusion_path(false) , is_extrusion_path(false)
@ -299,10 +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 == HS_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 == HS_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);
@ -312,18 +304,6 @@ void GLVolume::set_render_color()
set_render_color(OUTSIDE_COLOR, 4); set_render_color(OUTSIDE_COLOR, 4);
else else
set_render_color(color, 4); set_render_color(color, 4);
// if (selected)
// set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
// else if (hover)
// set_render_color(HOVER_COLOR, 4);
// else if (disabled)
// set_render_color(DISABLED_COLOR, 4);
// else if (is_outside && shader_outside_printer_detection_enabled)
// set_render_color(OUTSIDE_COLOR, 4);
// else
// set_render_color(color, 4);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
if (force_transparent) if (force_transparent)

View file

@ -225,11 +225,8 @@ private:
class GLVolume { class GLVolume {
public: public:
static const float SELECTED_COLOR[4]; static const float SELECTED_COLOR[4];
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
static const float HOVER_SELECT_COLOR[4]; static const float HOVER_SELECT_COLOR[4];
static const float HOVER_DESELECT_COLOR[4]; static const float HOVER_DESELECT_COLOR[4];
// static const float HOVER_COLOR[4];
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
static const float OUTSIDE_COLOR[4]; static const float OUTSIDE_COLOR[4];
static const float SELECTED_OUTSIDE_COLOR[4]; static const float SELECTED_OUTSIDE_COLOR[4];
static const float DISABLED_COLOR[4]; static const float DISABLED_COLOR[4];
@ -237,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
{
HS_None,
HS_Select,
HS_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();
@ -300,15 +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;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // Is mouse or rectangle selection over this object to select/deselect it ?
// Boolean: Is mouse over this object to select it ? EHoverState hover;
bool hover_select;
// Boolean: Is mouse over this object to deselect it ?
bool hover_deselect;
// // Boolean: Is mouse over this object?
// bool hover;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// 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

View file

@ -1617,15 +1617,15 @@ void GLCanvas3D::render()
wxGetApp().imgui()->new_frame(); wxGetApp().imgui()->new_frame();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (m_picking_enabled)
{
if (m_rectangle_selection.is_dragging()) if (m_rectangle_selection.is_dragging())
// picking pass using rectangle selection // picking pass using rectangle selection
_rectangular_selection_picking_pass(); _rectangular_selection_picking_pass();
else else
// regular picking pass // regular picking pass
// // picking pass
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
_picking_pass(); _picking_pass();
}
// draw scene // draw scene
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
@ -1661,10 +1661,8 @@ void GLCanvas3D::render()
_render_camera_target(); _render_camera_target();
#endif // ENABLE_SHOW_CAMERA_TARGET #endif // ENABLE_SHOW_CAMERA_TARGET
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (m_picking_enabled && m_rectangle_selection.is_dragging())
if (m_rectangle_selection.is_dragging())
m_rectangle_selection.render(*this); m_rectangle_selection.render(*this);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// draw overlays // draw overlays
_render_gizmos_overlay(); _render_gizmos_overlay();
@ -1681,7 +1679,7 @@ void GLCanvas3D::render()
#if ENABLE_RENDER_STATISTICS #if ENABLE_RENDER_STATISTICS
ImGuiWrapper& imgui = *wxGetApp().imgui(); ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.set_next_window_bg_alpha(0.5f); imgui.set_next_window_bg_alpha(0.5f);
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text("Last frame: "); imgui.text("Last frame: ");
ImGui::SameLine(); ImGui::SameLine();
imgui.text(std::to_string(m_render_stats.last_frame)); imgui.text(std::to_string(m_render_stats.last_frame));
@ -2376,12 +2374,12 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux // m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
post_event(SimpleEvent(EVT_GLCANVAS_TAB)); post_event(SimpleEvent(EVT_GLCANVAS_TAB));
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else if (keyCode == WXK_SHIFT) else if (keyCode == WXK_SHIFT)
{ {
if (m_picking_enabled && m_rectangle_selection.is_dragging()) if (m_picking_enabled && m_rectangle_selection.is_dragging())
{ {
_update_selection_from_hover(m_rectangle_selection.get_state()); _update_selection_from_hover();
m_rectangle_selection.stop_dragging();
m_dirty = true; m_dirty = true;
} }
set_cursor(Standard); set_cursor(Standard);
@ -2390,18 +2388,17 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
{ {
if (m_picking_enabled && m_rectangle_selection.is_dragging()) if (m_picking_enabled && m_rectangle_selection.is_dragging())
{ {
_update_selection_from_hover(m_rectangle_selection.get_state()); _update_selection_from_hover();
m_rectangle_selection.stop_dragging();
m_dirty = true; m_dirty = true;
} }
set_cursor(Standard); set_cursor(Standard);
} }
else if (keyCode == WXK_CONTROL) else if (keyCode == WXK_CONTROL)
m_dirty = true; m_dirty = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
else if (evt.GetEventType() == wxEVT_KEY_DOWN) { else if (evt.GetEventType() == wxEVT_KEY_DOWN) {
m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers(); m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (keyCode == WXK_SHIFT) if (keyCode == WXK_SHIFT)
{ {
if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports))
@ -2414,7 +2411,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
} }
else if (keyCode == WXK_CONTROL) else if (keyCode == WXK_CONTROL)
m_dirty = true; m_dirty = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
} }
} }
@ -2671,7 +2667,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_dirty = true; m_dirty = true;
} }
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) else if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled)
{ {
if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports) if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)
@ -2680,7 +2675,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_dirty = true; m_dirty = true;
} }
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else else
{ {
// Select volume in this 3D canvas. // Select volume in this 3D canvas.
@ -2789,13 +2783,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_dirty = true; m_dirty = true;
} }
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ else if (evt.Dragging() && evt.LeftIsDown() && m_picking_enabled && m_rectangle_selection.is_dragging())
else if (evt.Dragging() && evt.LeftIsDown() && m_rectangle_selection.is_dragging())
{ {
m_rectangle_selection.dragging(pos.cast<double>()); m_rectangle_selection.dragging(pos.cast<double>());
m_dirty = true; m_dirty = true;
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else if (evt.Dragging()) else if (evt.Dragging())
{ {
m_mouse.dragging = true; m_mouse.dragging = true;
@ -2851,15 +2843,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// of the scene with the background processing data should be performed. // of the scene with the background processing data should be performed.
post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED)); post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ else if (evt.LeftUp() && m_picking_enabled && m_rectangle_selection.is_dragging())
else if (evt.LeftUp() && m_rectangle_selection.is_dragging())
{ {
if (evt.ShiftDown() || evt.AltDown()) if (evt.ShiftDown() || evt.AltDown())
_update_selection_from_hover(m_rectangle_selection.get_state()); _update_selection_from_hover();
m_rectangle_selection.stop_dragging(); m_rectangle_selection.stop_dragging();
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else if (evt.LeftUp() && !m_mouse.dragging && m_hover_volume_idxs.empty() && !is_layers_editing_enabled()) else if (evt.LeftUp() && !m_mouse.dragging && m_hover_volume_idxs.empty() && !is_layers_editing_enabled())
{ {
// deselect and propagate event through callback // deselect and propagate event through callback
@ -3709,10 +3699,7 @@ void GLCanvas3D::_picking_pass() const
if (inside) if (inside)
{ {
glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color)); glsafe(::glReadPixels(m_mouse.position(0), cnv_size.get_height() - m_mouse.position(1) - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color));
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
volume_id = color[0] + (color[1] << 8) + (color[2] << 16); volume_id = color[0] + (color[1] << 8) + (color[2] << 16);
// volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size())) if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size()))
{ {
@ -3726,10 +3713,8 @@ void GLCanvas3D::_picking_pass() const
} }
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::_rectangular_selection_picking_pass() const void GLCanvas3D::_rectangular_selection_picking_pass() const
{ {
// m_hover_volume_ids.empty();
m_gizmos.set_hover_id(-1); m_gizmos.set_hover_id(-1);
std::set<int> idxs; std::set<int> idxs;
@ -3804,7 +3789,6 @@ void GLCanvas3D::_rectangular_selection_picking_pass() const
m_hover_volume_idxs.assign(idxs.begin(), idxs.end()); m_hover_volume_idxs.assign(idxs.begin(), idxs.end());
_update_volumes_hover_state(); _update_volumes_hover_state();
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GLCanvas3D::_render_background() const void GLCanvas3D::_render_background() const
{ {
@ -4291,73 +4275,95 @@ void GLCanvas3D::_update_volumes_hover_state() const
{ {
for (GLVolume* v : m_volumes.volumes) for (GLVolume* v : m_volumes.volumes)
{ {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ v->hover = GLVolume::HS_None;
v->hover_select = false;
v->hover_deselect = false;
// v->hover = false;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
if (m_hover_volume_idxs.empty()) if (m_hover_volume_idxs.empty())
return; return;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ bool ctrl_pressed = wxGetKeyState(WXK_CONTROL); // additive select/deselect
bool is_ctrl_pressed = wxGetKeyState(WXK_CONTROL); bool shift_pressed = wxGetKeyState(WXK_SHIFT); // select by rectangle
bool is_shift_pressed = wxGetKeyState(WXK_SHIFT); bool alt_pressed = wxGetKeyState(WXK_ALT); // deselect by rectangle
bool is_alt_pressed = wxGetKeyState(WXK_ALT);
std::vector<int>::iterator it = m_hover_volume_idxs.begin(); if (alt_pressed && (shift_pressed || ctrl_pressed))
while (it != m_hover_volume_idxs.end())
{ {
GLVolume* volume = m_volumes.volumes[*it]; // illegal combinations of keys
bool deselect = volume->selected && ((is_ctrl_pressed && !is_shift_pressed) || (!is_ctrl_pressed && (m_rectangle_selection.get_state() == GLSelectionRectangle::Deselect))); m_hover_volume_idxs.clear();
bool select = !volume->selected || (volume->is_modifier && ((is_ctrl_pressed && !is_alt_pressed) || (!is_ctrl_pressed && (!m_rectangle_selection.is_dragging() || (m_rectangle_selection.get_state() == GLSelectionRectangle::Select))))); return;
if (!select && !deselect)
{
// the volume is not eligible for selection nor for deselection, remove it from the list
// it = m_hover_volume_ids.erase(it);
} }
else
bool selection_modifiers_only = m_selection.is_empty() || m_selection.is_any_modifier();
bool hover_modifiers_only = true;
for (int i : m_hover_volume_idxs)
{ {
if (volume->is_modifier && (!deselect || ((volume->object_idx() == m_selection.get_object_idx()) && (volume->instance_idx() == m_selection.get_instance_idx())))) if (!m_volumes.volumes[i]->is_modifier)
// GLVolume* volume = m_volumes.volumes[m_hover_volume_id]; {
// if (volume->is_modifier) hover_modifiers_only = false;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ break;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ }
}
std::set<std::pair<int, int>> hover_instances;
for (int i : m_hover_volume_idxs)
{
const GLVolume& v = *m_volumes.volumes[i];
hover_instances.insert(std::make_pair(v.object_idx(), v.instance_idx()));
}
bool hover_from_single_instance = hover_instances.size() == 1;
if (hover_modifiers_only && !hover_from_single_instance)
{
// do not allow to select volumes from different instances
m_hover_volume_idxs.clear();
return;
}
for (int i : m_hover_volume_idxs)
{
GLVolume& volume = *m_volumes.volumes[i];
if (volume.hover != GLVolume::HS_None)
continue;
bool deselect = volume.selected && ((ctrl_pressed && !shift_pressed) || alt_pressed);
// (volume->is_modifier && !selection_modifiers_only && !is_ctrl_pressed) -> allows hovering on selected modifiers belonging to selection of type Instance
bool select = (!volume.selected || (volume.is_modifier && !selection_modifiers_only && !ctrl_pressed)) && !alt_pressed;
if (select || deselect)
{
bool as_volume =
volume.is_modifier && hover_from_single_instance && !ctrl_pressed &&
(
(!deselect) ||
(deselect && !m_selection.is_single_full_instance() && (volume.object_idx() == m_selection.get_object_idx()) && (volume.instance_idx() == m_selection.get_instance_idx()))
);
if (as_volume)
{ {
if (deselect) if (deselect)
volume->hover_deselect = true; volume.hover = GLVolume::HS_Deselect;
else else
volume->hover_select = true; volume.hover = GLVolume::HS_Select;
} }
// volume->hover = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
else else
{ {
int object_idx = volume->object_idx(); int object_idx = volume.object_idx();
int instance_idx = volume->instance_idx(); int instance_idx = volume.instance_idx();
for (GLVolume* v : m_volumes.volumes) for (GLVolume* v : m_volumes.volumes)
{ {
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::HS_Deselect;
else else
v->hover_select = true; v->hover = GLVolume::HS_Select;
} }
// v->hover = true;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// ++it;
} }
++it;
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt) void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt)
@ -5630,23 +5636,47 @@ void GLCanvas3D::_resize_toolbars() const
} }
#endif // !ENABLE_SVG_ICONS #endif // !ENABLE_SVG_ICONS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ void GLCanvas3D::_update_selection_from_hover()
void GLCanvas3D::_update_selection_from_hover(GLSelectionRectangle::EState state)
{ {
bool ctrl_pressed = wxGetKeyState(WXK_CONTROL);
if (m_hover_volume_idxs.empty()) if (m_hover_volume_idxs.empty())
return; {
if (!ctrl_pressed && (m_rectangle_selection.get_state() == GLSelectionRectangle::Select))
bool is_single_modifier = (m_hover_volume_idxs.size() == 1) && m_volumes.volumes[m_hover_volume_idxs.front()]->is_modifier;
if ((state == GLSelectionRectangle::Select) && !wxGetKeyState(WXK_CONTROL))
m_selection.clear(); m_selection.clear();
for (int idx : m_hover_volume_idxs) return;
}
GLSelectionRectangle::EState state = m_rectangle_selection.get_state();
bool hover_modifiers_only = true;
for (int i : m_hover_volume_idxs)
{
if (!m_volumes.volumes[i]->is_modifier)
{
hover_modifiers_only = false;
break;
}
}
if ((state == GLSelectionRectangle::Select) && !ctrl_pressed)
m_selection.clear();
for (int i : m_hover_volume_idxs)
{ {
if (state == GLSelectionRectangle::Select) if (state == GLSelectionRectangle::Select)
m_selection.add(idx, is_single_modifier); {
if (hover_modifiers_only)
{
const GLVolume& v = *m_volumes.volumes[i];
m_selection.add_volume(v.object_idx(), v.volume_idx(), v.instance_idx(), false);
}
else else
m_selection.remove(idx); m_selection.add(i, false);
}
else
m_selection.remove(i);
} }
m_gizmos.refresh_on_off_state(m_selection); m_gizmos.refresh_on_off_state(m_selection);
@ -5654,7 +5684,6 @@ void GLCanvas3D::_update_selection_from_hover(GLSelectionRectangle::EState state
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
m_dirty = true; m_dirty = true;
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const Print* GLCanvas3D::fff_print() const const Print* GLCanvas3D::fff_print() const
{ {

View file

@ -460,9 +460,7 @@ private:
bool m_moving; bool m_moving;
bool m_tab_down; bool m_tab_down;
ECursorType m_cursor_type; ECursorType m_cursor_type;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
GLSelectionRectangle m_rectangle_selection; GLSelectionRectangle m_rectangle_selection;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Following variable is obsolete and it should be safe to remove it. // Following variable is obsolete and it should be safe to remove it.
// I just don't want to do it now before a release (Lukas Matena 24.3.2019) // I just don't want to do it now before a release (Lukas Matena 24.3.2019)
@ -637,9 +635,7 @@ private:
void _refresh_if_shown_on_screen(); void _refresh_if_shown_on_screen();
void _picking_pass() const; void _picking_pass() const;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void _rectangular_selection_picking_pass() const; void _rectangular_selection_picking_pass() const;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void _render_background() const; void _render_background() const;
void _render_bed(float theta) const; void _render_bed(float theta) const;
void _render_axes() const; void _render_axes() const;
@ -718,9 +714,8 @@ private:
void _resize_toolbars() const; void _resize_toolbars() const;
#endif // !ENABLE_SVG_ICONS #endif // !ENABLE_SVG_ICONS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // updates the selection from the content of m_hover_volume_idxs
void _update_selection_from_hover(GLSelectionRectangle::EState state); void _update_selection_from_hover();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
static std::vector<float> _parse_colors(const std::vector<std::string>& colors); static std::vector<float> _parse_colors(const std::vector<std::string>& colors);

View file

@ -59,9 +59,7 @@ std::vector<unsigned int> GLSelectionRectangle::stop_dragging(const GLCanvas3D&
void GLSelectionRectangle::stop_dragging() void GLSelectionRectangle::stop_dragging()
{ {
if (!is_dragging()) if (is_dragging())
return;
m_state = Off; m_state = Off;
} }

View file

@ -35,14 +35,12 @@ 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)); }
float get_right() const { return std::max(m_start_corner(0), m_end_corner(0)); } float get_right() const { return std::max(m_start_corner(0), m_end_corner(0)); }
float get_top() const { return std::max(m_start_corner(1), m_end_corner(1)); } float get_top() const { return std::max(m_start_corner(1), m_end_corner(1)); }
float get_bottom() const { return std::min(m_start_corner(1), m_end_corner(1)); } float get_bottom() const { return std::min(m_start_corner(1), m_end_corner(1)); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
private: private:
EState m_state = Off; EState m_state = Off;