From 4a8a1fac7b6ad690ed4f81eae9d31ae6e145a4c5 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 16:00:44 +0100 Subject: [PATCH 1/6] Fix of #1976 --- src/slic3r/GUI/GUI_Preview.cpp | 7 +++---- src/slic3r/GUI/GUI_Preview.hpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 5a9426547..9860f26b1 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -559,15 +559,14 @@ static int find_close_layer_idx(const std::vector& zs, double &z, double return -1; } -void Preview::update_double_slider(const std::vector& layers_z, bool force_sliders_full_range) +void Preview::update_double_slider(const std::vector& layers_z) { // Save the initial slider span. double z_low = m_slider->GetLowerValueD(); double z_high = m_slider->GetHigherValueD(); bool was_empty = m_slider->GetMaxValue() == 0; - bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6; - force_sliders_full_range |= was_empty | span_changed; - bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min(); + bool force_sliders_full_range = was_empty; + bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min(); bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max(); std::vector> values; diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 7820c137b..59f62ded1 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -138,7 +138,7 @@ private: // Create/Update/Reset double slider on 3dPreview void create_double_slider(); - void update_double_slider(const std::vector& layers_z, bool force_sliders_full_range = false); + void update_double_slider(const std::vector& layers_z); void fill_slider_values(std::vector> &values, const std::vector &layers_z); void reset_double_slider(); From 456d09be766c3323e652b83952a502ec3b66e313 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 18 Mar 2019 16:18:28 +0100 Subject: [PATCH 2/6] Fix out of bounds selection in ObjectList, fix #1890 --- src/slic3r/GUI/GUI_ObjectList.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 7eef82063..abfc067ff 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -2022,6 +2022,8 @@ void ObjectList::update_selections_on_canvas() void ObjectList::select_item(const wxDataViewItem& item) { + if (! item.IsOk()) { return; } + m_prevent_list_events = true; UnselectAll(); From bdaadcccd9b67ed8d8fb56c4c011c70108933705 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 19 Mar 2019 09:51:50 +0100 Subject: [PATCH 3/6] Implemented SPE-874 (Delete items from context menu for Simple mode) --- src/libslic3r/PrintConfig.cpp | 2 +- src/slic3r/GUI/GUI_ObjectList.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 46 ++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index a9fc1c63f..8c67cc067 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -208,7 +208,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Horizontal width of the brim that will be printed around each object on the first layer."); def->sidetext = L("mm"); def->min = 0; - def->mode = comAdvanced; + def->mode = comSimple; def->default_value = new ConfigOptionFloat(0); def = this->add("clip_multipart_objects", coBool); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index abfc067ff..183820aed 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -871,7 +871,7 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu) const ConfigOptionMode mode = wxGetApp().get_mode(); - if (mode < comExpert) + if (mode == comAdvanced) { append_menu_item(menu, wxID_ANY, _(L("Add part")), "", [this](wxCommandEvent&) { load_subobject(ModelVolumeType::MODEL_PART); }, *m_bmp_vector[int(ModelVolumeType::MODEL_PART)]); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 56dc323b3..4c1d40048 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1089,6 +1089,15 @@ struct Plater::priv // SLA-Object popup menu PrusaMenu sla_object_menu; + // Removed/Prepended Items according to the view mode + std::vector items_increase; + std::vector items_decrease; + std::vector items_set_number_of_copies; + enum MenuIdentifier { + miObjectFFF=0, + miObjectSLA + }; + // Data Slic3r::DynamicPrintConfig *config; // FIXME: leak? Slic3r::Print fff_print; @@ -2582,6 +2591,32 @@ void Plater::priv::on_right_click(Vec2dEvent& evt) sidebar->obj_list()->append_menu_item_settings(menu); + /* Remove/Prepend "increase/decrease instances" menu items according to the view mode. + * Suppress to show those items for a Simple mode + */ + const MenuIdentifier id = printer_technology == ptSLA ? miObjectSLA : miObjectFFF; + if (wxGetApp().get_mode() == comSimple) { + if (menu->FindItem(_(L("Increase copies"))) != wxNOT_FOUND) + { + /* Detach an items from the menu, but don't delete them + * so that they can be added back later + * (after switching to the Advanced/Expert mode) + */ + menu->Remove(items_increase[id]); + menu->Remove(items_decrease[id]); + menu->Remove(items_set_number_of_copies[id]); + } + } + else { + if (menu->FindItem(_(L("Increase copies"))) == wxNOT_FOUND) + { + // Prepend items to the menu, if those aren't not there + menu->Prepend(items_set_number_of_copies[id]); + menu->Prepend(items_decrease[id]); + menu->Prepend(items_increase[id]); + } + } + if (q != nullptr) { #ifdef __linux__ // For some reason on Linux the menu isn't displayed if position is specified @@ -2618,6 +2653,10 @@ void Plater::priv::on_3dcanvas_mouse_dragging_finished(SimpleEvent&) bool Plater::priv::init_object_menu() { + items_increase.reserve(2); + items_decrease.reserve(2); + items_set_number_of_copies.reserve(2); + init_common_menu(&object_menu); complit_init_object_menu(); @@ -2643,6 +2682,11 @@ bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/ [this](wxCommandEvent&) { q->decrease_instances(); }, "delete.png"); wxMenuItem* item_set_number_of_copies = append_menu_item(menu, wxID_ANY, _(L("Set number of copies")) + dots, _(L("Change the number of copies of the selected object")), [this](wxCommandEvent&) { q->set_number_of_copies(); }, "textfield.png"); + + items_increase.push_back(item_increase); + items_decrease.push_back(item_decrease); + items_set_number_of_copies.push_back(item_set_number_of_copies); + // Delete menu was moved to be after +/- instace to make it more difficult to be selected by mistake. item_delete = append_menu_item(menu, wxID_ANY, _(L("Delete")) + "\tDel", _(L("Remove the selected object")), [this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png"); @@ -2713,7 +2757,7 @@ bool Plater::priv::complit_init_object_menu() { q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split_objects->GetId()); - q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split()); }, item_split_volumes->GetId()); + q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split() && wxGetApp().get_mode() > comSimple); }, item_split_volumes->GetId()); } return true; } From 262f187699cdad6b51b4940072f9244cec962083 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 19 Mar 2019 10:09:54 +0100 Subject: [PATCH 4/6] Fixed visual hints for position in case of single volume selection --- src/slic3r/GUI/GLCanvas3D.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index f38e257ac..481dcb712 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1698,8 +1698,11 @@ void GLCanvas3D::Selection::render_sidebar_hints(const std::string& sidebar_fiel } else if (is_single_volume() || is_single_modifier()) { - Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true) * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true); ::glTranslated(center(0), center(1), center(2)); + Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); + if (!boost::starts_with(sidebar_field, "position")) + orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true); + ::glMultMatrixd(orient_matrix.data()); } else From 6eafc97302c086c052ae26f5ead9c55fb5b5c74a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 19 Mar 2019 10:48:20 +0100 Subject: [PATCH 5/6] Alternate fix of #1976 --- src/slic3r/GUI/GUI_Preview.cpp | 21 +++++++++++++-------- src/slic3r/GUI/GUI_Preview.hpp | 8 ++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 9860f26b1..9db490787 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -355,11 +355,11 @@ void Preview::set_drop_target(wxDropTarget* target) SetDropTarget(target); } -void Preview::load_print() +void Preview::load_print(bool keep_z_range) { PrinterTechnology tech = m_process->current_printer_technology(); if (tech == ptFFF) - load_print_as_fff(); + load_print_as_fff(keep_z_range); else if (tech == ptSLA) load_print_as_sla(); } @@ -390,7 +390,7 @@ void Preview::refresh_print() if (!IsShown()) return; - load_print(); + load_print(true); } void Preview::bind_event_handlers() @@ -447,10 +447,10 @@ void Preview::reset_sliders() m_double_slider_sizer->Hide((size_t)0); } -void Preview::update_sliders(const std::vector& layers_z) +void Preview::update_sliders(const std::vector& layers_z, bool keep_z_range) { m_enabled = true; - update_double_slider(layers_z); + update_double_slider(layers_z, keep_z_range); m_double_slider_sizer->Show((size_t)0); Layout(); } @@ -559,13 +559,18 @@ static int find_close_layer_idx(const std::vector& zs, double &z, double return -1; } -void Preview::update_double_slider(const std::vector& layers_z) +void Preview::update_double_slider(const std::vector& layers_z, bool keep_z_range) { // Save the initial slider span. double z_low = m_slider->GetLowerValueD(); double z_high = m_slider->GetHigherValueD(); bool was_empty = m_slider->GetMaxValue() == 0; bool force_sliders_full_range = was_empty; + if (!keep_z_range) + { + bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6; + force_sliders_full_range |= span_changed; + } bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min(); bool snap_to_max = force_sliders_full_range || m_slider->is_higher_at_max(); @@ -652,7 +657,7 @@ void Preview::update_double_slider_from_canvas(wxKeyEvent& event) event.Skip(); } -void Preview::load_print_as_fff() +void Preview::load_print_as_fff(bool keep_z_range) { if (m_loaded || m_process->current_printer_technology() != ptFFF) return; @@ -753,7 +758,7 @@ void Preview::load_print_as_fff() reset_sliders(); m_canvas_widget->Refresh(); } else - update_sliders(zs); + update_sliders(zs, keep_z_range); } } diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 59f62ded1..216583580 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -113,7 +113,7 @@ public: void select_view(const std::string& direction); void set_drop_target(wxDropTarget* target); - void load_print(); + void load_print(bool keep_z_range = false); void reload_print(bool keep_volumes = false); void refresh_print(); @@ -126,7 +126,7 @@ private: void show_hide_ui_elements(const std::string& what); void reset_sliders(); - void update_sliders(const std::vector& layers_z); + void update_sliders(const std::vector& layers_z, bool keep_z_range = false); void on_size(wxSizeEvent& evt); void on_choice_view_type(wxCommandEvent& evt); @@ -138,14 +138,14 @@ private: // Create/Update/Reset double slider on 3dPreview void create_double_slider(); - void update_double_slider(const std::vector& layers_z); + void update_double_slider(const std::vector& layers_z, bool keep_z_range = false); void fill_slider_values(std::vector> &values, const std::vector &layers_z); void reset_double_slider(); // update DoubleSlider after keyDown in canvas void update_double_slider_from_canvas(wxKeyEvent& event); - void load_print_as_fff(); + void load_print_as_fff(bool keep_z_range = false); void load_print_as_sla(); void on_sliders_scroll_changed(wxEvent& event); From 731e5a36b763a8d50569b2d5d364d0cd9fe26d6f Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Tue, 19 Mar 2019 10:54:54 +0100 Subject: [PATCH 6/6] Commit 4a8a1fac7b6ad690ed4f81eae9d31ae6e145a4c5 re-made as linux-only --- src/slic3r/GUI/GUI_Preview.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 9db490787..a2c2dbc39 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -366,12 +366,7 @@ void Preview::load_print(bool keep_z_range) void Preview::reload_print(bool keep_volumes) { - if (!IsShown()) - { - m_volumes_cleanup_required = !keep_volumes; - return; - } - +#ifndef __linux__ if (m_volumes_cleanup_required || !keep_volumes) { m_canvas->reset_volumes(); @@ -379,6 +374,23 @@ void Preview::reload_print(bool keep_volumes) m_loaded = false; m_volumes_cleanup_required = false; } +#endif // __linux__ + + if (!IsShown()) + { + m_volumes_cleanup_required = !keep_volumes; + return; + } + +#ifdef __linux__ + if (m_volumes_cleanup_required || !keep_volumes) + { + m_canvas->reset_volumes(); + m_canvas->reset_legend_texture(); + m_loaded = false; + m_volumes_cleanup_required = false; + } +#endif // __linux__ load_print(); }