Changed conditions for the warning icon.
If mesh isn't manifold then always show the red "exclamation" icon It mesh is manifold but was repaired then show the gray/white "exclamation" icon
This commit is contained in:
parent
23cff74efb
commit
3e07d2e853
@ -382,46 +382,57 @@ int ObjectList::get_mesh_errors_count(const int obj_idx, const int vol_idx /*= -
|
||||
|
||||
static std::string get_warning_icon_name(const TriangleMeshStats& stats)
|
||||
{
|
||||
return stats.repaired() ? (stats.manifold() ? "exclamation_manifold" : "exclamation") : "";
|
||||
return stats.manifold() ? (stats.repaired() ? "exclamation_manifold" : "") : "exclamation";
|
||||
}
|
||||
|
||||
std::pair<wxString, std::string> ObjectList::get_mesh_errors(const int obj_idx, const int vol_idx /*= -1*/, bool from_plater /*= false*/) const
|
||||
std::pair<wxString, std::string> ObjectList::get_mesh_errors(const int obj_idx, const int vol_idx /*= -1*/, wxString* sidebar_info /*= nullptr*/) const
|
||||
{
|
||||
const int errors = get_mesh_errors_count(obj_idx, vol_idx);
|
||||
|
||||
if (errors == 0)
|
||||
return { {}, {} }; // hide tooltip
|
||||
|
||||
// Create tooltip string, if there are errors
|
||||
wxString tooltip = format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors) + ":\n";
|
||||
|
||||
const TriangleMeshStats& stats = vol_idx == -1 ?
|
||||
(*m_objects)[obj_idx]->get_object_stl_stats() :
|
||||
(*m_objects)[obj_idx]->volumes[vol_idx]->mesh().stats();
|
||||
|
||||
if (stats.degenerate_facets > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d degenerate facet", "%1$d degenerate facets", stats.degenerate_facets), stats.degenerate_facets) + "\n";
|
||||
if (stats.edges_fixed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d edge fixed", "%1$d edges fixed", stats.edges_fixed), stats.edges_fixed) + "\n";
|
||||
if (stats.facets_removed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d facet removed", "%1$d facets removed", stats.facets_removed), stats.facets_removed) + "\n";
|
||||
if (stats.facets_reversed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d facet reversed", "%1$d facets reversed", stats.facets_reversed), stats.facets_reversed) + "\n";
|
||||
if (stats.backwards_edges > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d backwards edge", "%1$d backwards edges", stats.backwards_edges), stats.backwards_edges) + "\n";
|
||||
if (!stats.repaired() && stats.manifold()) {
|
||||
if (sidebar_info)
|
||||
*sidebar_info = _L("No errors detected");
|
||||
return { {}, {} }; // hide tooltip
|
||||
}
|
||||
|
||||
wxString tooltip, auto_repaired_info, remaining_info;
|
||||
|
||||
// Create tooltip string, if there are errors
|
||||
if (stats.repaired()) {
|
||||
const int errors = get_mesh_errors_count(obj_idx, vol_idx);
|
||||
auto_repaired_info = format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors);
|
||||
tooltip += auto_repaired_info +":\n";
|
||||
|
||||
if (stats.degenerate_facets > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d degenerate facet", "%1$d degenerate facets", stats.degenerate_facets), stats.degenerate_facets) + "\n";
|
||||
if (stats.edges_fixed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d edge fixed", "%1$d edges fixed", stats.edges_fixed), stats.edges_fixed) + "\n";
|
||||
if (stats.facets_removed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d facet removed", "%1$d facets removed", stats.facets_removed), stats.facets_removed) + "\n";
|
||||
if (stats.facets_reversed > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d facet reversed", "%1$d facets reversed", stats.facets_reversed), stats.facets_reversed) + "\n";
|
||||
if (stats.backwards_edges > 0)
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d backwards edge", "%1$d backwards edges", stats.backwards_edges), stats.backwards_edges) + "\n";
|
||||
}
|
||||
if (!stats.manifold()) {
|
||||
remaining_info = format_wxstr(_L_PLURAL("Remaining %1$d open edge", "Remaining %1$d open edges", stats.open_edges), stats.open_edges);
|
||||
|
||||
tooltip += _L("Remaning errors") + ":\n";
|
||||
tooltip += "\t" + format_wxstr(_L_PLURAL("%1$d open edge", "%1$d open edges", stats.open_edges), stats.open_edges) + "\n";
|
||||
}
|
||||
|
||||
if (is_windows10() && !from_plater)
|
||||
if (sidebar_info)
|
||||
*sidebar_info = stats.manifold() ? auto_repaired_info : (remaining_info + (stats.repaired() ? ("\n" + auto_repaired_info) : ""));
|
||||
|
||||
if (is_windows10() && !sidebar_info)
|
||||
tooltip += "\n" + _L("Right button click the icon to fix STL through Netfabb");
|
||||
|
||||
return { tooltip, get_warning_icon_name(stats) };
|
||||
}
|
||||
|
||||
std::pair<wxString, std::string> ObjectList::get_mesh_errors(bool from_plater /*= false*/)
|
||||
std::pair<wxString, std::string> ObjectList::get_mesh_errors(wxString* sidebar_info /*= nullptr*/)
|
||||
{
|
||||
if (!GetSelection())
|
||||
return { "", "" };
|
||||
@ -429,7 +440,7 @@ std::pair<wxString, std::string> ObjectList::get_mesh_errors(bool from_plater /*
|
||||
int obj_idx, vol_idx;
|
||||
get_selected_item_indexes(obj_idx, vol_idx);
|
||||
|
||||
return get_mesh_errors(obj_idx, vol_idx, from_plater);
|
||||
return get_mesh_errors(obj_idx, vol_idx, sidebar_info);
|
||||
}
|
||||
|
||||
void ObjectList::set_tooltip_for_item(const wxPoint& pt)
|
||||
|
@ -217,8 +217,8 @@ public:
|
||||
// Return value is a pair <Tooltip, warning_icon_name>, used for the tooltip and related warning icon
|
||||
// Function without parameters is for a call from Manipulation panel,
|
||||
// when we don't know parameters of selected item
|
||||
std::pair<wxString, std::string> get_mesh_errors(const int obj_idx, const int vol_idx = -1, bool from_plater = false) const;
|
||||
std::pair<wxString, std::string> get_mesh_errors(bool from_plater = false);
|
||||
std::pair<wxString, std::string> get_mesh_errors(const int obj_idx, const int vol_idx = -1, wxString* sidebar_info = nullptr) const;
|
||||
std::pair<wxString, std::string> get_mesh_errors(wxString* sidebar_info = nullptr);
|
||||
void set_tooltip_for_item(const wxPoint& pt);
|
||||
|
||||
void selection_changed();
|
||||
|
@ -174,13 +174,10 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
||||
label_materials = init_info_label(&info_materials, _L("Materials"));
|
||||
Add(grid_sizer, 0, wxEXPAND);
|
||||
|
||||
auto *info_manifold_text = new wxStaticText(parent, wxID_ANY, _L("Manifold") + ":");
|
||||
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(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);
|
||||
sizer_manifold->Add(info_manifold, 0, wxLEFT, 2);
|
||||
Add(sizer_manifold, 0, wxEXPAND | wxTOP, 4);
|
||||
@ -202,10 +199,10 @@ void ObjectInfo::msw_rescale()
|
||||
|
||||
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));
|
||||
if (showing_manifold_warning_icon = !warning_icon_name.empty()) {
|
||||
m_warning_icon_name = warning_icon_name;
|
||||
manifold_warning_icon->SetBitmap(create_scaled_bitmap(m_warning_icon_name));
|
||||
}
|
||||
}
|
||||
|
||||
enum SlicedInfoIdx
|
||||
@ -1167,24 +1164,13 @@ void Sidebar::show_info_sizer()
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
p->object_info->info_manifold->SetLabel(_L("Yes"));
|
||||
p->object_info->showing_manifold_warning_icon = false;
|
||||
p->object_info->info_manifold->SetToolTip("");
|
||||
p->object_info->manifold_warning_icon->SetToolTip("");
|
||||
}
|
||||
wxString info_manifold_label;
|
||||
auto mesh_errors = obj_list()->get_mesh_errors(&info_manifold_label);
|
||||
wxString tooltip = mesh_errors.first;
|
||||
p->object_info->update_warning_icon(mesh_errors.second);
|
||||
p->object_info->info_manifold->SetLabel(info_manifold_label);
|
||||
p->object_info->info_manifold->SetToolTip(tooltip);
|
||||
p->object_info->manifold_warning_icon->SetToolTip(tooltip);
|
||||
|
||||
p->object_info->show_sizer(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user