mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-09 22:19:11 +08:00
Some code rebase
This commit is contained in:
parent
703f367e69
commit
398f15d546
@ -109,20 +109,15 @@ void MainFrame::init_tabpanel()
|
|||||||
|
|
||||||
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
|
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
|
||||||
auto panel = m_tabpanel->GetCurrentPage();
|
auto panel = m_tabpanel->GetCurrentPage();
|
||||||
// panel->OnActivate(); if panel->can('OnActivate');
|
|
||||||
|
|
||||||
if (panel == nullptr)
|
if (panel == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto& tab_name : { "print", "filament", "printer" }) {
|
auto& tabs_list = wxGetApp().tabs_list;
|
||||||
if (tab_name == panel->GetName()) {
|
if (find(tabs_list.begin(), tabs_list.end(), panel) != tabs_list.end()) {
|
||||||
// On GTK, the wxEVT_NOTEBOOK_PAGE_CHANGED event is triggered
|
// On GTK, the wxEVT_NOTEBOOK_PAGE_CHANGED event is triggered
|
||||||
// before the MainFrame is fully set up.
|
// before the MainFrame is fully set up.
|
||||||
auto it = m_options_tabs.find(tab_name);
|
static_cast<Tab*>(panel)->OnActivate();
|
||||||
assert(it != m_options_tabs.end());
|
|
||||||
if (it != m_options_tabs.end())
|
|
||||||
it->second->OnActivate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -140,9 +135,6 @@ void MainFrame::init_tabpanel()
|
|||||||
Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this);
|
Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this);
|
||||||
|
|
||||||
create_preset_tabs();
|
create_preset_tabs();
|
||||||
std::vector<std::string> tab_names = { "print", "filament", "sla_print", "sla_material", "printer" };
|
|
||||||
for (auto tab_name : tab_names)
|
|
||||||
m_options_tabs[tab_name] = get_preset_tab(tab_name.c_str());
|
|
||||||
|
|
||||||
if (m_plater) {
|
if (m_plater) {
|
||||||
// load initial config
|
// load initial config
|
||||||
@ -157,46 +149,12 @@ void MainFrame::init_tabpanel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PresetTab> preset_tabs = {
|
|
||||||
{ "print", nullptr, ptFFF },
|
|
||||||
{ "filament", nullptr, ptFFF },
|
|
||||||
{ "sla_print", nullptr, ptSLA },
|
|
||||||
{ "sla_material", nullptr, ptSLA }
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<PresetTab>& MainFrame::get_preset_tabs() {
|
|
||||||
return preset_tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tab* MainFrame::get_tab(const std::string& name)
|
|
||||||
{
|
|
||||||
std::vector<PresetTab>::iterator it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
|
|
||||||
[name](PresetTab& tab) { return name == tab.name; });
|
|
||||||
return it != preset_tabs.end() ? it->panel : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tab* MainFrame::get_preset_tab(const std::string& name)
|
|
||||||
{
|
|
||||||
Tab* tab = get_tab(name);
|
|
||||||
if (tab) return tab;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < m_tabpanel->GetPageCount(); ++i) {
|
|
||||||
tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(i));
|
|
||||||
if (!tab)
|
|
||||||
continue;
|
|
||||||
if (tab->name() == name) {
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainFrame::create_preset_tabs()
|
void MainFrame::create_preset_tabs()
|
||||||
{
|
{
|
||||||
wxGetApp().update_label_colours_from_appconfig();
|
wxGetApp().update_label_colours_from_appconfig();
|
||||||
add_created_tab(new TabPrint(m_tabpanel));
|
add_created_tab(new TabPrint(m_tabpanel));
|
||||||
add_created_tab(new TabSLAPrint(m_tabpanel));
|
|
||||||
add_created_tab(new TabFilament(m_tabpanel));
|
add_created_tab(new TabFilament(m_tabpanel));
|
||||||
|
add_created_tab(new TabSLAPrint(m_tabpanel));
|
||||||
add_created_tab(new TabSLAMaterial(m_tabpanel));
|
add_created_tab(new TabSLAMaterial(m_tabpanel));
|
||||||
add_created_tab(new TabPrinter(m_tabpanel));
|
add_created_tab(new TabPrinter(m_tabpanel));
|
||||||
}
|
}
|
||||||
@ -205,14 +163,9 @@ void MainFrame::add_created_tab(Tab* panel)
|
|||||||
{
|
{
|
||||||
panel->create_preset_tab();
|
panel->create_preset_tab();
|
||||||
|
|
||||||
const wxString& tab_name = panel->GetName();
|
const auto printer_tech = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
|
||||||
|
|
||||||
auto it = std::find_if(preset_tabs.begin(), preset_tabs.end(),
|
if (panel->supports_printer_technology(printer_tech))
|
||||||
[tab_name](PresetTab& tab) {return tab.name == tab_name; });
|
|
||||||
if (it != preset_tabs.end())
|
|
||||||
it->panel = panel;
|
|
||||||
|
|
||||||
if (panel->supports_printer_technology(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology()))
|
|
||||||
m_tabpanel->AddPage(panel, panel->title());
|
m_tabpanel->AddPage(panel, panel->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,8 +720,8 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
|
|||||||
// Also update the platter with the new presets.
|
// Also update the platter with the new presets.
|
||||||
void MainFrame::load_config(const DynamicPrintConfig& config)
|
void MainFrame::load_config(const DynamicPrintConfig& config)
|
||||||
{
|
{
|
||||||
for (auto tab : m_options_tabs)
|
for (auto tab : wxGetApp().tabs_list)
|
||||||
tab.second->load_config(config);
|
tab->load_config(config);
|
||||||
if (m_plater)
|
if (m_plater)
|
||||||
m_plater->on_config_change(config);
|
m_plater->on_config_change(config);
|
||||||
}
|
}
|
||||||
@ -838,11 +791,7 @@ void MainFrame::update_ui_from_settings()
|
|||||||
{
|
{
|
||||||
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
|
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
|
||||||
// if (m_plater) m_plater->update_ui_from_settings();
|
// if (m_plater) m_plater->update_ui_from_settings();
|
||||||
/*
|
|
||||||
std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
|
||||||
for (auto tab_name: tab_names)
|
|
||||||
m_options_tabs[tab_name]->update_ui_from_settings();
|
|
||||||
*/
|
|
||||||
for (auto tab: wxGetApp().tabs_list)
|
for (auto tab: wxGetApp().tabs_list)
|
||||||
tab->update_ui_from_settings();
|
tab->update_ui_from_settings();
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,6 @@ class MainFrame : public wxFrame
|
|||||||
wxString m_qs_last_output_file = wxEmptyString;
|
wxString m_qs_last_output_file = wxEmptyString;
|
||||||
wxString m_last_config = wxEmptyString;
|
wxString m_last_config = wxEmptyString;
|
||||||
|
|
||||||
std::map<std::string, Tab*> m_options_tabs;
|
|
||||||
|
|
||||||
wxMenuItem* m_menu_item_repeat { nullptr };
|
wxMenuItem* m_menu_item_repeat { nullptr };
|
||||||
wxMenuItem* m_menu_item_reslice_now { nullptr };
|
wxMenuItem* m_menu_item_reslice_now { nullptr };
|
||||||
#if !ENABLE_NEW_MENU_LAYOUT
|
#if !ENABLE_NEW_MENU_LAYOUT
|
||||||
@ -67,7 +65,6 @@ class MainFrame : public wxFrame
|
|||||||
|
|
||||||
void on_presets_changed(SimpleEvent&);
|
void on_presets_changed(SimpleEvent&);
|
||||||
void on_value_changed(wxCommandEvent&);
|
void on_value_changed(wxCommandEvent&);
|
||||||
Tab* get_tab(const std::string& name);
|
|
||||||
|
|
||||||
#if ENABLE_NEW_MENU_LAYOUT
|
#if ENABLE_NEW_MENU_LAYOUT
|
||||||
bool can_save() const;
|
bool can_save() const;
|
||||||
@ -84,8 +81,6 @@ public:
|
|||||||
Plater* plater() { return m_plater; }
|
Plater* plater() { return m_plater; }
|
||||||
|
|
||||||
void init_tabpanel();
|
void init_tabpanel();
|
||||||
const std::map<std::string, Tab*>& options_tabs() const { return m_options_tabs; }
|
|
||||||
Tab* get_preset_tab(const std::string& name);
|
|
||||||
void create_preset_tabs();
|
void create_preset_tabs();
|
||||||
void add_created_tab(Tab* panel);
|
void add_created_tab(Tab* panel);
|
||||||
void init_menubar();
|
void init_menubar();
|
||||||
@ -105,8 +100,6 @@ public:
|
|||||||
void select_tab(size_t tab) const;
|
void select_tab(size_t tab) const;
|
||||||
void select_view(const std::string& direction);
|
void select_view(const std::string& direction);
|
||||||
|
|
||||||
std::vector<PresetTab>& get_preset_tabs();
|
|
||||||
|
|
||||||
Plater* m_plater { nullptr };
|
Plater* m_plater { nullptr };
|
||||||
wxNotebook* m_tabpanel { nullptr };
|
wxNotebook* m_tabpanel { nullptr };
|
||||||
wxProgressDialog* m_progress_dialog { nullptr };
|
wxProgressDialog* m_progress_dialog { nullptr };
|
||||||
|
@ -2027,7 +2027,7 @@ void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
|
|||||||
DynamicPrintConfig cfg;
|
DynamicPrintConfig cfg;
|
||||||
cfg.opt<ConfigOptionFloat>("wipe_tower_x", true)->value = evt.data(0);
|
cfg.opt<ConfigOptionFloat>("wipe_tower_x", true)->value = evt.data(0);
|
||||||
cfg.opt<ConfigOptionFloat>("wipe_tower_y", true)->value = evt.data(1);
|
cfg.opt<ConfigOptionFloat>("wipe_tower_y", true)->value = evt.data(1);
|
||||||
main_frame->get_preset_tab("print")->load_config(cfg);
|
wxGetApp().get_tab(Preset::TYPE_PRINT)->load_config(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_enable_action_buttons(Event<bool>&)
|
void Plater::priv::on_enable_action_buttons(Event<bool>&)
|
||||||
|
@ -765,9 +765,7 @@ void Tab::on_presets_changed()
|
|||||||
{
|
{
|
||||||
// If the printer tells us that the print or filament/sla_material preset has been switched or invalidated,
|
// If the printer tells us that the print or filament/sla_material preset has been switched or invalidated,
|
||||||
// refresh the print or filament/sla_material tab page.
|
// refresh the print or filament/sla_material tab page.
|
||||||
Tab* tab = wxGetApp().get_tab(t);
|
wxGetApp().get_tab(t)->load_current_preset();
|
||||||
if (tab)
|
|
||||||
tab->load_current_preset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2251,14 +2249,16 @@ void Tab::load_current_preset()
|
|||||||
PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology();
|
PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology();
|
||||||
if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology)
|
if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology)
|
||||||
{
|
{
|
||||||
for (auto& tab : wxGetApp().mainframe->get_preset_tabs()) {
|
for (auto tab : wxGetApp().tabs_list) {
|
||||||
if (tab.technology != printer_technology)
|
if (tab->type() == Preset::TYPE_PRINTER) // Printer tab is shown every time
|
||||||
{
|
continue;
|
||||||
int page_id = wxGetApp().tab_panel()->FindPage(tab.panel);
|
if (tab->supports_printer_technology(printer_technology))
|
||||||
|
wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title());
|
||||||
|
else {
|
||||||
|
int page_id = wxGetApp().tab_panel()->FindPage(tab);
|
||||||
wxGetApp().tab_panel()->GetPage(page_id)->Show(false);
|
wxGetApp().tab_panel()->GetPage(page_id)->Show(false);
|
||||||
wxGetApp().tab_panel()->RemovePage(page_id);
|
wxGetApp().tab_panel()->RemovePage(page_id);
|
||||||
} else
|
}
|
||||||
wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab.panel, tab.panel->title());
|
|
||||||
}
|
}
|
||||||
static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology;
|
static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user