From 86afffa692145e55b490f5cb047fcddae431529e Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 30 Nov 2021 12:06:28 +0100 Subject: [PATCH] Don't let UI jobs overlap. --- src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp | 6 ++++++ src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 16 ++++++++++++---- src/slic3r/GUI/Plater.hpp | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp index 52e62f1571..61fe6e7095 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp @@ -553,9 +553,15 @@ GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui, auto btn_txt_sz = ImGui::CalcTextSize(btn_txt.c_str()); ImVec2 button_sz = {btn_txt_sz.x + padding.x, btn_txt_sz.y + padding.y}; ImGui::SetCursorPosX(padding.x + sz.x - button_sz.x); + + if (wxGetApp().plater()->is_any_job_running()) + imgui->disabled_begin(true); + if ( imgui->button(btn_txt) ) { wxGetApp().plater()->optimize_rotation(); } + + imgui->disabled_end(); } GLGizmoRotate3D::RotoptimzeWindow::~RotoptimzeWindow() diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 18aeeec34e..d953626c4d 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1203,7 +1203,7 @@ void MainFrame::init_menubar_as_editor() append_menu_item(import_menu, wxID_ANY, _L("Import SL1 / SL1S archive") + dots, _L("Load an SL1 / Sl1S archive"), [this](wxCommandEvent&) { if (m_plater) m_plater->import_sl1_archive(); }, "import_plater", nullptr, - [this](){return m_plater != nullptr; }, this); + [this](){return m_plater != nullptr && !m_plater->is_any_job_running(); }, this); import_menu->AppendSeparator(); append_menu_item(import_menu, wxID_ANY, _L("Import &Config") + dots + "\tCtrl+L", _L("Load exported configuration file"), diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 783cccd6bd..e61015388c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5082,7 +5082,8 @@ void Plater::add_model(bool imperial_units/* = false*/) void Plater::import_sl1_archive() { - p->m_ui_jobs.import_sla_arch(); + if (!p->m_ui_jobs.is_any_running()) + p->m_ui_jobs.import_sla_arch(); } void Plater::extract_config_from_project() @@ -5366,6 +5367,11 @@ void Plater::update() { p->update(); } void Plater::stop_jobs() { p->m_ui_jobs.stop_all(); } +bool Plater::is_any_job_running() const +{ + return p->m_ui_jobs.is_any_running(); +} + void Plater::update_ui_from_settings() { p->update_ui_from_settings(); } void Plater::select_view(const std::string& direction) { p->select_view(direction); } @@ -5514,7 +5520,8 @@ void Plater::set_number_of_copies(/*size_t num*/) void Plater::fill_bed_with_instances() { - p->m_ui_jobs.fill_bed(); + if (!p->m_ui_jobs.is_any_running()) + p->m_ui_jobs.fill_bed(); } bool Plater::is_selection_empty() const @@ -6394,7 +6401,8 @@ GLCanvas3D* Plater::get_current_canvas3D() void Plater::arrange() { - p->m_ui_jobs.arrange(); + if (!p->m_ui_jobs.is_any_running()) + p->m_ui_jobs.arrange(); } void Plater::set_current_canvas_as_dirty() @@ -6565,7 +6573,7 @@ void Plater::suppress_background_process(const bool stop_background_process) void Plater::mirror(Axis axis) { p->mirror(axis); } void Plater::split_object() { p->split_object(); } void Plater::split_volume() { p->split_volume(); } -void Plater::optimize_rotation() { p->m_ui_jobs.optimize_rotation();} +void Plater::optimize_rotation() { if (!p->m_ui_jobs.is_any_running()) p->m_ui_jobs.optimize_rotation(); } void Plater::update_menus() { p->menus.update(); } void Plater::show_action_buttons(const bool ready_to_slice) const { p->show_action_buttons(ready_to_slice); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 55a36d21c7..d3eead4ede 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -178,6 +178,7 @@ public: void update(); void stop_jobs(); + bool is_any_job_running() const; void select_view(const std::string& direction); void select_view_3D(const std::string& name);