Files
OrcaSlicer-KX/src/slic3r/Utils/CalibUtils.cpp
SoftFever 226450ea6a Merge some features from BS1.9 beta4 (#5181)
* FIX: linux: fix the building issue on Linux Mint 21.3 Virginia

github: https://github.com/bambulab/BambuStudio/issues/3874
author: https://github.com/lucianoloder

Change-Id: Ia3db6923d5dd68dba532d7bdba6f93f73cc51d59

* FIX: auto-arranging incorrect with rotation enabled

auto-arranging incorrect with rotation enabled and the objects already have been rotated.

jira: STUDIO-6022
Change-Id: I349d663efb1fc71367c8a77aa8ed5047a0bf2017
(cherry picked from commit 75fe40257a274ed83886e1ee20ce8dedd0de48f6)

* ENH: update X1C & X1E start gcode

1.Fix fan problem

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I68ee5be78e142e8a2a210a1a70f5663893390610

* ENH: update A series gcode

1. Update A1 series start gcode and change filament gcode
2. Add G2814 command
3. Add multi-filament extrusion compensation and vibration suppression

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I57d2bc8e98d3e547881dc1369c1fb31413c6205d

* FIX: fix some cali problem of P series

jira: none
Change-Id: Id57ea8d65da22ab653cca49509cb923ff065e43f

* FIX: fix can't enter ',' in multiplicator

github: #3805

Change-Id: I6dd70822d1c2e79d66c70514d6dd580ab029c7ea

* calib wizard

* NEW: FlipLines infill

jira:6701

New infill pattern that combine block lines infill and switching layers for smooth transition.

Change-Id: I2608a2d39b14efcdfe9d39a9437280da350b94c0
(cherry picked from commit 8d0a09c8b763dfc924cbba9913c241e6afadbc7f)

* ENH: add nozzle blob detection and air printing detection

jira: new

Change-Id: Ie4a19a7ad7d0b10a021c516cbc3a84b4ae734302

* FIX: Top surface bridging fail on 3DHC & FL infill

Add 45 degree angle offset when processing the bridge.
Need to raise infill_direction to invalidate posPrepareInfill

jira: 6774
Change-Id: I5e6bef3aa814b01c5f30398ac745937a67e3ef4c
(cherry picked from commit 7b12cab10b88f432a11414f8caa1c6427777a1ba)

* FIX: the error display when reset virtual slot

jira: none
Change-Id: I5ae5899baf1bfc2aaadb832083b277855a669fd5

* FIX: Error "Voronoi cell doesn't contain a sourcepoint"

github: 3859
Change-Id: Idca84992bcba5380bfe05e63ac9a5e40419dcfdf

* fix build error

* FIX: CLI: fix the crash issue caused by get_min_flush_volumes

JIRA: no jira
Change-Id: I0d5bfd605e51ebddac8fddc4d83dab5055b0fbf2

* FIX: can't use support filament in gcode.3mf

1. Add total_filament_volumes, directly access it to get used filaments

github:#3865

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I4fae4f1947b4ebd16e394e0f3cf5fb0e9f979717

* ENH: p series support long retraction

1. P series support long retraction in filament
2. Add long retraction params in common.json

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ib94184fa1f0b5ab151360f1f053d8c8ff92e7e18

* ENH::modify some logs level

jira:[for log]

Change-Id: I6a46b8fcd3a030b4b630e800fe9a9ac5c387f117

* NEW: support multi device

JIRA: STUDIO-6072

Change-Id: Ic514c4097767b0a728368c9ea48ee103c031fbb0
Signed-off-by: Stone Li <stone.li@bambulab.com>

* ENH: update A1 series  gcode

1.Update filament change gcode and machine start gcode for
  A1 and A1 mini

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I2f3be3fd89fef21e717a32f2b89985fc046f7f6e

* FIX: always have 0th filament in ams mapping

1. Only set the filament id in map when flush length is not 0

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I6e0aeaf010f6e6dcbdc3bca5c0034aa60750bb67

* ENH: add filament id in slice info

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ic5fe4632bca8acacc9ffd072ee2ed207c1da37aa

* ENH: refine ui for multi machine

JIRA: STUDIO-6819 STUDIO-6824
1. Shrink the Send Print dialog box
2. add input box for flipping panel

Change-Id: I4174c79ecd239c374ee11478951e12be399c57ce

* FIX: fix Issues with sending multiple devices

JIRA: STUDIO-6876

Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Change-Id: I33c6a932863fc715c3f0eb5dfd4b299f980a4918

* NEW: support hms error code

Change-Id: Ic256a83cf501fb05bb9d3203f3d24cb1d1290fa4

* FIX:fixed some multi job issue

Change-Id: I338078ad8fcf809888db9d8daeb470a9bf4eab46

* NEW:support pin code binding

Change-Id: Ida5d47881fbd83f3ffedc80369cfe377114d7f13

* ENH:add printable check for devices

Change-Id: I672988fa9cfa986d924bfc64331752f4aef68067
(cherry picked from commit 69de9e5b8334ec94eec7fcee31038b8ff42d1d3b)

* FIX: add more fonts

jira: none
Change-Id: I6bafed3563083858f29e92a3d84906a2e53dcb5c
(cherry picked from commit afbea693e807dcc1c406a59aa5376b9ea2a5d606)

* ENH: load more fonts

this feature is according to Prusa by Filip Sykala<filip.sykala@prusa3d.cz>, thanks to Filip Sykala
jira: none
Change-Id: I55e92f184f750c0b93b679d4382aaa5b164ec5c3
(cherry picked from commit d05522c4cc5d7ee4cac42de398b88d347a55f74b)

* ENH: add ProfileDescription for translate

1.Add ProfileDescription.hpp simply for translating

jira:NEW

Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com>
Change-Id: Iaa3ced1edccf67eaeebde35c1e8b36442d2e9a6f

* ENH: Improve CrossHatch transation layers

jira: 6701

Change name from Flippingline to CrossHatch.

Reduce noise, improve speed by 6.5%. Improve transation layers by
gradually increasing rotation angle and overshoot the transation
layer while direction changed.

Change-Id: I17fcc45b409074d121bf5bb5702e15553d925b51

* UP

* ENH: modify the default config for multi-device

JIRA: STUDIO-6072

Change-Id: If6e7582a8274eb5e685b8b8545f6eab5d17de3f5
Signed-off-by: Stone Li <stone.li@bambulab.com>

* ENH: add long retraction for P series

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I6890695b67e674fc5cdc2a208e89bd9e41404213

* FIX: all plates stats data missing issue

jira: new

Change-Id: I137a2b6d69ad08791f5a9a9788653621960dc63f

* ENH:update pre print options

jira:[for multi]

Change-Id: I2e9bb8a09436a71749af98a0bad94e9922f95c81

* FIX:fixed can't popup pinbind win on macos

jira:[STUDIO-6895]

Change-Id: I664bba78cf27420d736b586df19e3c09c6f8ed21

* FIX:fixed the task of padding cannot be cancelled

Change-Id: I401a22118c14ca7601be7a925cfd8e4796dfc1e9

* ENH:Play video after redirecting to device page

jira:[STUDIO-6884]

Change-Id: Ia5e2ac84e3d71baacfcf941b782dab2325f35d54

* FIX: fix ui bug in send multi machine page for mac

JIRA: STUDIO-6882
Incorrect background color when renaming during multi machine printing

Change-Id: I6c551f5023ffe747e7a7e2f5703b0707c9505922

* FIX: Fix some bugs in maintaining the selected status of local tasks

JIRA: STUDIO-6824

Change-Id: I12c4da3fc56ac5077b3ccd7e89a4b57c3675eaf5

* ENH: local task sort by send time by default

JIRA: STUDIO-6885

Change-Id: I03b5881a39ab2e90c5b9cf46052ba465ee707ccc

* FIX: Clicking to continue printing does not take effect in error code

JIRA: STUDIO-6830
Detected an incomplete printing task error pop-up when power outage occurred. Clicking to continue printing did not take effect

Change-Id: Ie85a1602093dabac861cd1f41ea21e1c312c83e9

* ENH: use designTitle when designId > 0

JIRA: STUDIO-6072

Change-Id: I8342df053edeab16f930522e099e2eef91e5c5a4
Signed-off-by: Stone Li <stone.li@bambulab.com>

* NEW:import vertex and mtl color from obj file

Jira: STUDIO-6805

Change-Id: Iaacb13ee2451effdb83e5aba4b7fe1637b7fc95f

* FIX:change the strategy of merge_ka_kd

Upgrade ui, users can directly ok to proceed to the next step
jira: STUDIO-6805

Change-Id: Ia81019c2eacb503666680c0b8583d026baa0134c
(cherry picked from commit 38a2434753c8e3b422267283b16c75f6ad195b14)

* FIX:use default_strategy after modifed cluster number

jira: STUDIO-6915
Change-Id: I4e0c3d62f5a766f73d48d1e06c4364fc6babe1ac

* FIX: the bug of incorrect button without restarting

JIRA: STUDIO-6824
The bug can cause the user to not restart when opening the multi-device option, but the button of send multi-devices appears

Change-Id: I0837fa79ecc1d8ab5ce98273ad134fa2f830421e

* FIX: wrong default value for long retraction

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ifc2ec57a320fdb14e7ca746e5795501ed146ff32

* FIX: error code pop-up window without retry button in some code

JIRA: STUDIO-6922

Change-Id: I67464bebaba4558618301592c455db8824bbfe30

* FIX: air printing and nozzle blob detection issue

jira: STUDIO-6897

Change-Id: I008ddb24b74119d7e4124ae26310b4b86c42a799

* FIX:fix bugs of algo and read quad in obj file

Jira: STUDIO-6805
Change-Id: I6c33e8197225f27dccdfa0681e64d76d1df14f61

* dd

* ENH:Set the default nozzle diameter to 0.4

jira:[for nozzle]

Change-Id: I74a5c9b0460046496b897eae3d9f917ac1b99052

* FIX:fixed backspace error on macos

Change-Id: I76066391783c04857c1a60a6f8438111501b6d7c

* ENH:Subscription list deduplication

jira:[for mulit]

Change-Id: I10e9d849986c9661b587c7b1a509180c2451816e

* ENH:update wiki url for Pin Code

jira:[pin code]

Change-Id: I95faaa396a839b5b159119ef235b650c76706a84

* NEW:add OpenCV.cmake in deps

jira: none
Change-Id: I1ae4a2bd5618e9e620b08a937904d6af5d00bc41

* FIX:cancel obj import restrictions

jira: none
Change-Id: Iaf3e799ca982ad6aeb3ec76e9a416c4c8e4d100c

* NEW:add multiple printer restrictions

jira:[for multiple]

Change-Id: I0bb5a0c1062a543c42f8d67a9347efa358b0864a

* ENH:Added two entrances for adding devices

jira:[multi device]

Change-Id: Ieb6197e067d422979606f93b22b337a2399aec74

* slic3r: Fix wxFont being undefined

[427/494] Building CXX object src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o
FAILED: src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o
/usr/bin/c++ -DBOOST_ATOMIC_NO_LIB -DBOOST_CHRONO_NO_LIB -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_NO_LIB -DBOOST_LOCALE_NO_LIB -DBOOST_LOG_NO_LIB -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_NO_LIB -DCURL_STATICLIB -DGLEW_STATIC -DLIBNEST2D_GEOMETRIES_libslic3r -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DLIBNEST2D_THREADING_tbb -DOPENSSL_CERT_OVERRIDE -DOPENVDB_OPENEXR_STATICLIB -DOPENVDB_STATICLIB -DSLIC3R_CURRENTLY_COMPILING_GUI_MODULE -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -D__WXGTK3__ -D__WXGTK__ -DwxDEBUG_LEVEL=0 -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/run/build/BambuStudio/src -I/run/build/BambuStudio/build/src/platform -I/run/build/BambuStudio/src/hidapi/include -I/run/build/BambuStudio/src/slic3r/Utils -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/webp -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/fribidi -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gstreamer-1.0 -I/run/build/BambuStudio/build/src/libslic3r -I/run/build/BambuStudio/deps/build/destdir/usr/local/include/opencascade -I/run/build/BambuStudio/src/libnest2d/include -I/run/build/BambuStudio/src/miniz -I/run/build/BambuStudio/src/glu-libtess/include -I/run/build/BambuStudio/src/clipper2/Clipper2Lib/include -I/run/build/BambuStudio/src/minilzo -isystem /run/build/BambuStudio/src/eigen -isystem /run/build/BambuStudio/src/libigl -isystem /app/lib/wx/include/gtk3-unicode-static-3.1 -isystem /app/include/wx-3.1 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/opencv4 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/OpenEXR -std=gnu++20 -fext-numeric-literals -Wall -Wno-reorder -pthread -O3 -DNDEBUG -std=gnu++17 -fPIC -fsigned-char -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -DOPENVDB_ABI_VERSION_NUMBER=8 -MD -MT src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o -MF src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o.d -o src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o -c /run/build/BambuStudio/src/slic3r/Utils/FontUtils.cpp
In file included from /run/build/BambuStudio/src/slic3r/Utils/FontUtils.cpp:1:
/run/build/BambuStudio/src/slic3r/Utils/FontUtils.hpp:51:21: error: ‘wxFont’ does not name a type
   51 | bool can_load(const wxFont &font);
      |                     ^~~~~~

* slic3r: Fix missing BOOST_LOG_TRIVIAL declaration

[427/494] Building CXX object src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o
FAILED: src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o
/usr/bin/c++ -DBOOST_ATOMIC_NO_LIB -DBOOST_CHRONO_NO_LIB -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_NO_LIB -DBOOST_LOCALE_NO_LIB -DBOOST_LOG_NO_LIB -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_NO_LIB -DCURL_STATICLIB -DGLEW_STATIC -DLIBNEST2D_GEOMETRIES_libslic3r -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DLIBNEST2D_THREADING_tbb -DOPENSSL_CERT_OVERRIDE -DOPENVDB_OPENEXR_STATICLIB -DOPENVDB_STATICLIB -DSLIC3R_CURRENTLY_COMPILING_GUI_MODULE -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -D__WXGTK3__ -D__WXGTK__ -DwxDEBUG_LEVEL=0 -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/run/build/BambuStudio/src -I/run/build/BambuStudio/build/src/platform -I/run/build/BambuStudio/src/hidapi/include -I/run/build/BambuStudio/src/slic3r/Utils -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/webp -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/fribidi -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gstreamer-1.0 -I/run/build/BambuStudio/build/src/libslic3r -I/run/build/BambuStudio/deps/build/destdir/usr/local/include/opencascade -I/run/build/BambuStudio/src/libnest2d/include -I/run/build/BambuStudio/src/miniz -I/run/build/BambuStudio/src/glu-libtess/include -I/run/build/BambuStudio/src/clipper2/Clipper2Lib/include -I/run/build/BambuStudio/src/minilzo -isystem /run/build/BambuStudio/src/eigen -isystem /run/build/BambuStudio/src/libigl -isystem /app/lib/wx/include/gtk3-unicode-static-3.1 -isystem /app/include/wx-3.1 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/opencv4 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/OpenEXR -std=gnu++20 -fext-numeric-literals -Wall -Wno-reorder -pthread -O3 -DNDEBUG -std=gnu++17 -fPIC -fsigned-char -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -DOPENVDB_ABI_VERSION_NUMBER=8 -MD -MT src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o -MF src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o.d -o src/slic3r/CMakeFiles/libslic3r_gui.dir/Utils/FontUtils.cpp.o -c /run/build/BambuStudio/src/slic3r/Utils/FontUtils.cpp
/run/build/BambuStudio/src/slic3r/Utils/FontUtils.cpp: In function ‘std::unique_ptr<Slic3r::FontFile> Slic3r::create_font_file(const char*)’:
/run/build/BambuStudio/src/slic3r/Utils/FontUtils.cpp:127:27: error: ‘error’ was not declared in this scope; did you mean ‘perror’?
  127 |         BOOST_LOG_TRIVIAL(error) << "Couldn't open " << file_path << " for reading.";
      |                           ^~~~~
      |                           perror

[447/494] Building CXX object src/slic3r/CMakeFiles/libslic3r_gui.dir/GUI/TaskManager.cpp.o
FAILED: src/slic3r/CMakeFiles/libslic3r_gui.dir/GUI/TaskManager.cpp.o
/usr/bin/c++ -DBOOST_ATOMIC_NO_LIB -DBOOST_CHRONO_NO_LIB -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_NO_LIB -DBOOST_LOCALE_NO_LIB -DBOOST_LOG_NO_LIB -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_NO_LIB -DCURL_STATICLIB -DGLEW_STATIC -DLIBNEST2D_GEOMETRIES_libslic3r -DLIBNEST2D_OPTIMIZER_nlopt -DLIBNEST2D_STATIC -DLIBNEST2D_THREADING_tbb -DOPENSSL_CERT_OVERRIDE -DOPENVDB_OPENEXR_STATICLIB -DOPENVDB_STATICLIB -DSLIC3R_CURRENTLY_COMPILING_GUI_MODULE -DSLIC3R_GUI -DTBB_USE_CAPTURED_EXCEPTION=0 -DUNICODE -DUSE_TBB -DWXINTL_NO_GETTEXT_MACRO -D_UNICODE -D__WXGTK3__ -D__WXGTK__ -DwxDEBUG_LEVEL=0 -DwxNO_UNSAFE_WXSTRING_CONV -DwxUSE_UNICODE -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/run/build/BambuStudio/src -I/run/build/BambuStudio/build/src/platform -I/run/build/BambuStudio/src/hidapi/include -I/run/build/BambuStudio/src/slic3r/Utils -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/webp -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/fribidi -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gstreamer-1.0 -I/run/build/BambuStudio/build/src/libslic3r -I/run/build/BambuStudio/deps/build/destdir/usr/local/include/opencascade -I/run/build/BambuStudio/src/libnest2d/include -I/run/build/BambuStudio/src/miniz -I/run/build/BambuStudio/src/glu-libtess/include -I/run/build/BambuStudio/src/clipper2/Clipper2Lib/include -I/run/build/BambuStudio/src/minilzo -isystem /run/build/BambuStudio/src/eigen -isystem /run/build/BambuStudio/src/libigl -isystem /app/lib/wx/include/gtk3-unicode-static-3.1 -isystem /app/include/wx-3.1 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/opencv4 -isystem /run/build/BambuStudio/deps/build/destdir/usr/local/include/OpenEXR -std=gnu++20 -fext-numeric-literals -Wall -Wno-reorder -pthread -O3 -DNDEBUG -std=gnu++17 -fPIC -fsigned-char -Werror=return-type -Wno-ignored-attributes -Wno-unknown-pragmas -DOPENVDB_ABI_VERSION_NUMBER=8 -MD -MT src/slic3r/CMakeFiles/libslic3r_gui.dir/GUI/TaskManager.cpp.o -MF src/slic3r/CMakeFiles/libslic3r_gui.dir/GUI/TaskManager.cpp.o.d -o src/slic3r/CMakeFiles/libslic3r_gui.dir/GUI/TaskManager.cpp.o -c /run/build/BambuStudio/src/slic3r/GUI/TaskManager.cpp
In file included from /run/build/BambuStudio/src/slic3r/GUI/TaskManager.cpp:1:
/run/build/BambuStudio/src/slic3r/GUI/TaskManager.hpp: In member function ‘void Slic3r::TaskStateInfo::set_state(Slic3r::TaskState)’:
/run/build/BambuStudio/src/slic3r/GUI/TaskManager.hpp:40:9: error: ‘BOOST_LOG_TRIVIAL’ was not declared in this scope
   40 |         BOOST_LOG_TRIVIAL(trace) << "TaskStateInfo set state = " << get_task_state_enum_str(ts);
      |         ^~~~~~~~~~~~~~~~~

* fix OpenCV

* wip - build break

* fix build error wip

* ENH: support preset description(tooltip)

Change-Id: Iff005baac4974c538d1109fb0ba1df20b04a8f69
Jira: STUDIO-5754

* fix more build errors

* Revert "ENH: load more fonts"

This reverts commit 32b6fd199ac50e21db1f72089e5b3287a1776e04.

* change colors

* misc fixes

* restore export gcode btn

---------

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Signed-off-by: Stone Li <stone.li@bambulab.com>
Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com>
Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com>
Co-authored-by: lane.wei <lane.wei@bambulab.com>
Co-authored-by: Arthur <arthur.tang@bambulab.com>
Co-authored-by: xun.zhang <xun.zhang@bambulab.com>
Co-authored-by: zhimin.zeng <zhimin.zeng@bambulab.com>
Co-authored-by: Kunlong Ma <kunlong.ma@bambulab.com>
Co-authored-by: jianjia.ma <jianjia.ma@bambulab.com>
Co-authored-by: liz.li <liz.li@bambulab.com>
Co-authored-by: tao wang <tao.wang@bambulab.com>
Co-authored-by: Stone Li <stone.li@bambulab.com>
Co-authored-by: zhou.xu <zhou.xu@bambulab.com>
Co-authored-by: Bastien Nocera <hadess@hadess.net>
Co-authored-by: chunmao.guo <chunmao.guo@bambulab.com>
2024-04-28 22:58:47 +08:00

1259 lines
49 KiB
C++

#include "CalibUtils.hpp"
#include "../GUI/I18N.hpp"
#include "../GUI/GUI_App.hpp"
#include "../GUI/DeviceManager.hpp"
#include "../GUI/Jobs/ProgressIndicator.hpp"
#include "../GUI/PartPlate.hpp"
#include "libslic3r/CutUtils.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/Jobs/BoostThreadWorker.hpp"
#include "slic3r/GUI/Jobs/PlaterWorker.hpp"
#include "../GUI/MsgDialog.hpp"
namespace Slic3r {
namespace GUI {
std::unique_ptr<Worker> CalibUtils::print_worker;
wxString wxstr_temp_dir = fs::path(fs::temp_directory_path() / "calib").wstring();
static const std::string temp_dir = wxstr_temp_dir.utf8_string();
static const std::string temp_gcode_path = temp_dir + "/temp.gcode";
static const std::string path = temp_dir + "/test.3mf";
static const std::string config_3mf_path = temp_dir + "/test_config.3mf";
static std::string MachineBedTypeString[5] = {
"auto",
"pc",
"ep",
"pei",
"pte"
};
std::string get_calib_mode_name(CalibMode cali_mode, int stage)
{
switch(cali_mode) {
case CalibMode::Calib_PA_Line:
return "pa_line_calib_mode";
case CalibMode::Calib_PA_Pattern:
return "pa_pattern_calib_mode";
case CalibMode::Calib_Flow_Rate:
if (stage == 1)
return "flow_rate_coarse_calib_mode";
else if (stage == 2)
return "flow_rate_fine_calib_mode";
else
return "flow_rate_coarse_calib_mode";
case CalibMode::Calib_Temp_Tower:
return "temp_tower_calib_mode";
case CalibMode::Calib_Vol_speed_Tower:
return "vol_speed_tower_calib_mode";
case CalibMode::Calib_VFA_Tower:
return "vfa_tower_calib_mode";
case CalibMode::Calib_Retraction_tower:
return "retration_tower_calib_mode";
default:
assert(false);
return "";
}
}
static wxString to_wstring_name(std::string name)
{
if (name == "hardened_steel") {
return _L("Hardened Steel");
} else if (name == "stainless_steel") {
return _L("Stainless Steel");
}
return wxEmptyString;
}
static bool is_same_nozzle_diameters(const DynamicPrintConfig &full_config, const MachineObject *obj, wxString& error_msg)
{
if (obj == nullptr)
return true;
try {
std::string nozzle_type;
const ConfigOptionEnum<NozzleType> * config_nozzle_type = full_config.option<ConfigOptionEnum<NozzleType>>("nozzle_type");
if (config_nozzle_type->value == NozzleType::ntHardenedSteel) {
nozzle_type = "hardened_steel";
} else if (config_nozzle_type->value == NozzleType::ntStainlessSteel) {
nozzle_type = "stainless_steel";
}
auto opt_nozzle_diameters = full_config.option<ConfigOptionFloats>("nozzle_diameter");
if (opt_nozzle_diameters != nullptr) {
float preset_nozzle_diameter = opt_nozzle_diameters->get_at(0);
if (preset_nozzle_diameter != obj->nozzle_diameter) {
wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"), wxString::Format("%.1f", preset_nozzle_diameter).ToStdString(), to_wstring_name(nozzle_type));
wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj->nozzle_diameter, to_wstring_name(obj->nozzle_type));
error_msg = _L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?") + "\n " + nozzle_in_preset +
"\n " + nozzle_in_printer + "\n";
return false;
}
}
} catch (...) {}
return true;
}
static bool is_same_nozzle_type(const DynamicPrintConfig &full_config, const MachineObject *obj, wxString& error_msg)
{
if (obj == nullptr)
return true;
NozzleType nozzle_type = NozzleType::ntUndefine;
if (obj->nozzle_type == "stainless_steel") {
nozzle_type = NozzleType::ntStainlessSteel;
} else if (obj->nozzle_type == "hardened_steel") {
nozzle_type = NozzleType::ntHardenedSteel;
}
int printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(nozzle_type);
if (full_config.has("required_nozzle_HRC")) {
int filament_nozzle_hrc = full_config.opt_int("required_nozzle_HRC", 0);
if (abs(filament_nozzle_hrc) > abs(printer_nozzle_hrc)) {
BOOST_LOG_TRIVIAL(info) << "filaments hardness mismatch: printer_nozzle_hrc = " << printer_nozzle_hrc << ", filament_nozzle_hrc = " << filament_nozzle_hrc;
std::string filament_type = full_config.opt_string("filament_type", 0);
error_msg = wxString::Format(_L("*Printing %s material with %s may cause nozzle damage"), filament_type, to_wstring_name(obj->nozzle_type));
error_msg += "\n";
MessageDialog msg_dlg(nullptr, error_msg, wxEmptyString, wxICON_WARNING | wxOK | wxCANCEL);
auto result = msg_dlg.ShowModal();
if (result == wxID_OK) {
error_msg.clear();
return true;
} else {
error_msg.clear();
return false;
}
}
}
return true;
}
static bool check_nozzle_diameter_and_type(const DynamicPrintConfig &full_config, wxString& error_msg)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
error_msg = _L("Need select printer");
return false;
}
MachineObject *obj = dev->get_selected_machine();
if (obj == nullptr) {
error_msg = _L("Need select printer");
return false;
}
// P1P/S
if (obj->nozzle_type.empty())
return true;
if (!is_same_nozzle_diameters(full_config, obj, error_msg))
return false;
if (!is_same_nozzle_type(full_config, obj, error_msg))
return false;
return true;
}
CalibMode CalibUtils::get_calib_mode_by_name(const std::string name, int& cali_stage)
{
if (name == "pa_line_calib_mode") {
cali_stage = 0;
return CalibMode::Calib_PA_Line;
}
else if (name == "pa_pattern_calib_mode") {
cali_stage = 1;
return CalibMode::Calib_PA_Line;
}
else if (name == "flow_rate_coarse_calib_mode") {
cali_stage = 1;
return CalibMode::Calib_Flow_Rate;
}
else if (name == "flow_rate_fine_calib_mode") {
cali_stage = 2;
return CalibMode::Calib_Flow_Rate;
}
else if (name == "temp_tower_calib_mode")
return CalibMode::Calib_Temp_Tower;
else if (name == "vol_speed_tower_calib_mode")
return CalibMode::Calib_Vol_speed_Tower;
else if (name == "vfa_tower_calib_mode")
return CalibMode::Calib_VFA_Tower;
else if (name == "retration_tower_calib_mode")
return CalibMode::Calib_Retraction_tower;
return CalibMode::Calib_None;
}
bool CalibUtils::validate_input_name(wxString name)
{
if (name.Length() > 40) {
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return false;
}
name.erase(std::remove(name.begin(), name.end(), L' '), name.end());
if (name.IsEmpty()) {
MessageDialog msg_dlg(nullptr, _L("The name cannot be empty."), wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return false;
}
return true;
}
bool CalibUtils::validate_input_k_value(wxString k_text, float* output_value)
{
float default_k = 0.0f;
if (k_text.IsEmpty()) {
*output_value = default_k;
return false;
}
double k_value = 0.0;
try {
if(!k_text.ToDouble(&k_value))
return false;
}
catch (...) {
;
}
if (k_value < 0 || k_value > 0.3) {
*output_value = default_k;
return false;
}
*output_value = k_value;
return true;
};
bool CalibUtils::validate_input_flow_ratio(wxString flow_ratio, float* output_value) {
float default_flow_ratio = 1.0f;
if (flow_ratio.IsEmpty()) {
*output_value = default_flow_ratio;
return false;
}
double flow_ratio_value = 0.0;
try {
flow_ratio.ToDouble(&flow_ratio_value);
}
catch (...) {
;
}
if (flow_ratio_value <= 0.0 || flow_ratio_value >= 2.0) {
*output_value = default_flow_ratio;
return false;
}
*output_value = flow_ratio_value;
return true;
}
static void cut_model(Model &model, double z, ModelObjectCutAttributes attributes)
{
size_t obj_idx = 0;
size_t instance_idx = 0;
if (!attributes.has(ModelObjectCutAttribute::KeepUpper) && !attributes.has(ModelObjectCutAttribute::KeepLower))
return;
auto* object = model.objects[0];
const Vec3d instance_offset = object->instances[instance_idx]->get_offset();
Cut cut(object, instance_idx, Geometry::translation_transform(z * Vec3d::UnitZ() - instance_offset), attributes);
const auto new_objects = cut.perform_with_plane();
model.delete_object(obj_idx);
for (ModelObject *model_object : new_objects) {
auto *object = model.add_object(*model_object);
object->sort_volumes(true);
std::string object_name = object->name.empty() ? fs::path(object->input_file).filename().string() : object->name;
object->ensure_on_bed();
}
}
static void read_model_from_file(const std::string& input_file, Model& model)
{
LoadStrategy strategy = LoadStrategy::LoadModel;
ConfigSubstitutionContext config_substitutions{ForwardCompatibilitySubstitutionRule::Enable};
int plate_to_slice = 0;
bool is_bbl_3mf;
Semver file_version;
DynamicPrintConfig config;
PlateDataPtrs plate_data_src;
std::vector<Preset *> project_presets;
model = Model::read_from_file(input_file, &config, &config_substitutions, strategy, &plate_data_src, &project_presets,
&is_bbl_3mf, &file_version, nullptr, nullptr, nullptr, nullptr, nullptr, plate_to_slice);
model.add_default_instances();
for (auto object : model.objects)
object->ensure_on_bed();
}
std::array<Vec3d, 4> get_cut_plane_points(const BoundingBoxf3 &bbox, const double &cut_height)
{
std::array<Vec3d, 4> plane_pts;
plane_pts[0] = Vec3d(bbox.min(0), bbox.min(1), cut_height);
plane_pts[1] = Vec3d(bbox.max(0), bbox.min(1), cut_height);
plane_pts[2] = Vec3d(bbox.max(0), bbox.max(1), cut_height);
plane_pts[3] = Vec3d(bbox.min(0), bbox.max(1), cut_height);
return plane_pts;
}
void CalibUtils::calib_PA(const X1CCalibInfos& calib_infos, int mode, wxString& error_message)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
if (calib_infos.calib_datas.size() > 0)
obj_->command_start_pa_calibration(calib_infos, mode);
}
void CalibUtils::emit_get_PA_calib_results(float nozzle_diameter)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->command_get_pa_calibration_result(nozzle_diameter);
}
bool CalibUtils::get_PA_calib_results(std::vector<PACalibResult>& pa_calib_results)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return false;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return false;
pa_calib_results = obj_->pa_calib_results;
return pa_calib_results.size() > 0;
}
void CalibUtils::emit_get_PA_calib_infos(float nozzle_diameter)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->command_get_pa_calibration_tab(nozzle_diameter);
}
bool CalibUtils::get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return false;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return false;
if (obj_->has_get_pa_calib_tab) {
pa_calib_infos.assign(obj_->pa_calib_tab.begin(), obj_->pa_calib_tab.end());
}
return obj_->has_get_pa_calib_tab;
}
void CalibUtils::emit_get_PA_calib_info(float nozzle_diameter, const std::string &filament_id)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return;
obj_->command_get_pa_calibration_tab(nozzle_diameter, filament_id);
}
bool CalibUtils::get_PA_calib_info(PACalibResult & pa_calib_info) {
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return false;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return false;
if (!obj_->pa_calib_tab.empty()) {
pa_calib_info = obj_->pa_calib_tab.front();
return true;
}
return false;
}
void CalibUtils::set_PA_calib_result(const std::vector<PACalibResult> &pa_calib_values, bool is_auto_cali)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject* obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->command_set_pa_calibration(pa_calib_values, is_auto_cali);
}
void CalibUtils::select_PA_calib_result(const PACalibIndexInfo& pa_calib_info)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject* obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->commnad_select_pa_calibration(pa_calib_info);
}
void CalibUtils::delete_PA_calib_result(const PACalibIndexInfo& pa_calib_info)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject* obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->command_delete_pa_calibration(pa_calib_info);
}
void CalibUtils::calib_flowrate_X1C(const X1CCalibInfos& calib_infos, std::string& error_message)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
if (calib_infos.calib_datas.size() > 0)
obj_->command_start_flow_ratio_calibration(calib_infos);
else {
BOOST_LOG_TRIVIAL(info) << "flow_rate_cali: auto | send info | cali_datas is empty.";
}
}
void CalibUtils::emit_get_flow_ratio_calib_results(float nozzle_diameter)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return;
obj_->command_get_flow_ratio_calibration_result(nozzle_diameter);
}
bool CalibUtils::get_flow_ratio_calib_results(std::vector<FlowRatioCalibResult>& flow_ratio_calib_results)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return false;
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr)
return false;
flow_ratio_calib_results = obj_->flow_ratio_results;
return flow_ratio_calib_results.size() > 0;
}
bool CalibUtils::calib_flowrate(int pass, const CalibInfo &calib_info, wxString &error_message)
{
if (pass != 1 && pass != 2)
return false;
Model model;
std::string input_file;
if (pass == 1)
input_file = Slic3r::resources_dir() + "/calib/filament_flow/flowrate-test-pass1.3mf";
else
input_file = Slic3r::resources_dir() + "/calib/filament_flow/flowrate-test-pass2.3mf";
read_model_from_file(input_file, model);
DynamicConfig print_config = calib_info.print_prest->config;
DynamicConfig filament_config = calib_info.filament_prest->config;
DynamicConfig printer_config = calib_info.printer_prest->config;
/// --- scale ---
// model is created for a 0.4 nozzle, scale z with nozzle size.
const ConfigOptionFloats *nozzle_diameter_config = printer_config.option<ConfigOptionFloats>("nozzle_diameter");
assert(nozzle_diameter_config->values.size() > 0);
float nozzle_diameter = nozzle_diameter_config->values[0];
float xyScale = nozzle_diameter / 0.6;
// scale z to have 7 layers
double first_layer_height = print_config.option<ConfigOptionFloat>("initial_layer_print_height")->value;
double layer_height = nozzle_diameter / 2.0; // prefer 0.2 layer height for 0.4 nozzle
first_layer_height = std::max(first_layer_height, layer_height);
float zscale = (first_layer_height + 6 * layer_height) / 1.4;
for (auto _obj : model.objects) _obj->scale(1, 1, zscale);
// only enlarge
//if (xyScale > 1.2) {
// for (auto _obj : model.objects) _obj->scale(xyScale, xyScale, zscale);
//} else {
// for (auto _obj : model.objects) _obj->scale(1, 1, zscale);
//}
Flow infill_flow = Flow(nozzle_diameter * 1.2f, layer_height, nozzle_diameter);
double filament_max_volumetric_speed = filament_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(0);
double max_infill_speed = filament_max_volumetric_speed / (infill_flow.mm3_per_mm() * (pass == 1 ? 1.2 : 1));
double internal_solid_speed = std::floor(std::min(print_config.opt_float("internal_solid_infill_speed"), max_infill_speed));
double top_surface_speed = std::floor(std::min(print_config.opt_float("top_surface_speed"), max_infill_speed));
// adjust parameters
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
for (auto _obj : model.objects) {
_obj->ensure_on_bed();
_obj->config.set_key_value("wall_loops", new ConfigOptionInt(3));
_obj->config.set_key_value("only_one_wall_top", new ConfigOptionBool(true));
_obj->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(35));
_obj->config.set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
_obj->config.set_key_value("top_shell_layers", new ConfigOptionInt(5));
_obj->config.set_key_value("detect_thin_wall", new ConfigOptionBool(true));
_obj->config.set_key_value("filter_out_gap_fill", new ConfigOptionFloat(0)); // OrcaSlicer parameter
_obj->config.set_key_value("sparse_infill_pattern", new ConfigOptionEnum<InfillPattern>(ipRectilinear));
_obj->config.set_key_value("top_surface_line_width", new ConfigOptionFloatOrPercent(nozzle_diameter * 1.2f, false));
_obj->config.set_key_value("internal_solid_infill_line_width", new ConfigOptionFloatOrPercent(nozzle_diameter * 1.2f, false));
_obj->config.set_key_value("top_surface_pattern", new ConfigOptionEnum<InfillPattern>(ipMonotonic));
_obj->config.set_key_value("top_solid_infill_flow_ratio", new ConfigOptionFloat(1.0f));
_obj->config.set_key_value("infill_direction", new ConfigOptionFloat(45));
_obj->config.set_key_value("ironing_type", new ConfigOptionEnum<IroningType>(IroningType::NoIroning));
_obj->config.set_key_value("internal_solid_infill_speed", new ConfigOptionFloat(internal_solid_speed));
_obj->config.set_key_value("top_surface_speed", new ConfigOptionFloat(top_surface_speed));
// extract flowrate from name, filename format: flowrate_xxx
std::string obj_name = _obj->name;
assert(obj_name.length() > 9);
obj_name = obj_name.substr(9);
if (obj_name[0] == 'm') obj_name[0] = '-';
auto modifier = stof(obj_name);
_obj->config.set_key_value("print_flow_ratio", new ConfigOptionFloat(1.0f + modifier / 100.f));
}
print_config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
print_config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(first_layer_height));
print_config.set_key_value("reduce_crossing_wall", new ConfigOptionBool(true));
// apply preset
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
Calib_Params params;
params.mode = CalibMode::Calib_Flow_Rate;
if (!process_and_store_3mf(&model, full_config, params, error_message))
return false;
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
error_message = _L("Need select printer");
return false;
}
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) {
error_message = _L("Need select printer");
return false;
}
send_to_print(calib_info, error_message, pass);
return true;
}
void CalibUtils::calib_pa_pattern(const CalibInfo &calib_info, Model& model)
{
DynamicPrintConfig& print_config = calib_info.print_prest->config;
DynamicPrintConfig& filament_config = calib_info.filament_prest->config;
DynamicPrintConfig& printer_config = calib_info.printer_prest->config;
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
float nozzle_diameter = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
for (const auto opt : SuggestedConfigCalibPAPattern().float_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionFloat(opt.second));
}
print_config.set_key_value("outer_wall_speed",
new ConfigOptionFloat(CalibPressureAdvance::find_optimal_PA_speed(
full_config, print_config.get_abs_value("line_width"),
print_config.get_abs_value("layer_height"), 0)));
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
}
for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second));
}
print_config.set_key_value(SuggestedConfigCalibPAPattern().brim_pair.first,
new ConfigOptionEnum<BrimType>(SuggestedConfigCalibPAPattern().brim_pair.second));
//DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
Vec3d plate_origin(0, 0, 0);
CalibPressureAdvancePattern pa_pattern(calib_info.params, full_config, true, model, plate_origin);
Pointfs bedfs = full_config.opt<ConfigOptionPoints>("printable_area")->values;
double current_width = bedfs[2].x() - bedfs[0].x();
double current_depth = bedfs[2].y() - bedfs[0].y();
Vec3d half_pattern_size = Vec3d(pa_pattern.print_size_x() / 2, pa_pattern.print_size_y() / 2, 0);
Vec3d offset = Vec3d(current_width / 2, current_depth / 2, 0) - half_pattern_size;
pa_pattern.set_start_offset(offset);
pa_pattern.generate_custom_gcodes(full_config, true, model, plate_origin);
model.calib_pa_pattern = std::make_unique<CalibPressureAdvancePattern>(pa_pattern);
}
bool CalibUtils::calib_generic_PA(const CalibInfo &calib_info, wxString &error_message)
{
const Calib_Params &params = calib_info.params;
if (params.mode != CalibMode::Calib_PA_Line && params.mode != CalibMode::Calib_PA_Pattern)
return false;
Model model;
std::string input_file;
if (params.mode == CalibMode::Calib_PA_Line)
input_file = Slic3r::resources_dir() + "/calib/pressure_advance/pressure_advance_test.stl";
else if (params.mode == CalibMode::Calib_PA_Pattern)
input_file = Slic3r::resources_dir() + "/calib/pressure_advance/pa_pattern.3mf";
read_model_from_file(input_file, model);
if (params.mode == CalibMode::Calib_PA_Pattern)
calib_pa_pattern(calib_info, model);
DynamicPrintConfig print_config = calib_info.print_prest->config;
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
if (!process_and_store_3mf(&model, full_config, params, error_message))
return false;
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
error_message = _L("Need select printer");
return false;
}
MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) {
error_message = _L("Need select printer");
return false;
}
send_to_print(calib_info, error_message);
return true;
}
void CalibUtils::calib_temptue(const CalibInfo &calib_info, wxString &error_message)
{
const Calib_Params &params = calib_info.params;
if (params.mode != CalibMode::Calib_Temp_Tower)
return;
Model model;
std::string input_file = Slic3r::resources_dir() + "/calib/temperature_tower/temperature_tower.stl";
read_model_from_file(input_file, model);
// cut upper
auto obj_bb = model.objects[0]->bounding_box_exact();
auto block_count = lround((350 - params.start) / 5 + 1);
if (block_count > 0) {
// add EPSILON offset to avoid cutting at the exact location where the flat surface is
auto new_height = block_count * 10.0 + EPSILON;
if (new_height < obj_bb.size().z()) {
cut_model(model, new_height, ModelObjectCutAttribute::KeepLower);
}
}
// cut bottom
obj_bb = model.objects[0]->bounding_box_exact();
block_count = lround((350 - params.end) / 5);
if (block_count > 0) {
auto new_height = block_count * 10.0 + EPSILON;
if (new_height < obj_bb.size().z()) {
cut_model(model, new_height, ModelObjectCutAttribute::KeepUpper);
}
}
// edit preset
DynamicPrintConfig print_config = calib_info.print_prest->config;
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
auto start_temp = lround(params.start);
filament_config.set_key_value("nozzle_temperature_initial_layer", new ConfigOptionInts(1, (int) start_temp));
filament_config.set_key_value("nozzle_temperature", new ConfigOptionInts(1, (int) start_temp));
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
model.objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model.objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(5.0));
model.objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
model.objects[0]->config.set_key_value("enable_support", new ConfigOptionBool(false));
// apply preset
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
process_and_store_3mf(&model, full_config, params, error_message);
if (!error_message.empty())
return;
send_to_print(calib_info, error_message);
}
void CalibUtils::calib_max_vol_speed(const CalibInfo &calib_info, wxString &error_message)
{
const Calib_Params &params = calib_info.params;
if (params.mode != CalibMode::Calib_Vol_speed_Tower)
return;
Model model;
std::string input_file = Slic3r::resources_dir() + "/calib/volumetric_speed/SpeedTestStructure.step";
read_model_from_file(input_file, model);
DynamicPrintConfig print_config = calib_info.print_prest->config;
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
auto obj = model.objects[0];
auto bed_shape = printer_config.option<ConfigOptionPoints>("printable_area")->values;
BoundingBoxf bed_ext = get_extents(bed_shape);
auto scale_obj = (bed_ext.size().x() - 10) / obj->bounding_box_exact().size().x();
if (scale_obj < 1.0)
obj->scale(scale_obj, 1, 1);
const ConfigOptionFloats *nozzle_diameter_config = printer_config.option<ConfigOptionFloats>("nozzle_diameter");
assert(nozzle_diameter_config->values.size() > 0);
double nozzle_diameter = nozzle_diameter_config->values[0];
double line_width = nozzle_diameter * 1.75;
double layer_height = nozzle_diameter * 0.8;
auto max_lh = printer_config.option<ConfigOptionFloats>("max_layer_height");
if (max_lh->values[0] < layer_height) max_lh->values[0] = {layer_height};
filament_config.set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{50});
filament_config.set_key_value("slow_down_layer_time", new ConfigOptionInts{0});
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
print_config.set_key_value("enable_overhang_speed", new ConfigOptionBool{false});
print_config.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config.set_key_value("wall_loops", new ConfigOptionInt(1));
print_config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config.set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config.set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
print_config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
print_config.set_key_value("overhang_reverse", new ConfigOptionBool(false));
print_config.set_key_value("spiral_mode", new ConfigOptionBool(true));
print_config.set_key_value("outer_wall_line_width", new ConfigOptionFloat(line_width));
print_config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(layer_height));
print_config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterAndInner));
obj->config.set_key_value("brim_width", new ConfigOptionFloat(3.0));
obj->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
// cut upper
auto obj_bb = obj->bounding_box_exact();
double height = (params.end - params.start + 1) / params.step;
if (height < obj_bb.size().z()) {
cut_model(model, height, ModelObjectCutAttribute::KeepLower);
}
auto new_params = params;
auto mm3_per_mm = Flow(line_width, layer_height, nozzle_diameter).mm3_per_mm() * filament_config.option<ConfigOptionFloats>("filament_flow_ratio")->get_at(0);
new_params.end = params.end / mm3_per_mm;
new_params.start = params.start / mm3_per_mm;
new_params.step = params.step / mm3_per_mm;
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
process_and_store_3mf(&model, full_config, new_params, error_message);
if (!error_message.empty())
return;
send_to_print(calib_info, error_message);
}
void CalibUtils::calib_VFA(const CalibInfo &calib_info, wxString &error_message)
{
const Calib_Params &params = calib_info.params;
if (params.mode != CalibMode::Calib_VFA_Tower)
return;
Model model;
std::string input_file = Slic3r::resources_dir() + "/calib/vfa/VFA.stl";
read_model_from_file(input_file, model);
DynamicPrintConfig print_config = calib_info.print_prest->config;
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
filament_config.set_key_value("slow_down_layer_time", new ConfigOptionInts{0});
filament_config.set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{200});
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
print_config.set_key_value("enable_overhang_speed", new ConfigOptionBool{false});
print_config.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config.set_key_value("wall_loops", new ConfigOptionInt(1));
print_config.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
print_config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config.set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config.set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
print_config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
print_config.set_key_value("overhang_reverse", new ConfigOptionBool(false));
print_config.set_key_value("spiral_mode", new ConfigOptionBool(true));
model.objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model.objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(3.0));
model.objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
// cut upper
auto obj_bb = model.objects[0]->bounding_box_exact();
auto height = 5 * ((params.end - params.start) / params.step + 1);
if (height < obj_bb.size().z()) {
cut_model(model, height, ModelObjectCutAttribute::KeepLower);
}
else {
error_message = _L("The start, end or step is not valid value.");
return;
}
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
process_and_store_3mf(&model, full_config, params, error_message);
if (!error_message.empty())
return;
send_to_print(calib_info, error_message);
}
void CalibUtils::calib_retraction(const CalibInfo &calib_info, wxString &error_message)
{
const Calib_Params &params = calib_info.params;
if (params.mode != CalibMode::Calib_Retraction_tower)
return;
Model model;
std::string input_file = Slic3r::resources_dir() + "/calib/retraction/retraction_tower.stl";
read_model_from_file(input_file, model);
DynamicPrintConfig print_config = calib_info.print_prest->config;
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
auto obj = model.objects[0];
double layer_height = 0.2;
auto max_lh = printer_config.option<ConfigOptionFloats>("max_layer_height");
if (max_lh->values[0] < layer_height) max_lh->values[0] = {layer_height};
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
obj->config.set_key_value("wall_loops", new ConfigOptionInt(2));
obj->config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
obj->config.set_key_value("top_shell_layers", new ConfigOptionInt(0));
obj->config.set_key_value("bottom_shell_layers", new ConfigOptionInt(3));
obj->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
obj->config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
// cut upper
auto obj_bb = obj->bounding_box_exact();
auto height = 1.0 + 0.4 + ((params.end - params.start)) / params.step;
if (height < obj_bb.size().z()) {
cut_model(model, height, ModelObjectCutAttribute::KeepLower);
}
DynamicPrintConfig full_config;
full_config.apply(FullPrintConfig::defaults());
full_config.apply(print_config);
full_config.apply(filament_config);
full_config.apply(printer_config);
process_and_store_3mf(&model, full_config, params, error_message);
if (!error_message.empty())
return;
send_to_print(calib_info, error_message);
}
int CalibUtils::get_selected_calib_idx(const std::vector<PACalibResult> &pa_calib_values, int cali_idx) {
for (int i = 0; i < pa_calib_values.size(); ++i) {
if(pa_calib_values[i].cali_idx == cali_idx)
return i;
}
return -1;
}
bool CalibUtils::get_pa_k_n_value_by_cali_idx(const MachineObject *obj, int cali_idx, float &out_k, float &out_n) {
if (!obj)
return false;
for (auto pa_calib_info : obj->pa_calib_tab) {
if (pa_calib_info.cali_idx == cali_idx) {
out_k = pa_calib_info.k_value;
out_n = pa_calib_info.n_coef;
return true;
}
}
return false;
}
bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &full_config, const Calib_Params &params, wxString &error_message)
{
Pointfs bedfs = full_config.opt<ConfigOptionPoints>("printable_area")->values;
double print_height = full_config.opt_float("printable_height");
double current_width = bedfs[2].x() - bedfs[0].x();
double current_depth = bedfs[2].y() - bedfs[0].y();
Vec3i plate_size;
plate_size[0] = bedfs[2].x() - bedfs[0].x();
plate_size[1] = bedfs[2].y() - bedfs[0].y();
plate_size[2] = print_height;
if (params.mode == CalibMode::Calib_PA_Line) {
double space_y = 3.5;
int max_line_nums = int(plate_size[1] - 10) / space_y;
int count = std::llround(std::ceil((params.end - params.start) / params.step)) + 1;
if (count > max_line_nums) {
error_message = _L("Unable to calibrate: maybe because the set calibration value range is too large, or the step is too small");
return false;
}
}
if (params.mode == CalibMode::Calib_PA_Pattern) {
ModelInstance *instance = model->objects[0]->instances[0];
Vec3d offset = model->calib_pa_pattern->get_start_offset() +
Vec3d(model->calib_pa_pattern->handle_xy_size() / 2, -model->calib_pa_pattern->handle_xy_size() / 2 - model->calib_pa_pattern->handle_spacing(), 0);
instance->set_offset(offset);
}
else if (model->objects.size() == 1) {
ModelInstance *instance = model->objects[0]->instances[0];
instance->set_offset(instance->get_offset() + Vec3d(current_width / 2, current_depth / 2, 0));
} else {
BoundingBoxf3 bbox = model->bounding_box_exact();
Vec3d bbox_center = bbox.center();
for (auto object : model->objects) {
ModelInstance *instance = object->instances[0];
instance->set_offset(instance->get_offset() + Vec3d(current_width / 2 - bbox_center.x(), current_depth / 2 - bbox_center.y(), 0));
}
}
Slic3r::GUI::PartPlateList partplate_list(nullptr, model, PrinterTechnology::ptFFF);
partplate_list.reset_size(plate_size.x(), plate_size.y(), plate_size.z(), false);
Slic3r::GUI::PartPlate *part_plate = partplate_list.get_plate(0);
PrintBase * print = NULL;
Slic3r::GUI::GCodeResult *gcode_result = NULL;
int print_index;
part_plate->get_print(&print, &gcode_result, &print_index);
BuildVolume build_volume(bedfs, print_height);
unsigned int count = model->update_print_volume_state(build_volume);
if (count == 0) {
error_message = _L("Unable to calibrate: maybe because the set calibration value range is too large, or the step is too small");
return false;
}
// apply the new print config
DynamicPrintConfig new_print_config = full_config;
print->apply(*model, new_print_config);
Print *fff_print = dynamic_cast<Print *>(print);
fff_print->set_calib_params(params);
//StringObjectException warning;
//auto err = print->validate(&warning);
//if (!err.string.empty()) {
// error_message = "slice validate: " + err.string;
// return;
//}
if (!check_nozzle_diameter_and_type(full_config, error_message))
return false;
fff_print->process();
part_plate->update_slice_result_valid_state(true);
gcode_result->reset();
fff_print->export_gcode(temp_gcode_path, gcode_result, nullptr);
std::vector<ThumbnailData*> thumbnails;
PlateDataPtrs plate_data_list;
partplate_list.store_to_3mf_structure(plate_data_list, true, 0);
for (auto plate_data : plate_data_list) {
plate_data->gcode_file = temp_gcode_path;
plate_data->is_sliced_valid = true;
FilamentInfo& filament_info = plate_data->slice_filaments_info.front();
filament_info.type = full_config.opt_string("filament_type", 0);
}
//draw thumbnails
{
GLVolumeCollection glvolume_collection;
std::vector<ColorRGBA> colors_out(1);
unsigned char rgb_color[4] = {255, 255, 255, 255};
ColorRGBA new_color {1.0f, 1.0f, 1.0f, 1.0f};
colors_out.push_back(new_color);
ThumbnailData* thumbnail_data = &plate_data_list[0]->plate_thumbnail;
unsigned int thumbnail_width = 512, thumbnail_height = 512;
const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, 0};
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail");
for (unsigned int obj_idx = 0; obj_idx < (unsigned int)model->objects.size(); ++ obj_idx) {
const ModelObject &model_object = *model->objects[obj_idx];
for (int volume_idx = 0; volume_idx < (int)model_object.volumes.size(); ++ volume_idx) {
const ModelVolume &model_volume = *model_object.volumes[volume_idx];
for (int instance_idx = 0; instance_idx < (int)model_object.instances.size(); ++ instance_idx) {
const ModelInstance &model_instance = *model_object.instances[instance_idx];
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true);
glvolume_collection.volumes.back()->set_render_color(new_color);
glvolume_collection.volumes.back()->set_color(new_color);
//glvolume_collection.volumes.back()->printable = model_instance.printable;
}
}
}
switch (Slic3r::GUI::OpenGLManager::get_framebuffers_type())
{
case Slic3r::GUI::OpenGLManager::EFramebufferType::Arb:
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": framebuffer_type: ARB");
Slic3r::GUI::GLCanvas3D::render_thumbnail_framebuffer(*thumbnail_data,
thumbnail_width, thumbnail_height, thumbnail_params,
partplate_list, model->objects, glvolume_collection, colors_out, shader, Slic3r::GUI::Camera::EType::Ortho);
break;
}
case Slic3r::GUI::OpenGLManager::EFramebufferType::Ext:
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": framebuffer_type: EXT");
Slic3r::GUI::GLCanvas3D::render_thumbnail_framebuffer_ext(*thumbnail_data,
thumbnail_width, thumbnail_height, thumbnail_params,
partplate_list, model->objects, glvolume_collection, colors_out, shader, Slic3r::GUI::Camera::EType::Ortho);
break;
}
default:
BOOST_LOG_TRIVIAL(info) << boost::format("framebuffer_type: unknown");
break;
}
thumbnails.push_back(thumbnail_data);
}
StoreParams store_params;
store_params.path = path.c_str();
store_params.model = model;
store_params.plate_data_list = plate_data_list;
store_params.config = &new_print_config;
store_params.export_plate_idx = 0;
store_params.thumbnail_data = thumbnails;
store_params.strategy = SaveStrategy::Silence | SaveStrategy::WithGcode | SaveStrategy::SplitModel | SaveStrategy::SkipModel;
bool success = Slic3r::store_bbs_3mf(store_params);
store_params.strategy = SaveStrategy::Silence | SaveStrategy::SplitModel | SaveStrategy::WithSliceInfo | SaveStrategy::SkipAuxiliary;
store_params.path = config_3mf_path.c_str();
success = Slic3r::store_bbs_3mf(store_params);
release_PlateData_list(plate_data_list);
return true;
}
void CalibUtils::send_to_print(const CalibInfo &calib_info, wxString &error_message, int flow_ratio_mode)
{
{ // before send
json j;
j["print"]["cali_mode"] = calib_info.params.mode;
j["print"]["start"] = calib_info.params.start;
j["print"]["end"] = calib_info.params.end;
j["print"]["step"] = calib_info.params.step;
j["print"]["print_numbers"] = calib_info.params.print_numbers;
j["print"]["flow_ratio_mode"] = flow_ratio_mode;
j["print"]["tray_id"] = calib_info.select_ams;
j["print"]["dev_id"] = calib_info.dev_id;
j["print"]["bed_type"] = calib_info.bed_type;
j["print"]["printer_prest"] = calib_info.printer_prest ? calib_info.printer_prest->name : "";
j["print"]["filament_prest"] = calib_info.filament_prest ? calib_info.filament_prest->name : "";
j["print"]["print_prest"] = calib_info.print_prest ? calib_info.print_prest->name : "";
BOOST_LOG_TRIVIAL(info) << "send_cali_job - before send: " << j.dump();
}
std::string dev_id = calib_info.dev_id;
std::string select_ams = calib_info.select_ams;
std::shared_ptr<ProgressIndicator> process_bar = calib_info.process_bar;
BedType bed_type = calib_info.bed_type;
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
error_message = _L("Need select printer");
return;
}
MachineObject* obj_ = dev->get_selected_machine();
if (obj_ == nullptr) {
error_message = _L("Need select printer");
return;
}
if (obj_->is_in_upgrading()) {
error_message = _L("Cannot send the print job when the printer is updating firmware");
return;
}
else if (obj_->is_system_printing()) {
error_message = _L("The printer is executing instructions. Please restart printing after it ends");
return;
}
else if (obj_->is_in_printing()) {
error_message = _L("The printer is busy on other print job");
return;
}
else if (!obj_->is_support_print_without_sd && (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)) {
error_message = _L("An SD card needs to be inserted before printing.");
return;
}
if (obj_->is_lan_mode_printer()) {
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) {
error_message = _L("An SD card needs to be inserted before printing via LAN.");
return;
}
}
print_worker = std::make_unique<PlaterWorker<BoostThreadWorker>>(wxGetApp().plater(), std::move(process_bar), "calib_worker");
auto print_job = std::make_unique<PrintJob>(dev_id);
print_job->m_dev_ip = obj_->dev_ip;
print_job->m_ftp_folder = obj_->get_ftp_folder();
print_job->m_access_code = obj_->get_access_code();
#if !BBL_RELEASE_TO_PUBLIC
print_job->m_local_use_ssl_for_ftp = wxGetApp().app_config->get("enable_ssl_for_ftp") == "true" ? true : false;
print_job->m_local_use_ssl_for_mqtt = wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false;
#else
print_job->m_local_use_ssl_for_ftp = obj_->local_use_ssl_for_ftp;
print_job->m_local_use_ssl_for_mqtt = obj_->local_use_ssl_for_mqtt;
#endif
print_job->connection_type = obj_->connection_type();
print_job->cloud_print_only = obj_->is_support_cloud_print_only;
PrintPrepareData job_data;
job_data.is_from_plater = false;
job_data.plate_idx = 0;
job_data._3mf_config_path = config_3mf_path;
job_data._3mf_path = path;
job_data._temp_path = temp_dir;
PlateListData plate_data;
plate_data.is_valid = true;
plate_data.plate_count = 1;
plate_data.cur_plate_index = 0;
plate_data.bed_type = bed_type;
print_job->job_data = job_data;
print_job->plate_data = plate_data;
print_job->m_print_type = "from_normal";
print_job->task_ams_mapping = select_ams;
print_job->task_ams_mapping_info = "";
print_job->task_use_ams = select_ams == "[254]" ? false : true;
CalibMode cali_mode = calib_info.params.mode;
print_job->m_project_name = get_calib_mode_name(cali_mode, flow_ratio_mode);
print_job->set_calibration_task(true);
print_job->has_sdcard = obj_->has_sdcard();
print_job->set_print_config(MachineBedTypeString[bed_type], true, false, false, false, true);
print_job->set_print_job_finished_event(wxGetApp().plater()->get_send_calibration_finished_event(), print_job->m_project_name);
{ // after send: record the print job
json j;
j["print"]["project_name"] = print_job->m_project_name;
j["print"]["is_cali_task"] = print_job->m_is_calibration_task;
BOOST_LOG_TRIVIAL(info) << "send_cali_job - after send: " << j.dump();
}
replace_job(*print_worker, std::move(print_job));
}
}
}