From 00f4a702c222d423c8a456b19acdf4b19ebba0cb Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 17 Feb 2023 12:32:42 +0100 Subject: [PATCH 1/5] Follow-up of 44d1e3de675e25fef0a1bfcff44687675622acdc - Improved fix of orientation of sequential print clearance contours while dragging instances --- src/slic3r/GUI/GLCanvas3D.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 299778be5..79ceae9ec 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3972,8 +3972,9 @@ void GLCanvas3D::update_sequential_clearance() Pointf3s& cache_hull_2d = m_sequential_print_clearance.m_hull_2d_cache.emplace_back(Pointf3s()); cache_hull_2d.reserve(hull_2d.points.size()); + const Transform3d inv_trafo = trafo.get_matrix().inverse(); for (const Point& p : hull_2d.points) { - cache_hull_2d.emplace_back(unscale(p.x()), unscale(p.y()), 0.0); + cache_hull_2d.emplace_back(inv_trafo * Vec3d(unscale(p.x()), unscale(p.y()), 0.0)); } } m_sequential_print_clearance_first_displacement = false; From 304424b6d47b8862c9e4ca1f39a74bbfad5d560a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 17 Feb 2023 12:45:00 +0100 Subject: [PATCH 2/5] Do not calculate the AABB raycaster in cut gizmo, it does not use it --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index e87978a22..8c33c3e03 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -2537,8 +2537,7 @@ CommonGizmosDataID GLGizmoCut3D::on_get_requirements() const { return CommonGizmosDataID( int(CommonGizmosDataID::SelectionInfo) | int(CommonGizmosDataID::InstancesHider) - | int(CommonGizmosDataID::ObjectClipper) - | int(CommonGizmosDataID::Raycaster)); + | int(CommonGizmosDataID::ObjectClipper)); } void GLGizmoCut3D::data_changed() From 0202eec4b715eaa28a79f8bb82b0330c1efce8c9 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 17 Feb 2023 12:57:16 +0100 Subject: [PATCH 3/5] Fixed Clipper library (our own fork of it) when working with Z coordinate: The Eigen vector type compares all components, while the ClipperLib own IntPoint type compared x and y only. Fixed by overriding the ==/!= operators to compare just x and y components for Eigen types. Fixes #9651 --- src/clipper/clipper.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 518b4b7c3..4d7a40726 100644 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -108,6 +108,10 @@ inline cInt Round(double val) return static_cast((val < 0) ? (val - 0.5) : (val + 0.5)); } +// Overriding the Eigen operators because we don't want to compare Z coordinate if IntPoint is 3 dimensional. +inline bool operator==(const IntPoint &l, const IntPoint &r) { return l.x() == r.x() && l.y() == r.y(); } +inline bool operator!=(const IntPoint &l, const IntPoint &r) { return l.x() != r.x() || l.y() != r.y(); } + //------------------------------------------------------------------------------ // PolyTree methods ... //------------------------------------------------------------------------------ @@ -178,19 +182,25 @@ double Area(const Path &poly) } //------------------------------------------------------------------------------ -double Area(const OutRec &outRec) +double Area(const OutPt *op) { - OutPt *op = outRec.Pts; + const OutPt *startOp = op; if (!op) return 0; double a = 0; do { a += (double)(op->Prev->Pt.x() + op->Pt.x()) * (double)(op->Prev->Pt.y() - op->Pt.y()); op = op->Next; - } while (op != outRec.Pts); + } while (op != startOp); return a * 0.5; } //------------------------------------------------------------------------------ +double Area(const OutRec &outRec) +{ + return Area(outRec.Pts); +} +//------------------------------------------------------------------------------ + bool PointIsVertex(const IntPoint &Pt, OutPt *pp) { OutPt *pp2 = pp; @@ -524,27 +534,32 @@ bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2) p = btmPt2->Next; while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next; double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt)); - return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n); + + if (std::max(dx1p, dx1n) == std::max(dx2p, dx2n) && + std::min(dx1p, dx1n) == std::min(dx2p, dx2n)) + return Area(btmPt1) > 0; //if otherwise identical use orientation + else + return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n); } //------------------------------------------------------------------------------ // Called by GetLowermostRec() OutPt* GetBottomPt(OutPt *pp) { - OutPt* dups = 0; + OutPt* dups = nullptr; OutPt* p = pp->Next; while (p != pp) { if (p->Pt.y() > pp->Pt.y()) { pp = p; - dups = 0; + dups = nullptr; } else if (p->Pt.y() == pp->Pt.y() && p->Pt.x() <= pp->Pt.x()) { if (p->Pt.x() < pp->Pt.x()) { - dups = 0; + dups = nullptr; pp = p; } else { @@ -565,6 +580,7 @@ OutPt* GetBottomPt(OutPt *pp) } return pp; } + //------------------------------------------------------------------------------ bool Pt2IsBetweenPt1AndPt3(const IntPoint &pt1, From 250463c6e9e049966064c79c7f6132e25bc701ad Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 17 Feb 2023 11:32:59 +0100 Subject: [PATCH 4/5] Fix for https://dev.prusa3d.com/browse/SPE-1490 - DarkMode, MSW specific: Selected item in SearchDialog is black --- src/slic3r/GUI/Search.cpp | 25 +++++++++++++++++++++++-- src/slic3r/GUI/Search.hpp | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 5ef18b7c9..d63a46d16 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -16,6 +16,7 @@ #include "Tab.hpp" #define FTS_FUZZY_MATCH_IMPLEMENTATION +#include "ExtraRenderers.hpp" #include "fts_fuzzy_match.h" #include "imgui/imconfig.h" @@ -500,6 +501,10 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher) search_list_model = new SearchListModel(this); search_list->AssociateModel(search_list_model); +#ifdef __WXMSW__ + search_list->AppendColumn(new wxDataViewColumn("", new BitmapTextRenderer(true, wxDATAVIEW_CELL_INERT), SearchListModel::colIconMarkedText, wxCOL_WIDTH_AUTOSIZE, wxALIGN_LEFT)); + search_list->GetColumn(SearchListModel::colIconMarkedText)->SetWidth(48 * em_unit()); +#else search_list->AppendBitmapColumn("", SearchListModel::colIcon); wxDataViewTextRenderer* const markupRenderer = new wxDataViewTextRenderer(); @@ -512,6 +517,7 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher) search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em_unit()); search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(40 * em_unit()); +#endif wxBoxSizer* check_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -725,10 +731,12 @@ void SearchDialog::OnLeftDown(wxMouseEvent& event) void SearchDialog::msw_rescale() { const int& em = em_unit(); - +#ifdef __WXMSW__ + search_list->GetColumn(SearchListModel::colIconMarkedText)->SetWidth(48 * em); +#else search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em); search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em); - +#endif const wxSize& size = wxSize(40 * em, 30 * em); SetMinSize(size); @@ -787,8 +795,13 @@ void SearchListModel::sys_color_changed() wxString SearchListModel::GetColumnType(unsigned int col) const { +#ifdef __WXMSW__ + if (col == colIconMarkedText) + return "DataViewBitmapText"; +#else if (col == colIcon) return "wxBitmap"; +#endif return "string"; } @@ -797,12 +810,20 @@ void SearchListModel::GetValueByRow(wxVariant& variant, { switch (col) { +#ifdef __WXMSW__ + case colIconMarkedText: { + const ScalableBitmap& icon = m_icon[m_values[row].second]; + variant << DataViewBitmapText(m_values[row].first, icon.bmp().GetBitmapFor(icon.parent())); + break; + } +#else case colIcon: variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent()); break; case colMarkedText: variant = m_values[row].first; break; +#endif case colMax: wxFAIL_MSG("invalid column"); default: diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index 0d7851132..e2fab87a0 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -202,8 +202,12 @@ class SearchListModel : public wxDataViewVirtualListModel public: enum { +#ifdef __WXMSW__ + colIconMarkedText, +#else colIcon, colMarkedText, +#endif colMax }; From 664e923f3c5378b6cd73534dd86888c463c80de3 Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Fri, 17 Feb 2023 13:34:50 +0100 Subject: [PATCH 5/5] Fix autopaint tool when using RAFT layers --- src/libslic3r/PrintObject.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 80e26944a..c4a5946e8 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -424,8 +424,12 @@ void PrintObject::generate_support_spots() float(this->print()->m_config.perimeter_acceleration.getFloat()), this->config().raft_layers.getInt(), this->config().brim_type.value, float(this->config().brim_width.getFloat())}; - auto [supp_points, partial_objects] = SupportSpotsGenerator::full_search(this, cancel_func, params); - this->m_shared_regions->generated_support_points = {this->trafo_centered(), supp_points, partial_objects}; + auto [supp_points, partial_objects] = SupportSpotsGenerator::full_search(this, cancel_func, params); + Transform3d po_transform = this->trafo_centered(); + if (this->layer_count() > 0) { + po_transform = Geometry::translation_transform(Vec3d{0, 0, this->layers().front()->bottom_z()}) * po_transform; + } + this->m_shared_regions->generated_support_points = {po_transform, supp_points, partial_objects}; m_print->throw_if_canceled(); } BOOST_LOG_TRIVIAL(debug) << "Searching support spots - end";