diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index fe695d081..6f1ea0c69 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -32,6 +32,7 @@ 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_PRINT_MULTI_MACHINE, SimpleEvent); +wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_MULTI_APP, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 0b21be272..5a686bca5 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -33,6 +33,7 @@ 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_PRINT_MULTI_MACHINE, SimpleEvent); +wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_MULTI_APP, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b8a80420b..ddfc6b041 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1639,6 +1639,8 @@ wxBoxSizer* MainFrame::create_side_tools() 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)); + else if (m_print_select == eSendMultiApp) + wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_MULTI_APP)); /* else if (m_print_select == ePrintMultiMachine) wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PRINT_MULTI_MACHINE));*/ }); @@ -1792,12 +1794,24 @@ wxBoxSizer* MainFrame::create_side_tools() p->Dismiss(); }); + SideButton *send_to_multi_app_btn = new SideButton(p, _L("Send to Bambu Farm Manager Client"), ""); + send_to_multi_app_btn->SetCornerRadius(0); + send_to_multi_app_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent &) { + m_print_btn->SetLabel(_L("Send to BFMC")); + m_print_select = eSendMultiApp; + m_print_enable = get_enable_print_status(); + m_print_btn->Enable(m_print_enable); + this->Layout(); + p->Dismiss(); + }); + 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); + p->append_button(send_to_multi_app_btn); if (enable_multi_machine) { SideButton* print_multi_machine_btn = new SideButton(p, _L("Send to Multi-device"), ""); print_multi_machine_btn->SetCornerRadius(0); @@ -1959,6 +1973,11 @@ bool MainFrame::get_enable_print_status() enable = false; } enable = enable && !is_all_plates; + }else if (m_print_select == eSendMultiApp) { + if (!current_plate->is_slice_result_ready_for_print()) { + enable = false; + } + enable = enable && !is_all_plates; } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": m_print_select %1%, enable= %2% ")%m_print_select %enable; diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index c45478a6b..463c7a199 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -238,7 +238,8 @@ public: eSendToPrinterAll = 6, eUploadGcode = 7, eExportAllSlicedFile = 8, - ePrintMultiMachine = 9 + ePrintMultiMachine = 9, + eSendMultiApp = 10 }; void update_layout(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7fcd68e3d..d9e5bcc51 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2693,6 +2693,7 @@ struct Plater::priv bool PopupObjectTable(int object_id, int volume_id, const wxPoint& position); void on_action_send_to_printer(bool isall = false); void on_action_send_to_multi_machine(SimpleEvent&); + void on_action_send_to_multi_app(SimpleEvent&); int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path); private: bool layers_height_allowed() const; @@ -3060,6 +3061,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) 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_GLTOOLBAR_PRINT_MULTI_MACHINE, &priv::on_action_send_to_multi_machine, this); + q->Bind(EVT_GLTOOLBAR_SEND_MULTI_APP, &priv::on_action_send_to_multi_app, 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); @@ -7243,6 +7245,54 @@ void Plater::priv::on_action_send_to_multi_machine(SimpleEvent&) m_send_multi_dlg->ShowModal(); } +void Plater::priv::on_action_send_to_multi_app(SimpleEvent &) +{ +#ifdef WIN32 + HKEY hKey; + + LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Bambulab\\Bambu Farm Manager Client"), 0, KEY_READ, &hKey); + LONG result_backup = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HKEY_CLASSES_ROOT\\bambu-farm-client\\shell\\open\\command"), 0, KEY_READ, &hKey); + + if (result == ERROR_SUCCESS || result_backup == ERROR_SUCCESS) { + RegCloseKey(hKey); + + auto gcodeResult = q->send_gcode(partplate_list.get_curr_plate_index(), [this](int export_stage, int current, int total, bool &cancel) {}); + + if (gcodeResult != 0) { + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":send_gcode failed\n"; + return; + } + + PrintPrepareData data; + q->get_print_job_data(&data); + + if (data._3mf_path.empty()) { + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":3mf path is empty\n"; + return; + } + + wxString filename = q->get_export_gcode_filename("", true, partplate_list.get_curr_plate_index() == PLATE_ALL_IDX ? true : false); + wxString filepath = wxString::FromUTF8(data._3mf_path.string()); + filepath.Replace("\\", "/"); + std::string filePath = "?version=v1.6.0&path=" + filepath.ToStdString() + "&name=" + filename.utf8_string(); + wxString url = "bambu-farm-client://upload-file" + Http::url_encode(filePath); + if (!wxLaunchDefaultBrowser(url)) { + GUI::MessageDialog msgdialog(nullptr, _L("Failed to start Bambu Farm Manager Client."), "", wxAPPLY | wxOK); + msgdialog.ShowModal(); + } + + } else { + GUI::MessageDialog msgdialog(nullptr, _L("No Bambu Farm Manager Client found."), "", wxAPPLY | wxOK); + msgdialog.ShowModal(); + } +#endif // WIN32 + +#ifdef __APPLE__ + // todo +#endif //__APPLE__ + +} + void Plater::priv::on_action_print_plate_from_sdcard(SimpleEvent&) { if (q != nullptr) {