From cbb62142debd70f21f3504170f4e7453ca2971ba Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 25 Oct 2018 21:13:45 +0200 Subject: [PATCH] =?UTF-8?q?Added=20"Set=20number=20of=20copies=E2=80=A6"?= =?UTF-8?q?=20to=20the=20context=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/slic3r/GUI/Plater.cpp | 11 ++++++++++- src/slic3r/GUI/Plater.hpp | 2 +- src/slic3r/GUI/wxExtensions.cpp | 11 ----------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 18e47ef8c..95d052001 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "libslic3r/libslic3r.h" #include "libslic3r/PrintConfig.hpp" @@ -2023,6 +2024,8 @@ bool Plater::priv::init_object_menu() [this](wxCommandEvent&){ q->increase_instances(); }, "add.png"); wxMenuItem* item_decrease = append_menu_item(&object_menu, wxID_ANY, _(L("Decrease copies\t-")), _(L("Remove one copy of the selected object")), [this](wxCommandEvent&){ q->decrease_instances(); }, "delete.png"); + wxMenuItem* item_set_number_of_copies = append_menu_item(&object_menu, wxID_ANY, _(L("Set number of copies…")), _(L("Change the number of copies of the selected object")), + [this](wxCommandEvent&){ q->set_number_of_copies(); }, "textfield.png"); object_menu.AppendSeparator(); @@ -2062,6 +2065,7 @@ bool Plater::priv::init_object_menu() q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_increase_instances()); }, item_increase->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_decrease_instances()); }, item_decrease->GetId()); + q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_increase_instances()); }, item_set_number_of_copies->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects() || can_split_to_volumes()); }, item_split->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects()); }, item_split_objects->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId()); @@ -2280,7 +2284,7 @@ void Plater::decrease_instances(size_t num) this->p->schedule_background_process(); } -void Plater::set_number_of_copies(size_t num) +void Plater::set_number_of_copies(/*size_t num*/) { #if ENABLE_EXTENDED_SELECTION int obj_idx = p->get_selected_object_idx(); @@ -2295,6 +2299,11 @@ void Plater::set_number_of_copies(size_t num) auto *model_object = p->model.objects[*obj_idx]; #endif // ENABLE_EXTENDED_SELECTION + const auto num = wxGetNumberFromUser( " ", _("Enter the number of copies:"), + _("Copies of the selected object"), model_object->instances.size(), 0, 1000, this ); + if (num < 0) + return; + int diff = (int)num - (int)model_object->instances.size(); if (diff > 0) increase_instances(diff); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 7ea5b1964..4c6d0ff30 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -114,7 +114,7 @@ public: void remove_selected(); void increase_instances(size_t num = 1); void decrease_instances(size_t num = 1); - void set_number_of_copies(size_t num); + void set_number_of_copies(/*size_t num*/); // Note: empty path means "use the default" void export_gcode(boost::filesystem::path output_path = boost::filesystem::path()); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 27628c3db..f9eb032c4 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -653,17 +653,6 @@ wxDataViewItem PrusaObjectDataViewModel::DeleteLastInstance(const wxDataViewItem ItemDeleted(inst_root_item, wxDataViewItem(last_instance_node)); } -// for (int i = delete_inst_root_item ? 0 : inst_cnt - num; i < inst_cnt; ++i) -// items.Add(wxDataViewItem(inst_root_node->GetNthChild(i))); -// -// if (delete_inst_root_item) -// inst_root_node->GetChildren().RemoveAt(0, inst_cnt); -// else { -// ret_item = wxDataViewItem(inst_root_node->GetNthChild(inst_cnt - num - 1)); -// inst_root_node->GetChildren().RemoveAt(inst_cnt - num, num); -// } - -// ItemsDeleted(inst_root_item, items); if (delete_inst_root_item) { ret_item = parent_item; parent_node->GetChildren().Remove(inst_root_node);