From 1df89650e98ec3667a4ea7b73d9988993beffbb4 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Thu, 22 Dec 2022 22:41:45 +0800 Subject: [PATCH] pa works --- resources/images/calib_sf.svg | 15 ++++++++ resources/images/calib_sf_inactive.svg | 17 ++++++++++ src/slic3r/GUI/BBLTopbar.cpp | 22 ++++++++---- src/slic3r/GUI/BBLTopbar.hpp | 10 +++--- src/slic3r/GUI/GLToolbar.cpp | 2 -- src/slic3r/GUI/GLToolbar.hpp | 2 -- src/slic3r/GUI/MainFrame.cpp | 47 +++----------------------- src/slic3r/GUI/MainFrame.hpp | 1 - src/slic3r/GUI/Plater.cpp | 44 +++++++++++------------- src/slic3r/GUI/Plater.hpp | 3 ++ 10 files changed, 82 insertions(+), 81 deletions(-) create mode 100644 resources/images/calib_sf.svg create mode 100644 resources/images/calib_sf_inactive.svg diff --git a/resources/images/calib_sf.svg b/resources/images/calib_sf.svg new file mode 100644 index 0000000000..54f08c2f2c --- /dev/null +++ b/resources/images/calib_sf.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/images/calib_sf_inactive.svg b/resources/images/calib_sf_inactive.svg new file mode 100644 index 0000000000..31a8351a7c --- /dev/null +++ b/resources/images/calib_sf_inactive.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/slic3r/GUI/BBLTopbar.cpp b/src/slic3r/GUI/BBLTopbar.cpp index 9daca4895f..fec6e98a85 100644 --- a/src/slic3r/GUI/BBLTopbar.cpp +++ b/src/slic3r/GUI/BBLTopbar.cpp @@ -244,8 +244,10 @@ void BBLTopbar::Init(wxFrame* parent) this->AddSpacer(FromDIP(10)); - wxBitmap calib_bitmap = create_scaled_bitmap("ams_readonly", nullptr, TOPBAR_ICON_SIZE); - m_redo_item = this->AddTool(ID_CALIB, "", calib_bitmap); + wxBitmap calib_bitmap = create_scaled_bitmap("calib_sf", nullptr, TOPBAR_ICON_SIZE); + wxBitmap calib_bitmap_inactive = create_scaled_bitmap("calib_sf_inactive", nullptr, TOPBAR_ICON_SIZE); + m_calib_item = this->AddTool(ID_CALIB, "Calibration", calib_bitmap); + m_calib_item->SetDisabledBitmap(calib_bitmap_inactive); this->AddSpacer(FromDIP(10)); this->AddStretchSpacer(1); @@ -304,7 +306,7 @@ void BBLTopbar::Init(wxFrame* parent) this->Bind(wxEVT_MENU_CLOSE, &BBLTopbar::OnMenuClose, this); this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnFileToolItem, this, ID_TOP_FILE_MENU); this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnDropdownToolItem, this, ID_TOP_DROPDOWN_MENU); - this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnDropdownToolItem, this, ID_CALIB); + this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnCalibToolItem, this, ID_CALIB); this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnIconize, this, wxID_ICONIZE_FRAME); this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnFullScreen, this, wxID_MAXIMIZE_FRAME); this->Bind(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, &BBLTopbar::OnCloseFrame, this, wxID_CLOSE_FRAME); @@ -360,17 +362,19 @@ void BBLTopbar::OnRedo(wxAuiToolBarEvent& event) plater->redo(); } -void BBLTopbar::EnableUndoRedoItems() +void BBLTopbar::Enable3DEditorItems() { this->EnableTool(m_undo_item->GetId(), true); this->EnableTool(m_redo_item->GetId(), true); + this->EnableTool(m_calib_item->GetId(), true); Refresh(); } -void BBLTopbar::DisableUndoRedoItems() +void BBLTopbar::Disable3DEditorItems() { this->EnableTool(m_undo_item->GetId(), false); this->EnableTool(m_redo_item->GetId(), false); + this->EnableTool(m_calib_item->GetId(), false); Refresh(); } @@ -423,6 +427,11 @@ wxMenu* BBLTopbar::GetTopMenu() return &m_top_menu; } +wxMenu* BBLTopbar::GetCalibMenu() +{ + return &m_calib_menu; +} + void BBLTopbar::SetTitle(wxString title) { wxGCDC dc(this); @@ -598,7 +607,8 @@ void BBLTopbar::OnCalibToolItem(wxAuiToolBarEvent& evt) tb->SetToolSticky(evt.GetId(), true); if (!m_skip_popup_calib_menu) { - PopupMenu(&m_calib_menu, wxPoint(FromDIP(1), this->GetSize().GetHeight() - 2)); + auto rec = this->GetToolRect(ID_CALIB); + PopupMenu(&m_calib_menu, wxPoint(rec.GetLeft(), this->GetSize().GetHeight() - 2)); } else { m_skip_popup_calib_menu = false; diff --git a/src/slic3r/GUI/BBLTopbar.hpp b/src/slic3r/GUI/BBLTopbar.hpp index df05ef6db0..c853955863 100644 --- a/src/slic3r/GUI/BBLTopbar.hpp +++ b/src/slic3r/GUI/BBLTopbar.hpp @@ -43,13 +43,14 @@ public: void SetFileMenu(wxMenu* file_menu); void AddDropDownSubMenu(wxMenu* sub_menu, const wxString& title); void AddDropDownMenuItem(wxMenuItem* menu_item); - wxMenu *GetTopMenu(); + wxMenu* GetTopMenu(); + wxMenu *GetCalibMenu(); void SetTitle(wxString title); void SetMaximizedSize(); void SetWindowSize(); - void EnableUndoRedoItems(); - void DisableUndoRedoItems(); + void Enable3DEditorItems(); + void Disable3DEditorItems(); void SaveNormalRect(); @@ -61,7 +62,7 @@ private: wxPoint m_delta; wxMenu m_top_menu; wxMenu* m_file_menu; - wxMenu* m_calib_menu; + wxMenu m_calib_menu; wxAuiToolBarItem* m_title_item; wxAuiToolBarItem* m_account_item; wxAuiToolBarItem* m_model_store_item; @@ -69,6 +70,7 @@ private: wxAuiToolBarItem *m_publish_item; wxAuiToolBarItem* m_undo_item; wxAuiToolBarItem* m_redo_item; + wxAuiToolBarItem* m_calib_item; wxAuiToolBarItem* maximize_btn; wxBitmap m_publish_bitmap; diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index d910e29dbf..be229426a5 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -32,8 +32,6 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent); -//SoftFever: goodie bag -wxDEFINE_EVENT(EVT_GLTOOLBAR_PA_CALIB, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index ecdf9c7e01..36723aac1a 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -32,8 +32,6 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent); -//SoftFever: goodie bag event -wxDECLARE_EVENT(EVT_GLTOOLBAR_PA_CALIB, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 9b8da6dd5e..f6bcf6627c 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -831,7 +831,6 @@ void MainFrame::show_option(bool show) m_print_btn->Hide(); m_slice_option_btn->Hide(); m_print_option_btn->Hide(); - m_goodie_bag_btn->Hide(); Layout(); } } else { @@ -840,7 +839,6 @@ void MainFrame::show_option(bool show) m_print_btn->Show(); m_slice_option_btn->Show(); m_print_option_btn->Show(); - m_goodie_bag_btn->Show(); Layout(); } } @@ -906,10 +904,10 @@ void MainFrame::init_tabpanel() #ifndef __APPLE__ if (sel == tp3DEditor) { - m_topbar->EnableUndoRedoItems(); + m_topbar->Enable3DEditorItems(); } else { - m_topbar->DisableUndoRedoItems(); + m_topbar->Disable3DEditorItems(); } #endif @@ -1356,16 +1354,13 @@ wxBoxSizer* MainFrame::create_side_tools() m_slice_select = eSlicePlate; m_print_select = ePrintPlate; - m_goodie_bag_btn = new SideButton(this, _L("Goodiebag"), ""); m_slice_btn = new SideButton(this, _L("Slice"), ""); m_slice_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14)); m_print_btn = new SideButton(this, _L("Print"), ""); m_print_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14)); update_side_button_style(); - m_goodie_bag_btn->Enable(); m_print_option_btn->Enable(); - sizer->Add(m_goodie_bag_btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(1)); sizer->Add(FromDIP(15), 0, 0, 0, 0); m_slice_option_btn->Enable(); @@ -1379,33 +1374,6 @@ wxBoxSizer* MainFrame::create_side_tools() sizer->Layout(); - m_goodie_bag_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) - { - SidePopup* p = new SidePopup(this); - SideButton* calib_pa_btn = new SideButton(p, _L("Calibrate PA"), ""); - calib_pa_btn->SetCornerRadius(0); - //SideButton* send_file_btn = new SideButton(p, _L("send file"), ""); - //send_file_btn->SetCornerRadius(0); - - calib_pa_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { - //this->m_plater->select_view_3D("Preview"); - m_plater->update(); - wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PA_CALIB)); - - this->m_tabpanel->SetSelection(tpPreview); - }); - - //send_file_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { - // //this->m_plater->select_view_3D("Preview"); - // wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE_FILE)); - - // }); - p->append_button(calib_pa_btn); - //p->append_button(send_file_btn); - p->Popup(m_goodie_bag_btn); - } - ); - m_slice_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { //this->m_plater->select_view_3D("Preview"); @@ -1738,13 +1706,6 @@ void MainFrame::update_side_button_style() { // BBS int em = em_unit(); - - m_goodie_bag_btn->SetLayoutStyle(1); - m_goodie_bag_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center, FromDIP(15)); - m_goodie_bag_btn->SetMinSize(wxSize(-1, FromDIP(24))); - m_goodie_bag_btn->SetCornerRadius(FromDIP(12)); - m_goodie_bag_btn->SetExtraSize(wxSize(FromDIP(38), FromDIP(10))); - m_goodie_bag_btn->SetBottomColour(wxColour(0x3B4446)); m_slice_btn->SetLayoutStyle(1); /*m_slice_btn->SetLayoutStyle(1); @@ -1830,7 +1791,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect) update_side_button_style(); - m_goodie_bag_btn->Rescale(); m_slice_btn->Rescale(); m_print_btn->Rescale(); m_slice_option_btn->Rescale(); @@ -2499,6 +2459,9 @@ void MainFrame::init_menubar_as_editor() //m_topbar->AddDropDownMenuItem(language_item); //m_topbar->AddDropDownMenuItem(config_item); m_topbar->AddDropDownSubMenu(helpMenu, _L("Help")); + append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("Pressure advance"), _L("Calibrate PA"), + [this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(); }, "", nullptr, + [this]() {return m_plater->is_view3D_shown();; }, this); #else m_menubar->Append(fileMenu, wxString::Format("&%s", _L("File"))); if (editMenu) diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index fc3a7f997b..0a0c295615 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -355,7 +355,6 @@ public: // BBS mutable int m_print_select{ ePrintAll }; mutable int m_slice_select{ eSliceAll }; - SideButton* m_goodie_bag_btn{ nullptr }; SideButton* m_slice_btn{ nullptr }; SideButton* m_slice_option_btn{ nullptr }; SideButton* m_print_btn{ nullptr }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d2b5cf3c24..1aa7988909 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2032,7 +2032,6 @@ struct Plater::priv //BBS: GUI refactor: GLToolbar void on_action_open_project(SimpleEvent&); void on_action_slice_plate(SimpleEvent&); - void on_action_calib_pa(SimpleEvent&); void on_action_slice_all(SimpleEvent&); void on_action_publish(wxCommandEvent &evt); void on_action_print_plate(SimpleEvent&); @@ -2442,7 +2441,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) q->Bind(EVT_GLVIEWTOOLBAR_PREVIEW, [q](SimpleEvent&) { q->select_view_3D("Preview", false); }); q->Bind(EVT_GLTOOLBAR_SLICE_PLATE, &priv::on_action_slice_plate, this); q->Bind(EVT_GLTOOLBAR_SLICE_ALL, &priv::on_action_slice_all, this); - q->Bind(EVT_GLTOOLBAR_PA_CALIB, &priv::on_action_calib_pa, this); q->Bind(EVT_GLTOOLBAR_PRINT_PLATE, &priv::on_action_print_plate, this); q->Bind(EVT_GLTOOLBAR_SELECT_SLICED_PLATE, &priv::on_action_select_sliced_plate, this); q->Bind(EVT_GLTOOLBAR_PRINT_ALL, &priv::on_action_print_all, this); @@ -5996,28 +5994,6 @@ void Plater::priv::on_action_slice_plate(SimpleEvent&) } } -//BBS: GUI refactor: slice plate -void Plater::priv::on_action_calib_pa(SimpleEvent&) -{ - if (q != nullptr) { - BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received calib pa event\n" ; - const auto calib_pa_name = "PressureAdvanceTest-SF"; - if (get_project_name() != calib_pa_name) { - q->new_project(false,false,calib_pa_name); - q->add_model(false, Slic3r::resources_dir() + "/calib/sf_placeholder.stl"); - q->select_view_3D("3D"); - } - - background_process.fff_print()->is_calib_mode() = true; - //BBS update extruder params and speed table before slicing - Plater::setExtruderParams(Slic3r::Model::extruderParamsMap); - Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap); - m_slice_all = false; - q->reslice(); - q->select_view_3D("Preview"); - } -} - //BBS: GUI refactor: slice all void Plater::priv::on_action_slice_all(SimpleEvent&) { @@ -7889,6 +7865,26 @@ void Plater::add_model(bool imperial_units/* = false*/, std::string fname/* = " } } +void Plater::calib_pa() { + const auto calib_pa_name = "PressureAdvanceTest-SF"; + if (get_project_name() != calib_pa_name) { + new_project(false, false, calib_pa_name); + add_model(false, Slic3r::resources_dir() + "/calib/sf_placeholder.stl"); + wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor)); + + //select_view_3D("3D"); + } + + p->background_process.fff_print()->is_calib_mode() = true; + //BBS update extruder params and speed table before slicing + Plater::setExtruderParams(Slic3r::Model::extruderParamsMap); + Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap); + p->m_slice_all = false; + reslice(); + wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor)); + select_view_3D("Preview"); +} + void Plater::import_sl1_archive() { if (!p->m_ui_jobs.is_any_running()) diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index d81c080473..1910f7504c 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -225,6 +225,9 @@ public: void reload_gcode_from_disk(); void refresh_print(); + // SoftFever + void calib_pa(); + //BBS: add only gcode mode bool only_gcode_mode() { return m_only_gcode; } void set_only_gcode(bool only_gcode) { m_only_gcode = only_gcode; }