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/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; 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 diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 7eef820631..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)]); @@ -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(); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 2211e8d7d5..a2c2dbc391 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)) { @@ -354,26 +355,42 @@ 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(); } -void Preview::reload_print(bool force, bool keep_volumes) +void Preview::reload_print(bool keep_volumes) { - if (!keep_volumes) +#ifndef __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__ + + if (!IsShown()) + { + m_volumes_cleanup_required = !keep_volumes; + return; } - if (!IsShown() && !force) - 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(); } @@ -385,7 +402,7 @@ void Preview::refresh_print() if (!IsShown()) return; - load_print(); + load_print(true); } void Preview::bind_event_handlers() @@ -442,10 +459,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(); } @@ -554,15 +571,19 @@ 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, 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 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; + 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(); std::vector> values; @@ -648,7 +669,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; @@ -749,7 +770,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 bfb604c403..2165835805 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; @@ -111,8 +113,8 @@ public: void select_view(const std::string& direction); void set_drop_target(wxDropTarget* target); - void load_print(); - void reload_print(bool force = false, bool keep_volumes = false); + void load_print(bool keep_z_range = false); + void reload_print(bool keep_volumes = false); void refresh_print(); private: @@ -124,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); @@ -136,14 +138,14 @@ 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, 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); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 601c2ddb6b..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; @@ -2388,7 +2397,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"); } @@ -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; }