Improvements for statistics information:

+ Show 2 groups of errors: "Auto-repared" and "Remaning".
 + Use different icons for volumes with/without remaining errors
 + Fixed update of the ObjectList warnings icons after switch the color mode of a PrusaSlicer
 + Some code refactoring: Use same code for tooltips for "exclamation"-icon from an ObjectList and from a Sidebar->ObjectInfo
This commit is contained in:
YuSanka 2021-09-21 17:18:12 +02:00
parent a5a7f64db0
commit 238e65e455
11 changed files with 163 additions and 82 deletions

View file

@ -125,6 +125,7 @@ wxDEFINE_EVENT(EVT_EXPORT_BEGAN, wxCommandEvent);
class ObjectInfo : public wxStaticBoxSizer
{
std::string m_warning_icon_name{ "exclamation" };
public:
ObjectInfo(wxWindow *parent);
@ -142,6 +143,7 @@ public:
bool showing_manifold_warning_icon;
void show_sizer(bool show);
void msw_rescale();
void update_warning_icon(const std::string& warning_icon_name);
};
ObjectInfo::ObjectInfo(wxWindow *parent) :
@ -175,7 +177,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
info_manifold_text->SetFont(wxGetApp().small_font());
info_manifold = new wxStaticText(parent, wxID_ANY, "");
info_manifold->SetFont(wxGetApp().small_font());
manifold_warning_icon = new wxStaticBitmap(parent, wxID_ANY, create_scaled_bitmap("exclamation"));
manifold_warning_icon = new wxStaticBitmap(parent, wxID_ANY, create_scaled_bitmap(m_warning_icon_name));
auto *sizer_manifold = new wxBoxSizer(wxHORIZONTAL);
sizer_manifold->Add(info_manifold_text, 0);
sizer_manifold->Add(manifold_warning_icon, 0, wxLEFT, 2);
@ -194,7 +196,15 @@ void ObjectInfo::show_sizer(bool show)
void ObjectInfo::msw_rescale()
{
manifold_warning_icon->SetBitmap(create_scaled_bitmap("exclamation"));
manifold_warning_icon->SetBitmap(create_scaled_bitmap(m_warning_icon_name));
}
void ObjectInfo::update_warning_icon(const std::string& warning_icon_name)
{
if (warning_icon_name.empty())
return;
m_warning_icon_name = warning_icon_name;
manifold_warning_icon->SetBitmap(create_scaled_bitmap(m_warning_icon_name));
}
enum SlicedInfoIdx
@ -1129,30 +1139,19 @@ void Sidebar::show_info_sizer()
p->object_info->info_size->SetLabel(wxString::Format("%.2f x %.2f x %.2f",size(0)*koef, size(1)*koef, size(2)*koef));
p->object_info->info_materials->SetLabel(wxString::Format("%d", static_cast<int>(model_object->materials_count())));
const auto& stats = model_object->get_object_stl_stats();//model_object->volumes.front()->mesh.stl.stats;
const auto& stats = model_object->get_object_stl_stats();
p->object_info->info_volume->SetLabel(wxString::Format("%.2f", stats.volume*pow(koef,3)));
p->object_info->info_facets->SetLabel(format_wxstr(_L_PLURAL("%1% (%2$d shell)", "%1% (%2$d shells)", stats.number_of_parts),
static_cast<int>(model_object->facets_count()), stats.number_of_parts));
int errors = stats.degenerate_facets + stats.edges_fixed + stats.facets_removed +
stats.facets_reversed + stats.backwards_edges;
if (errors > 0) {
wxString tooltip = format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors);
p->object_info->info_manifold->SetLabel(tooltip);
if (stats.repaired()) {
int errors = stats.degenerate_facets + stats.edges_fixed + stats.facets_removed + stats.facets_reversed + stats.backwards_edges;
p->object_info->info_manifold->SetLabel(format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors));
tooltip += ":\n";
if (stats.degenerate_facets > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d degenerate facet", "%1$d degenerate facets", stats.degenerate_facets), stats.degenerate_facets) + ", ";
if (stats.edges_fixed > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d edge fixed", "%1$d edges fixed", stats.edges_fixed), stats.edges_fixed) + ", ";
if (stats.facets_removed > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d facet removed", "%1$d facets removed", stats.facets_removed), stats.facets_removed) + ", ";
if (stats.facets_reversed > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d facet reversed", "%1$d facets reversed", stats.facets_reversed), stats.facets_reversed) + ", ";
if (stats.backwards_edges > 0)
tooltip += format_wxstr(_L_PLURAL("%1$d backwards edge", "%1$d backwards edges", stats.backwards_edges), stats.backwards_edges) + ", ";
tooltip.RemoveLast(2);//remove last coma
auto mesh_errors = obj_list()->get_mesh_errors(true);
wxString tooltip = mesh_errors.first;
p->object_info->update_warning_icon(mesh_errors.second);
p->object_info->showing_manifold_warning_icon = true;
p->object_info->info_manifold->SetToolTip(tooltip);
p->object_info->manifold_warning_icon->SetToolTip(tooltip);