Merge remote-tracking branch 'origin/master' into ys_ph_printers

This commit is contained in:
YuSanka 2020-07-21 09:47:29 +02:00
commit f138978fe7
51 changed files with 2297 additions and 917 deletions

View file

@ -239,7 +239,7 @@ void show_error_id(int id, const std::string& message)
void show_info(wxWindow* parent, const wxString& message, const wxString& title)
{
wxMessageDialog msg_wingow(parent, message, wxString(SLIC3R_APP_NAME " - ") + (title.empty() ? _(L("Notice")) : title), wxOK | wxICON_INFORMATION);
wxMessageDialog msg_wingow(parent, message, wxString(SLIC3R_APP_NAME " - ") + (title.empty() ? _L("Notice") : title), wxOK | wxICON_INFORMATION);
msg_wingow.ShowModal();
}
@ -251,7 +251,7 @@ void show_info(wxWindow* parent, const char* message, const char* title)
void warning_catcher(wxWindow* parent, const wxString& message)
{
wxMessageDialog msg(parent, message, _(L("Warning")), wxOK | wxICON_WARNING);
wxMessageDialog msg(parent, message, _L("Warning"), wxOK | wxICON_WARNING);
msg.ShowModal();
}
@ -261,14 +261,14 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
return;
wxCheckListBoxComboPopup* popup = new wxCheckListBoxComboPopup;
if (popup != nullptr)
{
// FIXME If the following line is removed, the combo box popup list will not react to mouse clicks.
if (popup != nullptr) {
// FIXME If the following line is removed, the combo box popup list will not react to mouse clicks.
// On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
comboCtrl->UseAltPopupWindow();
comboCtrl->EnablePopupAnimation(false);
comboCtrl->SetPopupControl(popup);
// the following line messes up the popup size the first time it is shown on wxWidgets 3.1.3
// comboCtrl->EnablePopupAnimation(false);
comboCtrl->SetPopupControl(popup);
popup->SetStringValue(from_u8(text));
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
@ -278,13 +278,11 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
std::vector<std::string> items_str;
boost::split(items_str, items, boost::is_any_of("|"), boost::token_compress_off);
for (const std::string& item : items_str)
{
for (const std::string& item : items_str) {
popup->Append(from_u8(item));
}
for (unsigned int i = 0; i < popup->GetCount(); ++i)
{
for (unsigned int i = 0; i < popup->GetCount(); ++i) {
popup->Check(i, initial_value);
}
}
@ -295,10 +293,8 @@ int combochecklist_get_flags(wxComboCtrl* comboCtrl)
int flags = 0;
wxCheckListBoxComboPopup* popup = wxDynamicCast(comboCtrl->GetPopupControl(), wxCheckListBoxComboPopup);
if (popup != nullptr)
{
for (unsigned int i = 0; i < popup->GetCount(); ++i)
{
if (popup != nullptr) {
for (unsigned int i = 0; i < popup->GetCount(); ++i) {
if (popup->IsChecked(i))
flags |= 1 << i;
}

View file

@ -106,6 +106,7 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension)
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
#ifdef WIN32
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
static void register_win32_dpi_event()
{
enum { WM_DPICHANGED_ = 0x02e0 };
@ -121,13 +122,12 @@ static void register_win32_dpi_event()
return true;
});
}
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
static void register_win32_device_notification_event()
{
enum { WM_DPICHANGED_ = 0x02e0 };
wxWindow::MSWRegisterMessageHandler(WM_DEVICECHANGE, [](wxWindow *win, WXUINT /* nMsg */, WXWPARAM wParam, WXLPARAM lParam) {
// Some messages are sent to top level windows by default, some messages are sent to only registered windows, and we explictely register on MainFrame only.
auto main_frame = dynamic_cast<MainFrame*>(win);
@ -410,7 +410,9 @@ bool GUI_App::on_init_inner()
}
#ifdef WIN32
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
register_win32_dpi_event();
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
register_win32_device_notification_event();
#endif // WIN32
@ -631,9 +633,9 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
{
mainframe->shutdown();
wxProgressDialog dlg(msg_name, msg_name);
wxProgressDialog dlg(msg_name, msg_name, 100, nullptr, wxPD_AUTO_HIDE);
dlg.Pulse();
dlg.Update(10, _(L("Recreating")) + dots);
dlg.Update(10, _L("Recreating") + dots);
MainFrame *old_main_frame = mainframe;
mainframe = new MainFrame();
@ -643,17 +645,17 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
sidebar().obj_list()->init_objects();
SetTopWindow(mainframe);
dlg.Update(30, _(L("Recreating")) + dots);
dlg.Update(30, _L("Recreating") + dots);
old_main_frame->Destroy();
// For this moment ConfigWizard is deleted, invalidate it.
m_wizard = nullptr;
dlg.Update(80, _(L("Loading of current presets")) + dots);
dlg.Update(80, _L("Loading of current presets") + dots);
m_printhost_job_queue.reset(new PrintHostJobQueue(mainframe->printhost_queue_dlg()));
load_current_presets();
mainframe->Show(true);
dlg.Update(90, _(L("Loading of a mode view")) + dots);
dlg.Update(90, _L("Loading of a mode view") + dots);
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
* change min hight of object list to the normal min value (15 * wxGetApp().em_unit())
* after first whole Mainframe updating/layouting
@ -1059,17 +1061,34 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break;
case ConfigMenuPreferences:
{
#if ENABLE_LAYOUT_NO_RESTART
bool app_layout_changed = false;
#else
bool recreate_app = false;
#endif // ENABLE_LAYOUT_NO_RESTART
{
// 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);
dlg.ShowModal();
#if ENABLE_LAYOUT_NO_RESTART
app_layout_changed = dlg.settings_layout_changed();
#else
recreate_app = dlg.settings_layout_changed();
#endif // ENABLE_LAYOUT_NO_RESTART
}
#if ENABLE_LAYOUT_NO_RESTART
if (app_layout_changed) {
mainframe->GetSizer()->Hide((size_t)0);
mainframe->update_layout();
mainframe->select_tab(0);
mainframe->GetSizer()->Show((size_t)0);
}
#else
if (recreate_app)
recreate_GUI(_L("Changing of the settings layout") + dots);
#endif // ENABLE_LAYOUT_NO_RESTART
break;
}
case ConfigMenuLanguage:
@ -1386,7 +1405,9 @@ void GUI_App::window_pos_restore(wxTopLevelWindow* window, const std::string &na
return;
}
window->SetSize(metrics->get_rect());
const wxRect& rect = metrics->get_rect();
window->SetPosition(rect.GetPosition());
window->SetSize(rect.GetSize());
window->Maximize(metrics->get_maximized());
}

View file

@ -347,7 +347,7 @@ void ObjectList::get_selection_indexes(std::vector<int>& obj_idxs, std::vector<i
else {
for (wxDataViewItem item : sels) {
const ItemType type = m_objects_model->GetItemType(item);
assert(type & itObject | itInstance | itInstanceRoot);
assert(type & (itObject | itInstance | itInstanceRoot));
obj_idxs.emplace_back(type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)));

View file

@ -250,6 +250,7 @@ bool Preview::init(wxWindow* parent, Model* model)
_(L("Internal infill")) + "|" +
_(L("Solid infill")) + "|" +
_(L("Top solid infill")) + "|" +
_(L("Ironing")) + "|" +
_(L("Bridge infill")) + "|" +
_(L("Gap fill")) + "|" +
_(L("Skirt")) + "|" +

View file

@ -61,7 +61,9 @@ void on_window_geometry(wxTopLevelWindow *tlw, std::function<void()> callback)
#endif
}
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
wxDEFINE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent);
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
#ifdef _WIN32
template<class F> typename F::FN winapi_get_function(const wchar_t *dll, const char *fn_name) {

View file

@ -24,6 +24,11 @@ class wxCheckBox;
class wxTopLevelWindow;
class wxRect;
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
#define wxVERSION_EQUAL_OR_GREATER_THAN(major, minor, release) ((wxMAJOR_VERSION > major) || ((wxMAJOR_VERSION == major) && (wxMINOR_VERSION > minor)) || ((wxMAJOR_VERSION == major) && (wxMINOR_VERSION == minor) && (wxRELEASE_NUMBER >= release)))
#else
#define wxVERSION_EQUAL_OR_GREATER_THAN(major, minor, release) 0
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
namespace Slic3r {
namespace GUI {
@ -51,6 +56,7 @@ enum { DPI_DEFAULT = 96 };
int get_dpi_for_window(wxWindow *window);
wxFont get_default_font_for_dpi(int dpi);
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
struct DpiChangedEvent : public wxEvent {
int dpi;
wxRect rect;
@ -66,6 +72,7 @@ struct DpiChangedEvent : public wxEvent {
};
wxDECLARE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent);
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
template<class P> class DPIAware : public P
{
@ -86,11 +93,33 @@ public:
this->SetFont(m_normal_font);
#endif
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
m_em_unit = std::max<size_t>(10, 10.0f * m_scale_factor);
#else
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
// recalc_font();
this->Bind(EVT_DPI_CHANGED_SLICER, [this](const DpiChangedEvent &evt) {
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
this->Bind(wxEVT_DPI_CHANGED, [this](wxDPIChangedEvent& evt) {
m_scale_factor = (float)evt.GetNewDPI().x / (float)DPI_DEFAULT;
m_new_font_point_size = get_default_font_for_dpi(evt.GetNewDPI().x).GetPointSize();
if (!m_can_rescale)
return;
#if ENABLE_LAYOUT_NO_RESTART
if (m_force_rescale || is_new_scale_factor())
rescale(wxRect());
#else
if (is_new_scale_factor())
rescale(wxRect());
#endif // ENABLE_LAYOUT_NO_RESTART
});
#else
this->Bind(EVT_DPI_CHANGED_SLICER, [this](const DpiChangedEvent& evt) {
m_scale_factor = (float)evt.dpi / (float)DPI_DEFAULT;
m_new_font_point_size = get_default_font_for_dpi(evt.dpi).GetPointSize();
@ -98,9 +127,15 @@ public:
if (!m_can_rescale)
return;
#if ENABLE_LAYOUT_NO_RESTART
if (m_force_rescale || is_new_scale_factor())
rescale(evt.rect);
#else
if (is_new_scale_factor())
rescale(evt.rect);
});
#endif // ENABLE_LAYOUT_NO_RESTART
});
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
this->Bind(wxEVT_MOVE_START, [this](wxMoveEvent& event)
{
@ -140,6 +175,9 @@ public:
int em_unit() const { return m_em_unit; }
// int font_size() const { return m_font_size; }
const wxFont& normal_font() const { return m_normal_font; }
#if ENABLE_LAYOUT_NO_RESTART
void enable_force_rescale() { m_force_rescale = true; }
#endif // ENABLE_LAYOUT_NO_RESTART
protected:
virtual void on_dpi_changed(const wxRect &suggested_rect) = 0;
@ -153,6 +191,9 @@ private:
wxFont m_normal_font;
float m_prev_scale_factor;
bool m_can_rescale{ true };
#if ENABLE_LAYOUT_NO_RESTART
bool m_force_rescale{ false };
#endif // ENABLE_LAYOUT_NO_RESTART
int m_new_font_point_size;
@ -192,17 +233,27 @@ private:
{
this->Freeze();
// rescale fonts of all controls
scale_controls_fonts(this, m_new_font_point_size);
// rescale current window font
scale_win_font(this, m_new_font_point_size);
#if ENABLE_LAYOUT_NO_RESTART && wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
if (m_force_rescale) {
#endif // ENABLE_LAYOUT_NO_RESTART
// rescale fonts of all controls
scale_controls_fonts(this, m_new_font_point_size);
// rescale current window font
scale_win_font(this, m_new_font_point_size);
#if ENABLE_LAYOUT_NO_RESTART && wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
m_force_rescale = false;
}
#endif // ENABLE_LAYOUT_NO_RESTART
// set normal application font as a current window font
m_normal_font = this->GetFont();
// update em_unit value for new window font
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
m_em_unit = std::max<int>(10, 10.0f * m_scale_factor);
#else
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
// rescale missed controls sizes and images
on_dpi_changed(suggested_rect);
@ -341,7 +392,7 @@ public:
static WindowMetrics from_window(wxTopLevelWindow *window);
static boost::optional<WindowMetrics> deserialize(const std::string &str);
wxRect get_rect() const { return rect; }
const wxRect& get_rect() const { return rect; }
bool get_maximized() const { return maximized; }
void sanitize_for_display(const wxRect &screen_rect);

View file

@ -448,6 +448,7 @@ void SupportsClipper::render_cut() const
// Get transformation of supports
Geometry::Transformation supports_trafo = trafo;
supports_trafo.set_scaling_factor(Vec3d::Ones());
supports_trafo.set_offset(Vec3d(trafo.get_offset()(0), trafo.get_offset()(1), sel_info->get_sla_shift()));
supports_trafo.set_rotation(Vec3d(0., 0., trafo.get_rotation()(2)));
// I don't know why, but following seems to be correct.

View file

@ -42,10 +42,44 @@
namespace Slic3r {
namespace GUI {
#if ENABLE_LAYOUT_NO_RESTART
enum class ERescaleTarget
{
Mainframe,
SettingsDialog
};
static void rescale_dialog_after_dpi_change(MainFrame& mainframe, SettingsDialog& dialog, ERescaleTarget target)
{
int mainframe_dpi = get_dpi_for_window(&mainframe);
int dialog_dpi = get_dpi_for_window(&dialog);
if (mainframe_dpi != dialog_dpi) {
if (target == ERescaleTarget::SettingsDialog) {
dialog.enable_force_rescale();
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
dialog.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(mainframe_dpi, mainframe_dpi), wxSize(dialog_dpi, dialog_dpi)));
#else
dialog.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, dialog_dpi, dialog.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
} else {
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
mainframe.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(dialog_dpi, dialog_dpi), wxSize(mainframe_dpi, mainframe_dpi)));
#else
mainframe.enable_force_rescale();
mainframe.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, mainframe_dpi, mainframe.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
}
}
}
#endif // ENABLE_LAYOUT_NO_RESTART
MainFrame::MainFrame() :
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"),
m_printhost_queue_dlg(new PrintHostQueueDialog(this))
, m_recent_projects(9)
#if ENABLE_LAYOUT_NO_RESTART
, m_settings_dialog(this)
#endif // ENABLE_LAYOUT_NO_RESTART
{
// Fonts were created by the DPIFrame constructor for the monitor, on which the window opened.
wxGetApp().update_fonts(this);
@ -85,6 +119,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
m_loaded = true;
#if !ENABLE_LAYOUT_NO_RESTART
#ifdef __APPLE__
// Using SetMinSize() on Mac messes up the window position in some cases
// cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0
@ -98,8 +133,19 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
m_tabpanel->SetMinSize(size);
}
#endif
#endif // !ENABLE_LAYOUT_NO_RESTART
// initialize layout
auto sizer = new wxBoxSizer(wxVERTICAL);
m_main_sizer = new wxBoxSizer(wxVERTICAL);
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_main_sizer, 1, wxEXPAND);
#if ENABLE_LAYOUT_NO_RESTART
SetSizer(sizer);
// initialize layout from config
update_layout();
sizer->SetSizeHints(this);
Fit();
#else
if (m_plater && m_layout != slOld)
sizer->Add(m_plater, 1, wxEXPAND);
@ -109,6 +155,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
sizer->SetSizeHints(this);
SetSizer(sizer);
Fit();
#endif // !ENABLE_LAYOUT_NO_RESTART
const wxSize min_size = wxGetApp().get_min_size(); //wxSize(76*wxGetApp().em_unit(), 49*wxGetApp().em_unit());
#ifdef __APPLE__
@ -200,8 +247,12 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
});
wxGetApp().persist_window_geometry(this, true);
#if ENABLE_LAYOUT_NO_RESTART
wxGetApp().persist_window_geometry(&m_settings_dialog, true);
#else
if (m_settings_dialog != nullptr)
wxGetApp().persist_window_geometry(m_settings_dialog, true);
#endif // ENABLE_LAYOUT_NO_RESTART
update_ui_from_settings(); // FIXME (?)
@ -209,6 +260,123 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
m_plater->show_action_buttons(true);
}
#if ENABLE_LAYOUT_NO_RESTART
void MainFrame::update_layout()
{
auto restore_to_creation = [this]() {
auto clean_sizer = [](wxSizer* sizer) {
while (!sizer->GetChildren().IsEmpty()) {
sizer->Detach(0);
}
};
// On Linux m_plater needs to be removed from m_tabpanel before to reparent it
int plater_page_id = m_tabpanel->FindPage(m_plater);
if (plater_page_id != wxNOT_FOUND)
m_tabpanel->RemovePage(plater_page_id);
if (m_plater->GetParent() != this)
m_plater->Reparent(this);
if (m_tabpanel->GetParent() != this)
m_tabpanel->Reparent(this);
plater_page_id = (m_plater_page != nullptr) ? m_tabpanel->FindPage(m_plater_page) : wxNOT_FOUND;
if (plater_page_id != wxNOT_FOUND) {
m_tabpanel->DeletePage(plater_page_id);
m_plater_page = nullptr;
}
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe);
clean_sizer(m_main_sizer);
clean_sizer(m_settings_dialog.GetSizer());
if (m_settings_dialog.IsShown())
m_settings_dialog.Close();
m_tabpanel->Hide();
m_plater->Hide();
Layout();
};
ESettingsLayout layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old;
if (m_layout == layout)
return;
wxBusyCursor busy;
Freeze();
// Remove old settings
if (m_layout != ESettingsLayout::Unknown)
restore_to_creation();
m_layout = layout;
// From the very beginning the Print settings should be selected
m_last_selected_tab = m_layout == ESettingsLayout::Dlg ? 0 : 1;
// Set new settings
switch (m_layout)
{
case ESettingsLayout::Old:
{
m_plater->Reparent(m_tabpanel);
m_tabpanel->InsertPage(0, m_plater, _L("Plater"));
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);
m_plater->Show();
m_tabpanel->Show();
break;
}
case ESettingsLayout::New:
{
m_main_sizer->Add(m_plater, 1, wxEXPAND);
m_tabpanel->Hide();
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);
m_plater_page = new wxPanel(m_tabpanel);
m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */
m_plater->Show();
break;
}
case ESettingsLayout::Dlg:
{
m_main_sizer->Add(m_plater, 1, wxEXPAND);
m_tabpanel->Reparent(&m_settings_dialog);
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND);
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
m_tabpanel->Show();
m_plater->Show();
break;
}
}
//#ifdef __APPLE__
// // Using SetMinSize() on Mac messes up the window position in some cases
// // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0
// // So, if we haven't possibility to set MinSize() for the MainFrame,
// // set the MinSize() as a half of regular for the m_plater and m_tabpanel, when settings layout is in slNew mode
// // Otherwise, MainFrame will be maximized by height
// if (m_layout == ESettingsLayout::New) {
// wxSize size = wxGetApp().get_min_size();
// size.SetHeight(int(0.5 * size.GetHeight()));
// m_plater->SetMinSize(size);
// m_tabpanel->SetMinSize(size);
// }
//#endif
Layout();
Thaw();
}
#endif // ENABLE_LAYOUT_NO_RESTART
// Called when closing the application and when switching the application language.
void MainFrame::shutdown()
{
@ -241,6 +409,11 @@ void MainFrame::shutdown()
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
this->Show(false);
#if ENABLE_LAYOUT_NO_RESTART
if (m_settings_dialog.IsShown())
// call Close() to trigger call to lambda defined into GUI_App::persist_window_geometry()
m_settings_dialog.Close();
#else
if (m_settings_dialog != nullptr)
{
if (m_settings_dialog->IsShown())
@ -249,6 +422,7 @@ void MainFrame::shutdown()
m_settings_dialog->Destroy();
}
#endif // ENABLE_LAYOUT_NO_RESTART
// Stop the background thread (Windows and Linux).
// Disconnect from a 3DConnextion driver (OSX).
@ -307,9 +481,19 @@ void MainFrame::update_title()
void MainFrame::init_tabpanel()
{
#if ENABLE_LAYOUT_NO_RESTART
// wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10
// with multiple high resolution displays connected.
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font());
#endif
m_tabpanel->Hide();
m_settings_dialog.set_tabpanel(m_tabpanel);
#else
m_layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? slOld :
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? slNew :
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? slDlg : slOld;
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? slNew :
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? slDlg : slOld;
// From the very beginning the Print settings should be selected
m_last_selected_tab = m_layout == slDlg ? 0 : 1;
@ -326,13 +510,14 @@ void MainFrame::init_tabpanel()
m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font());
#endif
}
#endif // ENABLE_LAYOUT_NO_RESTART
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
wxWindow* panel = m_tabpanel->GetCurrentPage();
Tab* tab = dynamic_cast<Tab*>(panel);
// There shouldn't be a case, when we try to select a tab, which doesn't support a printer technology
if (panel == nullptr || (tab && ! tab->supports_printer_technology(m_plater->printer_technology())))
if (panel == nullptr || (tab != nullptr && !tab->supports_printer_technology(m_plater->printer_technology())))
return;
auto& tabs_list = wxGetApp().tabs_list;
@ -346,6 +531,10 @@ void MainFrame::init_tabpanel()
select_tab(0); // select Plater
});
#if ENABLE_LAYOUT_NO_RESTART
m_plater = new Plater(this, this);
m_plater->Hide();
#else
if (m_layout == slOld) {
m_plater = new Plater(m_tabpanel, this);
m_tabpanel->AddPage(m_plater, _L("Plater"));
@ -355,6 +544,7 @@ void MainFrame::init_tabpanel()
if (m_layout == slNew)
m_tabpanel->AddPage(new wxPanel(m_tabpanel), _L("Plater")); // empty panel just for Plater tab
}
#endif // ENABLE_LAYOUT_NO_RESTART
wxGetApp().plater_ = m_plater;
wxGetApp().obj_list()->create_popup_menus();
@ -496,6 +686,18 @@ bool MainFrame::can_slice() const
bool MainFrame::can_change_view() const
{
#if ENABLE_LAYOUT_NO_RESTART
switch (m_layout)
{
default: { return false; }
case ESettingsLayout::New: { return m_plater->IsShown(); }
case ESettingsLayout::Dlg: { return true; }
case ESettingsLayout::Old: {
int page_id = m_tabpanel->GetSelection();
return page_id != wxNOT_FOUND && dynamic_cast<const Slic3r::GUI::Plater*>(m_tabpanel->GetPage((size_t)page_id)) != nullptr;
}
}
#else
if (m_layout == slNew)
return m_plater->IsShown();
if (m_layout == slDlg)
@ -503,6 +705,7 @@ bool MainFrame::can_change_view() const
// slOld layout mode
int page_id = m_tabpanel->GetSelection();
return page_id != wxNOT_FOUND && dynamic_cast<const Slic3r::GUI::Plater*>(m_tabpanel->GetPage((size_t)page_id)) != nullptr;
#endif // ENABLE_LAYOUT_NO_RESTART
}
bool MainFrame::can_select() const
@ -530,16 +733,24 @@ bool MainFrame::can_reslice() const
return (m_plater != nullptr) && !m_plater->model().objects.empty();
}
void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
{
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
wxGetApp().update_fonts(this);
#else
wxGetApp().update_fonts();
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
this->SetFont(this->normal_font());
// update Plater
wxGetApp().plater()->msw_rescale();
// update Tabs
#if ENABLE_LAYOUT_NO_RESTART
if (m_layout != ESettingsLayout::Dlg) // Do not update tabs if the Settings are in the separated dialog
#else
if (m_layout != slDlg) // Update tabs later, from the SettingsDialog, when the Settings are in the separated dialog
#endif // ENABLE_LAYOUT_NO_RESTART
for (auto tab : wxGetApp().tabs_list)
tab->msw_rescale();
@ -549,7 +760,7 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
// Workarounds for correct Window rendering after rescale
/* Even if Window is maximized during moving,
/* Even if Window is maximized during moving,
* first of all we should imitate Window resizing. So:
* 1. cancel maximization, if it was set
* 2. imitate resizing
@ -567,6 +778,11 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
this->SetSize(sz);
this->Maximize(is_maximized);
#if ENABLE_LAYOUT_NO_RESTART
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
#endif // ENABLE_LAYOUT_NO_RESTART
}
void MainFrame::on_sys_color_changed()
@ -1075,10 +1291,10 @@ void MainFrame::quick_slice(const int qs)
}
// show processbar dialog
m_progress_dialog = new wxProgressDialog(_(L("Slicing")) + dots,
// TRN "Processing input_file_basename"
from_u8((boost::format(_utf8(L("Processing %s"))) % (input_file_basename + dots)).str()),
100, this, 4);
m_progress_dialog = new wxProgressDialog(_L("Slicing") + dots,
// TRN "Processing input_file_basename"
from_u8((boost::format(_utf8(L("Processing %s"))) % (input_file_basename + dots)).str()),
100, nullptr, wxPD_AUTO_HIDE);
m_progress_dialog->Pulse();
{
// my @warnings = ();
@ -1299,15 +1515,41 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
{
#if ENABLE_LAYOUT_NO_RESTART
if (m_layout == ESettingsLayout::Dlg) {
#else
if (m_layout == slDlg) {
#endif // ENABLE_LAYOUT_NO_RESTART
if (tab==0) {
#if ENABLE_LAYOUT_NO_RESTART
if (m_settings_dialog.IsShown())
this->SetFocus();
#else
if (m_settings_dialog->IsShown())
this->SetFocus();
#endif // ENABLE_LAYOUT_NO_RESTART
// plater should be focused for correct navigation inside search window
if (m_plater->canvas3D()->is_search_pressed())
m_plater->SetFocus();
return;
}
#if ENABLE_LAYOUT_NO_RESTART
// Show/Activate Settings Dialog
#ifdef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
if (m_settings_dialog.IsShown())
m_settings_dialog.Hide();
m_tabpanel->Show();
m_settings_dialog.Show();
#else
if (m_settings_dialog.IsShown())
m_settings_dialog.SetFocus();
else {
m_tabpanel->Show();
m_settings_dialog.Show();
}
#endif
#else
// Show/Activate Settings Dialog
if (m_settings_dialog->IsShown())
#ifdef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
@ -1317,10 +1559,17 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
else
#endif
m_settings_dialog->Show();
#endif // ENABLE_LAYOUT_NO_RESTART
}
#if ENABLE_LAYOUT_NO_RESTART
else if (m_layout == ESettingsLayout::New) {
m_main_sizer->Show(m_plater, tab == 0);
m_main_sizer->Show(m_tabpanel, tab != 0);
#else
else if (m_layout == slNew) {
m_plater->Show(tab == 0);
m_tabpanel->Show(tab != 0);
#endif // ENABLE_LAYOUT_NO_RESTART
// plater should be focused for correct navigation inside search window
if (tab == 0 && m_plater->canvas3D()->is_search_pressed())
@ -1328,8 +1577,12 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
Layout();
}
// when tab == -1, it means we should to show the last selected tab
// when tab == -1, it means we should show the last selected tab
#if ENABLE_LAYOUT_NO_RESTART
m_tabpanel->SetSelection(tab == (size_t)(-1) ? m_last_selected_tab : (m_layout == ESettingsLayout::Dlg && tab != 0) ? tab - 1 : tab);
#else
m_tabpanel->SetSelection(tab == (size_t)(-1) ? m_last_selected_tab : (m_layout == slDlg && tab != 0) ? tab-1 : tab);
#endif // ENABLE_LAYOUT_NO_RESTART
}
// Set a camera direction, zoom to all objects.
@ -1440,14 +1693,12 @@ std::string MainFrame::get_dir_name(const wxString &full_name) const
// ----------------------------------------------------------------------------
SettingsDialog::SettingsDialog(MainFrame* mainframe)
: DPIDialog(nullptr, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxDIALOG_NO_PARENT, "settings_dialog"),
: DPIDialog(mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
m_main_frame(mainframe)
{
this->SetFont(wxGetApp().normal_font());
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
this->SetBackgroundColour(bgr_clr);
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
// Load the icon either from the exe, or from the ico file.
#if _WIN32
@ -1460,6 +1711,7 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
SetIcon(wxIcon(var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
#endif // _WIN32
#if !ENABLE_LAYOUT_NO_RESTART
// wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10
// with multiple high resolution displays connected.
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxGetApp().get_min_size(), wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
@ -1484,10 +1736,45 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
}
}
});
#endif // !ENABLE_LAYOUT_NO_RESTART
#if ENABLE_LAYOUT_NO_RESTART
this->Bind(wxEVT_SHOW, [this](wxShowEvent& evt) {
auto key_up_handker = [this](wxKeyEvent& evt) {
if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) {
switch (evt.GetKeyCode()) {
case '1': { m_main_frame->select_tab(0); break; }
case '2': { m_main_frame->select_tab(1); break; }
case '3': { m_main_frame->select_tab(2); break; }
case '4': { m_main_frame->select_tab(3); break; }
#ifdef __APPLE__
case 'f':
#else /* __APPLE__ */
case WXK_CONTROL_F:
#endif /* __APPLE__ */
case 'F': { m_main_frame->plater()->search(false); break; }
default:break;
}
}
};
if (evt.IsShown()) {
if (m_tabpanel != nullptr)
m_tabpanel->Bind(wxEVT_KEY_UP, key_up_handker);
}
else {
if (m_tabpanel != nullptr)
m_tabpanel->Unbind(wxEVT_KEY_UP, key_up_handker);
}
});
#endif // ENABLE_LAYOUT_NO_RESTART
// initialize layout
auto sizer = new wxBoxSizer(wxVERTICAL);
#if !ENABLE_LAYOUT_NO_RESTART
sizer->Add(m_tabpanel, 1, wxEXPAND);
#endif // !ENABLE_LAYOUT_NO_RESTART
sizer->SetSizeHints(this);
SetSizer(sizer);
Fit();

View file

@ -51,11 +51,15 @@ struct PresetTab {
class SettingsDialog : public DPIDialog
{
wxNotebook* m_tabpanel { nullptr };
MainFrame* m_main_frame {nullptr };
MainFrame* m_main_frame { nullptr };
public:
SettingsDialog(MainFrame* mainframe);
~SettingsDialog() {}
#if ENABLE_LAYOUT_NO_RESTART
void set_tabpanel(wxNotebook* tabpanel) { m_tabpanel = tabpanel; }
#else
wxNotebook* get_tabpanel() { return m_tabpanel; }
#endif // ENABLE_LAYOUT_NO_RESTART
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
@ -72,6 +76,7 @@ class MainFrame : public DPIFrame
wxMenuItem* m_menu_item_repeat { nullptr }; // doesn't used now
#endif
wxMenuItem* m_menu_item_reslice_now { nullptr };
wxSizer* m_main_sizer{ nullptr };
PrintHostQueueDialog *m_printhost_queue_dlg;
@ -114,11 +119,23 @@ class MainFrame : public DPIFrame
wxFileHistory m_recent_projects;
#if ENABLE_LAYOUT_NO_RESTART
enum class ESettingsLayout
{
Unknown,
Old,
New,
Dlg,
};
ESettingsLayout m_layout{ ESettingsLayout::Unknown };
#else
enum SettingsLayout {
slOld = 0,
slNew,
slDlg,
} m_layout;
#endif // ENABLE_LAYOUT_NO_RESTART
protected:
virtual void on_dpi_changed(const wxRect &suggested_rect);
@ -128,6 +145,10 @@ public:
MainFrame();
~MainFrame() = default;
#if ENABLE_LAYOUT_NO_RESTART
void update_layout();
#endif // ENABLE_LAYOUT_NO_RESTART
// Called when closing the application and when switching the application language.
void shutdown();
@ -169,7 +190,12 @@ public:
Plater* m_plater { nullptr };
wxNotebook* m_tabpanel { nullptr };
#if ENABLE_LAYOUT_NO_RESTART
SettingsDialog m_settings_dialog;
wxWindow* m_plater_page{ nullptr };
#else
SettingsDialog* m_settings_dialog { nullptr };
#endif // ENABLE_LAYOUT_NO_RESTART
wxProgressDialog* m_progress_dialog { nullptr };
std::shared_ptr<ProgressStatusBar> m_statusbar;

View file

@ -1929,9 +1929,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
// collapse sidebar according to saved value
bool is_collapsed = wxGetApp().app_config->get("collapsed_sidebar") == "1";
sidebar->collapse(is_collapsed);
// Update an enable of the collapse_toolbar: if sidebar is collapsed, then collapse_toolbar should be visible
if (is_collapsed)
wxGetApp().app_config->set("show_collapse_button", "1");
}
Plater::priv::~priv()
@ -2055,17 +2052,17 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
}
const auto loading = _L("Loading") + dots;
wxProgressDialog dlg(loading, loading);
wxProgressDialog dlg(loading, "", 100, q, wxPD_AUTO_HIDE);
dlg.Pulse();
auto *new_model = (!load_model || one_by_one) ? nullptr : new Slic3r::Model();
std::vector<size_t> obj_idxs;
for (size_t i = 0; i < input_files.size(); i++) {
for (size_t i = 0; i < input_files.size(); ++i) {
const auto &path = input_files[i];
const auto filename = path.filename();
const auto dlg_info = format_wxstr(_L("Processing input file %s"), from_path(filename)) + "\n";
dlg.Update(100 * i / input_files.size(), dlg_info);
const auto dlg_info = _L("Loading file") + ": " + from_path(filename);
dlg.Update(static_cast<int>(100.0f * static_cast<float>(i) / static_cast<float>(input_files.size())), dlg_info);
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
@ -3268,6 +3265,27 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
// Update the SLA preview. Only called if not RELOAD_SLA_SUPPORT_POINTS, as the block above will refresh the preview anyways.
this->preview->reload_print();
}
if (evt.status.flags & (PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS | PrintBase::SlicingStatus::UPDATE_PRINT_OBJECT_STEP_WARNINGS)) {
// Update notification center with warnings of object_id and its warning_step.
ObjectID object_id = evt.status.warning_object_id;
int warning_step = evt.status.warning_step;
PrintStateBase::StateWithWarnings state;
if (evt.status.flags & PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS) {
state = this->printer_technology == ptFFF ?
this->fff_print.step_state_with_warnings(static_cast<PrintStep>(warning_step)) :
this->sla_print.step_state_with_warnings(static_cast<SLAPrintStep>(warning_step));
} else if (this->printer_technology == ptFFF) {
const PrintObject *print_object = this->fff_print.get_object(object_id);
if (print_object)
state = print_object->step_state_with_warnings(static_cast<PrintObjectStep>(warning_step));
} else {
const SLAPrintObject *print_object = this->sla_print.get_object(object_id);
if (print_object)
state = print_object->step_state_with_warnings(static_cast<SLAPrintObjectStep>(warning_step));
}
// Now process state.warnings.
}
}
void Plater::priv::on_slicing_completed(wxCommandEvent &)
@ -4704,25 +4722,33 @@ void Plater::export_stl(bool extended, bool selection_only)
? Transform3d::Identity()
: object->model_object()->instances[instance_idx]->get_transformation().get_matrix();
TriangleMesh inst_mesh;
if (has_pad_mesh)
{
TriangleMesh inst_pad_mesh = pad_mesh;
inst_pad_mesh.transform(inst_transform, is_left_handed);
mesh.merge(inst_pad_mesh);
inst_mesh.merge(inst_pad_mesh);
}
if (has_supports_mesh)
{
TriangleMesh inst_supports_mesh = supports_mesh;
inst_supports_mesh.transform(inst_transform, is_left_handed);
mesh.merge(inst_supports_mesh);
inst_mesh.merge(inst_supports_mesh);
}
TriangleMesh inst_object_mesh = object->get_mesh_to_print();
inst_object_mesh.transform(mesh_trafo_inv);
inst_object_mesh.transform(inst_transform, is_left_handed);
mesh.merge(inst_object_mesh);
inst_mesh.merge(inst_object_mesh);
// ensure that the instance lays on the bed
inst_mesh.translate(0.0f, 0.0f, -inst_mesh.bounding_box().min[2]);
// merge instance with global mesh
mesh.merge(inst_mesh);
if (one_inst_only)
break;

View file

@ -161,7 +161,7 @@ void PreferencesDialog::build()
}
};
def.label = L("Show the button for the collapse sidebar");
def.label = L("Show sidebar collapse/expand button");
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" });
@ -234,6 +234,7 @@ void PreferencesDialog::accept()
}
}
#if !ENABLE_LAYOUT_NO_RESTART
if (m_settings_layout_changed) {
// the dialog needs to be destroyed before the call to recreate_gui()
// or sometimes the application crashes into wxDialogBase() destructor
@ -255,6 +256,7 @@ void PreferencesDialog::accept()
return;
}
}
#endif // !ENABLE_LAYOUT_NO_RESTART
for (std::map<std::string, std::string>::iterator it = m_values.begin(); it != m_values.end(); ++it)
app_config->set(it->first, it->second);
@ -351,9 +353,9 @@ void PreferencesDialog::create_icon_size_slider()
void PreferencesDialog::create_settings_mode_widget()
{
wxString choices[] = { _L("Old regular layout with tab bar"),
_L("New layout without the tab bar on the platter"),
_L("Settings will be shown in non-modal dialog") };
wxString choices[] = { _L("Old regular layout with the tab bar"),
_L("New layout without the tab bar on the plater"),
_L("Settings will be shown in the non-modal dialog") };
auto app_config = get_app_config();
int selection = app_config->get("old_settings_layout_mode") == "1" ? 0 :

View file

@ -617,8 +617,9 @@ void SearchDialog::update_list()
for (const FoundOption& item : filters)
search_list_model->Prepend(item.label);
// select first item
search_list->Select(search_list_model->GetItem(0));
// select first item, if search_list
if (search_list_model->GetCount() > 0)
search_list->Select(search_list_model->GetItem(0));
prevent_list_events = false;
}