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

This commit is contained in:
enricoturri1966 2020-05-07 16:48:11 +02:00
commit 3b2a4a0c13
8 changed files with 60 additions and 31 deletions

View file

@ -2134,6 +2134,7 @@ void GLCanvas3D::render()
set_tooltip(tooltip); set_tooltip(tooltip);
if (m_tooltip_enabled)
m_tooltip.render(m_mouse.position, *this); m_tooltip.render(m_mouse.position, *this);
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
@ -2894,6 +2895,9 @@ void GLCanvas3D::bind_event_handlers()
m_canvas->Bind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Bind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this);
m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this);
m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this); m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
} }
} }
@ -2921,6 +2925,9 @@ void GLCanvas3D::unbind_event_handlers()
m_canvas->Unbind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Unbind(wxEVT_MIDDLE_DCLICK, &GLCanvas3D::on_mouse, this);
m_canvas->Unbind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Unbind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this);
m_canvas->Unbind(wxEVT_PAINT, &GLCanvas3D::on_paint, this); m_canvas->Unbind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
m_canvas->Unbind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
} }
} }
@ -3649,12 +3656,18 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (top_level_wnd && top_level_wnd->IsActive()) if (top_level_wnd && top_level_wnd->IsActive())
m_canvas->SetFocus(); m_canvas->SetFocus();
m_mouse.position = pos.cast<double>(); m_mouse.position = pos.cast<double>();
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
m_tooltip_enabled = false;
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
// 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while // 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to // the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
// change the volume hover state if any is under the mouse // change the volume hover state if any is under the mouse
// 2) when switching between 3d view and preview the size of the canvas changes if the side panels are visible, // 2) when switching between 3d view and preview the size of the canvas changes if the side panels are visible,
// so forces a resize to avoid multiple renders with different sizes (seen as flickering) // so forces a resize to avoid multiple renders with different sizes (seen as flickering)
_refresh_if_shown_on_screen(); _refresh_if_shown_on_screen();
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
m_tooltip_enabled = true;
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
} }
m_mouse.set_start_position_2D_as_invalid(); m_mouse.set_start_position_2D_as_invalid();
//#endif //#endif
@ -3972,6 +3985,15 @@ void GLCanvas3D::on_paint(wxPaintEvent& evt)
this->render(); this->render();
} }
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
void GLCanvas3D::on_set_focus(wxFocusEvent& evt)
{
m_tooltip_enabled = false;
_refresh_if_shown_on_screen();
m_tooltip_enabled = true;
}
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
Size GLCanvas3D::get_canvas_size() const Size GLCanvas3D::get_canvas_size() const
{ {
int w = 0; int w = 0;

View file

@ -516,6 +516,7 @@ private:
Labels m_labels; Labels m_labels;
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI #if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
mutable Tooltip m_tooltip; mutable Tooltip m_tooltip;
mutable bool m_tooltip_enabled{ true };
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI #endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
#if ENABLE_SLOPE_RENDERING #if ENABLE_SLOPE_RENDERING
Slope m_slope; Slope m_slope;
@ -671,6 +672,9 @@ public:
void on_timer(wxTimerEvent& evt); void on_timer(wxTimerEvent& evt);
void on_mouse(wxMouseEvent& evt); void on_mouse(wxMouseEvent& evt);
void on_paint(wxPaintEvent& evt); void on_paint(wxPaintEvent& evt);
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
void on_set_focus(wxFocusEvent& evt);
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
Size get_canvas_size() const; Size get_canvas_size() const;
Vec2d get_local_mouse_position() const; Vec2d get_local_mouse_position() const;

View file

@ -591,11 +591,10 @@ float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
return 0.01f * int_val * icon_sc; return 0.01f * int_val * icon_sc;
} }
void GUI_App::recreate_GUI() void GUI_App::recreate_GUI(const wxString& msg_name)
{ {
mainframe->shutdown(); mainframe->shutdown();
const auto msg_name = _(L("Changing of an application language")) + dots;
wxProgressDialog dlg(msg_name, msg_name); wxProgressDialog dlg(msg_name, msg_name);
dlg.Pulse(); dlg.Pulse();
dlg.Update(10, _(L("Recreating")) + dots); dlg.Update(10, _(L("Recreating")) + dots);
@ -707,12 +706,6 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file) const
void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
{ {
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
if (this->plater_ != nullptr)
// hides the tooltip
plater_->get_current_canvas3D()->set_tooltip("");
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
input_files.Clear(); input_files.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(), wxFileDialog dialog(parent ? parent : GetTopWindow(),
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")), _(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),
@ -726,7 +719,7 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
bool GUI_App::switch_language() bool GUI_App::switch_language()
{ {
if (select_language()) { if (select_language()) {
recreate_GUI(); recreate_GUI(_L("Changing of an application language") + dots);
return true; return true;
} else { } else {
return false; return false;
@ -1030,8 +1023,17 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break; break;
case ConfigMenuPreferences: case ConfigMenuPreferences:
{ {
bool recreate_app = false;
{
// the dialog needs to be destroyed before the call to recreate_GUI()
// or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope
PreferencesDialog dlg(mainframe); PreferencesDialog dlg(mainframe);
dlg.ShowModal(); dlg.ShowModal();
recreate_app = dlg.settings_layout_changed();
}
if (recreate_app)
recreate_GUI(_L("Changing of the settings layout") + dots);
break; break;
} }
case ConfigMenuLanguage: case ConfigMenuLanguage:

View file

@ -136,7 +136,7 @@ public:
int em_unit() const { return m_em_unit; } int em_unit() const { return m_em_unit; }
float toolbar_icon_scale(const bool is_limited = false) const; float toolbar_icon_scale(const bool is_limited = false) const;
void recreate_GUI(); void recreate_GUI(const wxString& message);
void system_info(); void system_info();
void keyboard_shortcuts(); void keyboard_shortcuts();
void load_project(wxWindow *parent, wxString& input_file) const; void load_project(wxWindow *parent, wxString& input_file) const;

View file

@ -1267,8 +1267,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
} }
// Show/Activate Settings Dialog // Show/Activate Settings Dialog
if (m_settings_dialog->IsShown()) if (m_settings_dialog->IsShown())
m_settings_dialog->SetFocus(); m_settings_dialog->Hide();
else
m_settings_dialog->Show(); m_settings_dialog->Show();
} }
else if (m_layout == slNew) { else if (m_layout == slNew) {

View file

@ -178,7 +178,7 @@ public:
if (staticbox) { if (staticbox) {
stb = new wxStaticBox(_parent, wxID_ANY, _(title)); stb = new wxStaticBox(_parent, wxID_ANY, _(title));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT); if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxGetApp().bold_font()); stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
} else } else
stb = nullptr; stb = nullptr;
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL)); sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));

View file

@ -117,13 +117,6 @@ void PreferencesDialog::build()
m_optgroup_general->append_single_option_line(option); m_optgroup_general->append_single_option_line(option);
#endif #endif
def.label = L("Show the button for the collapse sidebar");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_general->append_single_option_line(option);
m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _(L("Camera"))); m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _(L("Camera")));
m_optgroup_camera->label_width = 40; m_optgroup_camera->label_width = 40;
m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) { m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
@ -154,6 +147,13 @@ void PreferencesDialog::build()
} }
}; };
def.label = L("Show the button for the collapse sidebar");
def.type = coBool;
def.tooltip = L("If enabled, the button for the collapse sidebar will be appeared in top right corner of the 3D Scene");
def.set_default_value(new ConfigOptionBool{ app_config->get("show_collapse_button") == "1" });
option = Option(def, "show_collapse_button");
m_optgroup_gui->append_single_option_line(option);
def.label = L("Use custom size for toolbar icons"); def.label = L("Use custom size for toolbar icons");
def.type = coBool; def.type = coBool;
def.tooltip = L("If enabled, you can change size of toolbar icons manually."); def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
@ -190,11 +190,11 @@ void PreferencesDialog::accept()
auto app_config = get_app_config(); auto app_config = get_app_config();
bool settings_layout_changed = m_values.find("old_settings_layout_mode") != m_values.end() || m_settings_layout_changed = m_values.find("old_settings_layout_mode") != m_values.end() ||
m_values.find("new_settings_layout_mode") != m_values.end() || m_values.find("new_settings_layout_mode") != m_values.end() ||
m_values.find("dlg_settings_layout_mode") != m_values.end(); m_values.find("dlg_settings_layout_mode") != m_values.end();
if (settings_layout_changed) { if (m_settings_layout_changed) {
// the dialog needs to be destroyed before the call to recreate_gui() // the dialog needs to be destroyed before the call to recreate_gui()
// or sometimes the application crashes into wxDialogBase() destructor // or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope // so we put it into an inner scope
@ -222,9 +222,8 @@ void PreferencesDialog::accept()
app_config->save(); app_config->save();
EndModal(wxID_OK); EndModal(wxID_OK);
if (settings_layout_changed) if (m_settings_layout_changed)
// recreate application, if settings layout was changed ;// application will be recreated after Preference dialog will be destroyed
wxGetApp().recreate_GUI();
else else
// Nothify the UI to update itself from the ini file. // Nothify the UI to update itself from the ini file.
wxGetApp().update_ui_from_settings(); wxGetApp().update_ui_from_settings();

View file

@ -23,10 +23,13 @@ class PreferencesDialog : public DPIDialog
wxSizer* m_icon_size_sizer; wxSizer* m_icon_size_sizer;
wxRadioBox* m_layout_mode_box; wxRadioBox* m_layout_mode_box;
bool isOSX {false}; bool isOSX {false};
bool m_settings_layout_changed {false};
public: public:
PreferencesDialog(wxWindow* parent); PreferencesDialog(wxWindow* parent);
~PreferencesDialog() {} ~PreferencesDialog() {}
bool settings_layout_changed() { return m_settings_layout_changed; }
void build(); void build();
void accept(); void accept();