From 46d19aa52dc4923ccbb87c4c5e7e550605c928a4 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 13 Mar 2019 15:34:27 +0100 Subject: [PATCH] Added function for the updating of the Error icon after a fix through the NetFabb --- src/slic3r/GUI/GUI_ObjectList.cpp | 42 +++++++++++++++++++++++-------- src/slic3r/GUI/GUI_ObjectList.hpp | 1 + src/slic3r/GUI/Tab.cpp | 4 +-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 494467f79..04fb9b7ca 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -427,10 +427,8 @@ void ObjectList::OnContextMenu(wxDataViewEvent&) else if (title == _("Name") && pt.x >15 && m_objects_model->GetBitmap(item).GetRefData() == m_bmp_manifold_warning.GetRefData()) { - if (is_windows10()) { - const auto obj_idx = m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)); - wxGetApp().plater()->fix_through_netfabb(obj_idx); - } + if (is_windows10()) + fix_through_netfabb(); } #ifndef __WXMSW__ GetMainWindow()->SetToolTip(""); // hide tooltip @@ -2272,13 +2270,37 @@ void ObjectList::fix_through_netfabb() const if (!item) return; - ItemType type = m_objects_model->GetItemType(item); + const ItemType type = m_objects_model->GetItemType(item); + + const int obj_idx = type & itObject ? m_objects_model->GetIdByItem(item) : + type & itVolume ? m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)) : -1; + + const int vol_idx = type & itVolume ? m_objects_model->GetVolumeIdByItem(item) : -1; + + wxGetApp().plater()->fix_through_netfabb(obj_idx, vol_idx); - if (type & itObject) - wxGetApp().plater()->fix_through_netfabb(m_objects_model->GetIdByItem(item)); - else if (type & itVolume) - wxGetApp().plater()->fix_through_netfabb(m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)), - m_objects_model->GetVolumeIdByItem(item)); + update_item_error_icon(obj_idx, vol_idx); +} + +void ObjectList::update_item_error_icon(const int obj_idx, const int vol_idx) const +{ + const wxDataViewItem item = vol_idx <0 ? m_objects_model->GetItemById(obj_idx) : + m_objects_model->GetItemByVolumeId(obj_idx, vol_idx); + if (!item) + return; + + auto model_object = (*m_objects)[obj_idx]; + + const stl_stats& stats = model_object->volumes[vol_idx<0 ? 0 : vol_idx]->mesh.stl.stats; + const int errors = stats.degenerate_facets + stats.edges_fixed + stats.facets_removed + + stats.facets_added + stats.facets_reversed + stats.backwards_edges; + + if (errors == 0) { + // delete Error_icon if all errors are fixed + wxVariant variant; + variant << PrusaDataViewBitmapText(from_u8(model_object->name), wxNullBitmap); + m_objects_model->SetValue(variant, item, 0); + } } void ObjectList::ItemValueChanged(wxDataViewEvent &event) diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 762020bda..a4df67497 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -270,6 +270,7 @@ public: void split_instances(); void rename_item(); void fix_through_netfabb() const; + void update_item_error_icon(const int obj_idx, int vol_idx) const ; private: void OnChar(wxKeyEvent& event); void OnContextMenu(wxDataViewEvent &event); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c75618132..56af8b4f9 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2455,7 +2455,7 @@ void Tab::load_current_preset() //Regerenerate content of the page tree. void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/) { - Freeze(); +// Freeze(); // get label of the currently selected item const auto sel_item = m_treectrl->GetSelection(); @@ -2481,7 +2481,7 @@ void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/) // this is triggered on first load, so we don't disable the sel change event m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem)); } - Thaw(); +// Thaw(); } void Tab::update_page_tree_visibility()