From a5b202aa1d28c0c3280f42f63b9af0bc394d4ca9 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 12:59:52 +0100 Subject: [PATCH 1/9] Fix of #1955 and #1874 --- src/slic3r/GUI/GUI_Preview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 2211e8d7d5..69f255be19 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -365,6 +365,9 @@ void Preview::load_print() void Preview::reload_print(bool force, bool keep_volumes) { + if (!IsShown() && !force) + return; + if (!keep_volumes) { m_canvas->reset_volumes(); @@ -372,9 +375,6 @@ void Preview::reload_print(bool force, bool keep_volumes) m_loaded = false; } - if (!IsShown() && !force) - return; - load_print(); } From f249155340c0ca8ecc923527142f57049e2b9d46 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 14:07:55 +0100 Subject: [PATCH 2/9] Follow-up of a5b202aa1d28c0c3280f42f63b9af0bc394d4ca9 (fixed cleanup of toolpaths in preview after scene update) --- src/slic3r/GUI/GUI_Preview.cpp | 11 ++++++++--- src/slic3r/GUI/GUI_Preview.hpp | 4 +++- src/slic3r/GUI/Plater.cpp | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 69f255be19..5a9426547d 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -186,6 +186,7 @@ Preview::Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_t , m_loaded(false) , m_enabled(false) , m_schedule_background_process(schedule_background_process_func) + , m_volumes_cleanup_required(false) { if (init(parent, bed, camera, view_toolbar)) { @@ -363,16 +364,20 @@ void Preview::load_print() load_print_as_sla(); } -void Preview::reload_print(bool force, bool keep_volumes) +void Preview::reload_print(bool keep_volumes) { - if (!IsShown() && !force) + if (!IsShown()) + { + m_volumes_cleanup_required = !keep_volumes; return; + } - if (!keep_volumes) + if (m_volumes_cleanup_required || !keep_volumes) { m_canvas->reset_volumes(); m_canvas->reset_legend_texture(); m_loaded = false; + m_volumes_cleanup_required = false; } load_print(); diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index bfb604c403..7820c137b1 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -86,6 +86,8 @@ class Preview : public wxPanel BackgroundSlicingProcess* m_process; GCodePreviewData* m_gcode_preview_data; + bool m_volumes_cleanup_required; + // Calling this function object forces Plater::schedule_background_process. std::function m_schedule_background_process; @@ -112,7 +114,7 @@ public: void set_drop_target(wxDropTarget* target); void load_print(); - void reload_print(bool force = false, bool keep_volumes = false); + void reload_print(bool keep_volumes = false); void refresh_print(); private: diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 601c2ddb6b..56dc323b32 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2388,7 +2388,7 @@ void Plater::priv::set_current_panel(wxPanel* panel) { this->q->reslice(); // keeps current gcode preview, if any - preview->reload_print(false, true); + preview->reload_print(true); preview->set_canvas_as_dirty(); view_toolbar.select_item("Preview"); } From cd2cccec5f2ff20fa06b8f66472656671032c616 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 18 Mar 2019 15:31:47 +0100 Subject: [PATCH 3/9] Adding validation code for support parameters (elevation) --- src/libslic3r/SLA/SLASupportTree.cpp | 4 ++-- src/libslic3r/SLAPrint.cpp | 17 +++++++++++++++++ src/libslic3r/SLAPrint.hpp | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 650dfe2e79..df9990822d 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -1466,7 +1466,7 @@ public: m_cfg.head_back_radius_mm, w); - if(t <= w || (hp(Z) + nn(Z) * w) < m_result.ground_level) { + if(t <= w) { // Let's try to optimize this angle, there might be a // viable normal that doesn't collide with the model @@ -1509,7 +1509,7 @@ public: // save the verified and corrected normal m_support_nmls.row(fidx) = nn; - if(t > w && (hp(Z) + nn(Z) * w) > m_result.ground_level) { + if(t > w) { // mark the point for needing a head. m_iheads.emplace_back(fidx); } else if( polar >= 3*PI/4 ) { diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 0e8e717cc6..83fa61fdd0 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -571,7 +571,24 @@ void swapXY(ExPolygon& expoly) { for(auto& p : expoly.contour.points) std::swap(p(X), p(Y)); for(auto& h : expoly.holes) for(auto& p : h.points) std::swap(p(X), p(Y)); } +} +std::string SLAPrint::validate() const +{ + for(SLAPrintObject * po : m_objects) { + sla::SupportConfig cfg = make_support_cfg(po->config()); + + double pinhead_width = + 2 * cfg.head_front_radius_mm + + cfg.head_width_mm + + 2 * cfg.head_back_radius_mm - + cfg.head_penetration_mm; + + if(pinhead_width > cfg.object_elevation_mm) + return L("Elevetion is too low for object."); + } + + return ""; } std::vector SLAPrint::calculate_heights(const BoundingBoxf3& bb3d, diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index eb927c769d..c06e2fc777 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -240,6 +240,8 @@ public: const SLAPrintStatistics& print_statistics() const { return m_print_statistics; } + std::string validate() const override; + private: using SLAPrinter = FilePrinter; using SLAPrinterPtr = std::unique_ptr; From 4a8a1fac7b6ad690ed4f81eae9d31ae6e145a4c5 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 18 Mar 2019 16:00:44 +0100 Subject: [PATCH 4/9] 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 5a9426547d..9860f26b1f 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 7820c137b1..59f62ded1d 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 5/9] 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 7eef820631..abfc067ff3 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 6/9] 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 a9fc1c63f1..8c67cc067e 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 abfc067ff3..183820aedf 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 56dc323b32..4c1d400485 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 7/9] 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 f38e257ac3..481dcb712d 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 8/9] 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 9860f26b1f..9db490787f 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 59f62ded1d..2165835805 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 9/9] 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 9db490787f..a2c2dbc391 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(); }