From db50a0814e2fd49f60af7cbe812083872ee6caaa Mon Sep 17 00:00:00 2001 From: QIDI TECH <893239786@qq.com> Date: Thu, 28 Nov 2024 14:53:09 +0800 Subject: [PATCH] Update dependency --- BuildLinux.sh | 2 +- CMakeLists.txt | 61 ++++++++++++ cmake/modules/MacOSXBundleInfo.plist.in | 7 +- deps/Boost/0001-Boost-fix.patch | 2 +- deps/Boost/Boost.cmake | 2 +- deps/CMakeLists.txt | 7 ++ deps/FFMPEG/FFMPEG.cmake | 60 ++++++++++++ deps/GMP/GMP.cmake | 2 +- deps/wxWidgets/wxWidgets.cmake | 2 +- doc/Localization_guide.md | 8 +- doc/release_notes_cn.md | 2 +- doc/release_notes_en.md | 2 +- linux.d/debian | 9 +- linux.d/fedora | 5 + .../qds_gcode_checker/GCodeChecker.cpp | 98 +++++++++++++++++-- .../qds_gcode_checker/GCodeChecker.h | 5 +- version.inc | 2 - 17 files changed, 250 insertions(+), 26 deletions(-) create mode 100644 deps/FFMPEG/FFMPEG.cmake diff --git a/BuildLinux.sh b/BuildLinux.sh index 9cf48cf..0860905 100644 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -119,7 +119,7 @@ fi if ! [[ -n "${DISABLE_PARALLEL_LIMIT}" ]] then FREE_MEM_GB=$(free -g -t | grep 'Mem' | rev | cut -d" " -f1 | rev) - MAX_THREADS=$(echo "scale=0; $FREE_MEM_GB / 2.5" | bc) + MAX_THREADS=$((FREE_MEM_GB * 10 / 25)) if [ "$MAX_THREADS" -lt 1 ]; then export CMAKE_BUILD_PARALLEL_LEVEL=1 else diff --git a/CMakeLists.txt b/CMakeLists.txt index 202403d..ee79eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ set(SLIC3R_GTK "2" CACHE STRING "GTK version to use with wxWidgets on Linux") set(IS_CROSS_COMPILE FALSE) +set(FLATPAK FALSE CACHE BOOL "Not copy FFMPEG file") if (APPLE) set(CMAKE_FIND_FRAMEWORK LAST) @@ -54,6 +55,8 @@ if (APPLE) set(CMAKE_INSTALL_RPATH @executable_path/../Frameworks) endif() set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(CMAKE_INSTALL_RPATH "$ORIGIN") endif () # Proposal for C++ unit tests and sandboxes @@ -167,6 +170,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # WIN10SDK_PATH is used to point CMake to the WIN10 SDK installation directory. # We pick it from environment if it is not defined in another way if(WIN32) + find_package(PkgConfig REQUIRED) if(NOT DEFINED WIN10SDK_PATH) if(DEFINED ENV{WIN10SDK_PATH}) set(WIN10SDK_PATH "$ENV{WIN10SDK_PATH}") @@ -619,6 +623,10 @@ function(qidistudio_copy_dlls target config postfix output_dlls) ${CMAKE_PREFIX_PATH}/bin/occt/TKXDESTEP.dll ${CMAKE_PREFIX_PATH}/bin/occt/TKXSBase.dll ${CMAKE_PREFIX_PATH}/bin/freetype.dll + ${CMAKE_PREFIX_PATH}/bin/avcodec-61.dll + ${CMAKE_PREFIX_PATH}/bin/swresample-5.dll + ${CMAKE_PREFIX_PATH}/bin/swscale-8.dll + ${CMAKE_PREFIX_PATH}/bin/avutil-59.dll DESTINATION ${_out_dir}) set(${output_dlls} @@ -654,11 +662,50 @@ function(qidistudio_copy_dlls target config postfix output_dlls) ${_out_dir}/TKXSBase.dll ${_out_dir}/freetype.dll + ${_out_dir}/avcodec-61.dll + ${_out_dir}/swresample-5.dll + ${_out_dir}/swscale-8.dll + ${_out_dir}/avutil-59.dll PARENT_SCOPE ) endfunction() +function(qidistudio_copy_sos target config postfix output_sos) + + set(_out_dir "${CMAKE_CURRENT_BINARY_DIR}") + message ("set out_dir to CMAKE_CURRENT_BINARY_DIR: ${_out_dir}") + + file(COPY ${CMAKE_PREFIX_PATH}/lib/libavcodec.so + ${CMAKE_PREFIX_PATH}/lib/libavcodec.so.61 + ${CMAKE_PREFIX_PATH}/lib/libavcodec.so.61.3.100 + ${CMAKE_PREFIX_PATH}/lib/libavutil.so + ${CMAKE_PREFIX_PATH}/lib/libavutil.so.59 + ${CMAKE_PREFIX_PATH}/lib/libavutil.so.59.8.100 + ${CMAKE_PREFIX_PATH}/lib/libswscale.so + ${CMAKE_PREFIX_PATH}/lib/libswscale.so.8 + ${CMAKE_PREFIX_PATH}/lib/libswscale.so.8.1.100 + ${CMAKE_PREFIX_PATH}/lib/libswresample.so + ${CMAKE_PREFIX_PATH}/lib/libswresample.so.5 + ${CMAKE_PREFIX_PATH}/lib/libswresample.so.5.1.100 + DESTINATION ${_out_dir}) + + set(${output_dlls} + ${_out_dir}/libavcodec.so + ${_out_dir}/libavcodec.so.61 + ${_out_dir}/libavcodec.so.61.3.100 + ${_out_dir}/libavutil.so + ${_out_dir}/libavutil.so.59 + ${_out_dir}/libavutil.so.59.8.100 + ${_out_dir}/libswscale.so + ${_out_dir}/libswscale.so.8 + ${_out_dir}/libswscale.so.8.1.100 + ${_out_dir}/libswresample.so + ${_out_dir}/libswresample.so.5 + ${_out_dir}/libswresample.so.5.1.100 + PARENT_SCOPE + ) +endfunction() # libslic3r, QIDIStudio GUI and the QIDIStudio executable. add_subdirectory(src) @@ -714,4 +761,18 @@ else () install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources") endif () +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT FLATPAK) + set(LIBRARY_FILES + ${LIBDIR_BIN}/libavcodec.so.61 + ${LIBDIR_BIN}/libavcodec.so.61.3.100 + ${LIBDIR_BIN}/libavutil.so.59 + ${LIBDIR_BIN}/libavutil.so.59.8.100 + ${LIBDIR_BIN}/libswresample.so.5 + ${LIBDIR_BIN}/libswresample.so.5.1.100 + ${LIBDIR_BIN}/libswscale.so.8 + ${LIBDIR_BIN}/libswscale.so.8.1.100 + ) + install(FILES ${LIBRARY_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") +endif () + configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp) diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in index 3e92b9d..aa9aa10 100644 --- a/cmake/modules/MacOSXBundleInfo.plist.in +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -11,7 +11,7 @@ CFBundleIconFile ${MACOSX_BUNDLE_ICON_FILE} CFBundleIdentifier - com.qidilab.qidi-studio + com.qiditech.qidi-studio CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString @@ -129,5 +129,10 @@ NSHumanReadableCopyright ${MACOSX_BUNDLE_COPYRIGHT} + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/deps/Boost/0001-Boost-fix.patch b/deps/Boost/0001-Boost-fix.patch index 9c6cf6f..7d8d154 100644 --- a/deps/Boost/0001-Boost-fix.patch +++ b/deps/Boost/0001-Boost-fix.patch @@ -1,5 +1,5 @@ From 1d6cd7c2f8640db3cda194c1b9b82f1e4b321395 Mon Sep 17 00:00:00 2001 -From: "chunmao.guo" +From: "chunmao.guo" Date: Thu, 5 Jan 2023 15:55:57 +0800 Subject: [PATCH] FIX: limit_handles diff --git a/deps/Boost/Boost.cmake b/deps/Boost/Boost.cmake index bc7e20c..16d4a32 100644 --- a/deps/Boost/Boost.cmake +++ b/deps/Boost/Boost.cmake @@ -129,7 +129,7 @@ list(APPEND _patch_command COMMAND git init && ${PATCH_CMD} ${CMAKE_CURRENT_LIST ExternalProject_Add( dep_Boost #URL "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.zip" - URL "https://github.com/qidilab/boost/releases/download/1.78.0/boost_1_78_0.zip" + URL "https://github.com/qiditech/boost/releases/download/1.78.0/boost_1_78_0.zip" URL_HASH SHA256=f22143b5528e081123c3c5ed437e92f648fe69748e95fa6e2bd41484e2986cc3 DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/Boost CONFIGURE_COMMAND "${_bootstrap_cmd}" diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index f2decd5..f2be137 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -39,6 +39,7 @@ option(DEP_BUILD_OPENSSL "Compile openssl" ON) option(DEP_BUILD_GLFW "Compile GLFW" ON) option(DEP_BUILD_FREETYPE "Compile freetype" ON) option(DEP_BUILD_WXWIDGETS "Compile wxWidgets" ON) +option(DEP_BUILD_FFMPEG "Compile ffmpeg" ON) set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") set(DEP_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Path for downloaded source packages.") @@ -229,6 +230,11 @@ if (DEP_BUILD_FREETYPE) endif () include(OCCT/OCCT.cmake) include(OpenCV/OpenCV.cmake) +set(FFMPEG_PKG "") +if (DEP_BUILD_FFMPEG) + include(FFMPEG/FFMPEG.cmake) + set(FFMPEG_PKG dep_FFMPEG) +endif () set(_dep_list ${BOOST_PKG} @@ -247,6 +253,7 @@ set(_dep_list ${ZLIB_PKG} ${EXPAT_PKG} ${FREETYPE_PKG} + ${FFMPEG_PKG} ) if (MSVC) diff --git a/deps/FFMPEG/FFMPEG.cmake b/deps/FFMPEG/FFMPEG.cmake new file mode 100644 index 0000000..080d6a9 --- /dev/null +++ b/deps/FFMPEG/FFMPEG.cmake @@ -0,0 +1,60 @@ +set(_conf_cmd ./configure) + +if (MSVC) + set(_dstdir ${DESTDIR}/usr/local) + set(_source_dir "${CMAKE_BINARY_DIR}/dep_FFMPEG-prefix/src/dep_FFMPEG") + ExternalProject_Add(dep_FFMPEG + URL https://github.com/qiditech/ffmpeg_prebuilts/releases/download/7.0.2/7.0.2_msvc.zip + URL_HASH SHA256=DF44AE6B97CE84C720695AE7F151B4A9654915D1841C68F10D62A1189E0E7181 + DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/FFMPEG + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND + # COMMAND ${CMAKE_COMMAND} -E make_directory "${_dstdir}/bin" + # COMMAND ${CMAKE_COMMAND} -E make_directory "${_dstdir}/lib" + # COMMAND ${CMAKE_COMMAND} -E make_directory "${_dstdir}/include" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_source_dir}/bin" "${_dstdir}/bin" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_source_dir}/lib" "${_dstdir}/lib" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_source_dir}/include" "${_dstdir}/include" + ) + +else () + set(_extra_cmd "--pkg-config-flags=\"--static\"") + string(APPEND _extra_cmd "--extra-cflags=\"-I ${DESTDIR}/usr/local/include\"") + string(APPEND _extra_cmd "--extra-ldflags=\"-I ${DESTDIR}/usr/local/lib\"") + string(APPEND _extra_cmd "--extra-libs=\"-lpthread -lm\"") + string(APPEND _extra_cmd "--ld=\"g++\"") + string(APPEND _extra_cmd "--bindir=\"${DESTDIR}/usr/local/bin\"") + string(APPEND _extra_cmd "--enable-gpl") + string(APPEND _extra_cmd "--enable-nonfree") + + + ExternalProject_Add(dep_FFMPEG + URL https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.0.2.tar.gz + URL_HASH SHA256=5EB46D18D664A0CCADF7B0ADEE03BD3B7FA72893D667F36C69E202A807E6D533 + DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/FFMPEG + CONFIGURE_COMMAND ${_conf_cmd} + "--prefix=${DESTDIR}/usr/local" + "--enable-shared" + "--disable-doc" + "--enable-small" + "--disable-outdevs" + "--disable-filters" + "--enable-filter=*null*,afade,*fifo,*format,*resample,aeval,allrgb,allyuv,atempo,pan,*bars,color,*key,crop,draw*,eq*,framerate,*_qsv,*_vaapi,*v4l2*,hw*,scale,volume,test*" + "--disable-protocols" + "--enable-protocol=file,fd,pipe,rtp,udp" + "--disable-muxers" + "--enable-muxer=rtp" + "--disable-encoders" + "--disable-decoders" + "--enable-decoder=*aac*,h264*,mp3*,mjpeg,rv*" + "--disable-demuxers" + "--enable-demuxer=h264,mp3,mov" + "--disable-zlib" + "--disable-avdevice" + BUILD_IN_SOURCE ON + BUILD_COMMAND make -j + INSTALL_COMMAND make install + ) + +endif() \ No newline at end of file diff --git a/deps/GMP/GMP.cmake b/deps/GMP/GMP.cmake index b5d377a..90209fd 100644 --- a/deps/GMP/GMP.cmake +++ b/deps/GMP/GMP.cmake @@ -43,7 +43,7 @@ else () endif () ExternalProject_Add(dep_GMP - URL https://github.com/qidilab/gmp/archive/refs/tags/6.2.1.tar.gz + URL https://github.com/qiditech/gmp/archive/refs/tags/6.2.1.tar.gz URL_HASH SHA256=705ae57ee2014b2c6fc0f572c85ee43276b99b6b256ee16c1a9d3a8c4e3609d5 DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/GMP BUILD_IN_SOURCE ON diff --git a/deps/wxWidgets/wxWidgets.cmake b/deps/wxWidgets/wxWidgets.cmake index 595ce6d..978b294 100644 --- a/deps/wxWidgets/wxWidgets.cmake +++ b/deps/wxWidgets/wxWidgets.cmake @@ -23,7 +23,7 @@ endif () # endif () qidistudio_add_cmake_project(wxWidgets - GIT_REPOSITORY "https://github.com/bambulab/wxWidgets" + GIT_REPOSITORY "https://github.com/qiditech/wxWidgets" GIT_TAG master DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} ${TIFF_PKG} ${JPEG_PKG} CMAKE_ARGS diff --git a/doc/Localization_guide.md b/doc/Localization_guide.md index 4fdceb3..02e256e 100644 --- a/doc/Localization_guide.md +++ b/doc/Localization_guide.md @@ -13,7 +13,7 @@ Full manual for GNUgettext can be seen here: http://www.gnu.org/software/gettext ### Scenario 1. How do I add a translation or fix an existing translation 1. Get PO-file 'QIDIStudio_xx.pot' from corresponding sub-folder here: -https://github.com/qidilab/QIDIStudio/tree/master/qdt/i18n +https://github.com/qiditech/QIDIStudio/tree/master/qdt/i18n 2. Open this file in PoEdit as "Edit a translation" 3. Apply your corrections to the translation 4. Push changed QIDIStudio_xx.po into the original folder @@ -21,14 +21,14 @@ https://github.com/qidilab/QIDIStudio/tree/master/qdt/i18n ### Scenario 2. How do I add a new language support 1. Get file QIDIStudio.pot here : -https://github.com/qidilab/QIDIStudio/tree/master/qdt/i18n +https://github.com/qiditech/QIDIStudio/tree/master/qdt/i18n 2. Open it in PoEdit for "Create new translation" 3. Select Translation Language (for example French). 4. As a result you will have fr.po - the file containing translation to French. Notice. When the translation is complete you need to: - Rename the file to QIDIStudio_fr.po - Click "Save file" button. QIDIStudio_fr.mo will be created immediately - - QIDI_Studio_fr.po needs to be copied into the sub-folder fr of https://github.com/qidilab/QIDIStudio/tree/master/qdt/i18n, and be pushed + - QIDI_Studio_fr.po needs to be copied into the sub-folder fr of https://github.com/qiditech/QIDIStudio/tree/master/qdt/i18n, and be pushed - copy QIDIStudio_xx.mo into resources/i18n/xx and rename it to QIDIStudio.mo, then push the changed file. ( name of folder "fr" means "French" - the translation language). @@ -43,7 +43,7 @@ If you add new file resource, add it to the list of files containing macro `L()` ### Scenario 4. How do I use GNUgettext to localize my own application taking QIDI Studio as an example 1. For convenience create a list of files with this macro `L(s)`. We have -https://github.com/qidilab/QIDIStudio/blob/master/qdt/i18n/list.txt. +https://github.com/qiditech/QIDIStudio/blob/master/qdt/i18n/list.txt. 2. Create template file(*.POT) with GNUgettext command: ``` diff --git a/doc/release_notes_cn.md b/doc/release_notes_cn.md index 079aab6..366154e 100644 --- a/doc/release_notes_cn.md +++ b/doc/release_notes_cn.md @@ -15,4 +15,4 @@ 7. 支持匈牙利语 8. 一些关键问题修复 -详细信息请查看:https://github.com/qidilab/QIDIStudio/releases +详细信息请查看:https://github.com/qiditech/QIDIStudio/releases diff --git a/doc/release_notes_en.md b/doc/release_notes_en.md index 69d1d02..bf3fc7b 100644 --- a/doc/release_notes_en.md +++ b/doc/release_notes_en.md @@ -15,4 +15,4 @@ 7. Added Magyar translations 8. Fixed some known bugs -For details, please check https://github.com/qidilab/QIDIStudio/releases +For details, please check https://github.com/qiditech/QIDIStudio/releases diff --git a/linux.d/debian b/linux.d/debian index b519d2e..071fcb1 100644 --- a/linux.d/debian +++ b/linux.d/debian @@ -27,16 +27,19 @@ REQUIRED_DEV_PACKAGES=( libunwind-dev libfuse2 texinfo + nasm + yasm + libx264-dev ) if [[ -n "$UPDATE_LIB" ]] then # for ubuntu 22+ and 23+: ubu_major_version="$(grep VERSION_ID /etc/os-release | cut -d "=" -f 2 | cut -d "." -f 1 | tr -d /\"/)" - if [ $ubu_major_version == "22" ] || [ $ubu_major_version == "23" ] + if [ $ubu_major_version = "22" ] || [ $ubu_major_version = "23" ] then REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.0-dev curl libfuse-dev libssl-dev libcurl4-openssl-dev m4) - elif [ $ubu_major_version == "24" ] + elif [ $ubu_major_version = "24" ] then REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.1-dev) else @@ -56,4 +59,4 @@ then exit 0 fi -FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '') \ No newline at end of file +FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '') diff --git a/linux.d/fedora b/linux.d/fedora index dd48349..8a95539 100644 --- a/linux.d/fedora +++ b/linux.d/fedora @@ -35,6 +35,9 @@ REQUIRED_DEV_PACKAGES=( wget libcurl-devel libquadmath-devel + nasm + yasm + x264-devel ) if [[ -n "$UPDATE_LIB" ]] @@ -52,6 +55,8 @@ then done if [ -n "${NEEDED_PKGS}" ]; then + sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm + sudo dnf -y update sudo dnf install -y ${NEEDED_PKGS} fi echo -e "done\n" diff --git a/qds_test_tools/qds_gcode_checker/GCodeChecker.cpp b/qds_test_tools/qds_gcode_checker/GCodeChecker.cpp index 820685c..b49475d 100644 --- a/qds_test_tools/qds_gcode_checker/GCodeChecker.cpp +++ b/qds_test_tools/qds_gcode_checker/GCodeChecker.cpp @@ -17,9 +17,12 @@ const std::string Extrusion_Role_Tag = " FEATURE: "; const std::string Width_Tag = " LINE_WIDTH: "; const std::string Wipe_Start_Tag = " WIPE_START"; const std::string Wipe_End_Tag = " WIPE_END"; +const std::string Wipe_Tower_Start_Tag = " WIPE_TOWER_START"; +const std::string Wipe_Tower_End_Tag = " WIPE_TOWER_END"; const std::string Layer_Change_Tag = " CHANGE_LAYER"; const std::string Height_Tag = " LAYER_HEIGHT: "; const std::string filament_flow_ratio_tag = " filament_flow_ratio"; +const std::string has_scarf_joint_seam_tag = " has_scarf_joint_seam"; const std::string nozzle_temperature_Tag = " nozzle_temperature ="; const std::string nozzle_temperature_initial_layer_Tag = " nozzle_temperature_initial_layer"; const std::string Z_HEIGHT_TAG = " Z_HEIGHT: "; @@ -130,6 +133,12 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line) m_wiping = true; } else if (starts_with(comment, Wipe_End_Tag)) { m_wiping = false; + } + else if (starts_with(comment, Wipe_Tower_Start_Tag)) { + is_wipe_tower = true; + } + else if (starts_with(comment, Wipe_Tower_End_Tag)) { + is_wipe_tower = false; } else if (starts_with(comment, Height_Tag)) { std::string str = comment.substr(Height_Tag.size()); if (!parse_double_from_str(str, m_height)) { @@ -162,6 +171,11 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line) return GCodeCheckResult::ParseFailed; } } + else if (starts_with(comment, has_scarf_joint_seam_tag)) + { + std::string str = comment.substr(has_scarf_joint_seam_tag.size() + 3); + has_scarf_joint_seam = (str == "1"); + } else if (starts_with(comment, nozzle_temperature_Tag)) { std::string str = comment.substr(nozzle_temperature_Tag.size() + 1); if (!parse_double_from_str(str, nozzle_temperature)) { @@ -232,6 +246,10 @@ GCodeCheckResult GCodeChecker::parse_command(GCodeLine& gcode_line) ret = parse_M104_M109(gcode_line); break; } // Set to nozzle temperature + case 1020: { + ret = parse_M1020(gcode_line); + break; + } default: { break; } } break; @@ -407,20 +425,31 @@ GCodeCheckResult GCodeChecker::parse_G92(GCodeLine& gcode_line) return GCodeCheckResult::ParseFailed; } - if (gcode_line.has(X)) + bool any_found = false; + if (gcode_line.has(X)){ m_origin[X] = m_end_position[X] - gcode_line.get(X); + any_found = true; + } - if (gcode_line.has(Y)) + if (gcode_line.has(Y)){ m_origin[Y] = m_end_position[Y] - gcode_line.get(Y); + any_found = true; + } - if (gcode_line.has(Z)) + if (gcode_line.has(Z)){ m_origin[Z] = m_end_position[Z] - gcode_line.get(Z); + any_found = true; + } - if (gcode_line.has(E)) + if (gcode_line.has(E)){ m_end_position[E] = gcode_line.get(E); + any_found = true; + } - for (unsigned char a = X; a <= E; ++a) { - m_origin[a] = m_end_position[a]; + if (!any_found) { + for (unsigned char a = X; a <= E; ++a) { + m_origin[a] = m_end_position[a]; + } } return GCodeCheckResult::Success; @@ -469,6 +498,46 @@ GCodeCheckResult GCodeChecker::parse_M104_M109(const GCodeLine &gcode_line) return GCodeCheckResult::Success; } +GCodeCheckResult GCodeChecker::parse_M1020(const GCodeLine& gcode_line) +{ + const char* c = gcode_line.m_raw.c_str(); + const char* rs = strchr(c, 'S'); + + if (rs != nullptr) { + std::string str = rs; + str = str.substr(1); + for (int i = 0; i < str.size(); i++) { + if (str[i] == ' ') + str = str.substr(0, i); + } + + try { + int value = std::stoi(str); + if (value >= 0 && value <= filament_flow_ratio.size() - 1) { + filament_id = value; + flow_ratio = filament_flow_ratio[value]; + return GCodeCheckResult::Success; + } + else { + return GCodeCheckResult::ParseFailed; + } + } + catch (std::invalid_argument&) { + std::cout << "Invalid argument: not a valid integer" << std::endl; + return GCodeCheckResult::ParseFailed; + } + catch (std::out_of_range&) { + std::cout << "Out of range: number is too large" << std::endl; + return GCodeCheckResult::ParseFailed; + } + } + else + { + std::cout << "Missing 'S' character in the G-code line!" << std::endl; + return GCodeCheckResult::ParseFailed; + } +} + double GCodeChecker::calculate_G1_width(const std::array& source, const std::array& target, double e, double height, bool is_bridge) const @@ -593,8 +662,21 @@ GCodeCheckResult GCodeChecker::check_G0_G1_width(const GCodeLine& line) std::array target = { m_end_position[X], m_end_position[Y], m_end_position[Z] }; bool is_bridge = m_role == erOverhangPerimeter || m_role == erBridgeInfill; - if (!is_bridge) { - double width_real = calculate_G1_width(source, target, delta_pos[E], m_height, is_bridge); + if (!is_bridge && !is_wipe_tower) { + double real_height = m_height; + if (line.has(Z) && has_scarf_joint_seam && line.get(Z) != 0) + { + if (line.get(Z) == z_height) + { + return GCodeCheckResult::Success; + } + if (line.get(Z) && line.get(E)) + { + return GCodeCheckResult::Success; + } + real_height = line.get(Z) - (z_height - m_height); + } + double width_real = calculate_G1_width(source, target, delta_pos[E], real_height, is_bridge); if (fabs(width_real - m_width) > WIDTH_THRESHOLD) { std::cout << "Invalid G0_G1 because has abnormal line width." << std::endl; std::cout << "Width: " << m_width << " Width_real: " << width_real << std::endl; diff --git a/qds_test_tools/qds_gcode_checker/GCodeChecker.h b/qds_test_tools/qds_gcode_checker/GCodeChecker.h index 8c7fbc9..d4b9e8f 100644 --- a/qds_test_tools/qds_gcode_checker/GCodeChecker.h +++ b/qds_test_tools/qds_gcode_checker/GCodeChecker.h @@ -109,6 +109,7 @@ private: GCodeCheckResult parse_M82(const GCodeLine& gcode_line); GCodeCheckResult parse_M83(const GCodeLine& gcode_line); GCodeCheckResult parse_M104_M109(const GCodeLine &gcode_line); + GCodeCheckResult parse_M1020(const GCodeLine& gcode_line); GCodeCheckResult parse_comment(GCodeLine& gcode_line); @@ -167,7 +168,7 @@ public: std::string cmd=input; size_t read = 0; - while (cmd.size() >= 5) + while (cmd.find(',') != std::string::npos) { int pt = 0; for (pt = 0; pt < cmd.size(); pt++) { @@ -217,6 +218,8 @@ private: std::vector filament_flow_ratio; std::vector nozzle_temperature; std::vector nozzle_temperature_initial_layer; + bool has_scarf_joint_seam = false; + bool is_wipe_tower = false; }; } diff --git a/version.inc b/version.inc index f797828..d4607d9 100644 --- a/version.inc +++ b/version.inc @@ -7,8 +7,6 @@ set(SLIC3R_APP_KEY "QIDIStudio") if(NOT DEFINED QDT_RELEASE_TO_PUBLIC) set(QDT_RELEASE_TO_PUBLIC "0") endif() -# Note that defining QDT_INTERNAL_TESTING will create a beta version -# not an "internal testing" version (the default) if(NOT DEFINED QDT_INTERNAL_TESTING) set(QDT_INTERNAL_TESTING "1") endif()