From 5e6a7216831cd6269a2fb41f481c7bcded8a1a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Wed, 11 Dec 2024 17:06:06 +0100 Subject: [PATCH] Make thumbnail regeneration a wxEvent Also call the event when a bed texture is fully loaded. --- src/slic3r/GUI/3DBed.cpp | 1 + src/slic3r/GUI/Plater.cpp | 12 +++++------- src/slic3r/GUI/Plater.hpp | 2 +- src/slic3r/GUI/Sidebar.cpp | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 81b39dec6d..b211445fda 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -421,6 +421,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas, const Transform3d& v else if (m_texture.unsent_compressed_data_available()) { // sends to gpu the already available compressed levels of the main texture m_texture.send_compressed_data_to_gpu(); + wxQueueEvent(wxGetApp().plater(), new SimpleEvent(EVT_REGENERATE_BED_THUMBNAILS)); // the temporary texture is not needed anymore, reset it if (m_temp_texture.get_id() != 0) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7ca787dbfe..661932065e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -170,6 +170,7 @@ wxDEFINE_EVENT(EVT_SLICING_COMPLETED, wxCommandEvent); // BackgroundSlicingProcess finished either with success or error. wxDEFINE_EVENT(EVT_PROCESS_COMPLETED, SlicingProcessCompletedEvent); wxDEFINE_EVENT(EVT_EXPORT_BEGAN, wxCommandEvent); +wxDEFINE_EVENT(EVT_REGENERATE_BED_THUMBNAILS, SimpleEvent); // Plater::DropTarget @@ -563,7 +564,7 @@ struct Plater::priv void generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, Camera::EType camera_type); ThumbnailsList generate_thumbnails(const ThumbnailsParams& params, Camera::EType camera_type); - void regenerate_thumbnails(); + void regenerate_thumbnails(SimpleEvent&); void bring_instance_forward() const; @@ -771,6 +772,7 @@ void Plater::priv::init() q->Bind(EVT_EXPORT_BEGAN, &priv::on_export_began, this); q->Bind(EVT_GLVIEWTOOLBAR_3D, [this](SimpleEvent&) { q->select_view_3D("3D"); }); q->Bind(EVT_GLVIEWTOOLBAR_PREVIEW, [this](SimpleEvent&) { q->select_view_3D("Preview"); }); + q->Bind(EVT_REGENERATE_BED_THUMBNAILS, &priv::regenerate_thumbnails, this); } // Drop target: @@ -2229,7 +2231,7 @@ std::vector apply_to_inactive_beds( return result; } -void Plater::priv::regenerate_thumbnails() { +void Plater::priv::regenerate_thumbnails(SimpleEvent&) { const int num{s_multiple_beds.get_number_of_beds()}; if (num <= 1 || num > MAX_NUMBER_OF_BEDS) { return; @@ -2391,7 +2393,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool // If current bed was invalidated, update thumbnails for all beds: if (any_status_changed) { - regenerate_thumbnails(); + wxQueueEvent(this->q, new SimpleEvent(EVT_REGENERATE_BED_THUMBNAILS)); } // Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile. @@ -4789,10 +4791,6 @@ void Plater::object_list_changed() p->object_list_changed(); } -void Plater::regenerate_thumbnails() { - p->regenerate_thumbnails(); -} - std::vector Plater::load_files(const std::vector& input_files, bool load_model, bool load_config, bool imperial_units /*= false*/) { return p->load_files(input_files, load_model, load_config, imperial_units); } // To be called when providing a list of files to the GUI slic3r on command line. diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index fff0159614..10e5d769fb 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -58,6 +58,7 @@ namespace UndoRedo { namespace GUI { wxDECLARE_EVENT(EVT_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent); +wxDECLARE_EVENT(EVT_REGENERATE_BED_THUMBNAILS, SimpleEvent); class MainFrame; class GLCanvas3D; @@ -122,7 +123,6 @@ public: void reload_print(); void object_list_changed(); void generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, Camera::EType camera_type); - void regenerate_thumbnails(); std::vector load_files(const std::vector& input_files, bool load_model = true, bool load_config = true, bool imperial_units = false); // To be called when providing a list of files to the GUI slic3r on command line. diff --git a/src/slic3r/GUI/Sidebar.cpp b/src/slic3r/GUI/Sidebar.cpp index 2f7df4ca37..cc39d38e17 100644 --- a/src/slic3r/GUI/Sidebar.cpp +++ b/src/slic3r/GUI/Sidebar.cpp @@ -761,7 +761,7 @@ void Sidebar::on_select_preset(wxCommandEvent& evt) m_object_list->update_object_list_by_printer_technology(); s_multiple_beds.stop_autoslice(false); this->switch_from_autoslicing_mode(); - this->m_plater->regenerate_thumbnails(); + wxQueueEvent(this->m_plater, new SimpleEvent(EVT_REGENERATE_BED_THUMBNAILS)); this->m_plater->update(); s_print_statuses.fill(PrintStatus::idle); }