From 70fdb48c12aa9c3207c1162747f5176b129da642 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 12 Nov 2018 15:35:58 +0100 Subject: [PATCH] Manipulation with colorprint ticks now calls Plater::schedule_background_process() --- src/slic3r/GUI/GUI_Preview.cpp | 11 ++++++++--- src/slic3r/GUI/GUI_Preview.hpp | 5 ++++- src/slic3r/GUI/Plater.cpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 78f8b7462..b7f85d1ad 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -24,7 +24,7 @@ namespace Slic3r { namespace GUI { -Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data) +Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function schedule_background_process_func) : m_canvas(nullptr) , m_double_slider_sizer(nullptr) , m_label_view_type(nullptr) @@ -43,6 +43,7 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, , m_loaded(false) , m_enabled(false) , m_force_sliders_full_range(false) + , m_schedule_background_process(schedule_background_process_func) { if (init(notebook, config, print, gcode_preview_data)) { @@ -488,6 +489,7 @@ void Preview::create_double_slider() Bind(wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) { auto& config = wxGetApp().preset_bundle->project_config; ((config.option("colorprint_heights"))->values) = (m_slider->GetTicksValues()); + m_schedule_background_process(); }); } @@ -529,13 +531,16 @@ void Preview::fill_slider_values(std::vector> &values, } // All ticks that would end up outside the slider range should be erased. - // TODO: this should probably be placed into more appropriate part of code, - // this way it relies on the Preview tab being active. + // TODO: this should be placed into more appropriate part of code, + // this function is e.g. not called when the last object is deleted auto& config = wxGetApp().preset_bundle->project_config; std::vector &ticks_from_config = (config.option("colorprint_heights"))->values; + unsigned int old_size = ticks_from_config.size(); ticks_from_config.erase(std::remove_if(ticks_from_config.begin(), ticks_from_config.end(), [values](double val) { return values.back().second < val; }), ticks_from_config.end()); + if (ticks_from_config.size() != old_size) + m_schedule_background_process(); } void Preview::set_double_slider_thumbs(const bool force_sliders_full_range, diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index ab7544ed8..bafcba1ba 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -40,6 +40,9 @@ class Preview : public wxPanel Print* m_print; GCodePreviewData* m_gcode_preview_data; + // Calling this function object forces Plater::schedule_background_process. + std::function m_schedule_background_process; + unsigned int m_number_extruders; std::string m_preferred_color_mode; @@ -50,7 +53,7 @@ class Preview : public wxPanel PrusaDoubleSlider* m_slider {nullptr}; public: - Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data); + Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data, std::function schedule_background_process = [](){}); virtual ~Preview(); wxGLCanvas* get_wxglcanvas() { return m_canvas; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6b29e72f3..5a742c07b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1002,7 +1002,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) : _3DScene::add_canvas(canvas3D); _3DScene::allow_multisample(canvas3D, GLCanvas3DManager::can_multisample()); notebook->AddPage(canvas3D, _(L("3D"))); - preview = new GUI::Preview(notebook, config, &print, &gcode_preview_data); + preview = new GUI::Preview(notebook, config, &print, &gcode_preview_data, [this](){ schedule_background_process(); }); // XXX: If have OpenGL _3DScene::enable_picking(canvas3D, true);