From bc81c22ea9327577f8f2fb558fb7bcadbb8eabda Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 4 Aug 2021 12:15:20 +0200 Subject: [PATCH 1/2] CLI: Ensure that objects are on bed by default, new CLI config option: 'dont-ensure-on-bed' (which allows to override). This was the original behaviour in Slic3r and Sli3rPE, probably broken long ago when CLI was ported from Perl. Also, --scale-to-fit should now work again (#5772) --- src/PrusaSlicer.cpp | 12 ++++++++++++ src/libslic3r/Model.cpp | 13 +++++-------- src/libslic3r/PrintConfig.cpp | 4 ++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index b3e6841c9..21b161456 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -258,6 +258,7 @@ int CLI::run(int argc, char **argv) Points bed = get_bed_shape(m_print_config); ArrangeParams arrange_cfg; arrange_cfg.min_obj_distance = scaled(min_object_distance(m_print_config)); + bool user_ensure_on_bed = true; for (auto const &opt_key : m_transforms) { if (opt_key == "merge") { @@ -330,6 +331,10 @@ int CLI::run(int argc, char **argv) } } else if (opt_key == "dont_arrange") { // do nothing - this option alters other transform options + } else if (opt_key == "dont_ensure_on_bed") { + // Remember that we saw this so we don't lift objects from the bed + // after the other transformations are processed. + user_ensure_on_bed = false; } else if (opt_key == "rotate") { for (auto &model : m_models) for (auto &o : model.objects) @@ -432,6 +437,13 @@ int CLI::run(int argc, char **argv) } } + // All transforms have been dealt with. Now ensure that the objects are on bed. + // (Unless the user said otherwise.) + if (user_ensure_on_bed) + for (auto &model : m_models) + for (auto &o : model.objects) + o->ensure_on_bed(); + // loop through action options for (auto const &opt_key : m_actions) { if (opt_key == "help") { diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index e6006ef58..ba743f49c 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1745,18 +1745,15 @@ void ModelVolume::scale(const Vec3d& scaling_factors) void ModelObject::scale_to_fit(const Vec3d &size) { -/* - BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const; Vec3d orig_size = this->bounding_box().size(); - float factor = fminf( - size.x / orig_size.x, - fminf( - size.y / orig_size.y, - size.z / orig_size.z + double factor = std::min( + size.x() / orig_size.x(), + std::min( + size.y() / orig_size.y(), + size.z() / orig_size.z() ) ); this->scale(factor); -*/ } void ModelVolume::assign_new_unique_ids_recursive() diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 512843110..16c16f038 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4154,6 +4154,10 @@ CLITransformConfigDef::CLITransformConfigDef() def->label = L("Don't arrange"); def->tooltip = L("Do not rearrange the given models before merging and keep their original XY coordinates."); + def = this->add("dont_ensure_on_bed", coBool); + def->label = L("Don't ensure on bed"); + def->tooltip = L("Do not lift the object above the bed when it is partially below."); + def = this->add("duplicate", coInt); def->label = L("Duplicate"); def->tooltip =L("Multiply copies by this factor."); From 7fd9a9cf6e50008aef0dd6f97b04615861b2ef0a Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 4 Aug 2021 12:30:15 +0200 Subject: [PATCH 2/2] ObjectList: Fixed a crash during a print technology change when InfoItem is selected + Add "Gallery" menu Item for Advanced mode too --- src/slic3r/GUI/GUI_Factories.cpp | 2 +- src/slic3r/GUI/GUI_ObjectList.cpp | 20 ++++++++++++++++---- src/slic3r/GUI/GUI_ObjectList.hpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 86f3eae0a..db3241e35 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -433,7 +433,7 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty [type, item](wxCommandEvent&) { obj_list()->load_generic_subobject(item, type); }, "", menu); } - if (wxGetApp().get_mode() == comExpert) { + if (wxGetApp().get_mode() >= comAdvanced) { sub_menu->AppendSeparator(); append_menu_item(sub_menu, wxID_ANY, _L("Gallery"), "", [type](wxCommandEvent&) { obj_list()->load_subobject(type, true); }, "", menu); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index a2d64d72c..b7027404e 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -2517,7 +2517,7 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D } -void ObjectList::update_info_items(size_t obj_idx) +void ObjectList::update_info_items(size_t obj_idx, wxDataViewItemArray* selections/* = nullptr*/) { const ModelObject* model_object = (*m_objects)[obj_idx]; wxDataViewItem item_obj = m_objects_model->GetItemById(obj_idx); @@ -2565,9 +2565,21 @@ void ObjectList::update_info_items(size_t obj_idx) } else if (shows && ! should_show) { - Unselect(item); + if (!selections) + Unselect(item); m_objects_model->Delete(item); - Select(item_obj); + if (selections) { + if (selections->Index(item) != wxNOT_FOUND) { + // If info item was deleted from the list, + // it's need to be deleted from selection array, if it was there + selections->Remove(item); + // Select item_obj, if info_item doesn't exist for item anymore, but was selected + if (selections->Index(item_obj) == wxNOT_FOUND) + selections->Add(item_obj); + } + } + else + Select(item_obj); } } } @@ -3760,7 +3772,7 @@ void ObjectList::update_object_list_by_printer_technology() for (auto& object_item : object_items) { // update custom supports info - update_info_items(m_objects_model->GetObjectIdByItem(object_item)); + update_info_items(m_objects_model->GetObjectIdByItem(object_item), &sel); // Update Settings Item for object update_settings_item_and_selection(object_item, sel); diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index cc34e348a..a57947044 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -350,7 +350,7 @@ public: void update_and_show_object_settings_item(); void update_settings_item_and_selection(wxDataViewItem item, wxDataViewItemArray& selections); void update_object_list_by_printer_technology(); - void update_info_items(size_t obj_idx); + void update_info_items(size_t obj_idx, wxDataViewItemArray* selections = nullptr); void instances_to_separated_object(const int obj_idx, const std::set& inst_idx); void instances_to_separated_objects(const int obj_idx);