From b777f09dc36ab43e8c2b2950a26cc7a849ed553a Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 10:25:22 +0800 Subject: [PATCH 01/26] 1. Build the linux engine by using "SERVER_ENGINE" 2. change name snapmaker-slicer to snapmaker-orca --- BuildLinux.sh | 10 +- CMakeLists.txt | 12 +- Dockerfile | 2 +- cmake/modules/MacOSXBundleInfo.plist.in | 2 +- flatpak/entrypoint | 2 +- src/CMakeLists.txt | 19 +- src/Engine.cpp | 325 ++++++++++++++++++++ src/Engine.h | 70 +++++ src/Snapmaker_Orca.cpp | 29 +- src/platform/msw/Snapmaker_Orca.rc.in | 2 +- src/platform/unix/BambuGcodeviewer.desktop | 2 +- src/platform/unix/Snapmaker_Orca.desktop | 4 +- src/slic3r/GUI/DesktopIntegrationDialog.cpp | 2 +- src/slic3r/GUI/GUI.cpp | 3 + src/slic3r/GUI/GUI_App.cpp | 22 ++ src/slic3r/GUI/InstanceCheck.cpp | 8 +- src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/Mouse3DHandlerMac.mm | 2 +- src/slic3r/GUI/Plater.cpp | 18 ++ src/slic3r/GUI/Plater.hpp | 4 + src/slic3r/Utils/Process.cpp | 4 +- 21 files changed, 513 insertions(+), 31 deletions(-) create mode 100644 src/Engine.cpp create mode 100644 src/Engine.h diff --git a/BuildLinux.sh b/BuildLinux.sh index defc337441c..5835403d66b 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -30,10 +30,11 @@ function usage() { echo " -b: build in debug mode" echo " -c: force a clean build" echo " -d: build deps (optional)" + echo " -e: build linux orca engine (optional)" echo " -h: this help output" echo " -i: Generate appimage (optional)" echo " -r: skip ram and disk checks (low ram compiling)" - echo " -s: build snapmaker-slicer (optional)" + echo " -s: build snapmaker-orca (optional)" echo " -u: update and build dependencies (optional and need sudo)" echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'" echo " and then './BuildLinux.sh -dsi'" @@ -54,6 +55,9 @@ while getopts ":1bcdghirsu" opt; do d ) BUILD_DEPS="1" ;; + e ) + BUILD_ENGINE="1" + ;; h ) usage exit 0 ;; @@ -151,6 +155,10 @@ then then BUILD_ARGS="-DSLIC3R_GTK=3" fi + if [[ -n "${BUILD_ENGINE}"]] + then + BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE" + fi if [[ -n "${BUILD_DEBUG}" ]] then BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1" diff --git a/CMakeLists.txt b/CMakeLists.txt index 57217d6cea7..57d760a7e3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ if (APPLE) if (CMAKE_MACOSX_BUNDLE) set(CMAKE_INSTALL_RPATH @executable_path/../Frameworks) endif() - SET(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.snapmaker.snapmaker-slicer") + SET(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.snapmaker.snapmaker-orca") message(STATUS "Orca: IS_CROSS_COMPILE: ${IS_CROSS_COMPILE}") endif () @@ -738,7 +738,7 @@ if(SLIC3R_BUILD_TESTS) endif() if (NOT WIN32 AND NOT APPLE) - set(SLIC3R_APP_CMD "snapmaker-slicer") + set(SLIC3R_APP_CMD "snapmaker-orca") configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh @ONLY) endif() @@ -788,17 +788,17 @@ set (CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) set (CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/images\\\\Snapmaker_Orca.ico") set (CPACK_NSIS_MUI_ICON "${CPACK_PACKAGE_ICON}") set (CPACK_NSIS_MUI_UNIICON "${CPACK_PACKAGE_ICON}") -set (CPACK_NSIS_INSTALLED_ICON_NAME "$INSTDIR\\\\snapmaker-slicer.exe") +set (CPACK_NSIS_INSTALLED_ICON_NAME "$INSTDIR\\\\snapmaker-orca.exe") set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " - CreateShortCut \\\"$DESKTOP\\\\Snapmaker_Orca.lnk\\\" \\\"$INSTDIR\\\\snapmaker-slicer.exe\\\" + CreateShortCut \\\"$DESKTOP\\\\Snapmaker_Orca.lnk\\\" \\\"$INSTDIR\\\\snapmaker-orca.exe\\\" ") set (CPACK_PACKAGE_CHECKSUM SHA256) set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Snapmaker_Orca") set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) set (CPACK_NSIS_EXECUTABLES_DIRECTORY ".") # set (CPACK_NSIS_MODIFY_PATH "ON") -set(CPACK_PACKAGE_EXECUTABLES "snapmaker-slicer;Snapmaker_Orca") -set(CPACK_CREATE_DESKTOP_LINKS "snapmaker-slicer") +set(CPACK_PACKAGE_EXECUTABLES "snapmaker-orca;Snapmaker_Orca") +set(CPACK_CREATE_DESKTOP_LINKS "snapmaker-orca") set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt) # must also include in install command set(CPACK_WIX_UPGRADE_GUID "058245e8-20e0-4a95-9ab7-1acfe17ad511") diff --git a/Dockerfile b/Dockerfile index e4a3dc6688a..f722109e5bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,4 +92,4 @@ RUN [[ "$UID" != "0" ]] \ # Using an entrypoint instead of CMD because the binary # accepts several command line arguments. -ENTRYPOINT ["/Snapmaker_Orca/build/package/bin/snapmaker-slicer"] +ENTRYPOINT ["/Snapmaker_Orca/build/package/bin/snapmaker-orca"] diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in index d76370395ff..1bc16b923c6 100644 --- a/cmake/modules/MacOSXBundleInfo.plist.in +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -11,7 +11,7 @@ CFBundleIconFile ${MACOSX_BUNDLE_ICON_FILE} CFBundleIdentifier - com.snapmaker.snapmaker-slicer + com.snapmaker.snapmaker-orca CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString diff --git a/flatpak/entrypoint b/flatpak/entrypoint index f96dbf95de3..1c953fcffbb 100644 --- a/flatpak/entrypoint +++ b/flatpak/entrypoint @@ -11,5 +11,5 @@ if [ $BAMBU_STUDIO_DARK_THEME == true ]; then # echo "Message: $(date +%T): INFO: using dark theme variant" fi -exec /app/bin/snapmaker-slicer "$@" & +exec /app/bin/snapmaker-orca "$@" & $(/app/bin/set-dark-theme-variant.py) & diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 946d946cf9d..86efd80e598 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,7 +120,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CU if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) + if (SERVER_ENGINE) + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) + else () + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) + endif () endif () if (MINGW) @@ -130,8 +134,13 @@ endif (MINGW) if (NOT WIN32 AND NOT APPLE) # Binary name on unix like systems (Linux, Unix) - set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-slicer") - set(SLIC3R_APP_CMD "snapmaker-slicer") + if (SERVER_ENGINE) + set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca") + set(SLIC3R_APP_CMD "snapmaker-orca") + else () + set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca-engine") + set(SLIC3R_APP_CMD "snapmaker-orca-engine") + endif () configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/BuildLinuxImage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/BuildLinuxImage.sh @ONLY) endif () @@ -184,7 +193,7 @@ if (WIN32) endif() target_compile_definitions(Snapmaker_Orca_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE) add_dependencies(Snapmaker_Orca_app_gui Snapmaker_Orca) - set_target_properties(Snapmaker_Orca_app_gui PROPERTIES OUTPUT_NAME "snapmaker-slicer") + set_target_properties(Snapmaker_Orca_app_gui PROPERTIES OUTPUT_NAME "snapmaker-orca") target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly) endif () @@ -232,7 +241,7 @@ else () if (APPLE AND NOT CMAKE_MACOSX_BUNDLE) # On OSX, the name of the binary matches the name of the Application. add_custom_command(TARGET Snapmaker_Orca POST_BUILD - COMMAND ln -sf Snapmaker_Orca snapmaker-slicer + COMMAND ln -sf Snapmaker_Orca snapmaker-orca WORKING_DIRECTORY "$" VERBATIM) else () diff --git a/src/Engine.cpp b/src/Engine.cpp new file mode 100644 index 00000000000..3a7f919b161 --- /dev/null +++ b/src/Engine.cpp @@ -0,0 +1,325 @@ +/* +#include "Engine.h" + +#include "wx/app.h" +#include "wx/timer.h" +#include "slic3r/GUI/GUI_App.hpp" +#include "slic3r/GUI/MainFrame.hpp" + +#include "slic3r/GUI/Plater.cpp" + +using namespace Slic3r::GUI; + +int Snapmaker_Orca_Engine::s_time_gui_load = 500; +int Snapmaker_Orca_Engine::s_time_check_export = 100; +int Snapmaker_Orca_Engine::s_time_delay_close = 500; + +Snapmaker_Orca_Engine::Snapmaker_Orca_Engine(std::vector& user_inputs) : m_OriFiles(user_inputs) {} + +void Snapmaker_Orca_Engine::init() +{ + if (!m_load_gui_timer) { + m_load_gui_timer = new wxTimer(this, wxNewId()); + } + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->on_gui_loaded(); + }, m_load_gui_timer->GetId()); + m_load_gui_timer->StartOnce(s_time_gui_load); +} + +void Snapmaker_Orca_Engine::on_gui_loaded() +{ + // load information from gui + m_gui_app = (GUI_App*) wxTheApp; + if (!m_gui_app) { + return; + } + + m_gui_main_frame = m_gui_app->mainframe; + if (!m_gui_main_frame) { + return; + } + + m_gui_plater = m_gui_main_frame->plater(); + if (!m_gui_plater) { + return; + } + + m_load_gui_timer->Stop(); + delete m_load_gui_timer; + m_load_gui_timer = nullptr; + + run_engine(); +} + +void Snapmaker_Orca_Engine::on_time_check() { + extern bool g_exported; + if (g_exported) { + m_check_export_timer->Stop(); + + g_exported = false; + + ++m_task_index; + + if (m_task_index >= m_OriFiles.size()) { + delete m_check_export_timer; + m_check_export_timer = nullptr; + + close_engine(); + } else { + do_next_task(); + } + } +} + +void Snapmaker_Orca_Engine::close_engine() { + if (!m_delay_close_timer) { + m_delay_close_timer = new wxTimer(this, wxNewId()); + } + + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->m_delay_close_timer->Stop(); + delete this->m_delay_close_timer; + this->m_delay_close_timer = nullptr; + + this->m_gui_main_frame->Close(false); + }, m_delay_close_timer->GetId()); + + m_delay_close_timer->StartOnce(s_time_delay_close); +} + + +void Snapmaker_Orca_Engine::do_next_task() { + + if (m_task_index > 0) { + m_gui_plater->new_project(); + } + + add_file_server(m_OriFiles[m_task_index]); + slice_all_plates_server(); + export_gcode_server(false); + + if (!m_check_export_timer) { + m_check_export_timer = new wxTimer(this, wxNewId()); + } + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->on_time_check(); + }, m_check_export_timer->GetId()); + m_check_export_timer->Start(s_time_check_export); + +} + +void Snapmaker_Orca_Engine::run_engine() { + if (m_OriFiles.size() >= 1) { + do_next_task(); + } else { + close_engine(); + } +} + +void Snapmaker_Orca_Engine::add_file_server(std::string& filePath) { + + wxArrayString input_files; + input_files.push_back(filePath); + + if (input_files.empty()) + return; + + std::vector paths; + for (const auto& file : input_files) + paths.emplace_back(into_path(file)); + + std::string snapshot_label; + assert(!paths.empty()); + + snapshot_label = "Import Objects"; + snapshot_label += ": "; + snapshot_label += encode_path(paths.front().filename().string().c_str()); + for (size_t i = 1; i < paths.size(); ++i) { + snapshot_label += ", "; + snapshot_label += encode_path(paths[i].filename().string().c_str()); + } + + // BBS: check file types + auto loadfiles_type = LoadFilesType::NoFile; + auto amf_files_count = m_gui_plater->get_3mf_file_count(paths); + + if (paths.size() > 1 && amf_files_count < paths.size()) { + loadfiles_type = LoadFilesType::Multiple3MFOther; + } + if (paths.size() > 1 && amf_files_count == paths.size()) { + loadfiles_type = LoadFilesType::Multiple3MF; + } + if (paths.size() > 1 && amf_files_count == 0) { + loadfiles_type = LoadFilesType::MultipleOther; + } + if (paths.size() == 1 && amf_files_count == 1) { + loadfiles_type = LoadFilesType::Single3MF; + }; + if (paths.size() == 1 && amf_files_count == 0) { + loadfiles_type = LoadFilesType::SingleOther; + }; + + auto first_file = std::vector{}; + auto tmf_file = std::vector{}; + auto other_file = std::vector{}; + + switch (loadfiles_type) { + case LoadFilesType::Single3MF: m_gui_plater->open_3mf_file(paths[0]); break; + + case LoadFilesType::SingleOther: { + Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); + if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, false).empty()) { + if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { + m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); + } + wxGetApp().mainframe->update_title(); + } + break; + } + case LoadFilesType::Multiple3MF: + first_file = std::vector{paths[0]}; + for (auto i = 0; i < paths.size(); i++) { + if (i > 0) { + other_file.push_back(paths[i]); + } + }; + + m_gui_plater->open_3mf_file(first_file[0]); + if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel).empty()) { + wxGetApp().mainframe->update_title(); + } + break; + + case LoadFilesType::MultipleOther: { + Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); + if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, true).empty()) { + if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { + m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); + } + wxGetApp().mainframe->update_title(); + } + break; + } + case LoadFilesType::Multiple3MFOther: + for (const auto& path : paths) { + if (wxString(encode_path(path.filename().string().c_str())).EndsWith("3mf")) { + if (first_file.size() <= 0) + first_file.push_back(path); + else + tmf_file.push_back(path); + } else { + other_file.push_back(path); + } + } + + m_gui_plater->open_3mf_file(first_file[0]); + m_gui_plater->load_files(tmf_file, LoadStrategy::LoadModel); + if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel, false).empty()) { + wxGetApp().mainframe->update_title(); + } + break; + default: break; + } +} + +void Snapmaker_Orca_Engine::slice_all_plates_server() { + if (m_gui_plater != nullptr) { + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice project event\n"; + // BBS update extruder params and speed table before slicing + const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config(); + auto& print = m_gui_plater->get_partplate_list().get_current_fff_print(); + auto print_config = print.config(); + int numExtruders = wxGetApp().preset_bundle->filament_presets.size(); + + Model::setExtruderParams(config, numExtruders); + Model::setPrintSpeedTable(config, print_config); + m_gui_plater->p->m_slice_all = true; + m_gui_plater->p->m_slice_all_only_has_gcode = true; + m_gui_plater->p->m_cur_slice_plate = 0; + // select plate + m_gui_plater->select_plate(m_gui_plater->p->m_cur_slice_plate); + m_gui_plater->reslice(); + if (!m_gui_plater->p->m_is_publishing) + m_gui_plater->select_view_3D("Preview"); + // BBS: wish to select all plates stats item + m_gui_plater->p->preview->get_canvas3d()->_update_select_plate_toolbar_stats_item(true); + } +} + +void Snapmaker_Orca_Engine::export_gcode_server(bool prefer_removable) { + if (m_gui_plater->p->model.objects.empty()) + return; + + // if (get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(true)) + // return; + + if (m_gui_plater->p->process_completed_with_error == m_gui_plater->p->partplate_list.get_curr_plate_index()) + return; + + // If possible, remove accents from accented latin characters. + // This function is useful for generating file names to be processed by legacy firmwares. + fs::path default_output_file; + try { + // Update the background processing, so that the placeholder parser will get the correct values for the ouput file template. + // Also if there is something wrong with the current configuration, a pop-up dialog will be shown and the export will not be performed. + unsigned int state = m_gui_plater->p->update_restart_background_process(false, false); + if (state & Plater::priv::UPDATE_BACKGROUND_PROCESS_INVALID) + return; + default_output_file = m_gui_plater->p->background_process.output_filepath_for_project(""); + } catch (const Slic3r::PlaceholderParserError& ex) { + // Show the error with monospaced font. + show_error(m_gui_plater, ex.what(), true); + return; + } catch (const std::exception& ex) { + show_error(m_gui_plater, ex.what(), false); + return; + } + default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string())); + AppConfig& appconfig = *wxGetApp().app_config; + RemovableDriveManager& removable_drive_manager = *wxGetApp().removable_drive_manager(); + // Get a last save path, either to removable media or to an internal media. + std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), prefer_removable); + if (prefer_removable) { + // Returns a path to a removable media if it exists, prefering start_dir. Update the internal removable drives database. + start_dir = removable_drive_manager.get_removable_drive_path(start_dir); + if (start_dir.empty()) + // Direct user to the last internal media. + start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false); + } + + fs::path input_path, output_path; + input_path = m_OriFiles[m_task_index]; + output_path = input_path.parent_path() / (input_path.stem().string() + ".gcode"); + + if (!output_path.empty()) { + bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string()); + // bool path_on_removable_media = false; + m_gui_plater->p->notification_manager->new_export_began(path_on_removable_media); + m_gui_plater->p->exporting_status = path_on_removable_media ? ExportingStatus::EXPORTING_TO_REMOVABLE : + ExportingStatus::EXPORTING_TO_LOCAL; + m_gui_plater->p->last_output_path = output_path.string(); + m_gui_plater->p->last_output_dir_path = output_path.parent_path().string(); + m_gui_plater->p->export_gcode(output_path, path_on_removable_media); + // Storing a path to AppConfig either as path to removable media or a path to internal media. + // is_path_on_removable_drive() is called with the "true" parameter to update its internal database as the user may have shuffled + // the external drives while the dialog was open. + appconfig.update_last_output_dir(output_path.parent_path().string(), path_on_removable_media); + + try { + json j; + auto printer_config = Slic3r::GUI::wxGetApp().preset_bundle->printers.get_edited_preset_with_vendor_profile().preset; + if (printer_config.is_system) { + j["printer_preset"] = printer_config.name; + } else { + j["printer_preset"] = printer_config.config.opt_string("inherits"); + } + + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + if (preset_bundle) { + j["gcode_printer_model"] = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); + } + } catch (...) {} + } +} +*/ \ No newline at end of file diff --git a/src/Engine.h b/src/Engine.h new file mode 100644 index 00000000000..bee6eda81a0 --- /dev/null +++ b/src/Engine.h @@ -0,0 +1,70 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#include +#include + +#include "wx/event.h" + +class wxTimer; + +namespace Slic3r { + namespace GUI{ + class GUI_App; + class MainFrame; + class Plater; + + class Snapmaker_Orca_Engine : public wxEvtHandler + { + public: + // input the 3mf/.stl... files to engine + Snapmaker_Orca_Engine(std::vector& user_inputs); + + void init(); + + void on_gui_loaded(); + + void on_time_check(); + + void run_engine(); + + void do_next_task(); + + void close_engine(); + + private: + void add_file_server(std::string& filePath); + + void slice_all_plates_server(); + + void export_gcode_server(bool prefer_removable); + + private: + std::vector m_OriFiles; + + wxTimer* m_load_gui_timer = nullptr; + + wxTimer* m_check_export_timer = nullptr; + + wxTimer* m_delay_close_timer = nullptr; + + private: + GUI_App* m_gui_app = nullptr; + + MainFrame* m_gui_main_frame = nullptr; + + Plater* m_gui_plater = nullptr; + + int m_task_index = 0; + private: + static int s_time_gui_load; + static int s_time_check_export; + static int s_time_delay_close; + }; + } +} + + + + +#endif \ No newline at end of file diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index 537f033309a..ea930ad1e31 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -83,6 +83,10 @@ using namespace nlohmann; #include "slic3r/GUI/Plater.hpp" #include +#ifdef SERVER_ENGINE +#include "Engine.h" +#endif + #ifdef __WXGTK__ #include #endif @@ -146,6 +150,12 @@ std::map cli_errors = { {CLI_GCODE_PATH_CONFLICTS, " G-code conflicts detected after slicing. Please make sure the 3mf file can be successfully sliced in the latest Snapmaker Orca."} }; +#ifdef SERVER_ENGINE +std::vector argv_narrow; +std::vector argv_ptrs; +bool g_exported = false; +#endif + typedef struct _sliced_plate_info{ int plate_id{0}; size_t sliced_time {0}; @@ -6024,7 +6034,7 @@ void CLI::print_help(bool include_print_options, PrinterTechnology printer_techn boost::nowide::cout << SLIC3R_APP_KEY <<"-"<< SLIC3R_VERSION << ":" << std::endl - << "Usage: snapmaker-slicer [ OPTIONS ] [ file.3mf/file.stl ... ]" << std::endl + << "Usage: snapmaker-orca [ OPTIONS ] [ file.3mf/file.stl ... ]" << std::endl << std::endl << "OPTIONS:" << std::endl; cli_misc_config_def.print_cli_help(boost::nowide::cout, false); @@ -6263,9 +6273,14 @@ LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) extern "C" { __declspec(dllexport) int __stdcall Snapmaker_Orca_main(int argc, wchar_t **argv) { +#ifndef SERVER_ENGINE // Convert wchar_t arguments to UTF8. - std::vector argv_narrow; - std::vector argv_ptrs(argc + 1, nullptr); + std::vector argv_narrow; + std::vector argv_ptrs(argc + 1, nullptr); +#endif + + argv_ptrs.resize(argc + 1, nullptr); + for (size_t i = 0; i < argc; ++ i) argv_narrow.emplace_back(boost::nowide::narrow(argv[i])); for (size_t i = 0; i < argc; ++ i) @@ -6289,6 +6304,14 @@ extern "C" { #else /* _MSC_VER */ int main(int argc, char **argv) { + #ifdef SERVER_ENGINE + argv_ptrs.resize(argc + 1, nullptr); + for (size_t i = 0; i < argc; ++i) + argv_narrow.emplace_back(boost::nowide::narrow(argv[i])); + for (size_t i = 0; i < argc; ++i) + argv_ptrs[i] = argv_narrow[i].data(); + #endif + return CLI().run(argc, argv); } #endif /* _MSC_VER */ diff --git a/src/platform/msw/Snapmaker_Orca.rc.in b/src/platform/msw/Snapmaker_Orca.rc.in index 36726f7134e..4946ab52109 100644 --- a/src/platform/msw/Snapmaker_Orca.rc.in +++ b/src/platform/msw/Snapmaker_Orca.rc.in @@ -13,7 +13,7 @@ PRODUCTVERSION @SLIC3R_VERSION@ VALUE "ProductVersion", "@SLIC3R_BUILD_ID@" VALUE "InternalName", "@SLIC3R_APP_NAME@" VALUE "LegalCopyright", "" - VALUE "OriginalFilename", "snapmaker-slicer.exe" + VALUE "OriginalFilename", "snapmaker-orca.exe" } } BLOCK "VarFileInfo" diff --git a/src/platform/unix/BambuGcodeviewer.desktop b/src/platform/unix/BambuGcodeviewer.desktop index 890564f1442..61292aee317 100644 --- a/src/platform/unix/BambuGcodeviewer.desktop +++ b/src/platform/unix/BambuGcodeviewer.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Name=Bambu GCode viewer -Exec=snapmaker-slicer --gcodeviewer %F +Exec=snapmaker-orca --gcodeviewer %F Icon=Snapmaker_Orca-gcodeviewer Terminal=false Type=Application diff --git a/src/platform/unix/Snapmaker_Orca.desktop b/src/platform/unix/Snapmaker_Orca.desktop index 249908eeafd..b7bf7ee0ba7 100644 --- a/src/platform/unix/Snapmaker_Orca.desktop +++ b/src/platform/unix/Snapmaker_Orca.desktop @@ -2,11 +2,11 @@ Name=Snapmaker_Orca GenericName=3D Printing Software Icon=Snapmaker_Orca -Exec=snapmaker-slicer %U +Exec=snapmaker-orca %U Terminal=false Type=Application MimeType=model/stl;model/3mf;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;application/x-amf; Categories=Graphics;3DGraphics;Engineering; Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA StartupNotify=false -StartupWMClass=snapmaker-slicer +StartupWMClass=snapmaker-orca diff --git a/src/slic3r/GUI/DesktopIntegrationDialog.cpp b/src/slic3r/GUI/DesktopIntegrationDialog.cpp index 9ac3a96eb5c..1720e1ca84e 100644 --- a/src/slic3r/GUI/DesktopIntegrationDialog.cpp +++ b/src/slic3r/GUI/DesktopIntegrationDialog.cpp @@ -340,7 +340,7 @@ void DesktopIntegrationDialog::perform_desktop_integration() "Categories=Graphics;3DGraphics;Engineering;\n" "Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA\n" "StartupNotify=false\n" - "StartupWMClass=snapmaker-slicer\n", name_suffix, version_suffix, excutable_path); + "StartupWMClass=snapmaker-orca\n", name_suffix, version_suffix, excutable_path); std::string path = GUI::format("%1%/applications/Snapmaker_Orca%2%.desktop", target_dir_desktop, version_suffix); if (create_desktop_file(path, desktop_file)){ diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 703bbbceae0..c962361e4ce 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -245,6 +245,9 @@ void show_error_id(int id, const std::string& message) void show_info(wxWindow* parent, const wxString& message, const wxString& title) { + #ifdef SERVER_ENGINE + return; + #endif //wxMessageDialog msg_wingow(parent, message, wxString(SLIC3R_APP_NAME " - ") + (title.empty() ? _L("Notice") : title), wxOK | wxICON_INFORMATION); MessageDialog msg_wingow(parent, message, wxString(SLIC3R_APP_FULL_NAME " - ") + (title.empty() ? _L("Notice") : title), wxOK | wxICON_INFORMATION); msg_wingow.ShowModal(); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8ff4cdd88d1..e462049dcfd 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -9,6 +9,10 @@ #include "libslic3r_version.h" #include "Downloader.hpp" +#ifdef SERVER_ENGINE +#include "engine.h" +#endif + // Localization headers: include libslic3r version first so everything in this file // uses the slic3r/GUI version (the macros will take precedence over the functions). // Also, there is a check that the former is not included from slic3r module. @@ -827,6 +831,11 @@ void GUI_App::post_init() for (auto& file : this->init_params->input_files) { input_files.push_back(wxString::FromUTF8(file)); } + + #ifdef SERVER_ENGINE + input_files.clear(); + #endif + this->plater()->set_project_filename(_L("Untitled")); this->plater()->load_files(input_files); try { @@ -2083,6 +2092,14 @@ void GUI_App::init_single_instance_checker(const std::string &name, const std::s bool GUI_App::OnInit() { try { + + #ifdef SERVER_ENGINE + extern std::vector argv_narrow; + std::vector files = std::vector(argv_narrow.begin() + 1, argv_narrow.end()); + Slic3r::GUI::Snapmaker_Orca_Engine* engine = new Slic3r::GUI::Snapmaker_Orca_Engine(files); + engine->init(); + #endif + return on_init_inner(); } catch (const std::exception&) { generic_exception_handle(); @@ -2379,6 +2396,11 @@ bool GUI_App::on_init_inner() skip_this_version = false; } } + + #ifdef SERVER_ENGINE + skip_this_version = true; + #endif + if (!skip_this_version || evt.GetInt() != 0) { UpdateVersionDialog dialog(this->mainframe); diff --git a/src/slic3r/GUI/InstanceCheck.cpp b/src/slic3r/GUI/InstanceCheck.cpp index 65bbfcad68c..a722862f68e 100644 --- a/src/slic3r/GUI/InstanceCheck.cpp +++ b/src/slic3r/GUI/InstanceCheck.cpp @@ -237,7 +237,7 @@ namespace instance_check_internal dbus_uint32_t serial = 0; const char* sigval = message_text.c_str(); //std::string interface_name = "com.prusa3d.prusaslicer.InstanceCheck"; - std::string interface_name = "com.snapmaker.snapmaker-slicer.InstanceCheck.Object" + version; + std::string interface_name = "com.snapmaker.snapmaker-orca.InstanceCheck.Object" + version; std::string method_name = "AnotherInstance"; //std::string object_name = "/com/prusa3d/prusaslicer/InstanceCheck"; std::string object_name = "/com/softfever3d/Snapmaker_Orca/InstanceCheck/Object" + version; @@ -550,7 +550,7 @@ namespace MessageHandlerDBusInternal " " " " " " - " " + " " " " " " " " @@ -588,7 +588,7 @@ namespace MessageHandlerDBusInternal { const char* interface_name = dbus_message_get_interface(message); const char* member_name = dbus_message_get_member(message); - std::string our_interface = "com.snapmaker.snapmaker-slicer.InstanceCheck.Object" + wxGetApp().get_instance_hash_string(); + std::string our_interface = "com.snapmaker.snapmaker-orca.InstanceCheck.Object" + wxGetApp().get_instance_hash_string(); BOOST_LOG_TRIVIAL(trace) << "DBus message received: interface: " << interface_name << ", member: " << member_name; if (0 == strcmp("org.freedesktop.DBus.Introspectable", interface_name) && 0 == strcmp("Introspect", member_name)) { respond_to_introspect(connection, message); @@ -608,7 +608,7 @@ void OtherInstanceMessageHandler::listen() int name_req_val; DBusObjectPathVTable vtable; std::string instance_hash = wxGetApp().get_instance_hash_string(); - std::string interface_name = "com.snapmaker.snapmaker-slicer.InstanceCheck.Object" + instance_hash; + std::string interface_name = "com.snapmaker.snapmaker-orca.InstanceCheck.Object" + instance_hash; std::string object_name = "/com/softfever3d/Snapmaker_Orca/InstanceCheck/Object" + instance_hash; //BOOST_LOG_TRIVIAL(debug) << "init dbus listen " << interface_name << " " << object_name; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index e879022f2b8..507bc6b1026 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -2872,7 +2872,7 @@ void MainFrame::init_menubar_as_editor() std::string url = "https://github.com/SoftFever/Snapmaker_Orca/wiki/Calibration"; if (const std::string country_code = wxGetApp().app_config->get_country_code(); country_code == "CN") { // Use gitee mirror for China users - url = "https://gitee.com/n0isyfox/snapmaker-slicer-docs/wikis/%E6%A0%A1%E5%87%86/%E6%89%93%E5%8D%B0%E5%8F%82%E6%95%B0%E6%A0%A1%E5%87%86"; + url = "https://gitee.com/n0isyfox/snapmaker-orca-docs/wikis/%E6%A0%A1%E5%87%86/%E6%89%93%E5%8D%B0%E5%8F%82%E6%95%B0%E6%A0%A1%E5%87%86"; } wxLaunchDefaultBrowser(url, wxBROWSER_NEW_WINDOW); }, "", nullptr, diff --git a/src/slic3r/GUI/Mouse3DHandlerMac.mm b/src/slic3r/GUI/Mouse3DHandlerMac.mm index 4403d00a8c1..90f40c5c3be 100644 --- a/src/slic3r/GUI/Mouse3DHandlerMac.mm +++ b/src/slic3r/GUI/Mouse3DHandlerMac.mm @@ -202,7 +202,7 @@ static void DeviceEvent(uint32_t unused, uint32_t msg_type, void *msg_arg) // Registration is done either by 4letter constant (CFBundleSignature - obsolete //and we dont have that) or Executable name in pascal string(first byte is string lenght). //If no packets are recieved the name might be different - check cmake. If debugging try commenting - // set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-slicer") + // set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca") clientID = RegisterConnexionClient( 0, "\013Snapmaker_Orca", kConnexionClientModeTakeOver, kConnexionMaskAxis); BOOST_LOG_TRIVIAL(info) << "3dx mac handler registered"; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f751d285b72..aee14d6f498 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -161,6 +161,12 @@ using namespace nlohmann; static const std::pair THUMBNAIL_SIZE_3MF = { 512, 512 }; +#ifdef SERVER_ENGINE +extern std::vector argv_narrow; +extern std::vector argv_ptrs; +extern bool g_exported; +#endif + namespace Slic3r { namespace GUI { @@ -6945,6 +6951,13 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error) notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false); + #ifdef SERVER_ENGINE + extern bool g_exported; + g_exported = true; + #endif + } + + // BBS, Generate calibration thumbnail for current plate if (!has_error && preview) { // generate calibration data @@ -11027,6 +11040,11 @@ void Plater::reset_with_confirm() // BBS: save logic int GUI::Plater::close_with_confirm(std::function second_check) { + + #ifdef SERVER_ENGINE + return wxID_NO; + #endif + if (up_to_date(false, false)) { if (second_check && !second_check(false)) return wxID_CANCEL; model().set_backup_path(""); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 52f0706e897..17a716972f0 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -813,6 +813,10 @@ class Plater: public wxPanel friend class SuppressBackgroundProcessingUpdate; friend class PlaterDropTarget; + + #ifdef SERVER_ENGINE + friend class Snapmaker_Orca_Engine; + #endif }; class SuppressBackgroundProcessingUpdate diff --git a/src/slic3r/Utils/Process.cpp b/src/slic3r/Utils/Process.cpp index 60c49eebb6a..fc95657fdf2 100644 --- a/src/slic3r/Utils/Process.cpp +++ b/src/slic3r/Utils/Process.cpp @@ -39,7 +39,7 @@ static void start_new_slicer_or_gcodeviewer(const NewSlicerInstanceType instance wxString path; wxFileName::SplitPath(wxStandardPaths::Get().GetExecutablePath(), &path, nullptr, nullptr, wxPATH_NATIVE); path += "\\"; - path += (instance_type == NewSlicerInstanceType::Slicer) ? "snapmaker-slicer.exe" : "bambu-gcodeviewer.exe"; + path += (instance_type == NewSlicerInstanceType::Slicer) ? "snapmaker-orca.exe" : "bambu-gcodeviewer.exe"; std::vector args; args.reserve(4); args.emplace_back(path.wc_str()); @@ -102,7 +102,7 @@ static void start_new_slicer_or_gcodeviewer(const NewSlicerInstanceType instance std::string my_path; if (args.empty()) { // Binary path was not set to the AppImage in the Linux specific block above, call the application directly. - my_path = (bin_path.parent_path() / ((instance_type == NewSlicerInstanceType::Slicer) ? "snapmaker-slicer" : "bambu-gcodeviewer")).string(); + my_path = (bin_path.parent_path() / ((instance_type == NewSlicerInstanceType::Slicer) ? "snapmaker-orca" : "bambu-gcodeviewer")).string(); args.emplace_back(my_path.c_str()); } std::string to_open; From c5b92e38d0c34a0e2202a801da88d087cfec056a Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 11:36:50 +0800 Subject: [PATCH 02/26] Build snapmaker Engine --- .github/workflows/build_orca.yml | 34 +++++++++++++++++ BuildLinux.sh | 1 + src/CMakeLists.txt | 63 ++++++++++++++++++++++++++------ 3 files changed, 87 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 2c7b2920831..e47bb0ed0bf 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -257,6 +257,17 @@ jobs: mv -n ./build/Snapmaker_Orca_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage chmod +x ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + - name: Build Slicer-Engine + if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' + shell: bash + env: + ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} + run: | + ./BuildLinux.sh -eisr + mv -n ./build/Snapmaker_Orca_Engine_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + chmod +x ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + + - name: Build orca_custom_preset_tests if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' working-directory: ${{ github.workspace }}/build/src @@ -275,6 +286,16 @@ jobs: with: name: Snapmaker_Orca_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} path: './build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' + + - name: Upload artifacts Ubuntu Engine + if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} + env: + ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} + ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} + uses: actions/upload-artifact@v4 + with: + name: Snapmaker_Orca_Engine_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} + path: './build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' - name: Deploy Ubuntu release if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} @@ -299,3 +320,16 @@ jobs: asset_name: orca_custom_preset_tests.zip asset_content_type: application/octet-stream max_releases: 1 + + - name: Deploy Ubuntu-Engine release + if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} + uses: WebFreak001/deploy-nightly@v3.1.0 + with: + upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} + release_id: 169912305 + asset_path: ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_name: Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_content_type: application/octet-stream + max_releases: 1 + + \ No newline at end of file diff --git a/BuildLinux.sh b/BuildLinux.sh index 5835403d66b..4962d9c7d2a 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -195,3 +195,4 @@ echo "[9/9] Generating Linux app..." popd echo "done" fi + \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86efd80e598..68661597440 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,7 +121,7 @@ if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () if (SERVER_ENGINE) - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) + add_executable(Snapmaker_Orca_Engine Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) else () add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) endif () @@ -135,16 +135,22 @@ endif (MINGW) if (NOT WIN32 AND NOT APPLE) # Binary name on unix like systems (Linux, Unix) if (SERVER_ENGINE) + set_target_properties(Snapmaker_Orca_Engine PROPERTIES OUTPUT_NAME "snapmaker-orca-engine") + set(SLIC3R_APP_CMD "snapmaker-orca-engine") + else () set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca") set(SLIC3R_APP_CMD "snapmaker-orca") - else () - set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca-engine") - set(SLIC3R_APP_CMD "snapmaker-orca-engine") endif () configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/BuildLinuxImage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/BuildLinuxImage.sh @ONLY) endif () -target_link_libraries(Snapmaker_Orca libslic3r cereal::cereal) + +if (SERVER_ENGINE) + target_link_libraries(Snapmaker_Orca_Engine libslic3r cereal::cereal) +else() + target_link_libraries(Snapmaker_Orca libslic3r cereal::cereal) +endif () + if (APPLE) # add_compile_options(-stdlib=libc++) # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) @@ -155,13 +161,22 @@ elseif (MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") else () # Boost on Raspberry-Pi does not link to pthreads explicitely. - target_link_libraries(Snapmaker_Orca ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) + if (SERVER_ENGINE) + target_link_libraries(Snapmaker_Orca_Engine ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) + else () + target_link_libraries(Snapmaker_Orca ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) + endif () endif () # Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries. if (SLIC3R_GUI) # target_link_libraries(Snapmaker_Orca ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES}) -target_link_libraries(Snapmaker_Orca libslic3r_gui) + if (SERVER_ENGINE) + target_link_libraries(Snapmaker_Orca_Engine libslic3r_gui) + else () + target_link_libraries(Snapmaker_Orca libslic3r_gui) + endif () + if (MSVC) # Generate debug symbols even in release mode. target_link_options(Snapmaker_Orca PUBLIC "$<$:/DEBUG>") @@ -171,7 +186,12 @@ target_link_libraries(Snapmaker_Orca libslic3r_gui) elseif (APPLE) target_link_libraries(Snapmaker_Orca "-framework OpenGL") else () - target_link_libraries(Snapmaker_Orca -ldl) + if (SERVER_ENGINE) + target_link_libraries(Snapmaker_Orca_Engine -ldl) + else () + target_link_libraries(Snapmaker_Orca -ldl) + endif () + endif () #if (WIN32) # find_library(PSAPI_LIB NAMES Psapi) @@ -245,9 +265,16 @@ else () WORKING_DIRECTORY "$" VERBATIM) else () - add_custom_command(TARGET Snapmaker_Orca POST_BUILD + if (SERVER_ENGINE) + add_custom_command(TARGET Snapmaker_Orca_Engine POST_BUILD + WORKING_DIRECTORY "$" + VERBATIM) + else () + add_custom_command(TARGET Snapmaker_Orca POST_BUILD WORKING_DIRECTORY "$" VERBATIM) + endif () + endif () if (XCODE) # Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level @@ -261,16 +288,26 @@ else () set(BIN_RESOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/$/Snapmaker_Orca.app/Contents/Resources") else() set(BIN_RESOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.app/Contents/Resources") + endif() set(MACOSX_BUNDLE_ICON_FILE Icon.icns) set(MACOSX_BUNDLE_BUNDLE_NAME "Snapmaker_Orca") set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${SoftFever_VERSION}) set(MACOSX_BUNDLE_COPYRIGHT "Copyright(C) 2022-2024 Li Jiang All Rights Reserved") endif() - add_custom_command(TARGET Snapmaker_Orca POST_BUILD + + if (SERVER_ENGINE) + add_custom_command(TARGET Snapmaker_Orca_Engine POST_BUILD COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" COMMENT "Symlinking the resources directory into the build tree" VERBATIM) + else () + add_custom_command(TARGET Snapmaker_Orca POST_BUILD + COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" + COMMENT "Symlinking the resources directory into the build tree" + VERBATIM) + endif () + endif () # Slic3r binary install target. Default build type is release in case no CMAKE_BUILD_TYPE is provided. @@ -293,5 +330,9 @@ if (WIN32) endif () install(FILES ${output_dlls_${build_type}} DESTINATION ".") else () - install(TARGETS Snapmaker_Orca RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) + if (SERVER_ENGINE) + install(TARGETS Snapmaker_Orca_Engine RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) + else () + install(TARGETS Snapmaker_Orca RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () From fc4af665b6a1d6e9e9853d476739072d039b65e9 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 11:48:37 +0800 Subject: [PATCH 03/26] fix BuildLinux.sh --- BuildLinux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 4962d9c7d2a..876a6ed316c 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -155,7 +155,7 @@ then then BUILD_ARGS="-DSLIC3R_GTK=3" fi - if [[ -n "${BUILD_ENGINE}"]] + if [[ -n "${BUILD_ENGINE}" ]] then BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE" fi From 3819d45b01b61e3f870b646f7564c825465ddeb9 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 12:12:41 +0800 Subject: [PATCH 04/26] fix Plater.cpp --- src/slic3r/GUI/Plater.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index aee14d6f498..5b56b6bd04e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6947,8 +6947,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) // Don't offer the "Eject" button on ChromeOS, the Linux side has no control over it. platform_flavor() != PlatformFlavor::LinuxOnChromium); wxGetApp().removable_drive_manager()->set_exporting_finished(true); - }else - if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error) + }else if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error){ notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false); #ifdef SERVER_ENGINE From 918b4b86dc30b09b5663c3a46135fa637b8f21d5 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 15:08:50 +0800 Subject: [PATCH 05/26] add definitions to the c++ project --- BuildLinux.sh | 2 +- CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 876a6ed316c..7cdf77f1b24 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -157,7 +157,7 @@ then fi if [[ -n "${BUILD_ENGINE}" ]] then - BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE" + BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE=ON" fi if [[ -n "${BUILD_DEBUG}" ]] then diff --git a/CMakeLists.txt b/CMakeLists.txt index 57d760a7e3d..09ce1054ded 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,10 @@ foreach (_cache_var ${_cache_vars}) endif () endforeach() +if (SERVER_ENGINE) + add_definitions(-DSERVER_ENGINE) +endif () + if (SLIC3R_GUI) add_definitions(-DSLIC3R_GUI) endif () From 36cdc9f42db04e34236382d7a5bf355812a4f811 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 15:12:33 +0800 Subject: [PATCH 06/26] cancel the ssl dialog in engine --- src/slic3r/GUI/GUI_App.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e462049dcfd..b98180b3b80 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2241,6 +2241,10 @@ bool GUI_App::on_init_inner() std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location"); bool ssl_accept = app_config->get("tls_cert_store_accepted") == "yes" && ssl_cert_store == Slic3r::Http::tls_system_cert_store(); +#ifdef SERVER_ENGINE + app_config->set("tls_cert_store_accepted", "yes"); + app_config->set("tls_accepted_cert_store_location", Slic3r::Http::tls_system_cert_store()); +#else if (!msg.empty() && !ssl_accept) { RichMessageDialog dlg(nullptr, @@ -2254,6 +2258,7 @@ bool GUI_App::on_init_inner() app_config->set("tls_accepted_cert_store_location", dlg.IsCheckBoxChecked() ? Slic3r::Http::tls_system_cert_store() : ""); } +#endif } // !!! Initialization of UI settings as a language, application color mode, fonts... have to be done before first UI action. From 3c66ab44bab2888c477e93b09e6308e16a3a9b58 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 17:00:09 +0800 Subject: [PATCH 07/26] fix sh and cmake and test --- BuildLinux.sh | 1 + CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + src/Engine.cpp | 4 +--- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 7cdf77f1b24..f25f3adfbbf 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -157,6 +157,7 @@ then fi if [[ -n "${BUILD_ENGINE}" ]] then + echo "BUILD_ENGINE=ON" BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE=ON" fi if [[ -n "${BUILD_DEBUG}" ]] diff --git a/CMakeLists.txt b/CMakeLists.txt index 09ce1054ded..8f2ef3da634 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ foreach (_cache_var ${_cache_vars}) endforeach() if (SERVER_ENGINE) + message("liuxiaoye add_definition SERVER_ENGINE") add_definitions(-DSERVER_ENGINE) endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68661597440..3c20afe7e3d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,6 +121,7 @@ if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () if (SERVER_ENGINE) + message("liuxioaye snapmaker_orca_engine") add_executable(Snapmaker_Orca_Engine Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) else () add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) diff --git a/src/Engine.cpp b/src/Engine.cpp index 3a7f919b161..7098fab09d5 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -1,4 +1,3 @@ -/* #include "Engine.h" #include "wx/app.h" @@ -321,5 +320,4 @@ void Snapmaker_Orca_Engine::export_gcode_server(bool prefer_removable) { } } catch (...) {} } -} -*/ \ No newline at end of file +} \ No newline at end of file From 2fc4c0d168424d2858a0c22f53d42af897cf7371 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 17:30:11 +0800 Subject: [PATCH 08/26] fix cmake and sh --- BuildLinux.sh | 15 +++++++++++---- src/CMakeLists.txt | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index f25f3adfbbf..80e52134953 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -25,7 +25,7 @@ function check_available_memory_and_disk() { } function usage() { - echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u]" + echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-e][-i][-r][-s][-u]" echo " -1: limit builds to 1 core (where possible)" echo " -b: build in debug mode" echo " -c: force a clean build" @@ -41,7 +41,7 @@ function usage() { } unset name -while getopts ":1bcdghirsu" opt; do +while getopts ":1bcdeghirsu" opt; do case ${opt} in 1 ) export CMAKE_BUILD_PARALLEL_LEVEL=1 @@ -173,8 +173,15 @@ then -DORCA_TOOLS=ON \ ${BUILD_ARGS} echo "done" - echo "Building Snapmaker_Orca ..." - cmake --build build --target Snapmaker_Orca + if [[ -n "${BUILD_ENGINE}" ]] + then + echo "Building Snapmaker_Orca_Engine ..." + cmake --build build --target Snapmaker_Orca_Engine + else + echo "Building Snapmaker_Orca ..." + cmake --build build --target Snapmaker_Orca + fi + echo "Building Snapmaker_Orca_profile_validator .." cmake --build build --target Snapmaker_Orca_profile_validator ./run_gettext.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c20afe7e3d..68661597440 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,7 +121,6 @@ if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () if (SERVER_ENGINE) - message("liuxioaye snapmaker_orca_engine") add_executable(Snapmaker_Orca_Engine Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) else () add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) From 073e7b9502c7e91ae2aa568adf0342fcea4c1492 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 17:30:22 +0800 Subject: [PATCH 09/26] fix cmake and sh --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f2ef3da634..09ce1054ded 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,6 @@ foreach (_cache_var ${_cache_vars}) endforeach() if (SERVER_ENGINE) - message("liuxiaoye add_definition SERVER_ENGINE") add_definitions(-DSERVER_ENGINE) endif () From 4649b381532e0c63d1786927872afe163ccea038 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 17:51:36 +0800 Subject: [PATCH 10/26] fix sh and cmake --- .github/workflows/build_orca.yml | 90 ++++++++++++++++---------------- BuildLinux.sh | 10 +--- src/CMakeLists.txt | 68 ++++++------------------ 3 files changed, 61 insertions(+), 107 deletions(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index e47bb0ed0bf..8aef52b475c 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -247,16 +247,6 @@ jobs: shell: bash run: sudo chown $USER -R ./ - - name: Build slicer - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - shell: bash - env: - ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} - run: | - ./BuildLinux.sh -isr - mv -n ./build/Snapmaker_Orca_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - chmod +x ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - - name: Build Slicer-Engine if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash @@ -264,20 +254,10 @@ jobs: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} run: | ./BuildLinux.sh -eisr - mv -n ./build/Snapmaker_Orca_Engine_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + mv -n ./build/Snapmaker_Orca_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage chmod +x ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - - - name: Build orca_custom_preset_tests - if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' - working-directory: ${{ github.workspace }}/build/src - shell: bash - run: | - ./Snapmaker_Orca_profile_validator -p ${{ github.workspace }}/resources/profiles -g 1 - cd ${{ github.workspace }}/resources/profiles - zip -r orca_custom_preset_tests.zip user/ - - - name: Upload artifacts Ubuntu + - name: Upload artifacts Ubuntu Engine if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} env: ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} @@ -286,29 +266,17 @@ jobs: with: name: Snapmaker_Orca_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} path: './build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' - - - name: Upload artifacts Ubuntu Engine - if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} - env: - ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} - ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} - uses: actions/upload-artifact@v4 - with: - name: Snapmaker_Orca_Engine_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} - path: './build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' - - name: Deploy Ubuntu release - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} - env: - ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} + - name: Deploy Ubuntu-Engine release + if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} uses: WebFreak001/deploy-nightly@v3.1.0 with: upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} release_id: 169912305 - asset_path: ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - asset_name: Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_path: ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_name: Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage asset_content_type: application/octet-stream - max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted + max_releases: 1 - name: Deploy orca_custom_preset_tests if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} @@ -321,15 +289,45 @@ jobs: asset_content_type: application/octet-stream max_releases: 1 - - name: Deploy Ubuntu-Engine release - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} + - name: Build slicer + if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' + shell: bash + env: + ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} + run: | + ./BuildLinux.sh -isr + mv -n ./build/Snapmaker_Orca_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + chmod +x ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + + - name: Build orca_custom_preset_tests + if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' + working-directory: ${{ github.workspace }}/build/src + shell: bash + run: | + ./Snapmaker_Orca_profile_validator -p ${{ github.workspace }}/resources/profiles -g 1 + cd ${{ github.workspace }}/resources/profiles + zip -r orca_custom_preset_tests.zip user/ + + - name: Upload artifacts Ubuntu + if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} + env: + ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} + ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} + uses: actions/upload-artifact@v4 + with: + name: Snapmaker_Orca_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} + path: './build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' + + + - name: Deploy Ubuntu release + if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} + env: + ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} uses: WebFreak001/deploy-nightly@v3.1.0 with: upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} release_id: 169912305 - asset_path: ./build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - asset_name: Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_path: ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + asset_name: Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage asset_content_type: application/octet-stream - max_releases: 1 - - \ No newline at end of file + max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted \ No newline at end of file diff --git a/BuildLinux.sh b/BuildLinux.sh index 80e52134953..2a2bb2fe6a6 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -173,14 +173,8 @@ then -DORCA_TOOLS=ON \ ${BUILD_ARGS} echo "done" - if [[ -n "${BUILD_ENGINE}" ]] - then - echo "Building Snapmaker_Orca_Engine ..." - cmake --build build --target Snapmaker_Orca_Engine - else - echo "Building Snapmaker_Orca ..." - cmake --build build --target Snapmaker_Orca - fi + echo "Building Snapmaker_Orca ..." + cmake --build build --target Snapmaker_Orca echo "Building Snapmaker_Orca_profile_validator .." cmake --build build --target Snapmaker_Orca_profile_validator diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68661597440..f8d94616a0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,7 +121,7 @@ if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () if (SERVER_ENGINE) - add_executable(Snapmaker_Orca_Engine Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) else () add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) endif () @@ -134,22 +134,13 @@ endif (MINGW) if (NOT WIN32 AND NOT APPLE) # Binary name on unix like systems (Linux, Unix) - if (SERVER_ENGINE) - set_target_properties(Snapmaker_Orca_Engine PROPERTIES OUTPUT_NAME "snapmaker-orca-engine") - set(SLIC3R_APP_CMD "snapmaker-orca-engine") - else () - set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca") - set(SLIC3R_APP_CMD "snapmaker-orca") - endif () + set_target_properties(Snapmaker_Orca PROPERTIES OUTPUT_NAME "snapmaker-orca") + set(SLIC3R_APP_CMD "snapmaker-orca") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/BuildLinuxImage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/BuildLinuxImage.sh @ONLY) endif () -if (SERVER_ENGINE) - target_link_libraries(Snapmaker_Orca_Engine libslic3r cereal::cereal) -else() - target_link_libraries(Snapmaker_Orca libslic3r cereal::cereal) -endif () +target_link_libraries(Snapmaker_Orca libslic3r cereal::cereal) if (APPLE) # add_compile_options(-stdlib=libc++) @@ -161,21 +152,13 @@ elseif (MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") else () # Boost on Raspberry-Pi does not link to pthreads explicitely. - if (SERVER_ENGINE) - target_link_libraries(Snapmaker_Orca_Engine ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) - else () - target_link_libraries(Snapmaker_Orca ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) - endif () + target_link_libraries(Snapmaker_Orca ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads pangoft2-1.0) endif () # Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries. if (SLIC3R_GUI) # target_link_libraries(Snapmaker_Orca ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES}) - if (SERVER_ENGINE) - target_link_libraries(Snapmaker_Orca_Engine libslic3r_gui) - else () - target_link_libraries(Snapmaker_Orca libslic3r_gui) - endif () + target_link_libraries(Snapmaker_Orca libslic3r_gui) if (MSVC) # Generate debug symbols even in release mode. @@ -186,11 +169,7 @@ if (SLIC3R_GUI) elseif (APPLE) target_link_libraries(Snapmaker_Orca "-framework OpenGL") else () - if (SERVER_ENGINE) - target_link_libraries(Snapmaker_Orca_Engine -ldl) - else () - target_link_libraries(Snapmaker_Orca -ldl) - endif () + target_link_libraries(Snapmaker_Orca -ldl) endif () #if (WIN32) @@ -265,15 +244,9 @@ else () WORKING_DIRECTORY "$" VERBATIM) else () - if (SERVER_ENGINE) - add_custom_command(TARGET Snapmaker_Orca_Engine POST_BUILD - WORKING_DIRECTORY "$" - VERBATIM) - else () - add_custom_command(TARGET Snapmaker_Orca POST_BUILD - WORKING_DIRECTORY "$" - VERBATIM) - endif () + add_custom_command(TARGET Snapmaker_Orca POST_BUILD + WORKING_DIRECTORY "$" + VERBATIM) endif () if (XCODE) @@ -296,17 +269,10 @@ else () set(MACOSX_BUNDLE_COPYRIGHT "Copyright(C) 2022-2024 Li Jiang All Rights Reserved") endif() - if (SERVER_ENGINE) - add_custom_command(TARGET Snapmaker_Orca_Engine POST_BUILD - COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" - COMMENT "Symlinking the resources directory into the build tree" - VERBATIM) - else () - add_custom_command(TARGET Snapmaker_Orca POST_BUILD - COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" - COMMENT "Symlinking the resources directory into the build tree" - VERBATIM) - endif () + add_custom_command(TARGET Snapmaker_Orca POST_BUILD + COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" + COMMENT "Symlinking the resources directory into the build tree" + VERBATIM) endif () @@ -330,9 +296,5 @@ if (WIN32) endif () install(FILES ${output_dlls_${build_type}} DESTINATION ".") else () - if (SERVER_ENGINE) - install(TARGETS Snapmaker_Orca_Engine RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) - else () - install(TARGETS Snapmaker_Orca RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif () + install(TARGETS Snapmaker_Orca RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) endif () From 5034cd58a41119f1fcc0c113237d248dbcec5c77 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 18:05:56 +0800 Subject: [PATCH 11/26] fix input handler --- src/Snapmaker_Orca.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index ea930ad1e31..68d11f10918 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -6307,7 +6307,7 @@ int main(int argc, char **argv) #ifdef SERVER_ENGINE argv_ptrs.resize(argc + 1, nullptr); for (size_t i = 0; i < argc; ++i) - argv_narrow.emplace_back(boost::nowide::narrow(argv[i])); + argv_narrow.emplace_back(argv[i]); for (size_t i = 0; i < argc; ++i) argv_ptrs[i] = argv_narrow[i].data(); #endif From c5ff49f56e8d3f672f5849c29005bc0a26f13bd0 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 18:16:00 +0800 Subject: [PATCH 12/26] fix yml --- .github/workflows/build_orca.yml | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 8aef52b475c..566f3aedcd6 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -278,17 +278,6 @@ jobs: asset_content_type: application/octet-stream max_releases: 1 - - name: Deploy orca_custom_preset_tests - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} - uses: WebFreak001/deploy-nightly@v3.1.0 - with: - upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} - release_id: 169912305 - asset_path: ${{ github.workspace }}/resources/profiles/orca_custom_preset_tests.zip - asset_name: orca_custom_preset_tests.zip - asset_content_type: application/octet-stream - max_releases: 1 - - name: Build slicer if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash @@ -299,15 +288,6 @@ jobs: mv -n ./build/Snapmaker_Orca_Linux_V${{ env.ver_pure }}.AppImage ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage chmod +x ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - - name: Build orca_custom_preset_tests - if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' - working-directory: ${{ github.workspace }}/build/src - shell: bash - run: | - ./Snapmaker_Orca_profile_validator -p ${{ github.workspace }}/resources/profiles -g 1 - cd ${{ github.workspace }}/resources/profiles - zip -r orca_custom_preset_tests.zip user/ - - name: Upload artifacts Ubuntu if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} env: @@ -330,4 +310,24 @@ jobs: asset_path: ./build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage asset_name: Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage asset_content_type: application/octet-stream - max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted \ No newline at end of file + max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted + + - name: Build orca_custom_preset_tests + if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' + working-directory: ${{ github.workspace }}/build/src + shell: bash + run: | + ./Snapmaker_Orca_profile_validator -p ${{ github.workspace }}/resources/profiles -g 1 + cd ${{ github.workspace }}/resources/profiles + zip -r orca_custom_preset_tests.zip user/ + + - name: Deploy orca_custom_preset_tests + if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }} + uses: WebFreak001/deploy-nightly@v3.1.0 + with: + upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} + release_id: 169912305 + asset_path: ${{ github.workspace }}/resources/profiles/orca_custom_preset_tests.zip + asset_name: orca_custom_preset_tests.zip + asset_content_type: application/octet-stream + max_releases: 1 \ No newline at end of file From 41ea2aa481baec94fb3f8694ca93603cb7113298 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 19:49:55 +0800 Subject: [PATCH 13/26] fix cmake --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8d94616a0d..7fb2655ed39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,10 @@ add_subdirectory(libnest2d) add_subdirectory(libslic3r) +if (SERVER_ENGINE) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +endif() + if (SLIC3R_GUI) add_subdirectory(imgui) add_subdirectory(imguizmo) From 214821f743bb48d66c4c2028869082cff159c9bb Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 20:03:17 +0800 Subject: [PATCH 14/26] fix the structor of engine --- src/CMakeLists.txt | 4 ---- src/slic3r/CMakeLists.txt | 5 +++++ src/{ => slic3r/GUI}/Engine.cpp | 0 src/{ => slic3r/GUI}/Engine.h | 0 4 files changed, 5 insertions(+), 4 deletions(-) rename src/{ => slic3r/GUI}/Engine.cpp (100%) rename src/{ => slic3r/GUI}/Engine.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fb2655ed39..f8d94616a0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,10 +24,6 @@ add_subdirectory(libnest2d) add_subdirectory(libslic3r) -if (SERVER_ENGINE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() - if (SLIC3R_GUI) add_subdirectory(imgui) add_subdirectory(imguizmo) diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 87d93965784..606ffa38ae5 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -565,6 +565,11 @@ set(SLIC3R_GUI_SOURCES Utils/SimplyPrint.hpp ) +if (SERVER_ENGINE) + message("SERVER_ENGINE INCULUDE engine.o") + list(APPEND SLIC3R_GUI_SOURCES "GUI/engine.cpp" "GUI/engine.h") +endif() + if (WIN32) list(APPEND SLIC3R_GUI_SOURCES GUI/dark_mode/dark_mode.hpp diff --git a/src/Engine.cpp b/src/slic3r/GUI/Engine.cpp similarity index 100% rename from src/Engine.cpp rename to src/slic3r/GUI/Engine.cpp diff --git a/src/Engine.h b/src/slic3r/GUI/Engine.h similarity index 100% rename from src/Engine.h rename to src/slic3r/GUI/Engine.h From 16df69514c7d973d97454c3fbecd3fdffef4fbd3 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 20:04:21 +0800 Subject: [PATCH 15/26] fix cmake --- src/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8d94616a0d..659d03378f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,11 +120,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CU if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () - if (SERVER_ENGINE) - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) - else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) - endif () + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) endif () if (MINGW) From e985e26aa158419fefb36d7f5103722987f2ee95 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 20:05:35 +0800 Subject: [PATCH 16/26] fix cmake --- src/slic3r/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 606ffa38ae5..bdd0382bfb1 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -567,7 +567,7 @@ set(SLIC3R_GUI_SOURCES if (SERVER_ENGINE) message("SERVER_ENGINE INCULUDE engine.o") - list(APPEND SLIC3R_GUI_SOURCES "GUI/engine.cpp" "GUI/engine.h") + list(APPEND SLIC3R_GUI_SOURCES "GUI/Engine.cpp" "GUI/Engine.h") endif() if (WIN32) From aab7be167f20c2e682c44307634ac3c6f8ca693e Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 20:06:53 +0800 Subject: [PATCH 17/26] fix Snapmaker_Orca.cpp --- src/Snapmaker_Orca.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index 68d11f10918..82fcfc45f1b 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -83,10 +83,6 @@ using namespace nlohmann; #include "slic3r/GUI/Plater.hpp" #include -#ifdef SERVER_ENGINE -#include "Engine.h" -#endif - #ifdef __WXGTK__ #include #endif From 3f522bfee7989f7e5bd38bfb580da54f1166681d Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 20:37:41 +0800 Subject: [PATCH 18/26] fix --- src/slic3r/GUI/GUI_App.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b98180b3b80..93aa86f6548 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -10,7 +10,7 @@ #include "Downloader.hpp" #ifdef SERVER_ENGINE -#include "engine.h" +#include "Engine.h" #endif // Localization headers: include libslic3r version first so everything in this file From a33ca80a3d3bd4cd9edca6359e0c41c4e03b4868 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 22:00:38 +0800 Subject: [PATCH 19/26] fix --- src/CMakeLists.txt | 7 ++++++- src/{slic3r/GUI => }/Engine.cpp | 0 src/{slic3r/GUI => }/Engine.h | 0 3 files changed, 6 insertions(+), 1 deletion(-) rename src/{slic3r/GUI => }/Engine.cpp (100%) rename src/{slic3r/GUI => }/Engine.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 659d03378f1..5997ce11e48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,7 +120,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CU if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) + if (SERVER_ENGINE) + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) + else () + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) + endif () + endif () if (MINGW) diff --git a/src/slic3r/GUI/Engine.cpp b/src/Engine.cpp similarity index 100% rename from src/slic3r/GUI/Engine.cpp rename to src/Engine.cpp diff --git a/src/slic3r/GUI/Engine.h b/src/Engine.h similarity index 100% rename from src/slic3r/GUI/Engine.h rename to src/Engine.h From 864a58af20dcb365438342f6738de3e6b4f35b55 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 22:01:09 +0800 Subject: [PATCH 20/26] fix --- src/slic3r/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index bdd0382bfb1..87d93965784 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -565,11 +565,6 @@ set(SLIC3R_GUI_SOURCES Utils/SimplyPrint.hpp ) -if (SERVER_ENGINE) - message("SERVER_ENGINE INCULUDE engine.o") - list(APPEND SLIC3R_GUI_SOURCES "GUI/Engine.cpp" "GUI/Engine.h") -endif() - if (WIN32) list(APPEND SLIC3R_GUI_SOURCES GUI/dark_mode/dark_mode.hpp From 09e8a5341f40291a0a2c76c89e3ea9a01062b3ac Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 22:09:01 +0800 Subject: [PATCH 21/26] fix --- src/slic3r/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 87d93965784..5f0bfbb9c9d 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -565,6 +565,8 @@ set(SLIC3R_GUI_SOURCES Utils/SimplyPrint.hpp ) +include_directories(${CMAKE_SOURCE_DIR}/src) + if (WIN32) list(APPEND SLIC3R_GUI_SOURCES GUI/dark_mode/dark_mode.hpp From 248d31b07fc4d1b7b19ca918e98f482fbb8bda01 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Tue, 24 Sep 2024 23:36:50 +0800 Subject: [PATCH 22/26] fix engine to plater --- src/CMakeLists.txt | 6 +- src/Engine.cpp | 323 -------------------------------------- src/Engine.h | 70 --------- src/slic3r/GUI/Plater.cpp | 316 +++++++++++++++++++++++++++++++++++++ src/slic3r/GUI/Plater.hpp | 52 ++++++ 5 files changed, 369 insertions(+), 398 deletions(-) delete mode 100644 src/Engine.cpp delete mode 100644 src/Engine.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5997ce11e48..819102664cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,11 +120,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CU if (WIN32) add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp BaseException.cpp BaseException.h StackWalker.cpp StackWalker.h) else () - if (SERVER_ENGINE) - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp Engine.cpp Engine.h) - else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) - endif () + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) endif () diff --git a/src/Engine.cpp b/src/Engine.cpp deleted file mode 100644 index 7098fab09d5..00000000000 --- a/src/Engine.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "Engine.h" - -#include "wx/app.h" -#include "wx/timer.h" -#include "slic3r/GUI/GUI_App.hpp" -#include "slic3r/GUI/MainFrame.hpp" - -#include "slic3r/GUI/Plater.cpp" - -using namespace Slic3r::GUI; - -int Snapmaker_Orca_Engine::s_time_gui_load = 500; -int Snapmaker_Orca_Engine::s_time_check_export = 100; -int Snapmaker_Orca_Engine::s_time_delay_close = 500; - -Snapmaker_Orca_Engine::Snapmaker_Orca_Engine(std::vector& user_inputs) : m_OriFiles(user_inputs) {} - -void Snapmaker_Orca_Engine::init() -{ - if (!m_load_gui_timer) { - m_load_gui_timer = new wxTimer(this, wxNewId()); - } - this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { - this->on_gui_loaded(); - }, m_load_gui_timer->GetId()); - m_load_gui_timer->StartOnce(s_time_gui_load); -} - -void Snapmaker_Orca_Engine::on_gui_loaded() -{ - // load information from gui - m_gui_app = (GUI_App*) wxTheApp; - if (!m_gui_app) { - return; - } - - m_gui_main_frame = m_gui_app->mainframe; - if (!m_gui_main_frame) { - return; - } - - m_gui_plater = m_gui_main_frame->plater(); - if (!m_gui_plater) { - return; - } - - m_load_gui_timer->Stop(); - delete m_load_gui_timer; - m_load_gui_timer = nullptr; - - run_engine(); -} - -void Snapmaker_Orca_Engine::on_time_check() { - extern bool g_exported; - if (g_exported) { - m_check_export_timer->Stop(); - - g_exported = false; - - ++m_task_index; - - if (m_task_index >= m_OriFiles.size()) { - delete m_check_export_timer; - m_check_export_timer = nullptr; - - close_engine(); - } else { - do_next_task(); - } - } -} - -void Snapmaker_Orca_Engine::close_engine() { - if (!m_delay_close_timer) { - m_delay_close_timer = new wxTimer(this, wxNewId()); - } - - this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { - this->m_delay_close_timer->Stop(); - delete this->m_delay_close_timer; - this->m_delay_close_timer = nullptr; - - this->m_gui_main_frame->Close(false); - }, m_delay_close_timer->GetId()); - - m_delay_close_timer->StartOnce(s_time_delay_close); -} - - -void Snapmaker_Orca_Engine::do_next_task() { - - if (m_task_index > 0) { - m_gui_plater->new_project(); - } - - add_file_server(m_OriFiles[m_task_index]); - slice_all_plates_server(); - export_gcode_server(false); - - if (!m_check_export_timer) { - m_check_export_timer = new wxTimer(this, wxNewId()); - } - this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { - this->on_time_check(); - }, m_check_export_timer->GetId()); - m_check_export_timer->Start(s_time_check_export); - -} - -void Snapmaker_Orca_Engine::run_engine() { - if (m_OriFiles.size() >= 1) { - do_next_task(); - } else { - close_engine(); - } -} - -void Snapmaker_Orca_Engine::add_file_server(std::string& filePath) { - - wxArrayString input_files; - input_files.push_back(filePath); - - if (input_files.empty()) - return; - - std::vector paths; - for (const auto& file : input_files) - paths.emplace_back(into_path(file)); - - std::string snapshot_label; - assert(!paths.empty()); - - snapshot_label = "Import Objects"; - snapshot_label += ": "; - snapshot_label += encode_path(paths.front().filename().string().c_str()); - for (size_t i = 1; i < paths.size(); ++i) { - snapshot_label += ", "; - snapshot_label += encode_path(paths[i].filename().string().c_str()); - } - - // BBS: check file types - auto loadfiles_type = LoadFilesType::NoFile; - auto amf_files_count = m_gui_plater->get_3mf_file_count(paths); - - if (paths.size() > 1 && amf_files_count < paths.size()) { - loadfiles_type = LoadFilesType::Multiple3MFOther; - } - if (paths.size() > 1 && amf_files_count == paths.size()) { - loadfiles_type = LoadFilesType::Multiple3MF; - } - if (paths.size() > 1 && amf_files_count == 0) { - loadfiles_type = LoadFilesType::MultipleOther; - } - if (paths.size() == 1 && amf_files_count == 1) { - loadfiles_type = LoadFilesType::Single3MF; - }; - if (paths.size() == 1 && amf_files_count == 0) { - loadfiles_type = LoadFilesType::SingleOther; - }; - - auto first_file = std::vector{}; - auto tmf_file = std::vector{}; - auto other_file = std::vector{}; - - switch (loadfiles_type) { - case LoadFilesType::Single3MF: m_gui_plater->open_3mf_file(paths[0]); break; - - case LoadFilesType::SingleOther: { - Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); - if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, false).empty()) { - if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { - m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); - } - wxGetApp().mainframe->update_title(); - } - break; - } - case LoadFilesType::Multiple3MF: - first_file = std::vector{paths[0]}; - for (auto i = 0; i < paths.size(); i++) { - if (i > 0) { - other_file.push_back(paths[i]); - } - }; - - m_gui_plater->open_3mf_file(first_file[0]); - if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel).empty()) { - wxGetApp().mainframe->update_title(); - } - break; - - case LoadFilesType::MultipleOther: { - Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); - if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, true).empty()) { - if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { - m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); - } - wxGetApp().mainframe->update_title(); - } - break; - } - case LoadFilesType::Multiple3MFOther: - for (const auto& path : paths) { - if (wxString(encode_path(path.filename().string().c_str())).EndsWith("3mf")) { - if (first_file.size() <= 0) - first_file.push_back(path); - else - tmf_file.push_back(path); - } else { - other_file.push_back(path); - } - } - - m_gui_plater->open_3mf_file(first_file[0]); - m_gui_plater->load_files(tmf_file, LoadStrategy::LoadModel); - if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel, false).empty()) { - wxGetApp().mainframe->update_title(); - } - break; - default: break; - } -} - -void Snapmaker_Orca_Engine::slice_all_plates_server() { - if (m_gui_plater != nullptr) { - BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice project event\n"; - // BBS update extruder params and speed table before slicing - const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config(); - auto& print = m_gui_plater->get_partplate_list().get_current_fff_print(); - auto print_config = print.config(); - int numExtruders = wxGetApp().preset_bundle->filament_presets.size(); - - Model::setExtruderParams(config, numExtruders); - Model::setPrintSpeedTable(config, print_config); - m_gui_plater->p->m_slice_all = true; - m_gui_plater->p->m_slice_all_only_has_gcode = true; - m_gui_plater->p->m_cur_slice_plate = 0; - // select plate - m_gui_plater->select_plate(m_gui_plater->p->m_cur_slice_plate); - m_gui_plater->reslice(); - if (!m_gui_plater->p->m_is_publishing) - m_gui_plater->select_view_3D("Preview"); - // BBS: wish to select all plates stats item - m_gui_plater->p->preview->get_canvas3d()->_update_select_plate_toolbar_stats_item(true); - } -} - -void Snapmaker_Orca_Engine::export_gcode_server(bool prefer_removable) { - if (m_gui_plater->p->model.objects.empty()) - return; - - // if (get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(true)) - // return; - - if (m_gui_plater->p->process_completed_with_error == m_gui_plater->p->partplate_list.get_curr_plate_index()) - return; - - // If possible, remove accents from accented latin characters. - // This function is useful for generating file names to be processed by legacy firmwares. - fs::path default_output_file; - try { - // Update the background processing, so that the placeholder parser will get the correct values for the ouput file template. - // Also if there is something wrong with the current configuration, a pop-up dialog will be shown and the export will not be performed. - unsigned int state = m_gui_plater->p->update_restart_background_process(false, false); - if (state & Plater::priv::UPDATE_BACKGROUND_PROCESS_INVALID) - return; - default_output_file = m_gui_plater->p->background_process.output_filepath_for_project(""); - } catch (const Slic3r::PlaceholderParserError& ex) { - // Show the error with monospaced font. - show_error(m_gui_plater, ex.what(), true); - return; - } catch (const std::exception& ex) { - show_error(m_gui_plater, ex.what(), false); - return; - } - default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string())); - AppConfig& appconfig = *wxGetApp().app_config; - RemovableDriveManager& removable_drive_manager = *wxGetApp().removable_drive_manager(); - // Get a last save path, either to removable media or to an internal media. - std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), prefer_removable); - if (prefer_removable) { - // Returns a path to a removable media if it exists, prefering start_dir. Update the internal removable drives database. - start_dir = removable_drive_manager.get_removable_drive_path(start_dir); - if (start_dir.empty()) - // Direct user to the last internal media. - start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false); - } - - fs::path input_path, output_path; - input_path = m_OriFiles[m_task_index]; - output_path = input_path.parent_path() / (input_path.stem().string() + ".gcode"); - - if (!output_path.empty()) { - bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string()); - // bool path_on_removable_media = false; - m_gui_plater->p->notification_manager->new_export_began(path_on_removable_media); - m_gui_plater->p->exporting_status = path_on_removable_media ? ExportingStatus::EXPORTING_TO_REMOVABLE : - ExportingStatus::EXPORTING_TO_LOCAL; - m_gui_plater->p->last_output_path = output_path.string(); - m_gui_plater->p->last_output_dir_path = output_path.parent_path().string(); - m_gui_plater->p->export_gcode(output_path, path_on_removable_media); - // Storing a path to AppConfig either as path to removable media or a path to internal media. - // is_path_on_removable_drive() is called with the "true" parameter to update its internal database as the user may have shuffled - // the external drives while the dialog was open. - appconfig.update_last_output_dir(output_path.parent_path().string(), path_on_removable_media); - - try { - json j; - auto printer_config = Slic3r::GUI::wxGetApp().preset_bundle->printers.get_edited_preset_with_vendor_profile().preset; - if (printer_config.is_system) { - j["printer_preset"] = printer_config.name; - } else { - j["printer_preset"] = printer_config.config.opt_string("inherits"); - } - - PresetBundle* preset_bundle = wxGetApp().preset_bundle; - if (preset_bundle) { - j["gcode_printer_model"] = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); - } - } catch (...) {} - } -} \ No newline at end of file diff --git a/src/Engine.h b/src/Engine.h deleted file mode 100644 index bee6eda81a0..00000000000 --- a/src/Engine.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef ENGINE_H -#define ENGINE_H - -#include -#include - -#include "wx/event.h" - -class wxTimer; - -namespace Slic3r { - namespace GUI{ - class GUI_App; - class MainFrame; - class Plater; - - class Snapmaker_Orca_Engine : public wxEvtHandler - { - public: - // input the 3mf/.stl... files to engine - Snapmaker_Orca_Engine(std::vector& user_inputs); - - void init(); - - void on_gui_loaded(); - - void on_time_check(); - - void run_engine(); - - void do_next_task(); - - void close_engine(); - - private: - void add_file_server(std::string& filePath); - - void slice_all_plates_server(); - - void export_gcode_server(bool prefer_removable); - - private: - std::vector m_OriFiles; - - wxTimer* m_load_gui_timer = nullptr; - - wxTimer* m_check_export_timer = nullptr; - - wxTimer* m_delay_close_timer = nullptr; - - private: - GUI_App* m_gui_app = nullptr; - - MainFrame* m_gui_main_frame = nullptr; - - Plater* m_gui_plater = nullptr; - - int m_task_index = 0; - private: - static int s_time_gui_load; - static int s_time_check_export; - static int s_time_delay_close; - }; - } -} - - - - -#endif \ No newline at end of file diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5b56b6bd04e..f18a7fa801d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -14415,3 +14415,319 @@ SuppressBackgroundProcessingUpdate::~SuppressBackgroundProcessingUpdate() } }} // namespace Slic3r::GUI + + +#ifdef SERVER_ENGINE +int Snapmaker_Orca_Engine::s_time_gui_load = 500; +int Snapmaker_Orca_Engine::s_time_check_export = 100; +int Snapmaker_Orca_Engine::s_time_delay_close = 500; + +Snapmaker_Orca_Engine::Snapmaker_Orca_Engine(std::vector& user_inputs) : m_OriFiles(user_inputs) {} + +void Snapmaker_Orca_Engine::init() +{ + if (!m_load_gui_timer) { + m_load_gui_timer = new wxTimer(this, wxNewId()); + } + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->on_gui_loaded(); + }, m_load_gui_timer->GetId()); + m_load_gui_timer->StartOnce(s_time_gui_load); +} + +void Snapmaker_Orca_Engine::on_gui_loaded() +{ + // load information from gui + m_gui_app = (GUI_App*) wxTheApp; + if (!m_gui_app) { + return; + } + + m_gui_main_frame = m_gui_app->mainframe; + if (!m_gui_main_frame) { + return; + } + + m_gui_plater = m_gui_main_frame->plater(); + if (!m_gui_plater) { + return; + } + + m_load_gui_timer->Stop(); + delete m_load_gui_timer; + m_load_gui_timer = nullptr; + + run_engine(); +} + +void Snapmaker_Orca_Engine::on_time_check() { + extern bool g_exported; + if (g_exported) { + m_check_export_timer->Stop(); + + g_exported = false; + + ++m_task_index; + + if (m_task_index >= m_OriFiles.size()) { + delete m_check_export_timer; + m_check_export_timer = nullptr; + + close_engine(); + } else { + do_next_task(); + } + } +} + +void Snapmaker_Orca_Engine::close_engine() { + if (!m_delay_close_timer) { + m_delay_close_timer = new wxTimer(this, wxNewId()); + } + + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->m_delay_close_timer->Stop(); + delete this->m_delay_close_timer; + this->m_delay_close_timer = nullptr; + + this->m_gui_main_frame->Close(false); + }, m_delay_close_timer->GetId()); + + m_delay_close_timer->StartOnce(s_time_delay_close); +} + + +void Snapmaker_Orca_Engine::do_next_task() { + + if (m_task_index > 0) { + m_gui_plater->new_project(); + } + + add_file_server(m_OriFiles[m_task_index]); + slice_all_plates_server(); + export_gcode_server(false); + + if (!m_check_export_timer) { + m_check_export_timer = new wxTimer(this, wxNewId()); + } + this->Bind(wxEVT_TIMER, [this](wxTimerEvent& event) { + this->on_time_check(); + }, m_check_export_timer->GetId()); + m_check_export_timer->Start(s_time_check_export); + +} + +void Snapmaker_Orca_Engine::run_engine() { + if (m_OriFiles.size() >= 1) { + do_next_task(); + } else { + close_engine(); + } +} + +void Snapmaker_Orca_Engine::add_file_server(std::string& filePath) { + + wxArrayString input_files; + input_files.push_back(filePath); + + if (input_files.empty()) + return; + + std::vector paths; + for (const auto& file : input_files) + paths.emplace_back(into_path(file)); + + std::string snapshot_label; + assert(!paths.empty()); + + snapshot_label = "Import Objects"; + snapshot_label += ": "; + snapshot_label += encode_path(paths.front().filename().string().c_str()); + for (size_t i = 1; i < paths.size(); ++i) { + snapshot_label += ", "; + snapshot_label += encode_path(paths[i].filename().string().c_str()); + } + + // BBS: check file types + auto loadfiles_type = LoadFilesType::NoFile; + auto amf_files_count = m_gui_plater->get_3mf_file_count(paths); + + if (paths.size() > 1 && amf_files_count < paths.size()) { + loadfiles_type = LoadFilesType::Multiple3MFOther; + } + if (paths.size() > 1 && amf_files_count == paths.size()) { + loadfiles_type = LoadFilesType::Multiple3MF; + } + if (paths.size() > 1 && amf_files_count == 0) { + loadfiles_type = LoadFilesType::MultipleOther; + } + if (paths.size() == 1 && amf_files_count == 1) { + loadfiles_type = LoadFilesType::Single3MF; + }; + if (paths.size() == 1 && amf_files_count == 0) { + loadfiles_type = LoadFilesType::SingleOther; + }; + + auto first_file = std::vector{}; + auto tmf_file = std::vector{}; + auto other_file = std::vector{}; + + switch (loadfiles_type) { + case LoadFilesType::Single3MF: m_gui_plater->open_3mf_file(paths[0]); break; + + case LoadFilesType::SingleOther: { + Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); + if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, false).empty()) { + if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { + m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); + } + wxGetApp().mainframe->update_title(); + } + break; + } + case LoadFilesType::Multiple3MF: + first_file = std::vector{paths[0]}; + for (auto i = 0; i < paths.size(); i++) { + if (i > 0) { + other_file.push_back(paths[i]); + } + }; + + m_gui_plater->open_3mf_file(first_file[0]); + if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel).empty()) { + wxGetApp().mainframe->update_title(); + } + break; + + case LoadFilesType::MultipleOther: { + Plater::TakeSnapshot snapshot(m_gui_plater, snapshot_label); + if (!m_gui_plater->load_files(paths, LoadStrategy::LoadModel, true).empty()) { + if (m_gui_plater->get_project_name() == _L("Untitled") && paths.size() > 0) { + m_gui_plater->p->set_project_filename(wxString::FromUTF8(paths[0].string())); + } + wxGetApp().mainframe->update_title(); + } + break; + } + case LoadFilesType::Multiple3MFOther: + for (const auto& path : paths) { + if (wxString(encode_path(path.filename().string().c_str())).EndsWith("3mf")) { + if (first_file.size() <= 0) + first_file.push_back(path); + else + tmf_file.push_back(path); + } else { + other_file.push_back(path); + } + } + + m_gui_plater->open_3mf_file(first_file[0]); + m_gui_plater->load_files(tmf_file, LoadStrategy::LoadModel); + if (!m_gui_plater->load_files(other_file, LoadStrategy::LoadModel, false).empty()) { + wxGetApp().mainframe->update_title(); + } + break; + default: break; + } +} + +void Snapmaker_Orca_Engine::slice_all_plates_server() { + if (m_gui_plater != nullptr) { + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received slice project event\n"; + // BBS update extruder params and speed table before slicing + const Slic3r::DynamicPrintConfig& config = wxGetApp().preset_bundle->full_config(); + auto& print = m_gui_plater->get_partplate_list().get_current_fff_print(); + auto print_config = print.config(); + int numExtruders = wxGetApp().preset_bundle->filament_presets.size(); + + Model::setExtruderParams(config, numExtruders); + Model::setPrintSpeedTable(config, print_config); + m_gui_plater->p->m_slice_all = true; + m_gui_plater->p->m_slice_all_only_has_gcode = true; + m_gui_plater->p->m_cur_slice_plate = 0; + // select plate + m_gui_plater->select_plate(m_gui_plater->p->m_cur_slice_plate); + m_gui_plater->reslice(); + if (!m_gui_plater->p->m_is_publishing) + m_gui_plater->select_view_3D("Preview"); + // BBS: wish to select all plates stats item + m_gui_plater->p->preview->get_canvas3d()->_update_select_plate_toolbar_stats_item(true); + } +} + +void Snapmaker_Orca_Engine::export_gcode_server(bool prefer_removable) { + if (m_gui_plater->p->model.objects.empty()) + return; + + // if (get_view3D_canvas3D()->get_gizmos_manager().is_in_editing_mode(true)) + // return; + + if (m_gui_plater->p->process_completed_with_error == m_gui_plater->p->partplate_list.get_curr_plate_index()) + return; + + // If possible, remove accents from accented latin characters. + // This function is useful for generating file names to be processed by legacy firmwares. + fs::path default_output_file; + try { + // Update the background processing, so that the placeholder parser will get the correct values for the ouput file template. + // Also if there is something wrong with the current configuration, a pop-up dialog will be shown and the export will not be performed. + unsigned int state = m_gui_plater->p->update_restart_background_process(false, false); + if (state & Plater::priv::UPDATE_BACKGROUND_PROCESS_INVALID) + return; + default_output_file = m_gui_plater->p->background_process.output_filepath_for_project(""); + } catch (const Slic3r::PlaceholderParserError& ex) { + // Show the error with monospaced font. + show_error(m_gui_plater, ex.what(), true); + return; + } catch (const std::exception& ex) { + show_error(m_gui_plater, ex.what(), false); + return; + } + default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string())); + AppConfig& appconfig = *wxGetApp().app_config; + RemovableDriveManager& removable_drive_manager = *wxGetApp().removable_drive_manager(); + // Get a last save path, either to removable media or to an internal media. + std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), prefer_removable); + if (prefer_removable) { + // Returns a path to a removable media if it exists, prefering start_dir. Update the internal removable drives database. + start_dir = removable_drive_manager.get_removable_drive_path(start_dir); + if (start_dir.empty()) + // Direct user to the last internal media. + start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false); + } + + fs::path input_path, output_path; + input_path = m_OriFiles[m_task_index]; + output_path = input_path.parent_path() / (input_path.stem().string() + ".gcode"); + + if (!output_path.empty()) { + bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string()); + // bool path_on_removable_media = false; + m_gui_plater->p->notification_manager->new_export_began(path_on_removable_media); + m_gui_plater->p->exporting_status = path_on_removable_media ? ExportingStatus::EXPORTING_TO_REMOVABLE : + ExportingStatus::EXPORTING_TO_LOCAL; + m_gui_plater->p->last_output_path = output_path.string(); + m_gui_plater->p->last_output_dir_path = output_path.parent_path().string(); + m_gui_plater->p->export_gcode(output_path, path_on_removable_media); + // Storing a path to AppConfig either as path to removable media or a path to internal media. + // is_path_on_removable_drive() is called with the "true" parameter to update its internal database as the user may have shuffled + // the external drives while the dialog was open. + appconfig.update_last_output_dir(output_path.parent_path().string(), path_on_removable_media); + + try { + json j; + auto printer_config = Slic3r::GUI::wxGetApp().preset_bundle->printers.get_edited_preset_with_vendor_profile().preset; + if (printer_config.is_system) { + j["printer_preset"] = printer_config.name; + } else { + j["printer_preset"] = printer_config.config.opt_string("inherits"); + } + + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + if (preset_bundle) { + j["gcode_printer_model"] = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); + } + } catch (...) {} + } +} +#endif SERVER_ENGINE \ No newline at end of file diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 17a716972f0..2e09aa4e9f6 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -199,6 +199,58 @@ class Sidebar : public wxPanel ScalableButton* ams_btn = nullptr; }; +#ifdef SERVER_ENGINE + + class Snapmaker_Orca_Engine : public wxEvtHandler + { + public: + // input the 3mf/.stl... files to engine + Snapmaker_Orca_Engine(std::vector& user_inputs); + + void init(); + + void on_gui_loaded(); + + void on_time_check(); + + void run_engine(); + + void do_next_task(); + + void close_engine(); + + private: + void add_file_server(std::string& filePath); + + void slice_all_plates_server(); + + void export_gcode_server(bool prefer_removable); + + private: + std::vector m_OriFiles; + + wxTimer* m_load_gui_timer = nullptr; + + wxTimer* m_check_export_timer = nullptr; + + wxTimer* m_delay_close_timer = nullptr; + + private: + GUI_App* m_gui_app = nullptr; + + MainFrame* m_gui_main_frame = nullptr; + + Plater* m_gui_plater = nullptr; + + int m_task_index = 0; + private: + static int s_time_gui_load; + static int s_time_check_export; + static int s_time_delay_close; + }; + +#endif + class Plater: public wxPanel { public: From 7be1f69b49643f0c24dc46a907e72f58a7592b22 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Wed, 25 Sep 2024 00:10:53 +0800 Subject: [PATCH 23/26] fix --- src/slic3r/GUI/GUI_App.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 93aa86f6548..ac5c3158a0e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -9,10 +9,6 @@ #include "libslic3r_version.h" #include "Downloader.hpp" -#ifdef SERVER_ENGINE -#include "Engine.h" -#endif - // Localization headers: include libslic3r version first so everything in this file // uses the slic3r/GUI version (the macros will take precedence over the functions). // Also, there is a check that the former is not included from slic3r module. From 7082d13abe74b9daffdeecb5e6ad22f4a9bad622 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Wed, 25 Sep 2024 09:49:53 +0800 Subject: [PATCH 24/26] fix --- src/Snapmaker_Orca.cpp | 17 ----------- src/slic3r/GUI/GUI_App.cpp | 6 ++-- src/slic3r/GUI/Plater.cpp | 17 ++++------- src/slic3r/GUI/Plater.hpp | 61 ++++++++++++++++++++------------------ 4 files changed, 41 insertions(+), 60 deletions(-) diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index 82fcfc45f1b..02a2deac701 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -146,12 +146,6 @@ std::map cli_errors = { {CLI_GCODE_PATH_CONFLICTS, " G-code conflicts detected after slicing. Please make sure the 3mf file can be successfully sliced in the latest Snapmaker Orca."} }; -#ifdef SERVER_ENGINE -std::vector argv_narrow; -std::vector argv_ptrs; -bool g_exported = false; -#endif - typedef struct _sliced_plate_info{ int plate_id{0}; size_t sliced_time {0}; @@ -6269,11 +6263,8 @@ LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) extern "C" { __declspec(dllexport) int __stdcall Snapmaker_Orca_main(int argc, wchar_t **argv) { -#ifndef SERVER_ENGINE - // Convert wchar_t arguments to UTF8. std::vector argv_narrow; std::vector argv_ptrs(argc + 1, nullptr); -#endif argv_ptrs.resize(argc + 1, nullptr); @@ -6300,14 +6291,6 @@ extern "C" { #else /* _MSC_VER */ int main(int argc, char **argv) { - #ifdef SERVER_ENGINE - argv_ptrs.resize(argc + 1, nullptr); - for (size_t i = 0; i < argc; ++i) - argv_narrow.emplace_back(argv[i]); - for (size_t i = 0; i < argc; ++i) - argv_ptrs[i] = argv_narrow[i].data(); - #endif - return CLI().run(argc, argv); } #endif /* _MSC_VER */ diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index ac5c3158a0e..5c30ada2077 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2090,8 +2090,10 @@ bool GUI_App::OnInit() try { #ifdef SERVER_ENGINE - extern std::vector argv_narrow; - std::vector files = std::vector(argv_narrow.begin() + 1, argv_narrow.end()); + std::vector files; + for (size_t i = 0; i < this->init_params->argc; ++i) { + files.push_back(this->init_params->argv[i]); + } Slic3r::GUI::Snapmaker_Orca_Engine* engine = new Slic3r::GUI::Snapmaker_Orca_Engine(files); engine->init(); #endif diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f18a7fa801d..1f943a327aa 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -161,12 +161,6 @@ using namespace nlohmann; static const std::pair THUMBNAIL_SIZE_3MF = { 512, 512 }; -#ifdef SERVER_ENGINE -extern std::vector argv_narrow; -extern std::vector argv_ptrs; -extern bool g_exported; -#endif - namespace Slic3r { namespace GUI { @@ -6951,8 +6945,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false); #ifdef SERVER_ENGINE - extern bool g_exported; - g_exported = true; + Snapmaker_Orca_Engine::s_exported = true; #endif } @@ -14421,6 +14414,7 @@ SuppressBackgroundProcessingUpdate::~SuppressBackgroundProcessingUpdate() int Snapmaker_Orca_Engine::s_time_gui_load = 500; int Snapmaker_Orca_Engine::s_time_check_export = 100; int Snapmaker_Orca_Engine::s_time_delay_close = 500; +bool Snapmaker_Orca_Engine::s_exported = false; Snapmaker_Orca_Engine::Snapmaker_Orca_Engine(std::vector& user_inputs) : m_OriFiles(user_inputs) {} @@ -14461,11 +14455,10 @@ void Snapmaker_Orca_Engine::on_gui_loaded() } void Snapmaker_Orca_Engine::on_time_check() { - extern bool g_exported; - if (g_exported) { + if (s_exported) { m_check_export_timer->Stop(); - g_exported = false; + s_exported = false; ++m_task_index; @@ -14730,4 +14723,4 @@ void Snapmaker_Orca_Engine::export_gcode_server(bool prefer_removable) { } catch (...) {} } } -#endif SERVER_ENGINE \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 2e09aa4e9f6..55ba24c9e00 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -202,53 +202,56 @@ class Sidebar : public wxPanel #ifdef SERVER_ENGINE class Snapmaker_Orca_Engine : public wxEvtHandler - { - public: - // input the 3mf/.stl... files to engine - Snapmaker_Orca_Engine(std::vector& user_inputs); +{ +public: + // input the 3mf/.stl... files to engine + Snapmaker_Orca_Engine(std::vector& user_inputs); - void init(); + void init(); - void on_gui_loaded(); + void on_gui_loaded(); - void on_time_check(); + void on_time_check(); - void run_engine(); + void run_engine(); - void do_next_task(); + void do_next_task(); - void close_engine(); + void close_engine(); + +private: + void add_file_server(std::string& filePath); - private: - void add_file_server(std::string& filePath); + void slice_all_plates_server(); - void slice_all_plates_server(); + void export_gcode_server(bool prefer_removable); - void export_gcode_server(bool prefer_removable); +private: + std::vector m_OriFiles; - private: - std::vector m_OriFiles; + wxTimer* m_load_gui_timer = nullptr; - wxTimer* m_load_gui_timer = nullptr; + wxTimer* m_check_export_timer = nullptr; - wxTimer* m_check_export_timer = nullptr; + wxTimer* m_delay_close_timer = nullptr; - wxTimer* m_delay_close_timer = nullptr; +private: + GUI_App* m_gui_app = nullptr; - private: - GUI_App* m_gui_app = nullptr; + MainFrame* m_gui_main_frame = nullptr; - MainFrame* m_gui_main_frame = nullptr; + Plater* m_gui_plater = nullptr; - Plater* m_gui_plater = nullptr; + int m_task_index = 0; - int m_task_index = 0; - private: - static int s_time_gui_load; - static int s_time_check_export; - static int s_time_delay_close; - }; +public: + static bool s_exported; +private: + static int s_time_gui_load; + static int s_time_check_export; + static int s_time_delay_close; +}; #endif class Plater: public wxPanel From 195904d83dd2b3098ff81551c99c024225816949 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Wed, 25 Sep 2024 10:50:54 +0800 Subject: [PATCH 25/26] fix yml --- .github/workflows/build_orca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 566f3aedcd6..558c4dc5e2d 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -264,7 +264,7 @@ jobs: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} uses: actions/upload-artifact@v4 with: - name: Snapmaker_Orca_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} + name: Snapmaker_Orca_Engine_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} path: './build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' - name: Deploy Ubuntu-Engine release From 90607b4fe5282d63b8110940c9d8de09636f1886 Mon Sep 17 00:00:00 2001 From: womendoushihaoyin Date: Wed, 25 Sep 2024 11:41:26 +0800 Subject: [PATCH 26/26] fix yml --- .github/workflows/build_orca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 558c4dc5e2d..d2745f6785b 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -265,7 +265,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Snapmaker_Orca_Engine_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} - path: './build/Snapmaker_Orca_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' + path: './build/Snapmaker_Orca_Engine_Linux${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' - name: Deploy Ubuntu-Engine release if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-20.04' }}