From afbbb36fa4c67ebbf9589ecc7ebb4c4db16c9dbb Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 1 Oct 2021 13:34:22 +0200 Subject: [PATCH 01/10] Fixed import of multi-material AMF files, broken due to admesh eradication. --- src/libslic3r/Format/3mf.cpp | 2 +- src/libslic3r/Format/AMF.cpp | 39 +++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index eca057a5b..131278e9f 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1922,7 +1922,7 @@ namespace Slic3r { { int min_id = its.indices.front()[0]; int max_id = min_id; - for (const Vec3i& face : its.indices) { + for (const Vec3i face : its.indices) { for (const int tri_id : face) { if (tri_id < 0 || tri_id >= int(geometry.vertices.size())) { add_error("Found invalid vertex id"); diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index f0807df51..48c25fc4d 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -617,19 +617,35 @@ void AMFParserContext::endElement(const char * /* name */) case NODE_TYPE_VOLUME: { assert(m_object && m_volume); - // Verify validity of face indices. - for (Vec3i face : m_volume_facets) - for (unsigned int tri_id : face) - if (tri_id < 0 || tri_id >= m_object_vertices.size()) { - this->stop("Malformed triangle mesh"); - return; - } + if (m_volume_facets.empty()) { + this->stop("An empty triangle mesh found"); + return; + } { - TriangleMesh triangle_mesh { std::move(m_object_vertices), std::move(m_volume_facets) }; - if (triangle_mesh.volume() < 0) - triangle_mesh.flip_triangles(); - m_volume->set_mesh(std::move(triangle_mesh)); + // Verify validity of face indices, find the vertex span. + int min_id = m_volume_facets.front()[0]; + int max_id = min_id; + for (const Vec3i face : m_volume_facets) { + for (const int tri_id : face) { + if (tri_id < 0 || tri_id >= int(m_object_vertices.size())) { + this->stop("Malformed triangle mesh"); + return; + } + min_id = std::min(min_id, tri_id); + max_id = std::max(max_id, tri_id); + } + } + + // rebase indices to the current vertices list + for (Vec3i &face : m_volume_facets) + face -= Vec3i(min_id, min_id, min_id); + + indexed_triangle_set its { std::move(m_volume_facets), { m_object_vertices.begin() + min_id, m_object_vertices.begin() + max_id + 1 } }; + its_compactify_vertices(its); + if (its_volume(its) < 0) + its_flip_triangles(its); + m_volume->set_mesh(std::move(its)); } // stores the volume matrix taken from the metadata, if present @@ -646,7 +662,6 @@ void AMFParserContext::endElement(const char * /* name */) m_volume->calculate_convex_hull(); m_volume_facets.clear(); - m_object_vertices.clear(); m_volume = nullptr; break; } From aaf47884cd699976321495bc9c4bec82d0ea1ee9 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 1 Oct 2021 14:14:47 +0200 Subject: [PATCH 02/10] Revert of 117df134f643ab2f62b6b955de36ebe6740e7eb3 --- src/slic3r/GUI/Plater.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 8c578a2d6..ecbcc61af 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2442,7 +2442,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ for (ModelObject* model_object : model.objects) { if (!type_3mf && !type_zip_amf) model_object->center_around_origin(false); - model_object->ensure_on_bed(is_project_file || type_3mf || type_zip_amf); + model_object->ensure_on_bed(is_project_file); } // check multi-part object adding for the SLA-printing @@ -2459,7 +2459,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ if (one_by_one) { if (type_3mf && !is_project_file) model.center_instances_around_point(bed_shape_bb().center()); - auto loaded_idxs = load_model_objects(model.objects, is_project_file || type_3mf || type_zip_amf); + auto loaded_idxs = load_model_objects(model.objects, is_project_file); obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end()); } else { // This must be an .stl or .obj file, which may contain a maximum of one volume. From 68de2a49a31f6ceabc2df5a91e3d03d1aacce292 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 1 Oct 2021 14:28:36 +0200 Subject: [PATCH 03/10] Fixed update of mesh volume after applying a transformation. Fixes flipped normals when importing some 3MFs. --- src/libslic3r/TriangleMesh.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 39815bd64..f5fea32f8 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -325,20 +325,24 @@ void TriangleMesh::mirror(const Axis axis) void TriangleMesh::transform(const Transform3d& t, bool fix_left_handed) { its_transform(its, t); - if (fix_left_handed && t.matrix().block(0, 0, 3, 3).determinant() < 0.) + double det = t.matrix().block(0, 0, 3, 3).determinant(); + if (fix_left_handed && det < 0.) { its_flip_triangles(its); - else - m_stats.volume = - m_stats.volume; + det = -det; + } + m_stats.volume *= det; update_bounding_box(this->its, this->m_stats); } void TriangleMesh::transform(const Matrix3d& m, bool fix_left_handed) { its_transform(its, m); - if (fix_left_handed && m.determinant() < 0.) + double det = m.block(0, 0, 3, 3).determinant(); + if (fix_left_handed && det < 0.) { its_flip_triangles(its); - else - m_stats.volume = - m_stats.volume; + det = -det; + } + m_stats.volume *= det; update_bounding_box(this->its, this->m_stats); } From 29aab3a426664d1d835f078cb3dda3ed2b8afb14 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 1 Oct 2021 15:02:31 +0200 Subject: [PATCH 04/10] PrintInfoNotificationLevel with icon --- resources/icons/notification_info.svg | 72 +++++++++++++++++++ src/imgui/imconfig.h | 3 +- src/slic3r/GUI/GUI_Preview.cpp | 2 +- .../GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 2 +- src/slic3r/GUI/HintNotification.cpp | 2 +- src/slic3r/GUI/ImGuiWrapper.cpp | 3 + src/slic3r/GUI/NotificationManager.cpp | 20 ++++-- src/slic3r/GUI/NotificationManager.hpp | 7 +- src/slic3r/GUI/Plater.cpp | 6 +- 11 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 resources/icons/notification_info.svg diff --git a/resources/icons/notification_info.svg b/resources/icons/notification_info.svg new file mode 100644 index 000000000..6cbc3fecd --- /dev/null +++ b/resources/icons/notification_info.svg @@ -0,0 +1,72 @@ + +image/svg+xml + +i diff --git a/src/imgui/imconfig.h b/src/imgui/imconfig.h index 713499a1b..c5627f16b 100644 --- a/src/imgui/imconfig.h +++ b/src/imgui/imconfig.h @@ -149,10 +149,11 @@ namespace ImGui const wchar_t CustomSupportsMarker = 0x1D; const wchar_t CustomSeamMarker = 0x1E; const wchar_t MmuSegmentationMarker = 0x1F; + // Do not forget use following letters only in wstring const wchar_t DocumentationButton = 0x2600; const wchar_t DocumentationHoverButton = 0x2601; const wchar_t ClippyMarker = 0x2602; - + const wchar_t InfoMarker = 0x2603; // void MyFunction(const char* name, const MyMatrix44& v); } diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index bbe54c2ab..cfe4d6561 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -727,7 +727,7 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee if( bottom_area - top_area > delta_area) { NotificationManager *notif_mngr = wxGetApp().plater()->get_notification_manager(); notif_mngr->push_notification( - NotificationType::SignDetected, NotificationManager::NotificationLevel::RegularNotificationLevel, + NotificationType::SignDetected, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, _u8L("NOTE:") + "\n" + _u8L("Sliced object looks like the sign") + "\n", _u8L("Apply auto color change to print"), [this](wxEvtHandler*) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index f0a627f90..d7824357f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -23,7 +23,7 @@ static inline void show_notification_extruders_limit_exceeded() wxGetApp() .plater() ->get_notification_manager() - ->push_notification(NotificationType::MmSegmentationExceededExtrudersLimit, NotificationManager::NotificationLevel::RegularNotificationLevel, + ->push_notification(NotificationType::MmSegmentationExceededExtrudersLimit, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, GUI::format(_L("Your printer has more extruders than the multi-material painting gizmo supports. For this reason, only the " "first %1% extruders will be able to be used for painting."), GLGizmoMmuSegmentation::EXTRUDERS_LIMIT)); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 4fab1bcb6..c5f4196a1 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -363,7 +363,7 @@ void GLGizmoSimplify::on_set_state() auto notification_manager = wxGetApp().plater()->get_notification_manager(); notification_manager->push_notification( NotificationType::CustomNotification, - NotificationManager::NotificationLevel::RegularNotificationLevel, + NotificationManager::NotificationLevel::PrintInfoNotificationLevel, _u8L("ERROR: Wait until Simplification ends or Cancel process.")); return; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 562226c2e..764c42c73 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -192,7 +192,7 @@ bool GLGizmosManager::check_gizmos_closed_except(EType type) const if (get_current_type() != type && get_current_type() != Undefined) { wxGetApp().plater()->get_notification_manager()->push_notification( NotificationType::CustomSupportsAndSeamRemovedAfterRepair, - NotificationManager::NotificationLevel::RegularNotificationLevel, + NotificationManager::NotificationLevel::PrintInfoNotificationLevel, _u8L("ERROR: Please close all manipulators available from " "the left toolbar first")); return false; diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 53435e318..4a97f2484 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -1012,7 +1012,7 @@ void NotificationManager::HintNotification::retrieve_data(bool new_hint/* = true if(hint_data != nullptr) { NotificationData nd { NotificationType::DidYouKnowHint, - NotificationLevel::RegularNotificationLevel, + NotificationLevel::HintNotificationLevel, 0, hint_data->text, hint_data->hypertext, nullptr, diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index fa9845c5d..b8b2337fb 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -48,6 +48,7 @@ static const std::map font_icons = { {ImGui::RightArrowHoverButton , "notification_right_hover" }, {ImGui::PreferencesButton , "notification_preferences" }, {ImGui::PreferencesHoverButton , "notification_preferences_hover"}, + }; static const std::map font_icons_large = { {ImGui::CloseNotifButton , "notification_close" }, @@ -65,6 +66,8 @@ static const std::map font_icons_large = { {ImGui::VarLayerHeightMarker , "layers" }, {ImGui::DocumentationButton , "notification_documentation" }, {ImGui::DocumentationHoverButton, "notification_documentation_hover"}, + {ImGui::InfoMarker , "notification_info" }, + }; static const std::map font_icons_extra_large = { diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index a2a0b2965..07cf855cc 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -43,10 +43,10 @@ const NotificationManager::NotificationData NotificationManager::basic_notificat }, {NotificationType::NewAppAvailable, NotificationLevel::ImportantNotificationLevel, 20, _u8L("New version is available."), _u8L("See Releases page."), [](wxEvtHandler* evnthndlr) { wxGetApp().open_browser_with_warning_dialog("https://github.com/prusa3d/PrusaSlicer/releases"); return true; }}, - {NotificationType::EmptyColorChangeCode, NotificationLevel::ObjectInfoNotificationLevel, 10, + {NotificationType::EmptyColorChangeCode, NotificationLevel::PrintInfoNotificationLevel, 10, _u8L("You have just added a G-code for color change, but its value is empty.\n" "To export the G-code correctly, check the \"Color Change G-code\" in \"Printer Settings > Custom G-code\"") }, - {NotificationType::EmptyAutoColorChange, NotificationLevel::ObjectInfoNotificationLevel, 10, + {NotificationType::EmptyAutoColorChange, NotificationLevel::PrintInfoNotificationLevel, 10, _u8L("No color change event was added to the print. The print does not look like a sign.") }, {NotificationType::DesktopIntegrationSuccess, NotificationLevel::RegularNotificationLevel, 10, _u8L("Desktop integration was successful.") }, @@ -276,7 +276,9 @@ void NotificationManager::PopNotification::count_spaces() m_line_height = ImGui::CalcTextSize("A").y; m_left_indentation = m_line_height; - if (m_data.level == NotificationLevel::ErrorNotificationLevel || m_data.level == NotificationLevel::WarningNotificationLevel) { + if (m_data.level == NotificationLevel::ErrorNotificationLevel + || m_data.level == NotificationLevel::WarningNotificationLevel + || m_data.level == NotificationLevel::PrintInfoNotificationLevel) { std::string text; text = (m_data.level == NotificationLevel::ErrorNotificationLevel ? ImGui::ErrorMarker : ImGui::WarningMarker); float picture_width = ImGui::CalcTextSize(text.c_str()).x; @@ -511,7 +513,13 @@ void NotificationManager::PopNotification::render_left_sign(ImGuiWrapper& imgui) ImGui::SetCursorPosX(m_line_height / 3); ImGui::SetCursorPosY(m_window_height / 2 - m_line_height); imgui.text(text.c_str()); - } + } else if (m_data.level == NotificationLevel::PrintInfoNotificationLevel) { + std::wstring text; + text = ImGui::InfoMarker; + ImGui::SetCursorPosX(m_line_height / 3); + ImGui::SetCursorPosY(m_window_height / 2 - m_line_height); + imgui.text(text.c_str()); + } } void NotificationManager::PopNotification::render_minimize_button(ImGuiWrapper& imgui, const float win_pos_x, const float win_pos_y) { @@ -1604,7 +1612,7 @@ void NotificationManager::close_slicing_error_notification(const std::string& te } void NotificationManager::push_simplify_suggestion_notification(const std::string& text, ObjectID object_id, const std::string& hypertext/* = ""*/, std::function callback/* = std::function()*/) { - NotificationData data{ NotificationType::SimplifySuggestion, NotificationLevel::ObjectInfoNotificationLevel, 10, text, hypertext, callback }; + NotificationData data{ NotificationType::SimplifySuggestion, NotificationLevel::PrintInfoNotificationLevel, 10, text, hypertext, callback }; auto notification = std::make_unique(data, m_id_provider, m_evt_handler); notification->object_id = object_id; push_notification_data(std::move(notification), 0); @@ -1914,7 +1922,7 @@ void NotificationManager::push_updated_item_info_notification(InfoItemType type) } } - NotificationData data{ NotificationType::UpdatedItemsInfo, NotificationLevel::ObjectInfoNotificationLevel, 10, "" }; + NotificationData data{ NotificationType::UpdatedItemsInfo, NotificationLevel::PrintInfoNotificationLevel, 10, "" }; auto notification = std::make_unique(data, m_id_provider, m_evt_handler, type); if (push_notification_data(std::move(notification), 0)) { (dynamic_cast(m_pop_notifications.back().get()))->add_type(type); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 4a92e1c42..3bd7ae735 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -122,7 +122,7 @@ public: // "Good to know" notification, usually but not always with a quick fade-out. RegularNotificationLevel, // Regular level notifiaction containing info about objects or print. Has Icon. - ObjectInfoNotificationLevel, + PrintInfoNotificationLevel, // Information notification without a fade-out or with a longer fade-out. ImportantNotificationLevel, // Warning, no fade-out. @@ -704,13 +704,14 @@ private: size_t get_standart_duration(NotificationLevel level) { switch (level) { - case NotificationLevel::RegularNotificationLevel: return 20; + case NotificationLevel::ErrorNotificationLevel: return 0; case NotificationLevel::WarningNotificationLevel: return 0; case NotificationLevel::ImportantNotificationLevel: return 0; case NotificationLevel::ProgressBarNotificationLevel: return 2; + case NotificationLevel::RegularNotificationLevel: return 10; + case NotificationLevel::PrintInfoNotificationLevel: return 10; case NotificationLevel::HintNotificationLevel: return 300; - case NotificationLevel::ObjectInfoNotificationLevel: return 20; default: return 10; } } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ecbcc61af..842055298 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2346,7 +2346,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ for (std::string& name : names) notif_text += "\n - " + name; notification_manager->push_notification(NotificationType::CustomNotification, - NotificationManager::NotificationLevel::RegularNotificationLevel, notif_text); + NotificationManager::NotificationLevel::PrintInfoNotificationLevel, notif_text); } } @@ -2910,7 +2910,7 @@ void Plater::priv::split_object() // If we splited object which is contain some parts/modifiers then all non-solid parts (modifiers) were deleted if (current_model_object->volumes.size() > 1 && current_model_object->volumes.size() != new_objects.size()) notification_manager->push_notification(NotificationType::CustomNotification, - NotificationManager::NotificationLevel::RegularNotificationLevel, + NotificationManager::NotificationLevel::PrintInfoNotificationLevel, _u8L("All non-solid parts (modifiers) were deleted")); Plater::TakeSnapshot snapshot(q, _L("Split to Objects")); @@ -6425,7 +6425,7 @@ void Plater::clear_before_change_mesh(int obj_idx) // snapshot_time is captured by copy so the lambda knows where to undo/redo to. get_notification_manager()->push_notification( NotificationType::CustomSupportsAndSeamRemovedAfterRepair, - NotificationManager::NotificationLevel::RegularNotificationLevel, + NotificationManager::NotificationLevel::PrintInfoNotificationLevel, _u8L("Custom supports, seams and multimaterial painting were " "removed after repairing the mesh.")); // _u8L("Undo the repair"), From c7d6a95cb36a0adeef996d871d0913f4a79c3a00 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 1 Oct 2021 15:07:03 +0200 Subject: [PATCH 05/10] Slightly reworded error messages for Cannot import .sl1 files into PrusaSlicer --- src/slic3r/GUI/Jobs/SLAImportJob.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.cpp b/src/slic3r/GUI/Jobs/SLAImportJob.cpp index 3d611ffc3..c4465edba 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.cpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.cpp @@ -153,8 +153,8 @@ void SLAImportJob::process() break; } } catch (MissingProfileError &) { - p->err = _L("The archive doesn't contain any profile data. Try to import after switching " - "to an SLA profile that can be used as fallback.").ToStdString(); + p->err = _L("The SLA archive doesn't contain any presets. " + "Please activate some SLA printer preset first before importing that SLA archive.").ToStdString(); } catch (std::exception &ex) { p->err = ex.what(); } @@ -207,8 +207,8 @@ void SLAImportJob::finalize() m_plater->get_notification_manager()->push_notification( NotificationType::CustomNotification, NotificationManager::NotificationLevel::WarningNotificationLevel, - _L("Loaded archive did not contain any profile data. " - "The current SLA profile was used as fallback.").ToStdString()); + _L("The imported SLA archive did not contain any presets. " + "The current SLA presets were used as fallback.").ToStdString()); } if (p->sel != Sel::modelOnly) { From 1edbdcfecf527a85589a2ec09451a5f8c35a1ab6 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 1 Oct 2021 15:45:53 +0200 Subject: [PATCH 06/10] remove simplify suggestion function --- src/slic3r/GUI/NotificationManager.cpp | 9 +++++++++ src/slic3r/GUI/NotificationManager.hpp | 1 + 2 files changed, 10 insertions(+) diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 07cf855cc..3f98bd903 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -1644,6 +1644,15 @@ void NotificationManager::remove_simplify_suggestion_of_released_objects(const s } } +void NotificationManager::remove_simplify_suggestion_with_id(const ObjectID oid) +{ + for (std::unique_ptr& notification : m_pop_notifications) + if (notification->get_type() == NotificationType::SimplifySuggestion) { + if (static_cast(notification.get())->object_id == oid) + notification->close(); + } +} + void NotificationManager::push_exporting_finished_notification(const std::string& path, const std::string& dir_path, bool on_removable) { close_notification_of_type(NotificationType::ExportFinished); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 3bd7ae735..73f6a6340 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -174,6 +174,7 @@ public: // Close object warnings, whose ObjectID is not in the list. // living_oids is expected to be sorted. void remove_simplify_suggestion_of_released_objects(const std::vector& living_oids); + void remove_simplify_suggestion_with_id(const ObjectID oid); // Called when the side bar changes its visibility, as the "slicing complete" notification supplements // the "slicing info" normally shown at the side bar. void set_sidebar_collapsed(bool collapsed); From 4ca2401b699e035c40cc9e8e23c0529aad534c3c Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 1 Oct 2021 14:31:22 +0200 Subject: [PATCH 07/10] Several minor improvements and fixed warnings --- src/libslic3r/Format/3mf.cpp | 2 +- src/libslic3r/Format/AMF.cpp | 2 +- src/libslic3r/GCode/GCodeProcessor.cpp | 3 ++- src/libslic3r/PrintApply.cpp | 2 +- src/libslic3r/TriangleMesh.cpp | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index 131278e9f..eca057a5b 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1922,7 +1922,7 @@ namespace Slic3r { { int min_id = its.indices.front()[0]; int max_id = min_id; - for (const Vec3i face : its.indices) { + for (const Vec3i& face : its.indices) { for (const int tri_id : face) { if (tri_id < 0 || tri_id >= int(geometry.vertices.size())) { add_error("Found invalid vertex id"); diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index 48c25fc4d..bcc5c8b4a 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -626,7 +626,7 @@ void AMFParserContext::endElement(const char * /* name */) // Verify validity of face indices, find the vertex span. int min_id = m_volume_facets.front()[0]; int max_id = min_id; - for (const Vec3i face : m_volume_facets) { + for (const Vec3i& face : m_volume_facets) { for (const int tri_id : face) { if (tri_id < 0 || tri_id >= int(m_object_vertices.size())) { this->stop("Malformed triangle mesh"); diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 2397a17ff..3e42c91f5 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1456,7 +1456,7 @@ void GCodeProcessor::apply_config_simplify3d(const std::string& filename) begin = skip_whitespaces(begin, end); end = remove_eols(begin, end); - if (begin != end) + if (begin != end) { if (*begin == ';') { // Comment. begin = skip_whitespaces(++ begin, end); @@ -1485,6 +1485,7 @@ void GCodeProcessor::apply_config_simplify3d(const std::string& filename) // Some non-empty G-code line detected, stop parsing config comments. reader.quit_parsing(); } + } }); if (m_result.extruders_count == 0) diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index da26f905c..0f70cf3cc 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1300,7 +1300,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ num_extruders, painting_extruders, *print_object_regions, - [&print_object, it_print_object, it_print_object_end, &update_apply_status](const PrintRegionConfig &old_config, const PrintRegionConfig &new_config, const t_config_option_keys &diff_keys) { + [it_print_object, it_print_object_end, &update_apply_status](const PrintRegionConfig &old_config, const PrintRegionConfig &new_config, const t_config_option_keys &diff_keys) { for (auto it = it_print_object; it != it_print_object_end; ++it) if ((*it)->m_shared_regions != nullptr) update_apply_status((*it)->invalidate_state_by_config_options(old_config, new_config, diff_keys)); diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index f5fea32f8..7285fc8fa 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -465,7 +465,7 @@ TriangleMesh TriangleMesh::convex_hull_3d() const std::vector map_dst_vertices; #ifndef NDEBUG Vec3f centroid = Vec3f::Zero(); - for (auto pt : this->its.vertices) + for (const stl_vertex& pt : this->its.vertices) centroid += pt; centroid /= float(this->its.vertices.size()); #endif // NDEBUG @@ -1261,7 +1261,7 @@ bool its_write_stl_ascii(const char *file, const char *label, const std::vector< fprintf(fp, "solid %s\n", label); - for (const stl_triangle_vertex_indices face : indices) { + for (const stl_triangle_vertex_indices& face : indices) { Vec3f vertex[3] = { vertices[face(0)], vertices[face(1)], vertices[face(2)] }; Vec3f normal = (vertex[1] - vertex[0]).cross(vertex[2] - vertex[1]).normalized(); fprintf(fp, " facet normal % .8E % .8E % .8E\n", normal(0), normal(1), normal(2)); @@ -1301,7 +1301,7 @@ bool its_write_stl_binary(const char *file, const char *label, const std::vector stl_facet f; f.extra[0] = 0; f.extra[1] = 0; - for (const stl_triangle_vertex_indices face : indices) { + for (const stl_triangle_vertex_indices& face : indices) { f.vertex[0] = vertices[face(0)]; f.vertex[1] = vertices[face(1)]; f.vertex[2] = vertices[face(2)]; From 1de422e93219ea3913cc47f95723b0ee025e2e1a Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 1 Oct 2021 16:47:19 +0200 Subject: [PATCH 08/10] refactor mr. clippy rendering --- src/slic3r/GUI/HintNotification.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 4a97f2484..1963e7915 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -917,29 +917,14 @@ void NotificationManager::HintNotification::render_right_arrow_button(ImGuiWrapp } void NotificationManager::HintNotification::render_logo(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y) { - ImVec2 win_size(win_size_x, win_size_y); - ImVec2 win_pos(win_pos_x, win_pos_y); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f)); - push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_state == EState::FadingOut, m_current_fade_opacity); - push_style_color(ImGuiCol_TextSelectedBg, ImVec4(0, .75f, .75f, 1.f), m_state == EState::FadingOut, m_current_fade_opacity); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f)); - - std::wstring button_text; - button_text = ImGui::ClippyMarker;//LeftArrowButton; std::string placeholder_text; placeholder_text = ImGui::EjectButton; - ImVec2 button_pic_size = ImGui::CalcTextSize(placeholder_text.c_str()); - ImVec2 button_size(button_pic_size.x * 1.25f * 2.f, button_pic_size.y * 1.25f * 2.f); - ImGui::SetCursorPosY(win_size.y / 2 - button_size.y * 1.1f); - ImGui::SetCursorPosX(0); - // shouldnt it render as text? - if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) - { - } - - ImGui::PopStyleColor(5); + std::wstring text; + text = ImGui::ClippyMarker; + ImGui::SetCursorPosX(button_pic_size.x / 3); + ImGui::SetCursorPosY(win_size_y / 2 - button_pic_size.y * 2.f); + imgui.text(text.c_str()); } void NotificationManager::HintNotification::render_documentation_button(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y) { From 0b55c89978a3da573584bfc722bfe1f9dd94ba27 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 1 Oct 2021 17:25:49 +0200 Subject: [PATCH 09/10] print info notification icon --- resources/icons/notification_info.svg | 75 +++++++++++++-------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/resources/icons/notification_info.svg b/resources/icons/notification_info.svg index 6cbc3fecd..e2db40745 100644 --- a/resources/icons/notification_info.svg +++ b/resources/icons/notification_info.svg @@ -8,18 +8,20 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.0" - id="Layer_1" + id="warning" x="0px" y="0px" - viewBox="0 0 16 16" - enable-background="new 0 0 16 16" + viewBox="0 0 200 200" + enable-background="new 0 0 100 100" xml:space="preserve" sodipodi:docname="notification_info.svg" + width="200" + height="200" inkscape:version="1.0 (4035a4fb49, 2020-05-01)">image/svg+xml + inkscape:current-layer="warning" /> -i + + + From f5faad80a92f00670dd03afebea47829473f3582 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Fri, 1 Oct 2021 17:40:30 +0200 Subject: [PATCH 10/10] add close suggestion notification --- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index c5f4196a1..52e65f1b6 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -80,6 +80,10 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi set_its(*m_original_its); } + // close suggestion notification + auto notification_manager = wxGetApp().plater()->get_notification_manager(); + notification_manager->remove_simplify_suggestion_with_id(act_volume->get_object()->id()); + m_obj_index = obj_index; // to remember correct object m_volume = act_volume; m_original_its = {};