From a21f1783a97e72d5c01024b594e370e71da62e38 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 21 Nov 2018 13:52:46 +0100 Subject: [PATCH] Added force_full_scene_refresh parameter to the 3DScene::refresh() function to force a refresh of all GLVolumes. Currently this hack is used by the Platter::arrange() function only, and ideally we should replace this parameter with a smarter 3DScene::refresh() function, which would check for the transformation matrices as well. --- src/slic3r/GUI/3DScene.cpp | 4 ++-- src/slic3r/GUI/3DScene.hpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++--- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/GLCanvas3DManager.cpp | 4 ++-- src/slic3r/GUI/GLCanvas3DManager.hpp | 2 +- src/slic3r/GUI/Plater.cpp | 12 ++++++------ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 4f1161f79..b6b5691a1 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -2107,9 +2107,9 @@ void _3DScene::mirror_selection(wxGLCanvas* canvas, Axis axis) s_canvas_mgr.mirror_selection(canvas, axis); } -void _3DScene::reload_scene(wxGLCanvas* canvas, bool force) +void _3DScene::reload_scene(wxGLCanvas* canvas, bool refresh_immediately, bool force_full_scene_refresh) { - s_canvas_mgr.reload_scene(canvas, force); + s_canvas_mgr.reload_scene(canvas, refresh_immediately, force_full_scene_refresh); } void _3DScene::load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 1e3618ba8..7fdb845cf 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -644,7 +644,7 @@ public: static void mirror_selection(wxGLCanvas* canvas, Axis axis); - static void reload_scene(wxGLCanvas* canvas, bool force); + static void reload_scene(wxGLCanvas* canvas, bool refresh_immediately, bool force_full_scene_refresh = false); static void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors); static void load_preview(wxGLCanvas* canvas, const std::vector& str_tool_colors); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 154043045..e378eb23d 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3767,7 +3767,7 @@ void GLCanvas3D::mirror_selection(Axis axis) // 3) SLA support meshes for their respective ModelObjects / ModelInstances // 4) Wipe tower preview // 5) Out of bed collision status & message overlay (texture) -void GLCanvas3D::reload_scene(bool force) +void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_refresh) { if ((m_canvas == nullptr) || (m_config == nullptr) || (m_model == nullptr)) return; @@ -3809,7 +3809,7 @@ void GLCanvas3D::reload_scene(bool force) glvolumes_new.reserve(m_volumes.volumes.size()); auto model_volume_state_lower = [](const ModelVolumeState &m1, const ModelVolumeState &m2) { return m1.geometry_id < m2.geometry_id; }; - m_reload_delayed = ! m_canvas->IsShown() && ! force; + m_reload_delayed = ! m_canvas->IsShown() && ! refresh_immediately && ! force_full_scene_refresh; PrinterTechnology printer_technology = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology(); @@ -3866,7 +3866,7 @@ void GLCanvas3D::reload_scene(bool force) if (it != model_volume_state.end() && it->geometry_id == key.geometry_id) mvs = &(*it); } - if (mvs == nullptr) { + if (mvs == nullptr || force_full_scene_refresh) { // This GLVolume will be released. volume->release_geometry(); if (! m_reload_delayed) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index a659889c0..a52b544cf 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -824,7 +824,7 @@ public: void mirror_selection(Axis axis); - void reload_scene(bool force); + void reload_scene(bool refresh_immediately, bool force_full_scene_refresh); void load_gcode_preview(const GCodePreviewData& preview_data, const std::vector& str_tool_colors); void load_preview(const std::vector& str_tool_colors); diff --git a/src/slic3r/GUI/GLCanvas3DManager.cpp b/src/slic3r/GUI/GLCanvas3DManager.cpp index 6e75d2a1d..fb5b8addb 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -506,11 +506,11 @@ void GLCanvas3DManager::mirror_selection(wxGLCanvas* canvas, Axis axis) it->second->mirror_selection(axis); } -void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool force) +void GLCanvas3DManager::reload_scene(wxGLCanvas* canvas, bool refresh_immediately, bool force_full_scene_refresh) { CanvasesMap::iterator it = _get_canvas(canvas); if (it != m_canvases.end()) - it->second->reload_scene(force); + it->second->reload_scene(refresh_immediately, force_full_scene_refresh); } void GLCanvas3DManager::load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors) diff --git a/src/slic3r/GUI/GLCanvas3DManager.hpp b/src/slic3r/GUI/GLCanvas3DManager.hpp index ead7945d5..881befa1b 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -141,7 +141,7 @@ public: void mirror_selection(wxGLCanvas* canvas, Axis axis); - void reload_scene(wxGLCanvas* canvas, bool force); + void reload_scene(wxGLCanvas* canvas, bool refresh_immediately, bool force_full_scene_refresh = false); void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors); void load_preview(wxGLCanvas* canvas, const std::vector& str_tool_colors); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1514a3eaa..99c6148c7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -930,7 +930,7 @@ struct Plater::priv priv(Plater *q, MainFrame *main_frame); - void update(); + void update(bool force_full_scene_refresh = false); void select_view(const std::string& direction); void update_ui_from_settings(); ProgressStatusBar* statusbar(); @@ -1144,7 +1144,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) q->Layout(); } -void Plater::priv::update() +void Plater::priv::update(bool force_full_scene_refresh) { wxWindowUpdateLocker freeze_guard(q); if (get_config("autocenter") == "1") { @@ -1160,7 +1160,7 @@ void Plater::priv::update() // pulls the correct data. this->update_background_process(); } - _3DScene::reload_scene(canvas3D, false); + _3DScene::reload_scene(canvas3D, false, force_full_scene_refresh); preview->reset_gcode_preview_data(); preview->reload_print(); @@ -1662,9 +1662,9 @@ void Plater::priv::arrange() // We enable back the arrange button _3DScene::enable_toolbar_item(canvas3D, "arrange", can_arrange()); - // FIXME: none of the following seem to work now. (update did the job previously) - // _3DScene::reload_scene(canvas3D, false); - update(); + // Do a full refresh of scene tree, including regenerating all the GLVolumes. + //FIXME The update function shall just reload the modified matrices. + update(true); } void Plater::priv::split_object()