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

This commit is contained in:
YuSanka 2020-04-29 19:17:20 +02:00
commit bf09d8f93a
103 changed files with 19303 additions and 1133 deletions

View file

@ -26,6 +26,7 @@
#include "GUI_ObjectList.hpp"
#include "Mouse3DController.hpp"
#include "RemovableDriveManager.hpp"
#include "InstanceCheck.hpp"
#include "I18N.hpp"
#include <fstream>
@ -89,6 +90,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
// initialize layout
auto sizer = new wxBoxSizer(wxVERTICAL);
if (m_plater)
sizer->Add(m_plater, 1, wxEXPAND);
if (m_tabpanel)
sizer->Add(m_tabpanel, 1, wxEXPAND);
sizer->SetSizeHints(this);
@ -234,7 +237,8 @@ void MainFrame::shutdown()
// Stop the background thread of the removable drive manager, so that no new updates will be sent to the Plater.
wxGetApp().removable_drive_manager()->shutdown();
//stop listening for messages from other instances
wxGetApp().other_instance_message_handler()->shutdown();
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
// but in rare cases it may not have been called yet.
wxGetApp().app_config->save();
@ -304,11 +308,16 @@ void MainFrame::init_tabpanel()
// before the MainFrame is fully set up.
static_cast<Tab*>(panel)->OnActivate();
}
else
select_tab(0);
});
m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
//! m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
m_plater = new Plater(this, this);
wxGetApp().plater_ = m_plater;
m_tabpanel->AddPage(m_plater, _(L("Plater")));
// m_tabpanel->AddPage(m_plater, _(L("Plater")));
m_tabpanel->AddPage(new wxPanel(m_tabpanel), _L("Plater")); // empty panel just for Plater tab
wxGetApp().obj_list()->create_popup_menus();
@ -334,6 +343,13 @@ void MainFrame::init_tabpanel()
}
}
void MainFrame::switch_to(bool plater)
{
this->m_plater->Show(plater);
this->m_tabpanel->Show(!plater);
this->Layout();
}
void MainFrame::create_preset_tabs()
{
wxGetApp().update_label_colours_from_appconfig();
@ -741,31 +757,37 @@ void MainFrame::init_menubar()
append_menu_item(editMenu, wxID_ANY, _(L("Re&load from disk")) + sep + "F5",
_(L("Reload the plater from disk")), [this](wxCommandEvent&) { m_plater->reload_all_from_disk(); },
"", nullptr, [this]() {return !m_plater->model().objects.empty(); }, this);
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("Searc&h")) + "\tCtrl+F",
_(L("Find option")), [this](wxCommandEvent&) { m_plater->search(/*m_tabpanel->GetCurrentPage() == */m_plater->IsShown()); },
"search", nullptr, [this]() {return true; }, this);
}
// Window menu
auto windowMenu = new wxMenu();
{
size_t tab_offset = 0;
//! size_t tab_offset = 0;
if (m_plater) {
append_menu_item(windowMenu, wxID_HIGHEST + 1, _(L("&Plater Tab")) + "\tCtrl+1", _(L("Show the plater")),
[this](wxCommandEvent&) { select_tab(0); }, "plater", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*(size_t)(-1)*/0); }, "plater", nullptr,
[this]() {return true; }, this);
tab_offset += 1;
}
if (tab_offset > 0) {
//! tab_offset += 1;
//! }
//! if (tab_offset > 0) {
windowMenu->AppendSeparator();
}
append_menu_item(windowMenu, wxID_HIGHEST + 2, _(L("P&rint Settings Tab")) + "\tCtrl+2", _(L("Show the print settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 0); }, "cog", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 0*/1); }, "cog", nullptr,
[this]() {return true; }, this);
wxMenuItem* item_material_tab = append_menu_item(windowMenu, wxID_HIGHEST + 3, _(L("&Filament Settings Tab")) + "\tCtrl+3", _(L("Show the filament settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 1); }, "spool", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 1*/2); }, "spool", nullptr,
[this]() {return true; }, this);
m_changeable_menu_items.push_back(item_material_tab);
append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 2); }, "printer", nullptr,
wxMenuItem* item_printer_tab = append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")),
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 2*/3); }, "printer", nullptr,
[this]() {return true; }, this);
m_changeable_menu_items.push_back(item_printer_tab);
if (m_plater) {
windowMenu->AppendSeparator();
append_menu_item(windowMenu, wxID_HIGHEST + 5, _(L("3&D")) + "\tCtrl+5", _(L("Show the 3D editing view")),
@ -832,6 +854,9 @@ void MainFrame::init_menubar()
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this,
[this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this);
#endif // ENABLE_SLOPE_RENDERING
append_menu_check_item(viewMenu, wxID_ANY, _(L("&Collapse sidebar")), _(L("Collapse sidebar")),
[this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this,
[this]() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this);
}
// Help menu
@ -906,7 +931,9 @@ void MainFrame::update_menubar()
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _(L("S&end G-code")) : _(L("S&end to print"))) + dots + "\tCtrl+Shift+G");
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _(L("&Filament Settings Tab")) : _(L("Mate&rial Settings Tab"))) + "\tCtrl+3");
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool": "resin"));
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool" : "resin"));
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "printer" : "sla_printer"));
}
// To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
@ -1222,9 +1249,17 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
#endif
}
void MainFrame::select_tab(size_t tab) const
void MainFrame::select_tab(size_t tab)
{
m_tabpanel->SetSelection(tab);
if (tab == /*(size_t)(-1)*/0) {
if (m_plater && !m_plater->IsShown())
this->switch_to(true);
}
else {
if (m_plater && m_plater->IsShown())
switch_to(false);
m_tabpanel->SetSelection(tab);
}
}
// Set a camera direction, zoom to all objects.