Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_sinking_objects_collision

This commit is contained in:
enricoturri1966 2021-10-05 15:33:37 +02:00
commit 982172b878
8 changed files with 132 additions and 62 deletions

View file

@ -27,6 +27,7 @@
#include <wx/numdlg.h>
#include <wx/debug.h>
#include <wx/busyinfo.h>
#include <wx/richtooltip.h>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Format/STL.hpp"
@ -173,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);
@ -201,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
@ -611,6 +609,7 @@ struct Sidebar::priv
wxButton *btn_export_gcode;
wxButton *btn_reslice;
wxString btn_reslice_tip;
ScalableButton *btn_send_gcode;
//ScalableButton *btn_eject_device;
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
@ -622,6 +621,7 @@ struct Sidebar::priv
~priv();
void show_preset_comboboxes();
void show_rich_tip(const wxString& tooltip, wxButton* btn);
};
Sidebar::priv::~priv()
@ -650,6 +650,18 @@ void Sidebar::priv::show_preset_comboboxes()
scrolled->Refresh();
}
void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn)
{
if (tooltip.IsEmpty())
return;
wxRichToolTip tip(tooltip, "");
tip.SetIcon(wxICON_NONE);
tip.SetTipKind(wxTipKind_BottomRight);
tip.SetTitleFont(wxGetApp().normal_font());
tip.SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
tip.SetTimeout(1200);
tip.ShowFor(btn);
}
// Sidebar / public
@ -784,7 +796,11 @@ Sidebar::Sidebar(Plater *parent)
#endif //__APPLE__
ScalableBitmap bmp = ScalableBitmap(this, icon_name, bmp_px_cnt);
*btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT);
(*btn)->SetToolTip(tooltip);
(*btn)->Bind(wxEVT_ENTER_WINDOW, [tooltip, btn, this](wxMouseEvent& event) {
p->show_rich_tip(tooltip, *btn);
event.Skip();
});
(*btn)->Hide();
};
@ -843,6 +859,11 @@ Sidebar::Sidebar(Plater *parent)
p->plater->reslice();
p->plater->select_view_3D("Preview");
});
p->btn_reslice->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& event) {
p->show_rich_tip(p->btn_reslice_tip, p->btn_reslice);
event.Skip();
});
p->btn_send_gcode->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->send_gcode(); });
// p->btn_eject_device->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->eject_drive(); });
p->btn_export_gcode_removable->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->export_gcode(true); });
@ -970,7 +991,7 @@ void Sidebar::update_reslice_btn_tooltip() const
wxString tooltip = wxString("Slice") + " [" + GUI::shortkey_ctrl_prefix() + "R]";
if (m_mode != comSimple)
tooltip += wxString("\n") + _L("Hold Shift to Slice & Export G-code");
p->btn_reslice->SetToolTip(tooltip);
p->btn_reslice_tip = tooltip;
}
void Sidebar::msw_rescale()
@ -1144,24 +1165,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);