From ec6599da98a5a478a2ca6c0f0ca5e042b0712875 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Thu, 1 Oct 2020 19:39:51 +0200 Subject: [PATCH 1/2] notifications: sla supports outside error appearing/disappearing --- src/slic3r/GUI/GLCanvas3D.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index c138b937c9..60192f0a24 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2662,6 +2662,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re _set_warning_texture(WarningTexture::ObjectClashed, state == ModelInstancePVS_Partly_Outside); _set_warning_texture(WarningTexture::ObjectOutside, state == ModelInstancePVS_Fully_Outside); + if(printer_technology != ptSLA || state == ModelInstancePVS_Inside) + _set_warning_texture(WarningTexture::SlaSupportsOutside, false); post_event(Event(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, contained_min_one && !m_model->objects.empty() && state != ModelInstancePVS_Partly_Outside)); @@ -2670,6 +2672,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re { _set_warning_texture(WarningTexture::ObjectOutside, false); _set_warning_texture(WarningTexture::ObjectClashed, false); + _set_warning_texture(WarningTexture::SlaSupportsOutside, false); post_event(Event(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, false)); } From 092a9f80b6828bc214ae65428ae0984acb043379 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 2 Oct 2020 10:26:11 +0200 Subject: [PATCH 2/2] notifications: avoid collision with gizmos on same position by moving to left --- src/slic3r/GUI/GLCanvas3D.cpp | 17 ++++++++++++++++- src/slic3r/GUI/GLCanvas3D.hpp | 20 ++++++++++++++++++-- src/slic3r/GUI/NotificationManager.cpp | 12 +++++++----- src/slic3r/GUI/NotificationManager.hpp | 10 ++++++++-- src/slic3r/GUI/Plater.cpp | 1 + 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 60192f0a24..b88b642f89 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -215,6 +215,8 @@ void GLCanvas3D::LayersEditing::set_enabled(bool enabled) m_enabled = is_allowed() && enabled; } +float GLCanvas3D::LayersEditing::s_overelay_window_width; + void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const { if (!m_enabled) @@ -297,6 +299,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const if (imgui.button(_L("Reset"))) wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), SimpleEvent(EVT_GLCANVAS_RESET_LAYER_HEIGHT_PROFILE)); + GLCanvas3D::LayersEditing::s_overelay_window_width = ImGui::GetWindowSize().x /*+ (float)m_layers_texture.width/4*/; imgui.end(); const Rect& bar_rect = get_bar_rect_viewport(canvas); @@ -1426,6 +1429,16 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas } #if ENABLE_SLOPE_RENDERING + +float GLCanvas3D::Slope::s_window_width; + +void GLCanvas3D::Slope::show_dialog(bool show) { + if (show && is_used()) + return; use(show); + m_dialog_shown = show; + wxGetApp().plater()->get_notification_manager()->set_move_from_slope(show); +} + void GLCanvas3D::Slope::render() const { if (m_dialog_shown) { @@ -1482,6 +1495,8 @@ void GLCanvas3D::Slope::render() const if (ImGui::GetWindowContentRegionWidth() + 2.0f * ImGui::GetStyle().WindowPadding.x != ImGui::CalcWindowExpectedSize(ImGui::GetCurrentWindow()).x) m_canvas.request_extra_frame(); + s_window_width = ImGui::GetWindowSize().x; + imgui.end(); if (modified) @@ -2151,7 +2166,7 @@ void GLCanvas3D::render() wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this); - wxGetApp().plater()->get_notification_manager()->render_notifications(*this); + wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overelay_window_width(), get_slope_window_width()); wxGetApp().imgui()->render(); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 03d42089b8..127f822c80 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -186,6 +186,8 @@ private: mutable float m_adaptive_quality; mutable HeightProfileSmoothingParams m_smooth_params; + + static float s_overelay_window_width; class LayersTexture { @@ -241,6 +243,7 @@ private: static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y); static Rect get_bar_rect_screen(const GLCanvas3D& canvas); static Rect get_bar_rect_viewport(const GLCanvas3D& canvas); + static float get_overelay_window_width() { return LayersEditing::s_overelay_window_width; } float object_max_z() const { return m_object_max_z; } @@ -254,6 +257,7 @@ private: void update_slicing_parameters(); static float thickness_bar_width(const GLCanvas3D &canvas); + }; struct Mouse @@ -425,7 +429,7 @@ private: bool m_dialog_shown{ false }; GLCanvas3D& m_canvas; GLVolumeCollection& m_volumes; - + static float s_window_width; public: Slope(GLCanvas3D& canvas, GLVolumeCollection& volumes) : m_canvas(canvas), m_volumes(volumes) {} @@ -433,12 +437,13 @@ private: bool is_enabled() const { return m_enabled; } void use(bool use) { m_volumes.set_slope_active(m_enabled ? use : false); } bool is_used() const { return m_volumes.is_slope_active(); } - void show_dialog(bool show) { if (show && is_used()) return; use(show); m_dialog_shown = show; } + void show_dialog(bool show); bool is_dialog_shown() const { return m_dialog_shown; } void render() const; void set_range(const std::array& range) const { m_volumes.set_slope_z_range({ -::cos(Geometry::deg2rad(90.0f - range[0])), -::cos(Geometry::deg2rad(90.0f - range[1])) }); } + static float get_window_width() { return s_window_width; }; }; #endif // ENABLE_SLOPE_RENDERING @@ -772,6 +777,8 @@ public: void set_slope_range(const std::array& range) { m_slope.set_range(range); } #endif // ENABLE_SLOPE_RENDERING + + private: bool _is_shown_on_screen() const; @@ -892,6 +899,15 @@ private: bool _activate_search_toolbar_item(); bool _deactivate_collapse_toolbar_items(); + float get_overelay_window_width() { return LayersEditing::get_overelay_window_width(); } + float get_slope_window_width() { +#if ENABLE_SLOPE_RENDERING + return Slope::get_window_width(); +#else + return 0.0f; +#endif + } + static std::vector _parse_colors(const std::vector& colors); public: diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index b9e7c7a6fc..228e6c3e9c 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -54,7 +54,7 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n, NotificationManager::PopNotification::~PopNotification() { } -NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y) +NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width) { if (!m_initialized) { init(); @@ -76,6 +76,7 @@ NotificationManager::PopNotification::RenderResult NotificationManager::PopNotif bool shown = true; std::string name; ImVec2 mouse_pos = ImGui::GetMousePos(); + float right_gap = SPACE_RIGHT_PANEL + (move_from_overlay ? overlay_width + m_line_height * 5 : (move_from_slope ? slope_width /*+ m_line_height * 0.3f*/ : 0)); if (m_line_height != ImGui::CalcTextSize("A").y) init(); @@ -85,10 +86,11 @@ NotificationManager::PopNotification::RenderResult NotificationManager::PopNotif //top y of window m_top_y = initial_y + m_window_height; //top right position - ImVec2 win_pos(1.0f * (float)cnv_size.get_width() - SPACE_RIGHT_PANEL, 1.0f * (float)cnv_size.get_height() - m_top_y); + + ImVec2 win_pos(1.0f * (float)cnv_size.get_width() - right_gap, 1.0f * (float)cnv_size.get_height() - m_top_y); imgui.set_next_window_pos(win_pos.x, win_pos.y, ImGuiCond_Always, 1.0f, 0.0f); imgui.set_next_window_size(m_window_width, m_window_height, ImGuiCond_Always); - + //find if hovered if (mouse_pos.x < win_pos.x && mouse_pos.x > win_pos.x - m_window_width && mouse_pos.y > win_pos.y&& mouse_pos.y < win_pos.y + m_window_height) { @@ -820,7 +822,7 @@ bool NotificationManager::push_notification_data(NotificationManager::PopNotific return false; } } -void NotificationManager::render_notifications(GLCanvas3D& canvas) +void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width) { float last_x = 0.0f; float current_height = 0.0f; @@ -835,7 +837,7 @@ void NotificationManager::render_notifications(GLCanvas3D& canvas) it = m_pop_notifications.erase(it); } else { (*it)->set_paused(m_hovered); - PopNotification::RenderResult res = (*it)->render(canvas, last_x); + PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width, m_move_from_slope, slope_width); if (res != PopNotification::RenderResult::Finished) { last_x = (*it)->get_top() + GAP_WIDTH; current_height = std::max(current_height, (*it)->get_current_top()); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index c2cbc242c8..24be35b91a 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -76,7 +76,7 @@ public: }; PopNotification(const NotificationData &n, const int id, wxEvtHandler* evt_handler); virtual ~PopNotification(); - RenderResult render(GLCanvas3D& canvas, const float& initial_y); + RenderResult render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width); // close will dissapear notification on next render void close() { m_close_pending = true; } // data from newer notification of same type @@ -229,11 +229,15 @@ public: void set_slicing_complete_print_time(std::string info); void set_slicing_complete_large(bool large); // renders notifications in queue and deletes expired ones - void render_notifications(GLCanvas3D& canvas); + void render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width); // finds and closes all notifications of given type void close_notification_of_type(const NotificationType type); void dpi_changed(); void set_in_preview(bool preview); + // Move to left to avoid colision with variable layer height gizmo + void set_move_from_overlay(bool move) { m_move_from_overlay = move; } + // or slope visualization gizmo + void set_move_from_slope (bool move) { m_move_from_slope = move; } private: //pushes notification into the queue of notifications that are rendered //can be used to create custom notification @@ -252,6 +256,8 @@ private: //timestamps used for slining finished - notification could be gone so it needs to be stored here std::unordered_set m_used_timestamps; bool m_in_preview { false }; + bool m_move_from_overlay { false }; + bool m_move_from_slope{ false }; //prepared (basic) notifications const std::vector basic_notifications = { diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6607bd5752..8111cbcae1 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3625,6 +3625,7 @@ void Plater::priv::on_action_split_volumes(SimpleEvent&) void Plater::priv::on_action_layersediting(SimpleEvent&) { view3D->enable_layers_editing(!view3D->is_layers_editing_enabled()); + notification_manager->set_move_from_overlay(view3D->is_layers_editing_enabled()); } void Plater::priv::on_object_select(SimpleEvent& evt)