From 0f00adb0d1333435c03da27f9f522798db59cf28 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 23 Nov 2022 17:29:47 +0800 Subject: [PATCH] NEW:added to send all plate to printer sd card Change-Id: Ib7610d64a3b45afaea432c26832313d248c6890b --- src/slic3r/GUI/GLToolbar.cpp | 1 + src/slic3r/GUI/GLToolbar.hpp | 1 + src/slic3r/GUI/MainFrame.cpp | 21 +++++++++++++++++++++ src/slic3r/GUI/MainFrame.hpp | 6 +++--- src/slic3r/GUI/Plater.cpp | 29 ++++++++++++++++++++++------- src/slic3r/GUI/Plater.hpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 18 ++++++++++++++++-- src/slic3r/GUI/SendToPrinter.cpp | 18 ++++++++++++++++-- 8 files changed, 81 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 5090c8658..6a78edd90 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -30,6 +30,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_EXPORT_SLICED_FILE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent); +wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, 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 c87188e5e..c349e9db9 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -30,6 +30,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_EXPORT_SLICED_FILE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent); +wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, 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 b7a4af422..a35bce25f 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1345,6 +1345,8 @@ wxBoxSizer* MainFrame::create_side_tools() wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE)); else if (m_print_select == eSendToPrinter) wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_TO_PRINTER)); + else if (m_print_select == eSendToPrinterAll) + wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL)); }); m_slice_option_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) @@ -1467,6 +1469,17 @@ wxBoxSizer* MainFrame::create_side_tools() p->Dismiss(); });*/ + /*SideButton* send_to_printer_all_btn = new SideButton(p, _L("Send all"), ""); + send_to_printer_all_btn->SetCornerRadius(0); + send_to_printer_all_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { + m_print_btn->SetLabel(_L("Send all")); + m_print_select = eSendToPrinterAll; + m_print_enable = get_enable_print_status(); + m_print_btn->Enable(m_print_enable); + this->Layout(); + p->Dismiss(); + });*/ + export_sliced_file_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { m_print_btn->SetLabel(_L("Export plate sliced file")); m_print_select = eExportSlicedFile; @@ -1488,6 +1501,7 @@ wxBoxSizer* MainFrame::create_side_tools() p->append_button(print_plate_btn); p->append_button(print_all_btn); //p->append_button(send_to_printer_btn); + //p->append_button(send_to_printer_all_btn); p->append_button(export_sliced_file_btn); p->append_button(export_all_sliced_file_btn); } @@ -1611,6 +1625,13 @@ bool MainFrame::get_enable_print_status() enable = false; } } + else if (m_print_select == eSendToPrinterAll) + { + if (!part_plate_list.is_all_slice_results_ready_for_print()) + { + enable = false; + } + } else if (m_print_select == eExportAllSlicedFile) { if (!part_plate_list.is_all_slice_results_ready_for_print()) diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index ea5a4f2e4..c30aff094 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -172,7 +172,6 @@ class MainFrame : public DPIFrame ESettingsLayout m_layout{ ESettingsLayout::Unknown }; - enum SliceSelectType { eSliceAll = 0, @@ -211,8 +210,9 @@ public: eExportGcode = 3, eSendGcode = 4, eSendToPrinter = 5, - eUploadGcode = 6, - eExportAllSlicedFile = 7 + eSendToPrinterAll = 6, + eUploadGcode = 7, + eExportAllSlicedFile = 8 }; //BBS: add slice&&print status update logic diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index dd5340f09..da9e43811 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2013,7 +2013,7 @@ struct Plater::priv void update_fff_scene_only_shells(bool only_shells = true); //BBS: add popup object table logic bool PopupObjectTable(int object_id, int volume_id, const wxPoint& position); - void on_action_send_to_printer(); + void on_action_send_to_printer(bool isall = false); private: bool layers_height_allowed() const; @@ -2023,6 +2023,7 @@ private: void undo_redo_to(std::vector::const_iterator it_snapshot); void update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bool temp_snapshot_was_taken = false); void on_action_export_to_sdcard(SimpleEvent&); + void on_action_export_to_sdcard_all(SimpleEvent&); // path to project folder stored with no extension boost::filesystem::path m_project_folder; @@ -2335,6 +2336,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) q->Bind(EVT_GLTOOLBAR_EXPORT_SLICED_FILE, &priv::on_action_export_sliced_file, this); q->Bind(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE, &priv::on_action_export_all_sliced_file, this); q->Bind(EVT_GLTOOLBAR_SEND_TO_PRINTER, &priv::on_action_export_to_sdcard, this); + q->Bind(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, &priv::on_action_export_to_sdcard_all, this); q->Bind(EVT_GLCANVAS_PLATE_SELECT, &priv::on_plate_selected, this); q->Bind(EVT_DOWNLOAD_PROJECT, &priv::on_action_download_project, this); q->Bind(EVT_IMPORT_MODEL_ID, &priv::on_action_request_model_id, this); @@ -5849,10 +5851,16 @@ void Plater::priv::on_action_print_plate(SimpleEvent&) } -void Plater::priv::on_action_send_to_printer() +void Plater::priv::on_action_send_to_printer(bool isall) { if (!m_send_to_sdcard_dlg) m_send_to_sdcard_dlg = new SendToPrinterDialog(q); - m_send_to_sdcard_dlg->prepare(partplate_list.get_curr_plate_index()); + if (isall) { + m_send_to_sdcard_dlg->prepare(PLATE_ALL_IDX); + } + else { + m_send_to_sdcard_dlg->prepare(partplate_list.get_curr_plate_index()); + } + m_send_to_sdcard_dlg->ShowModal(); } @@ -5870,8 +5878,6 @@ void Plater::priv::on_action_print_all(SimpleEvent&) BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received print all event\n" ; } - if (!wxGetApp().check_login()) return; - //BBS if (!m_select_machine_dlg) m_select_machine_dlg = new SelectMachineDialog(q); m_select_machine_dlg->prepare(PLATE_ALL_IDX); @@ -5926,6 +5932,15 @@ void Plater::priv::on_action_export_to_sdcard(SimpleEvent&) } } +void Plater::priv::on_action_export_to_sdcard_all(SimpleEvent&) +{ + if (q != nullptr) { + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received export sliced file event\n"; + q->send_to_printer(true); + } +} + + //BBS: add plate select logic void Plater::priv::on_plate_selected(SimpleEvent&) { @@ -8797,9 +8812,9 @@ void Plater::export_gcode(bool prefer_removable) } } -void Plater::send_to_printer() +void Plater::send_to_printer(bool isall) { - p->on_action_send_to_printer(); + p->on_action_send_to_printer(isall); } //BBS export gcode 3mf to file diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 4255ce239..3354afdd8 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -303,7 +303,7 @@ public: void segment(size_t obj_idx, size_t instance_idx, double smoothing_alpha=0.5, int segment_number=5); void merge(size_t obj_idx, std::vector& vol_indeces); - void send_to_printer(); + void send_to_printer(bool isall = false); void export_gcode(bool prefer_removable); void export_gcode_3mf(bool export_all = false); void send_gcode_finish(wxString name); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 31c6c354b..fffc95bd5 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -2301,7 +2301,12 @@ void SelectMachineDialog::on_rename_enter(wxCommandEvent& event) if (m_valid_type != Valid) { MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK); - if (msg_wingow.ShowModal() == wxOK) { return; } + if (msg_wingow.ShowModal() == wxID_OK) { + m_rename_switch_panel->SetSelection(0); + m_rename_text->SetLabel(m_current_project_name); + m_rename_normal_panel->Layout(); + return; + } } m_current_project_name = new_file_name; @@ -2659,10 +2664,19 @@ void SelectMachineDialog::set_default() { //project name m_rename_switch_panel->SetSelection(0); - wxString filename = m_plater->get_export_gcode_filename("", false); + + wxString filename = m_plater->get_export_gcode_filename("", false, + m_print_plate_idx == PLATE_ALL_IDX ?true:false); + + if (m_print_plate_idx == PLATE_ALL_IDX && filename.empty()) { + filename = _L("Untitled"); + } if (filename.empty()) { filename = m_plater->get_export_gcode_filename("", true); + if (std::strstr(filename.c_str(), _L("Untitled").c_str()) == NULL) { + filename = wxString::Format("Untitled%s",filename); + } } fs::path filename_path(filename.c_str()); diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index b26fbe4ce..5bd5590df 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -128,7 +128,12 @@ void SendToPrinterDialog::on_rename_enter(wxCommandEvent& event) if (m_valid_type != Valid) { MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK); - if (msg_wingow.ShowModal() == wxOK) { return; } + if (msg_wingow.ShowModal() == wxID_OK) { + m_rename_switch_panel->SetSelection(0); + m_rename_text->SetLabel(m_current_project_name); + m_rename_normal_panel->Layout(); + return; + } } m_current_project_name = new_file_name; @@ -1033,10 +1038,19 @@ void SendToPrinterDialog::set_default() { //project name m_rename_switch_panel->SetSelection(0); - wxString filename = m_plater->get_export_gcode_filename("", false); + + wxString filename = m_plater->get_export_gcode_filename("", false, + m_print_plate_idx == PLATE_ALL_IDX ? true : false); + + if (m_print_plate_idx == PLATE_ALL_IDX && filename.empty()) { + filename = _L("Untitled"); + } if (filename.empty()) { filename = m_plater->get_export_gcode_filename("", true); + if (std::strstr(filename.c_str(), _L("Untitled").c_str()) == NULL) { + filename = wxString::Format("Untitled%s", filename); + } } fs::path filename_path(filename.c_str());