diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 2c7b2920831..d2745f6785b 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -247,6 +247,37 @@ jobs: shell: bash run: sudo chown $USER -R ./ + - 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_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: 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-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 + - name: Build slicer if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash @@ -256,16 +287,7 @@ jobs: ./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: @@ -275,7 +297,8 @@ 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: Deploy Ubuntu release if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} env: @@ -289,6 +312,15 @@ jobs: 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 + - 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 @@ -298,4 +330,4 @@ jobs: 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 + max_releases: 1 \ No newline at end of file diff --git a/BuildLinux.sh b/BuildLinux.sh index defc337441c..2a2bb2fe6a6 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -25,22 +25,23 @@ 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" 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'" } unset name -while getopts ":1bcdghirsu" opt; do +while getopts ":1bcdeghirsu" opt; do case ${opt} in 1 ) export CMAKE_BUILD_PARALLEL_LEVEL=1 @@ -54,6 +55,9 @@ while getopts ":1bcdghirsu" opt; do d ) BUILD_DEPS="1" ;; + e ) + BUILD_ENGINE="1" + ;; h ) usage exit 0 ;; @@ -151,6 +155,11 @@ then then BUILD_ARGS="-DSLIC3R_GTK=3" fi + if [[ -n "${BUILD_ENGINE}" ]] + then + echo "BUILD_ENGINE=ON" + BUILD_ARGS="${BUILD_ARGS} -DSERVER_ENGINE=ON" + fi if [[ -n "${BUILD_DEBUG}" ]] then BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1" @@ -166,6 +175,7 @@ then echo "done" echo "Building Snapmaker_Orca ..." cmake --build build --target Snapmaker_Orca + echo "Building Snapmaker_Orca_profile_validator .." cmake --build build --target Snapmaker_Orca_profile_validator ./run_gettext.sh @@ -187,3 +197,4 @@ echo "[9/9] Generating Linux app..." popd echo "done" fi + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 57217d6cea7..09ce1054ded 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 () @@ -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 () @@ -738,7 +742,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 +792,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..819102664cf 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 () add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp) + endif () if (MINGW) @@ -130,12 +131,14 @@ 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") + 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 () + target_link_libraries(Snapmaker_Orca libslic3r cereal::cereal) + if (APPLE) # add_compile_options(-stdlib=libc++) # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) @@ -152,7 +155,8 @@ 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) + target_link_libraries(Snapmaker_Orca libslic3r_gui) + if (MSVC) # Generate debug symbols even in release mode. target_link_options(Snapmaker_Orca PUBLIC "$<$:/DEBUG>") @@ -163,6 +167,7 @@ target_link_libraries(Snapmaker_Orca libslic3r_gui) target_link_libraries(Snapmaker_Orca "-framework OpenGL") else () target_link_libraries(Snapmaker_Orca -ldl) + endif () #if (WIN32) # find_library(PSAPI_LIB NAMES Psapi) @@ -184,7 +189,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,13 +237,14 @@ 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 () add_custom_command(TARGET Snapmaker_Orca POST_BUILD - WORKING_DIRECTORY "$" - VERBATIM) + WORKING_DIRECTORY "$" + VERBATIM) + endif () if (XCODE) # Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level @@ -252,16 +258,19 @@ 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 - COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" - COMMENT "Symlinking the resources directory into the build tree" - VERBATIM) + COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}" + COMMENT "Symlinking the resources directory into the build tree" + VERBATIM) + endif () # Slic3r binary install target. Default build type is release in case no CMAKE_BUILD_TYPE is provided. diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index 537f033309a..02a2deac701 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -6024,7 +6024,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 +6263,11 @@ LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) extern "C" { __declspec(dllexport) int __stdcall Snapmaker_Orca_main(int argc, wchar_t **argv) { - // 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); + + 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) 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/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 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..5c30ada2077 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -827,6 +827,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 +2088,16 @@ void GUI_App::init_single_instance_checker(const std::string &name, const std::s bool GUI_App::OnInit() { try { + + #ifdef SERVER_ENGINE + 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 + return on_init_inner(); } catch (const std::exception&) { generic_exception_handle(); @@ -2224,6 +2239,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, @@ -2237,6 +2256,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. @@ -2379,6 +2399,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..1f943a327aa 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6941,10 +6941,15 @@ 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 + Snapmaker_Orca_Engine::s_exported = true; + #endif + } + + // BBS, Generate calibration thumbnail for current plate if (!has_error && preview) { // generate calibration data @@ -11027,6 +11032,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(""); @@ -14398,3 +14408,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; +bool Snapmaker_Orca_Engine::s_exported = false; + +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() { + if (s_exported) { + m_check_export_timer->Stop(); + + s_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 \ No newline at end of file diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 52f0706e897..55ba24c9e00 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -199,6 +199,61 @@ 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; + +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 { public: @@ -813,6 +868,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;