From d99d22a9014acaed5c50b45954020e420f1c2381 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 23 May 2023 16:43:26 +0200 Subject: [PATCH] Make partial arrange callable using a flag --- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 7 +++++-- src/slic3r/GUI/Jobs/ArrangeJob.hpp | 5 ++++- src/slic3r/GUI/Plater.cpp | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index d7c01c368..a0659a235 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -243,7 +243,7 @@ coord_t get_skirt_offset(const Plater* plater) { void ArrangeJob::prepare() { - wxGetKeyState(WXK_SHIFT) ? prepare_selected() : prepare_all(); + m_selection_only ? prepare_selected() : prepare_all(); coord_t min_offset = 0; for (auto &ap : m_selected) { @@ -307,7 +307,10 @@ void ArrangeJob::process(Ctl &ctl) _u8L("Arranging done.")); } -ArrangeJob::ArrangeJob() : m_plater{wxGetApp().plater()} {} +ArrangeJob::ArrangeJob(Mode mode) + : m_plater{wxGetApp().plater()}, + m_selection_only{mode == Mode::SelectionOnly} +{} static std::string concat_strings(const std::set &strings, const std::string &delim = "\n") diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.hpp b/src/slic3r/GUI/Jobs/ArrangeJob.hpp index 6ff25923e..4defc07e8 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.hpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.hpp @@ -24,6 +24,7 @@ class ArrangeJob : public Job coord_t m_min_bed_inset = 0.; Plater *m_plater; + bool m_selection_only = false; // clear m_selected and m_unselected, reserve space for next usage void clear_input(); @@ -39,11 +40,13 @@ class ArrangeJob : public Job public: + enum Mode { Full, SelectionOnly }; + void prepare(); void process(Ctl &ctl) override; - ArrangeJob(); + ArrangeJob(Mode mode = Full); int status_range() const { diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 2e22dc0de..9ef9a3314 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7177,7 +7177,11 @@ void Plater::arrange() if (p->can_arrange()) { auto &w = get_ui_job_worker(); p->take_snapshot(_L("Arrange")); - replace_job(w, std::make_unique()); + + auto mode = wxGetKeyState(WXK_SHIFT) ? ArrangeJob::SelectionOnly : + ArrangeJob::Full; + + replace_job(w, std::make_unique(mode)); } }