mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-23 21:05:31 -07:00
Merge some changes from BS 1.9 (#4994)
* FIX: do not touch the plate with different printing sequence jira: STUDIO-5424 Change-Id: I8ad00fa991b753de126a5bef0d320c452033e2e7 (cherry picked from commit c4adfe16e285f238f2c5cd8938b2167fdfb6b1b0) * FIX: global arrange setting is wrong global arrange setting is wrong if a plate's setting is changed from object list jira: STUDIO-5438 Change-Id: Iaa7f35837edbacff9b97ca17a8ab34c8e6bb023d (cherry picked from commit fa2f56575b2e4305e35dd59ff55e0881720de025) * FIX: temperature symbols not shown correctly Need to use wxString::FromUTF8 to convert unicode symbols to wxString. jira: none Change-Id: Ia8b559d437c956a2cc28916d8963823356402d05 * FIX:Repair calculation process of plate_box Jira: STUDIO-5520 Change-Id: I4c3f9597542ad2dfec4d7849e75fa28272fa4ea3 * FIX:frequent calls to _update_imgui_select_plate_toolbar Jira: STUDIO-5488 Change-Id: I12e6f37c2fe94de004aa6da43421970d6df10f0f * FIX: & is not displayed on the sending print page Jira: STUDIO-5343 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I1736bb97433581ff117bfe09afe8ee70c1b08fc4 * FIX: file name is not fully displayed if it is too long Jira: STUDIO-5230 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I992fa0c0575afbd2eecb2af02c8a305eda028f7f (cherry picked from commit d0d7fb0b1394429ee9d28d8ef4060a286ba0112d) * FIX: The warning box still exits when the temperature has reset. Jira: STUDIO-5562 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I7532db69880449eb3fa0a14fc4dfc61e7f6d518e (cherry picked from commit 589ed5fe045b5e7ec3effe437c9685085960c0fc) * FIX: White circle is not clear on auto refill page Jira: STUDIO-3262 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I05ac6257638063d32a9943c09bb7c14cc9229b3a * FIX: Groove text ctrl is not wide engough Jira: STUDIO-5434 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I93c0995473a72b5c19bc413c38c090906e360455 (cherry picked from commit e4a8b0ef5e62ba0053dc782c30ea79b237a46ac3) * FIX: values are not saved when clicking on an empty space Jira: STUDIO-4637 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I837050029635f673b3ae671ea1ad049aaf4fdd16 * FIX: Temperature warning is not fully displayed Jira: STUDIO-5038 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I460cbe2a5d0a092c4257b7bd5192058bf2e4707b * NEW: display bitmap when calibrating Jira: STUDIO-4661 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I60cf4f9769feca74699012418880e93fcfe34432 (cherry picked from commit 1213aea816694405311dc0c1061655a4c2a1d067) * FIX: remember the flow ratio calibration type Jira: STUDIO-5181 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: Id6125d1d4ea58972ce55c2c2498259596b25111e (cherry picked from commit 1af1038fd4824d989e992cb630cf34e00c787af7) * FIX: File panel crash on scroll Change-Id: I56833a376fa52c960efea5fbd60003367ba410c2 Jira: STUDIO-5337, STUDIO-5513 * FIX: auto arranging skip unprintable high items Jira: STUDIO-5646 Change-Id: I72dc3d8c71a075bab8204f4418e869a7a34c0c8e (cherry picked from commit 0afdf8361493485da2254c426719594fd9a982ed) * FIX: MediaFilePanel error state Change-Id: I318ef59fb97478ffee16dff594022b2b9029964a Jira: STUDIO-5638 * FIX: sync whole preset vendor directory Change-Id: I191dbe979a87ff35d38cab1149b7975664344838 Jira: STUDIO-5534 * ENH: support turn off liveview auto retry Change-Id: I24b39f74e0a40a13277d6eae3830c95c5c9de333 Jira: none (cherry picked from commit f6ceb3fb8e4df3f876c50a1c4ba96b4a1be60190) * FIX: SwitchButton auto scale font Change-Id: If4004c0963cc8bb2f41e8e71c304d5239bf252ab Jira: STUDIO-4969 STUDIO-4921 * FIX: set WEBKIT_DISABLE_COMPOSITING_MODE=1 for linux gtk Change-Id: I8a500585ca815948bab1210578ba5c45858ed78e Jira: STUDIO-5199 * FIX: Prefer old selection when sync AMS not compatible Change-Id: I6b18db51887132a997cf78d70fff9a92e23bc44a Jira: STUDIO-5416 * ENH: show liveview stat Change-Id: I70d1f458aa2ed379ad7fe07dee76fbe035316420 Jira: none * NEW:remember custom color Jira: STUDIO-5635 Change-Id: I439080f6a8ddb6fde3899cffbabc3b6e66afbd96 * FIX: copy live555 dll Change-Id: Idf727b8e26107e93aa9934299e87dc71531d1c63 Jira: STUDIO-4480 * FIX: optimize batch update object list on macOS Change-Id: I92e24cc53c0b3bf0658d15abc64292f0e17c0a82 Jira: STUDIO-5440 STUDIO-5515 * FIX: network plugins tip disappear on dark mode Change-Id: I422ab63f71158a49920438f01dd9c39774c27744 Jira: STUDIO-4891 * FIX: Display inconsistence in parameter table JIra: STUDIO-3716 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: I986473bcbb3efff4abd9c5917926d9e888a4f28c * FIX: Incomplete copy display in Transfer or discard dialog Jira: 5569 5549 Change-Id: I757b636259d7e1a222b9fc09276c12235360fd57 * FIX: Limit the max length of k when calibrating Jira: STUDIO-4291 Signed-off-by: wenjie.guo <wenjie.guo@bambulab.com> Change-Id: Ie7cff086cf2a3c744213525d5d83f9ac4b55333d * fix build break * FIX: delete sdcard file crash Change-Id: I814fd4b557fa92ac4060cbeb18a53f5616e49662 Jira: STUDIO-5977 * FIX: Yield when join media thread Change-Id: I746d7df88a0de8363da7d9507cb63c9e0ffe970a Jira: STUDIO-5952 * FIX: Guide page can't show in screen with mainframe Jira: STUDIO-4911 Change-Id: I7e89614e0f1585263456c847a1b38dcfd0ad59e6 * FIX: filament combox has blank line Change-Id: Ia39ddb564b3c9cc943d0ea4c0cf7cc4d24bef799 * FIX: load 3mf crash when studio has no base filament Jira: none Change-Id: I4387f425f60e6a53a53cf68addb1ab2d6f8f8901 Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * FIX:add resume button JIRA2860 Change-Id: I39035d929876ab3c84c5f5c3494376967300938c * FIX: CLI: fix an arrange issue when duplicate failed restore the wipe_tower position to original when duplicate fail JIRA: MAK-2638 Change-Id: I355056f1d87648cc1f6aafa15a98ff569359b44f * FIX: fix printer list without nozzle such as 0.35 or 0.75 Jira: 5409 Change-Id: I1a258fd10bcc03e297b791256880f2518d602905 * ENH:The first object should locate at plate center Jira: STUDIO-6023 Change-Id: If4284136fe63ca576463445f3ab16b6e18ead30f * FIX: Colored filament is not matched against. github: #2190 Colored filament is not matched against the same color in AMS slot. Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: Id4588fc9c8115a46881e2f5d198d79fe831f4371 * FIX: Revert "[STUDIO-4284] not set max height of liveview window" This reverts commit 0312aee4d9b92e23884be8802da9801ff3b9fe93. Reason for revert: STUDIO-5653 Jira: STUDIO-5653 Change-Id: If9d5f3e63968a0a54f9af1a2dae8f95f7f1f3f80 * ENH:modify file name rules when export stl Jira: STUDIO-6091 Change-Id: Ic27e4e341cc09099e98a5eab7dfd48416f2922ae * FIX: Flow calibration stage incorrect when switching printers Jira: 6093 Change-Id: I41f1ac10ac9422ac808eab3254f32ea14a0d3b76 * FIX: UserGuide Can not Click When Computer User name has chinese JIRA: None Change-Id: If50baa8c6a13eb501918fd5cdaf0ea3da7c788ef (cherry picked from commit 4e5ccc9f2de5ac429af6541c6a8bd412848801d0) * ENH: Little Optimize JS Code Execute Progress JIRA: STUDIO-5792 Change-Id: I12b03d8b968a9dd8dfce9eb3ef925fa8768e2046 (cherry picked from commit 2bf861092c9e306e1311eda8ac36fd981e73b6c2) * FIX: Delete Test Code JIRA: NONE Change-Id: I838a348edb22e09d2b1d5c41600c6fade535d184 (cherry picked from commit 51e664da0209ae8a3de5cbf30a72505c0b5bd028) * FIX: the object list order changed after clone github: 2798 Change-Id: I10a05ee7e00b05cb1255cfb708876ed784cabac7 * ENH: add alias for custom Filament preset Jira: XXXX Change-Id: I2fecc8b2bdb63618155e3d21f9db374a6119e416 * FIX: [5779] fix show alias logic when load preset Jira: 5779 Change-Id: I4fefe3c1ffbca9bd8296f1b3fdd5de48c6a36a28 * ENH: Optimize the logic for deleting third-party printers Mark the Filament and Process presets to be deleted first then delete the child presets first and then the parent presets. Jira: none Change-Id: I100b873baae96c6ba27af258e708e6ab8e6ee4ab * ENH:default selection of virtual tray jira:[for def selected] Change-Id: I0661f179f8e4bcac33ae12fbbeaeaf95c5b7c110 * ENH:add protection when no thumbnail data jira:[for protection] Change-Id: I3834a5ffde11ff54567dd854271184f06f94547f * FIX:fixed issue with chinese path jira:[Fixed the issue of failed loading of configuration files under Chinese path] Change-Id: I9badd8fc158fcf49f46411ac4e5f72d58823eeb2 * NEW:add new msg notification for hms jira:[STUDIO-6154] Change-Id: If1aa33030a99550d0c859d594a2711aea4dcea4a * NEW:using new humidity display ui jira:[STUDIO-5967] Change-Id: I13be4212e6b97f646d21e0af64cbc5006753fdeb * NEW:Dye materials above grade 10 with shortcut keys JIRA:STUDIO-5827 Change-Id: I002ecdd19167fb36772e4b4e9e2f7760e21079db * NEW:update automatically when inserting materials JIRA: STUDIO-6157 Change-Id: I2cefbb7b330ca4f13e841066548992b3fb3740f1 * FIX: check sdcard exists for file connect Change-Id: I69199a29294c04d1fe46ee66682085b1f1d1d049 Jira: none * FIX: not load printer files when it's busy Change-Id: Ie5a58befcfc0d7fa0d4e587e8429c0b1bfeff72a Jira: STUDIO-6105 * ENH: save video ctrl size to reduce layout change Change-Id: I470f29d7f029d304c9badeeb8f94bed281080b29 Jira: STUDIO-6141 * ENH: stop liveview track record Change-Id: Id4f236b239740bd919f2aa2f2892c1e63ce233bd Jira: STUDIO-6131 * FIX: thread safe of http extra headers Change-Id: I6ffa424be7ccb6abd78a66cc8be535f038b05469 Jira: none * optimize MeshBoolean * FIX: parse printer_model_id from 3mf Change-Id: Ib149c986885ee6412898f1f51dd5a4aaad0a596d Jira: none * ENH: find grid empty cells for fill bed if the item is too small jira: STUDIO-6015 Change-Id: I4e5eafdadd77482a27a8903d32bb83325283088d (cherry picked from commit 8df4da4a863cdc42c790a9d5da37f8633423e406) * ENH: always return product for firmware and lifycycle JIRA: STUDIO-6282 Change-Id: I1f942babdcb7afee2c9a9076ac539063c5406ad7 Signed-off-by: Stone Li <stone.li@bambulab.com> * ENH:STL tracking restricted area jira:[STUDIO-6155] Change-Id: I289c8b8aa8f62f0e5cc7004fb60437aa3337ca85 * NEW:add nozzle settings jira:[STUDIO-6226] Change-Id: I0db8333e5b5c8195add111fdcfa2e92387997815 * ENH:display the current humidity of AMS jira:[ENH] Change-Id: I98bdd6d70cd173ed640f0d96692fcb6836416bb8 * FIX: [6123] create printer for exist printer can not into next page Jira: 6123 Change-Id: I338ac0fde4f69b6f312f20e53851d91339e8156f * ENH: Display value of flushing volumes JIRA:STUDIO-6139 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I273fb22b0d378a839c34e9e0e9c414f0e5134799 * FIX: show printer file path & title Change-Id: Ie5eff188c3039deeca5da96b54407194bf8910a0 Jira: STUDIO-6268 * FIX: liveview error message Change-Id: Ie437e07916d7b6feae2dbcfa166c4e73bdcf31a1 Jira: STUDIO-6107 * FIX: file proto error message Change-Id: I2c4117961c615e424780fb3830441e6a93c50bcc Jira: none * ENH: earse sensitive fields when export configs Jira: None Change-Id: Id9ca0637240b80773f39d2308192f8c78a5de3c6 * fix build errors * FIX: unexpected layers in multi color print github: 3131 Change-Id: I2a42e3bbd2247fbc0957022e1baae43c9375a8fb * ENH: Add "New" button for PA cali Jira: XXXX Change-Id: Ic39f2508f2f9d390c2b9246fb3d3e281cde9b064 * NEW:add printer compatible check from sd card view jira:[STUDIO-5969] Change-Id: I86d10ebe2e9bc77e6350e26aeed6b4f0f9fdcecb * NEW:enable loadl/unload when printing pause jira:[STUDIO-5968] Change-Id: Ieb3ef2423378e44b81a61a2b18c16f68aa335922 * FIX:fixed HMS message not cleared jira:[STUDIO-6296] Change-Id: Ic7692ce337fd00ece4ab8d65214a8c406f8543f8 * ENH:error code setting default value jira:[for error code] Change-Id: Ica61344c8217d41adb2947a40f633dc8d19a197a * ENH:display conflict information jira:[STUDIO-6297] Change-Id: Ie1501323a7e8d9ceb4060ae6c0b4eab20f8b088a * ENH: refresh printer file list Change-Id: Ic86942d2b0b2e8383ef0f06311164aad59e837ad Github: 3383 * FIX: Unnecessary prime tower error prompts Custom gcode on other plate causes unnecessary prime tower error prompts Jira: 6305 Change-Id: If499659b364a6b6898db1587b7b2aeed03758667 * FIX:multi colour displayed as gradient color on AMS JIRA:5925 Change-Id: Ic7a925dda2e3bde066ba40ba27002569040f9518 * NEW:Color painting shortcut keys 10~16 JIRA:STUDIO-6238 Change-Id: I3cce838fad5e73d41f109b32f2e563716fd5b0da * ENH: Print when unnamed project, task named as object names github: #2286 Change-Id: I9be3fd25d16a00b78326ec43db9afcf3645d90f1 * ENH:reset user access code jira:[for lan mode] Change-Id: I2d0ed48411d683c3f20b2febc0d54747287870a7 * FIX:fixed crash when selecting new printer jira:[fix] Change-Id: I6a81186e822eb6bf6ce7aa70561dfae35d4de0e7 * FIX: not show printer's camera error when updating Jira: STUDIO-6232 Change-Id: I985d75b3772849e07100799c4f13db5d4cbafde3 * FIX: clear error after reload file list ok Change-Id: I5d5e4f2870302b198d3a9d40603a6fa8010b7e76 Jira: STUDIO-6306 * ENH: custom filament sync with printer 1. prompt sync user presets when create custom filament 2. Fix the issue of not displaying printers when creating custom Filaments based on presets when selecting PLA Aero Type. 3. Optimizing the traversal logic during AMS Setting Pop up reduces time complexity and allows for quick pop ups. Additionally, using nozzle calibers for retrieval and repairing custom materials may result in inaccurate retrieval. 4. Implement synchronization logic with the printer -a. Received slot information, reset the slot when the "filament_id" in the information does not exist in Studio -b. Received slot information, the nozzle temperature in the information is different from the preset nozzle temperature in Studio, reset the current temperature. Jira: none Change-Id: I511dc82563ec77a341839671d398607048ce1985 Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * NEW: add api of "toggle_selected_volume_visibility" Jira: STUDIO-6166 Change-Id: I77eb988a3ea43cd37d50888d1753b973795d8b36 * FIX: No data in the drop-down menu of the AMS settings page Jira: 6342 6343 Change-Id: I6938fb4a7ae2816a4675d8d739622e25f219f469 * fix build error * FIX: label wrap all & ping test for liveview Change-Id: I7767ed0740e20bb578b6ef9f5e9873c8c79d172a Jira: STUDIO-5821 * ENH: reuse controls in param Field Change-Id: I42bb4da01e1e9b64c343b7fda4357a9553cf8684 Jira: STUDIO-5983 * FIX: use wide path to create camera process Change-Id: I5de31fce0dea14df9a0ad363f3cb16dc40c275bc Jira: STUDIO-4946 * ENH: optimize the get_tool_order func Use Dp to refine performance jira:[NEW] Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I38b0c875e4deee9d9fbe926087fb5b2e274f8f90 (cherry picked from commit 9b7b66dc7a1f5e3efa318227ae7694bec5ec1216) * Fix build errors * ENH: add customize other layers print sequence Jira: 6338 Change-Id: Ic14b2671ade37ab37583b81c5b509447b6c0d8f8 * ENH: [#3236] Unsaved changes to interface copy adjustment github: #3236 Change-Id: I53931859bdcdfedfa9f63f6239d0fd2fd6d2766c * NEW: support to adjust other layers print sequence Jira: 6338 Change-Id: I5e6aef71aa9e6e97c1859aaaeb9ada5f1340414a * FIX: imgui support toolbar window text wrapping issue jira: STUDIO-5821 Change-Id: I57ee984baffbb2f00a7ecc5d5c8061074b06aff6 * FIX: updater: fix force upgrade logic JIRA: STUDIO-6393 Change-Id: I46c51e09e7390e5ab0de40215911aac9635ab476 (cherry picked from commit 673ba6ff4ebda039d71dcbfdaa28c1252f5b8821) * FIX:final step of slicing is to execute post-processing script JIRA: STUDIO-5828 Change-Id: I8c33e2a66ac5c692244c778586040663b7b54bd7 * NEW:enable 3dMouse detect in .conf JIRA: 5830 Change-Id: I8731e0244d2f551130c84bcfbbb46967ae6b19cd * FIX:finish init "return" icon and hide it Jira: STUDIO-6350 Change-Id: I0f1efd4a64ea204daeac7de822602ef6dfa3e4a5 * FIX: seq_print: fix an invalid warning caused by sinking github: https://github.com/bambulab/BambuStudio/issues/3007 Change-Id: I1111910f2c625d5a871ea01b37dbfa7b04a849ee (cherry picked from commit a3db95bb0940d5afe07ef0bb07113cc2acd7cd0a) * ENH: plater: optimize the loading time of 3mf with large objects JIRA: STUDIO-6021 Change-Id: Ia97f681041bb553c5c4b5b1d9109e5e5c42daf6b * FIX:Fixed HMS issue jira:[STUDIO-6344 STUDIO-6310 STUDIO-6356 STUDIO-6348] Change-Id: I9d6660e7c349775004b69bfe41b651bfa8b359b7 * ENH:handling dirty data after nozzle settings jira:[STUDIO-6332] Change-Id: I00d6d1324376f973ec3cf9f2154ae83ef3302705 * ENH: use Bambu_StartStreamEx for agora tunnel Change-Id: I5c28dea49d267bf7ff967d0982dd83555899c8c4 Jira: none * FIX: use safe language code for http Change-Id: Id1f4927308350ee35b891a5352cbf1e2d0c2577e Github: 3655 * FIX: add cli_id, cli_ver to bambu url Change-Id: Ic527d1497c6dee0c723d7b4629f0be825a8f7545 Jira: none * FIX: not throw when _add_auxiliary_dir_to_archive Change-Id: Idf54bbbd0ef557ec5e1a8e51ed669a1eb1fb4261 Jira: STUDIO-6339 * NEW: vase mode can be applied to one plate jira: STUDIO-5838 Change-Id: Ifb315f7d79b570aeb7ee31d3495b4d465e3af0c6 * fix crashes * ENH: update overhang degree method on calssic mode Jira: none Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I90f6e4c2ef618fdaef00bdaf1ca309893f484c1e * FIX: auto-arranging unprintable items may crash github: #3676 Change-Id: I68eb87c73ad2c0c269f60e661136fd1a72ee5e2f (cherry picked from commit 7e3c57eaa811424935fe8db6a4e77dd142ee2b58) * FIX: use old slicer_uuid for client_id Change-Id: I6c45e83213d613fc28eef04115f9cfb19dea703e Jira: none * ci: update network module based on commit 542ced8 Change-Id: I3ad5032cc56a99d1c3a687b2891d147b13af066d * NEW:Support OLTP file Jira: STUDIO-6421 Change-Id: I58bc94e978e6d2dd136ea370fb01f6ec80e14b23 * ENH: detect in_head_wrap_zone more precisly 1.Union first layer convex hull with object's bbox to detect whether model enter head_wrap_detect_zone jira:NEW Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com> Change-Id: I11f26967d7421f41e9c824e62794c96591e6ae71 * FIX: fix the plate cannot be searched JIRA: STUDIO-6283 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I88206c91ea24c6a41a0bd06f05f0f3c2fdc58a36 * NEW:hms error code JIRA: STUDIO-6302 Change-Id: Ia33511f4c636c8ada39ed5a4e52d9b185da9c00b * FIX:Color adaptation for numpad JIRA:STUDIO-6410 Change-Id: If6e49638af8616fd349367073883592e6bebb503 * FIX: error overhang degree mapping Jira: none Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: Ifa24aa0cad0a06b09ee62a8be8781188a765d1d0 * FIX:display correct humidity jira:[fix] Change-Id: I27aae54a8355911b5d88ed45be320d3c9178081c * ENH:Hide confirmation button when unable to send print jira:[STUDIO-6355, STUDIO-6332] Change-Id: I8f9c0edea4d5ee70e9fef1e9d42838d598dc32c4 * NEW: new type for Custom Filament Type: "PE", "PP", "EVA", "PHA", "BVOH", "PE-CF", "PP-CF", "PP-GF" Github: 3205 3169 3127 Change-Id: I8a30dd806c35460d9dae0f808190ce013b125d51 Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * FIX:fixed filament settings page display error in French jira:[STUDIO-5821] Change-Id: I6cc6dd9b83c7570688c2adc55efe2407cbcb4390 * FIX:fixed thumbnail not updating when using multiple plates jira:[STUDIO-6313] Change-Id: If49daa5b38b9a580ae226ff00a1e0085d167c15c * FIX: Color Bleed in slicer github: 3681 jira: 6450 Change-Id: Icb6274f7ddb238c238c133b95167310b1af905f7 * ci: update network module based on commit 8befd46 Change-Id: I3a6420684f106bdde5897a50d27dfec69e0aa37f * ci: update network module based on commit e411785 Change-Id: I3a9c7bfa5ac5a942f339ad0194a24d9170847371 * FIX:reload paint after background process apply Jira: STUDIO-6493 Change-Id: I9a1986152f05163f236f58bb24210b690ca3d562 * FIX: use object name of plate when send task in untitled project Jira: 6430 Change-Id: I78ec811fab1cf028c0d5f81ac7738abdbeb6145f * FIX: auto arranging spacing can't be adjusted correctly jira: none Change-Id: Ibddfe85aab9f3fad6a1612e8db437e52c40e20a3 (cherry picked from commit 136bca01f45e62042bd699a9a0a9f6d13519712c) * FIX: fix change nozzle temp in Studio but printer not change Jira: 6510 Change-Id: Ia0e1ac586ff41ddbabdac0845415e70774299387 Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * ENH:rename some img files jira:[STUDIO-6512] Change-Id: I69872533cccda37b94384bc219cc35c5dec9310b * ENH:PEI bed is no longer unchecked by default jira:[STUDIO-6508] Change-Id: Ic9ca99860d46c27ca4c36a735df3f57fe71417df * FIX:fix the load status of vtray jira:[STUDIO-6435] Change-Id: I8cafcc0b6caf19492aae6c153fb509f470dc7e83 * FIX: Supports automatic calibration of textured PEI jira: 6504 Change-Id: I3234fb555b9bf0ea97e73387651874733e761ee7 * ENH:add tooltip for search item JIRA: STUDIO-6459 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I7602a32159d21de8f37ea0208dd6a9f59b90dcce * ENH: CLI: add version check logic add option allow_newer_file Change-Id: I8e8e4a45f77ebdd6dae6189841e4a9952e95ca82 * ci: update build version to 01.09.00.52 Change-Id: Id6e32b5afcf5eaabce9c0c7ab2c422e97b00e632 * NEW: switch to object panel if double click on object jira: none switch to object panel if double click on object, otherwise switch to global panel if double click on background. Change-Id: I6e54d7957aa19f1ebb1f993bc38125bbee8a1c98 (cherry picked from commit cc2e07bc9489c76a7d767acff0406c83c996504c) * FIX:fixed loading img resource failure jira:[for fix img load] Change-Id: Ifb26b2ca23029abeda000322bf2ef7d2b3cda3b4 * FIX: Project Title can Click JIRA: none Change-Id: I614c60e76efe04875e36e3a8ef7a10acd3ef9ecf * FIX:Prioritize selecting filament with smaller serial numbers in AMS JIRA: 5909 Change-Id: If3030d4dd8d59af36bc1ae1801be1b89b0027a71 * NEW:material adaptation in select machine dialog JIRA:xxxx Change-Id: I625eac75c88cad804dd3741f750c5ea68a975421 * FIX:mac ams setting display JIRA: STUDIO-6228\6409 Change-Id: I432a3aa96601a8e223b5949bc0ad5234c1374dca * FIX: Image Scale Mode and Online Display JIRA: none Change-Id: I528f16e93b82748d86dc93e2dd3d85f317babaa7 * FIX: sequential_print_clearance_valid not working not working correctly with short objects jira: STUDIO-6489 Change-Id: I33e1a165f448e1c3e272d4045934c63ad345db2f (cherry picked from commit 9348eaa22a056db5384a38ea966cec9ba4a533a7) * NEW: add nozzle_height to machine profile and do not detect conflict Jira: request from 1.9 1. add nozzle_height to machine profile 2. auto arranging and sequential_print_clearance_valid don't consider objects conflicting if they are all shorter than nozzle_height and close. 3. do not detect conflict when all models are short. Change-Id: I8d1eebb15d5bfa8c40d7491e033149e360531b89 (cherry picked from commit 6b4b52653db5f08d724a556c5c766c0bfa00f34d) * FIX: sequential_print_clearance_valid not working not working correctly with short objects jira: STUDIO-6489 Change-Id: I33e1a165f448e1c3e272d4045934c63ad345db2f (cherry picked from commit 9348eaa22a056db5384a38ea966cec9ba4a533a7) * FIX: [6510] set nozzle temp incorrectly when popup AMS Setting Change-Id: I898f0b94794a3d67017b1917ce196c4019f5eb4a * FIX: auto-calculate flushing volumes JIRA: STUDIO-6547 FIX the first modification of consumable color after synchronizing filaments, without automatically calculating the flushing volumes Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I2bc76a29afde5241d100cc42a5161db0f9b901c4 * FIX: custom layer sequence from End to End comboBox display issue jira: new Change-Id: I413cd5896d7e921f2c7c03b91b08788fefb9a4f3 * FIX:fix the v tray's filament unload logic jira:[STUDIO-6627] Change-Id: I34420bc4d1d27b6b36defb9852bba2eaf77fdcf2 * NEW:reducing purge through retracting filament 1.reducing purge through retracting filament.Currently only applicable to X&P series github: PR#3100 Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com> Change-Id: Ie328039872e50e699dc5e5082fa99f68ac5f5fd1 * FIX: wrong role cache in wipe tower 1. Add wipe tower role cache in GCodeProcessor result 2. Add wiki link for prime tower jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ia766c7218df68fb1ffba567af193d6bfecacf588 * Fix plate settng icon * NEW:revert hms error code Change-Id: Ib5cc8bb8b8ced0f70d5bbe4751a1f97258218c6f * FIX: calibration page button broken display issue jira: STUDIO-3913 Change-Id: I2fd488e829d898b7d81d09db814ed6518f0c54a8 * FIX: do not check spiral vase mode config if an object is loaded jira: STUDIO-6514 Change-Id: Ib44ec8322ff178b5765f7fe94b588aa38339691d * FIX: implicitly set spiral vase config for objects just loading jira: 6514 Change-Id: I04bb2b1abeb62d4dfff4e526b723b1cf1bd5fd7f * FIX: filling bed fails if the bed is already full JIRA: STUDIO-6490 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I71b5a01a95cdffef7c0750e6347fa8911dcd781d * ci: update network module based on commit 868f5d7 Change-Id: I5584e4441e1f2ab400addaa87ee8013927fb9e15 * FIX: add query_real_volume_idx_from_other_view api Jira: STUDIO-6545 Change-Id: Ib8216981c5d2945a0221a5caa1fbc14ed74e930b * FIX: Can't edit text github: 3750 Change-Id: I1caecaa968e60cadcdbe9f7aa67cba141bb88230 * FIX: Slicer creates invalid color pattern github: 3749 Change-Id: I3fd74a9ca59b75873fcbca4437e4858c749ee853 * ENH: hide tuck did Change-Id: I9021d3f51c9a73bc9208b479f96b1ddbe7a2f8f8 Jira: none * FIX: PrinterFileSystem: retry connect on user action Change-Id: I3e8902298385ed2e5906fd15d1817b6e33522a76 Jira: STUDIO-6354 * FIX: Remove user ID and other information Jira: XXXX Change-Id: Ia63ec88a335d88fd40a29952abe6d40d8991efee * ENH: refine retraction before cut 1. Add filament retraction before cut control jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ifcb087c9791c0461b793ef811b21ebd4c007d880 * FIX: enable resumed read only Field Change-Id: Id09e671932458699c020f0a061d8cfc11a6958ab Jira: STUDIO-6641 * ENH: add precise_z_height jira: none Change-Id: Idb9fcf0063e773f1531a49961478460b91ded10f * ENH: modify the multi-material segmentation and voronoi This patch is cherry pick from Prusa, thanks to Prusa Rework multi-material segmentation to work directly on the Voronoi diagram without creating a copy of it. Previous algorithms assume that they can get an invalid Voronoi diagram. Because of that, during the multi-material segmentation, a copy of the Voronoi diagram was created, and there were several attempts to fix missing vertices and edges. But as it shows, this wasn't a good enough approach and sometimes led to several issues like bleeding layers. After generalization, our approach for detection and repairs of invalid Voronoi diagrams from Arachne, we could assume that multi-material segmentation gets non-invalid Voronoi diagrams. With this assumption, we reimplement multi-materials segmentation to work directly on the Voronoi diagram. That should make multi-material segmentation more stable. So, this should fix several issues like bleeding layers. Also, memory consumption should decrease by a lot. Also, there should be some speedup of multi-materials segmentation. Jira: none Change-Id: I72aa6e1f9634d9ee8759aa469a0b39a36ace62f5 * FIX: infill speed not work on region level Jira: none Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: Ie3d17c5e3cbf91a8854e3b4cd80babeb2b1bd121 * ENH: support saving PA calibration results for P series Jira: none Change-Id: I9402b8bcce7b48a63d0e97e0708080701d065e7a * ENH: refine long retraction ui 1. associate button display logic 2. Add valid range tip 3. seperate the printer into three types jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ie14c8746eb20456dacd5c129a5449c1e7c7db372 * FIX:height range cut = volume_count * 2 Jira: none Change-Id: I539c2f9cda7985b4b3c318ca8aa1eb7c52fdce82 * FIX: auto arranging gets wrong object height obj->bounding_box().size() is not the real object size if the object has been rotated. jira: STUDIO-5999 Change-Id: I6553d4c990696efd674e3e57063802127d5d5282 (cherry picked from commit 479ea9fb02f55d24f27c94633f3d852bd5c62c83) * ENH: seperate support weight from model jira:NEW Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com> Change-Id: I86bb34941269bf1aa29436a94ebbdff675497e85 * ENH: add support for gcodeviewer statistics jira: new Change-Id: Ied6d61e8c48ac82daf16579d9caed9723cf8e29d * FIX: invalid support weight per extruder jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I0e4b857c9c758ab7c54ef13aee1bf596f975640b * FIX: do not need reset bed_type for pa calibration jira: none Change-Id: I411064cf14d94a9bd1f0f6668ee23aa10d372f3d * FIX: P1P/S can not modify the k value in old version jira: 6745 Change-Id: I5c9dffe8e998213e6af6e1d01a6b0ae82521e8db * Add rotation support for 3D Honeycomb Ported from BS * ENH: add default params for long retraction 1. Only auto calculate flush when enabled 2. Add default params for long retraction 3. Disable filament override for unsupport machines jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ib5d51505b58101839527e944f9a237483951f9fe * misc fixes * ENH: remove long retraction warning jira:NEW Signed-off-by: tao wang <tao.wang@bambulab.com> Change-Id: If60236b3282991a2d94df7d125427cff86899536 * avoid zero length path * FIX: check recommended nozzle temperature Jira: XXXX Change-Id: I4dbb274cf27ef9c6d20a8479b29af1069652b2bc * FIX: fix not popping up a prompt when the temperature is set to 0 Jira: 6497 Change-Id: I6498fc6962e7da376d4c652dab0a99a161932eef Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * ENH: When creating a custom Filament, use the system Filament type. Jira: 6301 Change-Id: I1bfddcf43d2ebaebca4eb494d1f64165c3d59e9e Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com> * FIX: seam and unretarct pos error on smooth vase casused by invalid path of smooth vase mode Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: Ib597e8c05760886aae2c42e42e8d46e82b844578 * FIX: unable to map if filament not used in model 1.Fix filament can not map if it's not used in model body jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ibd2685ffd198b2e17dbf44289d0144b5b7c25788 * NEW:Update data only on device pages jira:[STUDIO-6776] Change-Id: I33b0c9f35c1dc6df2db3b6bd4f446f46b31ecf6c * set(SLIC3R_VERSION "01.09.00.70") * update BBL machine profile 01.09.00.04 * scarf clip start and end Ported from BambuStudio * fix linux build error --------- Co-authored-by: Arthur <arthur.tang@bambulab.com> Co-authored-by: zhou.xu <zhou.xu@bambulab.com> Co-authored-by: wenjie.guo <wenjie.guo@bambulab.com> Co-authored-by: chunmao.guo <chunmao.guo@bambulab.com> Co-authored-by: maosheng.wei <maosheng.wei@bambulab.com> Co-authored-by: hu.wang <hu.wang@bambulab.com> Co-authored-by: lane.wei <lane.wei@bambulab.com> Co-authored-by: Kunlong Ma <kunlong.ma@bambulab.com> Co-authored-by: zhimin.zeng <zhimin.zeng@bambulab.com> Co-authored-by: zorro.zhang <zorro.zhang@bambulab.com> Co-authored-by: tao wang <tao.wang@bambulab.com> Co-authored-by: Stone Li <stone.li@bambulab.com> Co-authored-by: xun.zhang <xun.zhang@bambulab.com> Co-authored-by: liz.li <liz.li@bambulab.com> Co-authored-by: qing.zhang <qing.zhang@bambulab.com> Co-authored-by: gerrit <gerrit@bambulab.com> Co-authored-by: Leon Fisher-Skipper <47602359+LeonFisherSkipper@users.noreply.github.com> Co-authored-by: Lukas Matena <lukasmatena@seznam.cz> Co-authored-by: jianjia.ma <jianjia.ma@bambulab.com>
This commit is contained in:
parent
c6094d48aa
commit
1bb8fad63f
484 changed files with 11279 additions and 3579 deletions
|
|
@ -80,6 +80,7 @@ using namespace nlohmann;
|
|||
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __WXGTK__
|
||||
|
|
@ -124,6 +125,7 @@ std::map<int, std::string> cli_errors = {
|
|||
{CLI_OBJECT_ARRANGE_FAILED, "An error occurred when auto-arranging object(s)."},
|
||||
{CLI_OBJECT_ORIENT_FAILED, "An error occurred when auto-orienting object(s)."},
|
||||
{CLI_MODIFIED_PARAMS_TO_PRINTER, "Found modified parameter in printer preset in the 3mf file, which should not be changed."},
|
||||
{CLI_FILE_VERSION_NOT_SUPPORTED, "Unsupported 3MF version. Please make sure the 3MF file was created with the official version of Bambu Studio, not a beta version."},
|
||||
{CLI_NO_SUITABLE_OBJECTS, "One of the plate is empty or has no object fully inside it. Please check that the 3mf contains no empty plate in Orca Slicer before uploading."},
|
||||
{CLI_VALIDATE_ERROR, "There are some incorrect slicing parameters in the 3mf. Please verify the slicing of all plates in Orca Slicer before uploading."},
|
||||
{CLI_OBJECTS_PARTLY_INSIDE, "Some objects are located over the boundary of the heated bed."},
|
||||
|
|
@ -889,6 +891,8 @@ int CLI::run(int argc, char **argv)
|
|||
// instruct the window manager to fall back to X server mode.
|
||||
::setenv("GDK_BACKEND", "x11", /* replace */ true);
|
||||
|
||||
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", /* replace */ false);
|
||||
|
||||
// Also on Linux, we need to tell Xlib that we will be using threads,
|
||||
// lest we crash when we fire up GStreamer.
|
||||
XInitThreads();
|
||||
|
|
@ -1028,7 +1032,7 @@ int CLI::run(int argc, char **argv)
|
|||
int arrange_option;
|
||||
int plate_to_slice = 0, filament_count = 0, duplicate_count = 0, real_duplicate_count = 0;
|
||||
bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false, normative_check = true, duplicate_single_object = false, use_first_fila_as_default = false, minimum_save = false, enable_timelapse = false;
|
||||
bool allow_rotations = true, skip_modified_gcodes = false, avoid_extrusion_cali_region = false;
|
||||
bool allow_rotations = true, skip_modified_gcodes = false, avoid_extrusion_cali_region = false, skip_useless_pick = false, allow_newer_file = false;
|
||||
Semver file_version;
|
||||
std::map<size_t, bool> orients_requirement;
|
||||
std::vector<Preset*> project_presets;
|
||||
|
|
@ -1073,6 +1077,14 @@ int CLI::run(int argc, char **argv)
|
|||
if (skip_modified_gcodes_option)
|
||||
skip_modified_gcodes = skip_modified_gcodes_option->value;
|
||||
|
||||
ConfigOptionBool* skip_useless_picks_option = m_config.option<ConfigOptionBool>("skip_useless_pick");
|
||||
if (skip_useless_picks_option)
|
||||
skip_useless_pick = skip_useless_picks_option->value;
|
||||
|
||||
ConfigOptionBool* allow_newer_file_option = m_config.option<ConfigOptionBool>("allow_newer_file");
|
||||
if (allow_newer_file_option)
|
||||
allow_newer_file = allow_newer_file_option->value;
|
||||
|
||||
ConfigOptionBool* avoid_extrusion_cali_region_option = m_config.option<ConfigOptionBool>("avoid_extrusion_cali_region");
|
||||
if (avoid_extrusion_cali_region_option)
|
||||
avoid_extrusion_cali_region = avoid_extrusion_cali_region_option->value;
|
||||
|
|
@ -1124,8 +1136,8 @@ int CLI::run(int argc, char **argv)
|
|||
const std::vector<int> clone_objects = m_config.option<ConfigOptionInts>("clone_objects", true)->values;
|
||||
//when load objects from stl/obj, the total used filaments set
|
||||
std::set<int> used_filament_set;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("allow_multicolor_oneplate %1%, allow_rotations %2% skip_modified_gcodes %3% avoid_extrusion_cali_region %4% loaded_filament_ids size %5%, clone_objects size %6%")
|
||||
%allow_multicolor_oneplate %allow_rotations %skip_modified_gcodes %avoid_extrusion_cali_region %loaded_filament_ids.size() %clone_objects.size();
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("allow_multicolor_oneplate %1%, allow_rotations %2% skip_modified_gcodes %3% avoid_extrusion_cali_region %4% loaded_filament_ids size %5%, clone_objects size %6%, skip_useless_pick %7%, allow_newer_file %8%")
|
||||
%allow_multicolor_oneplate %allow_rotations %skip_modified_gcodes %avoid_extrusion_cali_region %loaded_filament_ids.size() %clone_objects.size() %skip_useless_pick %allow_newer_file;
|
||||
if (clone_objects.size() > 0)
|
||||
{
|
||||
if (clone_objects.size() != m_input_files.size())
|
||||
|
|
@ -1223,6 +1235,12 @@ int CLI::run(int argc, char **argv)
|
|||
BOOST_LOG_TRIVIAL(info) << "object "<<o->name <<", id :" << o->id().id << ", from bbl 3mf\n";
|
||||
}*/
|
||||
|
||||
Semver cli_ver = *Semver::parse(SLIC3R_VERSION);
|
||||
if (!allow_newer_file && ((cli_ver.maj() != file_version.maj()) || (cli_ver.min() < file_version.min()))){
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Version Check: File Version %1% not supported by current cli version %2%")%file_version.to_string() %SLIC3R_VERSION;
|
||||
record_exit_reson(outfile_dir, CLI_FILE_VERSION_NOT_SUPPORTED, 0, cli_errors[CLI_FILE_VERSION_NOT_SUPPORTED], sliced_info);
|
||||
flush_and_exit(CLI_FILE_VERSION_NOT_SUPPORTED);
|
||||
}
|
||||
Semver old_version(1, 5, 9), old_version2(1, 5, 9);
|
||||
if ((file_version < old_version) && !config.empty()) {
|
||||
translate_old = true;
|
||||
|
|
@ -2605,8 +2623,8 @@ int CLI::run(int argc, char **argv)
|
|||
//flush_vol_vector.resize(project_filament_count);
|
||||
//set multiplier to 1?
|
||||
m_print_config.option<ConfigOptionFloat>("flush_multiplier", true)->set(new ConfigOptionFloat(1.f));
|
||||
ConfigOption* extra_flush_volume_opt = m_print_config.option("nozzle_volume");
|
||||
int extra_flush_volume = extra_flush_volume_opt ? (int)extra_flush_volume_opt->getFloat() : 0;
|
||||
|
||||
const std::vector<int>& min_flush_volumes = Slic3r::GUI::get_min_flush_volumes();
|
||||
|
||||
if (filament_is_support->size() != project_filament_count)
|
||||
{
|
||||
|
|
@ -2615,9 +2633,13 @@ int CLI::run(int argc, char **argv)
|
|||
flush_and_exit(CLI_CONFIG_FILE_ERROR);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("extra_flush_volume: %1%")%extra_flush_volume;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("filament_is_support: %1%")%filament_is_support->serialize();
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("flush_volumes_matrix before computing: %1%")%m_print_config.option<ConfigOptionFloats>("flush_volumes_matrix")->serialize();
|
||||
{
|
||||
std::ostringstream volumes_str;
|
||||
std::copy(min_flush_volumes.begin(), min_flush_volumes.end(), std::ostream_iterator<int>(volumes_str, ","));
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("extra_flush_volume: %1%") % volumes_str.str();
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("filament_is_support: %1%") % filament_is_support->serialize();
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("flush_volumes_matrix before computing: %1%") % m_print_config.option<ConfigOptionFloats>("flush_volumes_matrix")->serialize();
|
||||
}
|
||||
for (int from_idx = 0; from_idx < project_filament_count; from_idx++) {
|
||||
const std::string& from_color = project_filament_colors[from_idx];
|
||||
unsigned char from_rgb[4] = {};
|
||||
|
|
@ -2641,7 +2663,7 @@ int CLI::run(int argc, char **argv)
|
|||
//BOOST_LOG_TRIVIAL(info) << boost::format("src_rgba {%1%,%2%,%3%,%4%} dst_rgba {%5%,%6%,%7%,%8%}")%(unsigned int)(from_rgb[0]) %(unsigned int)(from_rgb[1]) %(unsigned int)(from_rgb[2]) %(unsigned int)(from_rgb[3])
|
||||
// %(unsigned int)(to_rgb[0]) %(unsigned int)(to_rgb[1]) %(unsigned int)(to_rgb[2]) %(unsigned int)(to_rgb[3]);
|
||||
|
||||
Slic3r::FlushVolCalculator calculator(extra_flush_volume, Slic3r::g_max_flush_volume);
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], Slic3r::g_max_flush_volume);
|
||||
|
||||
flushing_volume = calculator.calc_flush_vol(from_rgb[3], from_rgb[0], from_rgb[1], from_rgb[2], to_rgb[3], to_rgb[0], to_rgb[1], to_rgb[2]);
|
||||
if (is_from_support) {
|
||||
|
|
@ -3540,6 +3562,7 @@ int CLI::run(int argc, char **argv)
|
|||
bool finished_arrange = false, first_run = true;
|
||||
Slic3r::GUI::PartPlate* cur_plate = nullptr;
|
||||
int low_duplicate_count = 0, up_duplicate_count = duplicate_count, arrange_count = 0;
|
||||
float orig_wipe_x = 0.f, orig_wipe_y = 0.f;
|
||||
|
||||
if (duplicate_count > 0) {
|
||||
original_model = model;
|
||||
|
|
@ -3566,8 +3589,22 @@ int CLI::run(int argc, char **argv)
|
|||
unprintable.clear();
|
||||
locked_aps.clear();
|
||||
}
|
||||
else
|
||||
else {
|
||||
first_run = false;
|
||||
if (plate_to_slice > 0) {
|
||||
ConfigOptionFloats* wipe_x_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_x");
|
||||
ConfigOptionFloats* wipe_y_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_y");
|
||||
|
||||
if (wipe_x_option && (wipe_x_option->size() > (plate_to_slice-1))) {
|
||||
orig_wipe_x = wipe_x_option->get_at(plate_to_slice-1);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%, plate_to_slice %2%, orig_wipe_x=%3%")%__LINE__%plate_to_slice%orig_wipe_x;
|
||||
}
|
||||
if (wipe_y_option && (wipe_y_option->size() > (plate_to_slice-1))) {
|
||||
orig_wipe_y = wipe_y_option->get_at(plate_to_slice-1);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%, plate_to_slice %2%, orig_wipe_y=%3%")%__LINE__%plate_to_slice%orig_wipe_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_plate = (Slic3r::GUI::PartPlate *)partplate_list.get_plate(plate_to_slice-1);
|
||||
cur_plate->duplicate_all_instance(duplicate_count, need_skip, skip_maps);
|
||||
|
|
@ -4000,11 +4037,22 @@ int CLI::run(int argc, char **argv)
|
|||
if (duplicate_count == 0)
|
||||
{
|
||||
//restore to the original
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": restore to the original model and plates");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": restore to the original model and plates, orig_wipe_x %1%, orig_wipe_y %2%")%orig_wipe_x %orig_wipe_y;
|
||||
finished_arrange = true;
|
||||
model = original_model;
|
||||
partplate_list.load_from_3mf_structure(plate_data_src);
|
||||
partplate_list.reset_size(current_printable_width, current_printable_depth, current_printable_height, true, true);
|
||||
if ((orig_wipe_x > 0.f) && (orig_wipe_y > 0.f))
|
||||
{
|
||||
ConfigOptionFloat wt_x_opt(orig_wipe_x);
|
||||
ConfigOptionFloat wt_y_opt(orig_wipe_y);
|
||||
ConfigOptionFloats* wipe_x_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_x", true);
|
||||
ConfigOptionFloats* wipe_y_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_y", true);
|
||||
|
||||
wipe_x_option->set_at(&wt_x_opt, plate_to_slice-1, 0);
|
||||
wipe_y_option->set_at(&wt_y_opt, plate_to_slice-1, 0);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": restore wipe_tower position to {%1%, %2%}")%orig_wipe_x %orig_wipe_y;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
||||
}
|
||||
continue;
|
||||
|
|
@ -4013,7 +4061,7 @@ int CLI::run(int argc, char **argv)
|
|||
if (duplicate_single_object)
|
||||
{
|
||||
if (real_duplicate_count <= 1) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "no object can be placed under single object mode, restore to the original model and plates also" << std::endl;
|
||||
BOOST_LOG_TRIVIAL(warning) << boost::format("no object can be placed under single object mode, restore to the original model and plates also, orig_wipe_x %1%, orig_wipe_y %2%")%orig_wipe_x %orig_wipe_y;
|
||||
//record_exit_reson(outfile_dir, CLI_OBJECT_ARRANGE_FAILED, 0, cli_errors[CLI_OBJECT_ARRANGE_FAILED], sliced_info);
|
||||
//flush_and_exit(CLI_OBJECT_ARRANGE_FAILED);
|
||||
finished_arrange = true;
|
||||
|
|
@ -4021,6 +4069,17 @@ int CLI::run(int argc, char **argv)
|
|||
partplate_list.load_from_3mf_structure(plate_data_src);
|
||||
partplate_list.reset_size(current_printable_width, current_printable_depth, current_printable_height, true, true);
|
||||
duplicate_count = 0;
|
||||
if ((orig_wipe_x > 0.f) && (orig_wipe_y > 0.f))
|
||||
{
|
||||
ConfigOptionFloat wt_x_opt(orig_wipe_x);
|
||||
ConfigOptionFloat wt_y_opt(orig_wipe_y);
|
||||
ConfigOptionFloats* wipe_x_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_x", true);
|
||||
ConfigOptionFloats* wipe_y_option = m_print_config.option<ConfigOptionFloats>("wipe_tower_y", true);
|
||||
|
||||
wipe_x_option->set_at(&wt_x_opt, plate_to_slice-1, 0);
|
||||
wipe_y_option->set_at(&wt_y_opt, plate_to_slice-1, 0);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": restore wipe_tower position to {%1%, %2%}")%orig_wipe_x %orig_wipe_y;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": exit arrange process");
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ typedef Eigen::Matrix<int, 3, 1, Eigen::DontAlign> stl_triangle_vertex_indices
|
|||
static_assert(sizeof(stl_vertex) == 12, "size of stl_vertex incorrect");
|
||||
static_assert(sizeof(stl_normal) == 12, "size of stl_normal incorrect");
|
||||
|
||||
typedef std::function<void(int current, int total, bool& cancel, std::string& model_id)> ImportstlProgressFn;
|
||||
typedef std::function<void(int current, int total, bool& cancel, std::string& model_id, std::string& code)> ImportstlProgressFn;
|
||||
|
||||
typedef enum {
|
||||
eNormal, // normal face
|
||||
|
|
@ -98,8 +98,12 @@ struct stl_neighbors {
|
|||
};
|
||||
|
||||
struct stl_stats {
|
||||
stl_stats() { memset(&header, 0, 81); }
|
||||
char header[81];
|
||||
stl_stats() {}
|
||||
void reset_header(int size) {
|
||||
header.clear();
|
||||
header.resize(size +1);
|
||||
}
|
||||
std::vector<char> header;
|
||||
stl_type type = (stl_type)0;
|
||||
// Should always match the number of facets stored inside stl_file::facet_start.
|
||||
uint32_t number_of_facets = 0;
|
||||
|
|
@ -247,7 +251,7 @@ struct indexed_triangle_set
|
|||
}
|
||||
};
|
||||
|
||||
extern bool stl_open(stl_file *stl, const char *file, ImportstlProgressFn stlFn = nullptr);
|
||||
extern bool stl_open(stl_file *stl, const char *file, ImportstlProgressFn stlFn = nullptr,int custom_header_length = 80);
|
||||
extern void stl_stats_out(stl_file *stl, FILE *file, char *input_file);
|
||||
extern bool stl_print_neighbors(stl_file *stl, char *file);
|
||||
extern bool stl_write_ascii(stl_file *stl, const char *file, const char *label);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void stl_stats_out(stl_file *stl, FILE *file, char *input_file)
|
|||
fprintf(file, "File type : Binary STL file\n");
|
||||
else
|
||||
fprintf(file, "File type : ASCII STL file\n");
|
||||
fprintf(file, "Header : %s\n", stl->stats.header);
|
||||
fprintf(file, "Header : %s\n", stl->stats.header.data());
|
||||
fprintf(file, "============== Size ==============\n");
|
||||
fprintf(file, "Min X = % f, Max X = % f\n", stl->stats.min(0), stl->stats.max(0));
|
||||
fprintf(file, "Min Y = % f, Max Y = % f\n", stl->stats.min(1), stl->stats.max(1));
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ extern void stl_internal_reverse_quads(char *buf, size_t cnt);
|
|||
|
||||
const int LOAD_STL_UNIT_NUM = 5;
|
||||
static std::string model_id = "";
|
||||
static std::string country_code = "";
|
||||
|
||||
static FILE* stl_open_count_facets(stl_file *stl, const char *file)
|
||||
static FILE *stl_open_count_facets(stl_file *stl, const char *file, unsigned int custom_header_length)
|
||||
{
|
||||
// Open the file in binary mode first.
|
||||
FILE *fp = boost::nowide::fopen(file, "rb");
|
||||
|
|
@ -59,7 +60,8 @@ static FILE* stl_open_count_facets(stl_file *stl, const char *file)
|
|||
long file_size = ftell(fp);
|
||||
|
||||
// Check for binary or ASCII file.
|
||||
fseek(fp, HEADER_SIZE, SEEK_SET);
|
||||
int header_size = custom_header_length + NUM_FACET_SIZE;
|
||||
fseek(fp, header_size, SEEK_SET);
|
||||
unsigned char chtest[128];
|
||||
if (! fread(chtest, sizeof(chtest), 1, fp)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "stl_open_count_facets: The input is an empty file: " << file;
|
||||
|
|
@ -81,16 +83,16 @@ static FILE* stl_open_count_facets(stl_file *stl, const char *file)
|
|||
// If the .STL file is binary, then do the following:
|
||||
if (stl->stats.type == binary) {
|
||||
// Test if the STL file has the right size.
|
||||
if (((file_size - HEADER_SIZE) % SIZEOF_STL_FACET != 0) || (file_size < STL_MIN_FILE_SIZE)) {
|
||||
if (((file_size - header_size) % SIZEOF_STL_FACET != 0) || (file_size < STL_MIN_FILE_SIZE)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "stl_open_count_facets: The file " << file << " has the wrong size.";
|
||||
fclose(fp);
|
||||
return nullptr;
|
||||
}
|
||||
num_facets = (file_size - HEADER_SIZE) / SIZEOF_STL_FACET;
|
||||
num_facets = (file_size - header_size) / SIZEOF_STL_FACET;
|
||||
|
||||
// Read the header.
|
||||
if (fread(stl->stats.header, LABEL_SIZE, 1, fp) > 79)
|
||||
stl->stats.header[80] = '\0';
|
||||
if (fread(stl->stats.header.data(), custom_header_length, 1, fp) > custom_header_length -1)
|
||||
stl->stats.header[custom_header_length] = '\0';
|
||||
|
||||
// Read the int following the header. This should contain # of facets.
|
||||
uint32_t header_num_facets;
|
||||
|
|
@ -134,9 +136,9 @@ static FILE* stl_open_count_facets(stl_file *stl, const char *file)
|
|||
|
||||
// Get the header.
|
||||
int i = 0;
|
||||
for (; i < 80 && (stl->stats.header[i] = getc(fp)) != '\n'; ++ i) ;
|
||||
for (; i < custom_header_length && (stl->stats.header[i] = getc(fp)) != '\n'; ++ i) ;
|
||||
stl->stats.header[i] = '\0'; // Lose the '\n'
|
||||
stl->stats.header[80] = '\0';
|
||||
stl->stats.header[custom_header_length] = '\0';
|
||||
|
||||
num_facets = num_lines / ASCII_LINES_PER_FACET;
|
||||
}
|
||||
|
|
@ -149,10 +151,13 @@ static FILE* stl_open_count_facets(stl_file *stl, const char *file)
|
|||
/* Reads the contents of the file pointed to by fp into the stl structure,
|
||||
starting at facet first_facet. The second argument says if it's our first
|
||||
time running this for the stl and therefore we should reset our max and min stats. */
|
||||
static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, ImportstlProgressFn stlFn)
|
||||
static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, ImportstlProgressFn stlFn, int custom_header_length)
|
||||
{
|
||||
if (stl->stats.type == binary) {
|
||||
fseek(fp, HEADER_SIZE, SEEK_SET);
|
||||
int header_size = custom_header_length + NUM_FACET_SIZE;
|
||||
fseek(fp, header_size, SEEK_SET);
|
||||
model_id = "";
|
||||
country_code = "";
|
||||
}
|
||||
else {
|
||||
rewind(fp);
|
||||
|
|
@ -165,18 +170,22 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, Impor
|
|||
// Extract the value after "MW"
|
||||
char version_str[16];
|
||||
char model_id_str[128];
|
||||
int num_values = sscanf(mw_position + 3, "%s %s", version_str, model_id_str);
|
||||
if (num_values == 2) {
|
||||
char country_code_str[16];
|
||||
int num_values = sscanf(mw_position + 3, "%s %s %s", version_str, model_id_str, country_code_str);
|
||||
if (num_values == 3) {
|
||||
if (strcmp(version_str, "1.0") == 0) {
|
||||
model_id = model_id_str;
|
||||
country_code = country_code_str;
|
||||
}
|
||||
}
|
||||
else {
|
||||
model_id = "";
|
||||
country_code = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
model_id = ""; // No MW format found
|
||||
country_code = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +204,7 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, Impor
|
|||
if ((i % unit) == 0) {
|
||||
bool cb_cancel = false;
|
||||
if (stlFn) {
|
||||
stlFn(i, facets_num, cb_cancel, model_id);
|
||||
stlFn(i, facets_num, cb_cancel, model_id, country_code);
|
||||
if (cb_cancel)
|
||||
return false;
|
||||
}
|
||||
|
|
@ -293,20 +302,24 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, Impor
|
|||
return true;
|
||||
}
|
||||
|
||||
bool stl_open(stl_file *stl, const char *file, ImportstlProgressFn stlFn)
|
||||
bool stl_open(stl_file *stl, const char *file, ImportstlProgressFn stlFn, int custom_header_length)
|
||||
{
|
||||
if (custom_header_length < LABEL_SIZE) {
|
||||
custom_header_length = LABEL_SIZE;
|
||||
}
|
||||
Slic3r::CNumericLocalesSetter locales_setter;
|
||||
stl->clear();
|
||||
FILE *fp = stl_open_count_facets(stl, file);
|
||||
stl->stats.reset_header(custom_header_length);
|
||||
FILE *fp = stl_open_count_facets(stl, file, custom_header_length);
|
||||
if (fp == nullptr)
|
||||
return false;
|
||||
stl_allocate(stl);
|
||||
bool result = stl_read(stl, fp, 0, true, stlFn);
|
||||
bool result = stl_read(stl, fp, 0, true, stlFn, custom_header_length);
|
||||
fclose(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
void stl_allocate(stl_file *stl)
|
||||
void stl_allocate(stl_file *stl)
|
||||
{
|
||||
// Allocate memory for the entire .STL file.
|
||||
stl->facet_start.assign(stl->stats.number_of_facets, stl_facet());
|
||||
|
|
@ -314,7 +327,7 @@ void stl_allocate(stl_file *stl)
|
|||
stl->neighbors_start.assign(stl->stats.number_of_facets, stl_neighbors());
|
||||
}
|
||||
|
||||
void stl_reallocate(stl_file *stl)
|
||||
void stl_reallocate(stl_file *stl)
|
||||
{
|
||||
stl->facet_start.resize(stl->stats.number_of_facets);
|
||||
stl->neighbors_start.resize(stl->stats.number_of_facets);
|
||||
|
|
|
|||
|
|
@ -279,6 +279,10 @@ void AppConfig::set_defaults()
|
|||
set_bool("remember_printer_config", true);
|
||||
}
|
||||
|
||||
if (get("auto_calculate_when_filament_change").empty()){
|
||||
set_bool("auto_calculate_when_filament_change", true);
|
||||
}
|
||||
|
||||
if (get("show_home_page").empty()) {
|
||||
set_bool("show_home_page", true);
|
||||
}
|
||||
|
|
@ -562,6 +566,8 @@ std::string AppConfig::load()
|
|||
cali_info.cali_finished = bool(calis_j["cali_finished"].get<int>());
|
||||
if (calis_j.contains("flow_ratio"))
|
||||
cali_info.cache_flow_ratio = calis_j["flow_ratio"].get<float>();
|
||||
if (calis_j.contains("cache_flow_rate_calibration_type"))
|
||||
cali_info.cache_flow_rate_calibration_type = static_cast<FlowRatioCalibrationType>(calis_j["cache_flow_rate_calibration_type"].get<int>());
|
||||
if (calis_j.contains("presets")) {
|
||||
cali_info.selected_presets.clear();
|
||||
for (auto cali_it = calis_j["presets"].begin(); cali_it != calis_j["presets"].end(); cali_it++) {
|
||||
|
|
@ -684,6 +690,7 @@ void AppConfig::save()
|
|||
cali_json["dev_id"] = cali_info.dev_id;
|
||||
cali_json["flow_ratio"] = cali_info.cache_flow_ratio;
|
||||
cali_json["cali_finished"] = cali_info.cali_finished ? 1 : 0;
|
||||
cali_json["cache_flow_rate_calibration_type"] = static_cast<int>(cali_info.cache_flow_rate_calibration_type);
|
||||
for (auto filament_preset : cali_info.selected_presets) {
|
||||
json preset_json;
|
||||
preset_json["tray_id"] = filament_preset.tray_id;
|
||||
|
|
@ -1036,6 +1043,7 @@ void AppConfig::save_printer_cali_infos(const PrinterCaliInfo &cali_info, bool n
|
|||
}
|
||||
(*iter).cache_flow_ratio = cali_info.cache_flow_ratio;
|
||||
(*iter).selected_presets = cali_info.selected_presets;
|
||||
(*iter).cache_flow_rate_calibration_type = cali_info.cache_flow_rate_calibration_type;
|
||||
}
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,37 +10,17 @@
|
|||
#include <functional>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "utils/VoronoiUtils.hpp"
|
||||
|
||||
#include "utils/linearAlg2D.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "SVG.hpp"
|
||||
#include "Geometry/VoronoiVisualUtils.hpp"
|
||||
#include "Geometry/VoronoiUtilsCgal.hpp"
|
||||
#include "../EdgeGrid.hpp"
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
#include "Geometry/VoronoiUtils.hpp"
|
||||
|
||||
#define SKELETAL_TRAPEZOIDATION_BEAD_SEARCH_MAX 1000 //A limit to how long it'll keep searching for adjacent beads. Increasing will re-use beadings more often (saving performance), but search longer for beading (costing performance).
|
||||
|
||||
namespace boost::polygon {
|
||||
|
||||
template<> struct geometry_concept<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef coord_t coordinate_type;
|
||||
typedef Slic3r::Point point_type;
|
||||
static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir)
|
||||
{
|
||||
return dir.to_int() ? CSegment.p() : CSegment.next().p();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost::polygon
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
|
||||
|
|
@ -109,8 +89,7 @@ static void export_graph_to_svg(const std::string
|
|||
}
|
||||
#endif
|
||||
|
||||
SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(vd_t::vertex_type& vd_node, Point p)
|
||||
{
|
||||
SkeletalTrapezoidation::node_t &SkeletalTrapezoidation::makeNode(const VD::vertex_type &vd_node, Point p) {
|
||||
auto he_node_it = vd_node_to_he_node.find(&vd_node);
|
||||
if (he_node_it == vd_node_to_he_node.end())
|
||||
{
|
||||
|
|
@ -125,8 +104,7 @@ SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(vd_t::vertex_ty
|
|||
}
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::transferEdge(Point from, Point to, vd_t::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments)
|
||||
{
|
||||
void SkeletalTrapezoidation::transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments) {
|
||||
auto he_edge_it = vd_edge_to_he_edge.find(vd_edge.twin());
|
||||
if (he_edge_it != vd_edge_to_he_edge.end())
|
||||
{ // Twin segment(s) have already been made
|
||||
|
|
@ -181,7 +159,7 @@ void SkeletalTrapezoidation::transferEdge(Point from, Point to, vd_t::edge_type&
|
|||
}
|
||||
else
|
||||
{
|
||||
std::vector<Point> discretized = discretize(vd_edge, segments);
|
||||
Points discretized = discretize(vd_edge, segments);
|
||||
assert(discretized.size() >= 2);
|
||||
if(discretized.size() < 2)
|
||||
{
|
||||
|
|
@ -236,45 +214,42 @@ void SkeletalTrapezoidation::transferEdge(Point from, Point to, vd_t::edge_type&
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Point> SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_edge, const std::vector<Segment>& segments)
|
||||
Points SkeletalTrapezoidation::discretize(const VD::edge_type& vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(vd_edge));
|
||||
|
||||
/*Terminology in this function assumes that the edge moves horizontally from
|
||||
left to right. This is not necessarily the case; the edge can go in any
|
||||
direction, but it helps to picture it in a certain direction in your head.*/
|
||||
|
||||
const vd_t::cell_type* left_cell = vd_edge.cell();
|
||||
const vd_t::cell_type* right_cell = vd_edge.twin()->cell();
|
||||
const VD::cell_type *left_cell = vd_edge.cell();
|
||||
const VD::cell_type *right_cell = vd_edge.twin()->cell();
|
||||
|
||||
assert(VoronoiUtils::p(vd_edge.vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
Point start = Geometry::VoronoiUtils::to_point(vd_edge.vertex0()).cast<coord_t>();
|
||||
Point end = Geometry::VoronoiUtils::to_point(vd_edge.vertex1()).cast<coord_t>();
|
||||
|
||||
Point start = VoronoiUtils::p(vd_edge.vertex0()).cast<coord_t>();
|
||||
Point end = VoronoiUtils::p(vd_edge.vertex1()).cast<coord_t>();
|
||||
|
||||
bool point_left = left_cell->contains_point();
|
||||
bool point_right = right_cell->contains_point();
|
||||
if ((!point_left && !point_right) || vd_edge.is_secondary()) // Source vert is directly connected to source segment
|
||||
{
|
||||
return std::vector<Point>({ start, end });
|
||||
return Points({ start, end });
|
||||
}
|
||||
else if (point_left != point_right) //This is a parabolic edge between a point and a line.
|
||||
{
|
||||
Point p = VoronoiUtils::getSourcePoint(*(point_left ? left_cell : right_cell), segments);
|
||||
const Segment& s = VoronoiUtils::getSourceSegment(*(point_left ? right_cell : left_cell), segments);
|
||||
return VoronoiUtils::discretizeParabola(p, s, start, end, discretization_step_size, transitioning_angle);
|
||||
Point p = Geometry::VoronoiUtils::get_source_point(*(point_left ? left_cell : right_cell), segments.begin(), segments.end());
|
||||
const Segment& s = Geometry::VoronoiUtils::get_source_segment(*(point_left ? right_cell : left_cell), segments.begin(), segments.end());
|
||||
return Geometry::VoronoiUtils::discretize_parabola(p, s, start, end, discretization_step_size, transitioning_angle);
|
||||
}
|
||||
else //This is a straight edge between two points.
|
||||
{
|
||||
/*While the edge is straight, it is still discretized since the part
|
||||
becomes narrower between the two points. As such it may need different
|
||||
beadings along the way.*/
|
||||
Point left_point = VoronoiUtils::getSourcePoint(*left_cell, segments);
|
||||
Point right_point = VoronoiUtils::getSourcePoint(*right_cell, segments);
|
||||
coord_t d = (right_point - left_point).cast<int64_t>().norm();
|
||||
Point middle = (left_point + right_point) / 2;
|
||||
Point x_axis_dir = Point(right_point - left_point).rotate_90_degree_ccw();
|
||||
Point left_point = Geometry::VoronoiUtils::get_source_point(*left_cell, segments.begin(), segments.end());
|
||||
Point right_point = Geometry::VoronoiUtils::get_source_point(*right_cell, segments.begin(), segments.end());
|
||||
coord_t d = (right_point - left_point).cast<int64_t>().norm();
|
||||
Point middle = (left_point + right_point) / 2;
|
||||
Point x_axis_dir = perp(Point(right_point - left_point));
|
||||
coord_t x_axis_length = x_axis_dir.cast<int64_t>().norm();
|
||||
|
||||
const auto projected_x = [x_axis_dir, x_axis_length, middle](Point from) //Project a point on the edge.
|
||||
|
|
@ -311,7 +286,7 @@ std::vector<Point> SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_
|
|||
//Start generating points along the edge.
|
||||
Point a = start;
|
||||
Point b = end;
|
||||
std::vector<Point> ret;
|
||||
Points ret;
|
||||
ret.emplace_back(a);
|
||||
|
||||
//Introduce an extra edge at the borders of the markings?
|
||||
|
|
@ -351,8 +326,7 @@ std::vector<Point> SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_
|
|||
}
|
||||
}
|
||||
|
||||
bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
bool SkeletalTrapezoidation::computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments) {
|
||||
if (cell.incident_edge()->is_infinite())
|
||||
return false; //Infinite edges only occur outside of the polygon. Don't copy any part of this cell.
|
||||
|
||||
|
|
@ -360,16 +334,16 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
|||
// Copy whole cell into graph or not at all
|
||||
|
||||
// If the cell.incident_edge()->vertex0() is far away so much that it doesn't even fit into Vec2i64, then there is no way that it will be inside the input polygon.
|
||||
if (const vd_t::vertex_type &vert = *cell.incident_edge()->vertex0();
|
||||
if (const VD::vertex_type &vert = *cell.incident_edge()->vertex0();
|
||||
vert.x() >= double(std::numeric_limits<int64_t>::max()) || vert.x() <= double(std::numeric_limits<int64_t>::lowest()) ||
|
||||
vert.y() >= double(std::numeric_limits<int64_t>::max()) || vert.y() <= double(std::numeric_limits<int64_t>::lowest()))
|
||||
return false; // Don't copy any part of this cell
|
||||
|
||||
const Point source_point = VoronoiUtils::getSourcePoint(cell, segments);
|
||||
const PolygonsPointIndex source_point_index = VoronoiUtils::getSourcePointIndex(cell, segments);
|
||||
Vec2i64 some_point = VoronoiUtils::p(cell.incident_edge()->vertex0());
|
||||
const Point source_point = Geometry::VoronoiUtils::get_source_point(cell, segments.begin(), segments.end());
|
||||
const PolygonsPointIndex source_point_index = Geometry::VoronoiUtils::get_source_point_index(cell, segments.begin(), segments.end());
|
||||
Vec2i64 some_point = Geometry::VoronoiUtils::to_point(cell.incident_edge()->vertex0());
|
||||
if (some_point == source_point.cast<int64_t>())
|
||||
some_point = VoronoiUtils::p(cell.incident_edge()->vertex1());
|
||||
some_point = Geometry::VoronoiUtils::to_point(cell.incident_edge()->vertex1());
|
||||
|
||||
//Test if the some_point is even inside the polygon.
|
||||
//The edge leading out of a polygon must have an endpoint that's not in the corner following the contour of the polygon at that vertex.
|
||||
|
|
@ -378,16 +352,16 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
|||
if (!LinearAlg2D::isInsideCorner(source_point_index.prev().p(), source_point_index.p(), source_point_index.next().p(), some_point))
|
||||
return false; // Don't copy any part of this cell
|
||||
|
||||
vd_t::edge_type* vd_edge = cell.incident_edge();
|
||||
const VD::edge_type* vd_edge = cell.incident_edge();
|
||||
do {
|
||||
assert(vd_edge->is_finite());
|
||||
if (Vec2i64 p1 = VoronoiUtils::p(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
||||
if (Vec2i64 p1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
||||
start_source_point = source_point;
|
||||
end_source_point = source_point;
|
||||
starting_vd_edge = vd_edge->next();
|
||||
ending_vd_edge = vd_edge;
|
||||
} else {
|
||||
assert((VoronoiUtils::p(vd_edge->vertex0()) == source_point.cast<int64_t>() || !vd_edge->is_secondary()) && "point cells must end in the point! They cannot cross the point with an edge, because collinear edges are not allowed in the input.");
|
||||
assert((Geometry::VoronoiUtils::to_point(vd_edge->vertex0()) == source_point.cast<int64_t>() || !vd_edge->is_secondary()) && "point cells must end in the point! They cannot cross the point with an edge, because collinear edges are not allowed in the input.");
|
||||
}
|
||||
}
|
||||
while (vd_edge = vd_edge->next(), vd_edge != cell.incident_edge());
|
||||
|
|
@ -396,47 +370,6 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
|||
return true;
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::computeSegmentCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
const Segment &source_segment = VoronoiUtils::getSourceSegment(cell, segments);
|
||||
const Point from = source_segment.from();
|
||||
const Point to = source_segment.to();
|
||||
|
||||
// Find starting edge
|
||||
// Find end edge
|
||||
bool seen_possible_start = false;
|
||||
bool after_start = false;
|
||||
bool ending_edge_is_set_before_start = false;
|
||||
vd_t::edge_type* edge = cell.incident_edge();
|
||||
do {
|
||||
if (edge->is_infinite())
|
||||
continue;
|
||||
|
||||
Vec2i64 v0 = VoronoiUtils::p(edge->vertex0());
|
||||
Vec2i64 v1 = VoronoiUtils::p(edge->vertex1());
|
||||
|
||||
assert(!(v0 == to.cast<int64_t>() && v1 == from.cast<int64_t>() ));
|
||||
if (v0 == to.cast<int64_t>() && !after_start) { // Use the last edge which starts in source_segment.to
|
||||
starting_vd_edge = edge;
|
||||
seen_possible_start = true;
|
||||
}
|
||||
else if (seen_possible_start) {
|
||||
after_start = true;
|
||||
}
|
||||
|
||||
if (v1 == from.cast<int64_t>() && (!ending_vd_edge || ending_edge_is_set_before_start)) {
|
||||
ending_edge_is_set_before_start = !after_start;
|
||||
ending_vd_edge = edge;
|
||||
}
|
||||
} while (edge = edge->next(), edge != cell.incident_edge());
|
||||
|
||||
assert(starting_vd_edge && ending_vd_edge);
|
||||
assert(starting_vd_edge != ending_vd_edge);
|
||||
|
||||
start_source_point = source_segment.to();
|
||||
end_source_point = source_segment.from();
|
||||
}
|
||||
|
||||
SkeletalTrapezoidation::SkeletalTrapezoidation(const Polygons& polys, const BeadingStrategy& beading_strategy,
|
||||
double transitioning_angle, coord_t discretization_step_size,
|
||||
coord_t transition_filter_dist, coord_t allowed_filter_deviation,
|
||||
|
|
@ -451,128 +384,6 @@ SkeletalTrapezoidation::SkeletalTrapezoidation(const Polygons& polys, const Bead
|
|||
constructFromPolygons(polys);
|
||||
}
|
||||
|
||||
static bool has_finite_edge_with_non_finite_vertex(const Geometry::VoronoiDiagram &voronoi_diagram)
|
||||
{
|
||||
for (const VoronoiUtils::vd_t::edge_type &edge : voronoi_diagram.edges()) {
|
||||
if (edge.is_finite()) {
|
||||
assert(edge.vertex0() != nullptr && edge.vertex1() != nullptr);
|
||||
if (edge.vertex0() == nullptr || edge.vertex1() == nullptr || !VoronoiUtils::is_finite(*edge.vertex0()) ||
|
||||
!VoronoiUtils::is_finite(*edge.vertex1()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool detect_missing_voronoi_vertex(const Geometry::VoronoiDiagram &voronoi_diagram, const std::vector<SkeletalTrapezoidation::Segment> &segments) {
|
||||
if (has_finite_edge_with_non_finite_vertex(voronoi_diagram))
|
||||
return true;
|
||||
|
||||
for (VoronoiUtils::vd_t::cell_type cell : voronoi_diagram.cells()) {
|
||||
if (!cell.incident_edge())
|
||||
continue; // There is no spoon
|
||||
|
||||
if (cell.contains_segment()) {
|
||||
const SkeletalTrapezoidation::Segment &source_segment = VoronoiUtils::getSourceSegment(cell, segments);
|
||||
const Point from = source_segment.from();
|
||||
const Point to = source_segment.to();
|
||||
|
||||
// Find starting edge
|
||||
// Find end edge
|
||||
bool seen_possible_start = false;
|
||||
bool after_start = false;
|
||||
bool ending_edge_is_set_before_start = false;
|
||||
VoronoiUtils::vd_t::edge_type *starting_vd_edge = nullptr;
|
||||
VoronoiUtils::vd_t::edge_type *ending_vd_edge = nullptr;
|
||||
VoronoiUtils::vd_t::edge_type *edge = cell.incident_edge();
|
||||
do {
|
||||
if (edge->is_infinite() || edge->vertex0() == nullptr || edge->vertex1() == nullptr || !VoronoiUtils::is_finite(*edge->vertex0()) || !VoronoiUtils::is_finite(*edge->vertex1()))
|
||||
continue;
|
||||
|
||||
Vec2i64 v0 = VoronoiUtils::p(edge->vertex0());
|
||||
Vec2i64 v1 = VoronoiUtils::p(edge->vertex1());
|
||||
|
||||
assert(!(v0 == to.cast<int64_t>() && v1 == from.cast<int64_t>()));
|
||||
if (v0 == to.cast<int64_t>() && !after_start) { // Use the last edge which starts in source_segment.to
|
||||
starting_vd_edge = edge;
|
||||
seen_possible_start = true;
|
||||
} else if (seen_possible_start) {
|
||||
after_start = true;
|
||||
}
|
||||
|
||||
if (v1 == from.cast<int64_t>() && (!ending_vd_edge || ending_edge_is_set_before_start)) {
|
||||
ending_edge_is_set_before_start = !after_start;
|
||||
ending_vd_edge = edge;
|
||||
}
|
||||
} while (edge = edge->next(), edge != cell.incident_edge());
|
||||
|
||||
if (!starting_vd_edge || !ending_vd_edge || starting_vd_edge == ending_vd_edge)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool has_missing_twin_edge(const SkeletalTrapezoidationGraph &graph)
|
||||
{
|
||||
for (const auto &edge : graph.edges)
|
||||
if (edge.twin == nullptr)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static ankerl::unordered_dense::map<Point, Point, PointHash> try_to_fix_degenerated_voronoi_diagram_by_rotation(
|
||||
Geometry::VoronoiDiagram &voronoi_diagram,
|
||||
const Polygons &polys,
|
||||
Polygons &polys_rotated,
|
||||
std::vector<SkeletalTrapezoidation::Segment> &segments,
|
||||
const double fix_angle)
|
||||
{
|
||||
ankerl::unordered_dense::map<Point, Point, PointHash> vertex_mapping;
|
||||
for (Polygon &poly : polys_rotated)
|
||||
poly.rotate(fix_angle);
|
||||
|
||||
assert(polys_rotated.size() == polys.size());
|
||||
for (size_t poly_idx = 0; poly_idx < polys.size(); ++poly_idx) {
|
||||
assert(polys_rotated[poly_idx].size() == polys[poly_idx].size());
|
||||
for (size_t point_idx = 0; point_idx < polys[poly_idx].size(); ++point_idx)
|
||||
vertex_mapping.insert({polys_rotated[poly_idx][point_idx], polys[poly_idx][point_idx]});
|
||||
}
|
||||
|
||||
segments.clear();
|
||||
for (size_t poly_idx = 0; poly_idx < polys_rotated.size(); poly_idx++)
|
||||
for (size_t point_idx = 0; point_idx < polys_rotated[poly_idx].size(); point_idx++)
|
||||
segments.emplace_back(&polys_rotated, poly_idx, point_idx);
|
||||
|
||||
voronoi_diagram.clear();
|
||||
construct_voronoi(segments.begin(), segments.end(), &voronoi_diagram);
|
||||
|
||||
#ifdef ARACHNE_DEBUG_VORONOI
|
||||
{
|
||||
static int iRun = 0;
|
||||
dump_voronoi_to_svg(debug_out_path("arachne_voronoi-diagram-rotated-%d.svg", iRun++).c_str(), voronoi_diagram, to_points(polys), to_lines(polys));
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
|
||||
return vertex_mapping;
|
||||
}
|
||||
|
||||
inline static void rotate_back_skeletal_trapezoidation_graph_after_fix(SkeletalTrapezoidationGraph &graph,
|
||||
const double fix_angle,
|
||||
const ankerl::unordered_dense::map<Point, Point, PointHash> &vertex_mapping)
|
||||
{
|
||||
for (STHalfEdgeNode &node : graph.nodes) {
|
||||
// If a mapping exists between a rotated point and an original point, use this mapping. Otherwise, rotate a point in the opposite direction.
|
||||
if (auto node_it = vertex_mapping.find(node.p); node_it != vertex_mapping.end())
|
||||
node.p = node_it->second;
|
||||
else
|
||||
node.p.rotate(-fix_angle);
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
||||
{
|
||||
#ifdef ARACHNE_DEBUG
|
||||
|
|
@ -604,8 +415,8 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
|||
}
|
||||
#endif
|
||||
|
||||
Geometry::VoronoiDiagram voronoi_diagram;
|
||||
construct_voronoi(segments.begin(), segments.end(), &voronoi_diagram);
|
||||
VD voronoi_diagram;
|
||||
voronoi_diagram.construct_voronoi(segments.cbegin(), segments.cend());
|
||||
|
||||
#ifdef ARACHNE_DEBUG_VORONOI
|
||||
{
|
||||
|
|
@ -614,126 +425,59 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Try to detect cases when some Voronoi vertex is missing and when
|
||||
// the Voronoi diagram is not planar.
|
||||
// When any Voronoi vertex is missing, or the Voronoi diagram is not
|
||||
// planar, rotate the input polygon and try again.
|
||||
const bool has_missing_voronoi_vertex = detect_missing_voronoi_vertex(voronoi_diagram, segments);
|
||||
// Detection of non-planar Voronoi diagram detects at least GH issues #8474, #8514 and #8446.
|
||||
const bool is_voronoi_diagram_planar = Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram);
|
||||
const double fix_angle = PI / 6;
|
||||
|
||||
ankerl::unordered_dense::map<Point, Point, PointHash> vertex_mapping;
|
||||
// polys_copy is referenced through items stored in the std::vector segments.
|
||||
Polygons polys_copy = polys;
|
||||
if (has_missing_voronoi_vertex || !is_voronoi_diagram_planar) {
|
||||
if (has_missing_voronoi_vertex)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected missing Voronoi vertex, input polygons will be rotated back and forth.";
|
||||
else if (!is_voronoi_diagram_planar)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected non-planar Voronoi diagram, input polygons will be rotated back and forth.";
|
||||
|
||||
vertex_mapping = try_to_fix_degenerated_voronoi_diagram_by_rotation(voronoi_diagram, polys, polys_copy, segments, fix_angle);
|
||||
|
||||
assert(!detect_missing_voronoi_vertex(voronoi_diagram, segments));
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram));
|
||||
if (detect_missing_voronoi_vertex(voronoi_diagram, segments))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected missing Voronoi vertex even after the rotation of input.";
|
||||
else if (!Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected non-planar Voronoi diagram even after the rotation of input.";
|
||||
}
|
||||
|
||||
bool degenerated_voronoi_diagram = has_missing_voronoi_vertex || !is_voronoi_diagram_planar;
|
||||
|
||||
process_voronoi_diagram:
|
||||
assert(this->graph.edges.empty() && this->graph.nodes.empty() && this->vd_edge_to_he_edge.empty() && this->vd_node_to_he_node.empty());
|
||||
for (vd_t::cell_type cell : voronoi_diagram.cells()) {
|
||||
for (const VD::cell_type &cell : voronoi_diagram.cells()) {
|
||||
if (!cell.incident_edge())
|
||||
continue; // There is no spoon
|
||||
|
||||
Point start_source_point;
|
||||
Point end_source_point;
|
||||
vd_t::edge_type* starting_vonoroi_edge = nullptr;
|
||||
vd_t::edge_type* ending_vonoroi_edge = nullptr;
|
||||
Point start_source_point;
|
||||
Point end_source_point;
|
||||
const VD::edge_type *starting_voronoi_edge = nullptr;
|
||||
const VD::edge_type *ending_voronoi_edge = nullptr;
|
||||
// Compute and store result in above variables
|
||||
|
||||
|
||||
if (cell.contains_point()) {
|
||||
const bool keep_going = computePointCellRange(cell, start_source_point, end_source_point, starting_vonoroi_edge, ending_vonoroi_edge, segments);
|
||||
const bool keep_going = computePointCellRange(cell, start_source_point, end_source_point, starting_voronoi_edge, ending_voronoi_edge, segments);
|
||||
if (!keep_going)
|
||||
continue;
|
||||
} else {
|
||||
assert(cell.contains_segment());
|
||||
computeSegmentCellRange(cell, start_source_point, end_source_point, starting_vonoroi_edge, ending_vonoroi_edge, segments);
|
||||
Geometry::SegmentCellRange<Point> cell_range = Geometry::VoronoiUtils::compute_segment_cell_range(cell, segments.cbegin(), segments.cend());
|
||||
assert(cell_range.is_valid());
|
||||
start_source_point = cell_range.segment_start_point;
|
||||
end_source_point = cell_range.segment_end_point;
|
||||
starting_voronoi_edge = cell_range.edge_begin;
|
||||
ending_voronoi_edge = cell_range.edge_end;
|
||||
}
|
||||
|
||||
if (!starting_vonoroi_edge || !ending_vonoroi_edge) {
|
||||
|
||||
if (!starting_voronoi_edge || !ending_voronoi_edge) {
|
||||
assert(false && "Each cell should start / end in a polygon vertex");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Copy start to end edge to graph
|
||||
edge_t* prev_edge = nullptr;
|
||||
assert(VoronoiUtils::p(starting_vonoroi_edge->vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_vonoroi_edge->vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(starting_vonoroi_edge->vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_vonoroi_edge->vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
transferEdge(start_source_point, VoronoiUtils::p(starting_vonoroi_edge->vertex1()).cast<coord_t>(), *starting_vonoroi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
node_t* starting_node = vd_node_to_he_node[starting_vonoroi_edge->vertex0()];
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*starting_voronoi_edge));
|
||||
edge_t *prev_edge = nullptr;
|
||||
transferEdge(start_source_point, Geometry::VoronoiUtils::to_point(starting_voronoi_edge->vertex1()).cast<coord_t>(), *starting_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
node_t *starting_node = vd_node_to_he_node[starting_voronoi_edge->vertex0()];
|
||||
starting_node->data.distance_to_boundary = 0;
|
||||
|
||||
constexpr bool is_next_to_start_or_end = true;
|
||||
graph.makeRib(prev_edge, start_source_point, end_source_point, is_next_to_start_or_end);
|
||||
for (vd_t::edge_type* vd_edge = starting_vonoroi_edge->next(); vd_edge != ending_vonoroi_edge; vd_edge = vd_edge->next()) {
|
||||
for (const VD::edge_type* vd_edge = starting_voronoi_edge->next(); vd_edge != ending_voronoi_edge; vd_edge = vd_edge->next()) {
|
||||
assert(vd_edge->is_finite());
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*vd_edge));
|
||||
|
||||
assert(VoronoiUtils::p(vd_edge->vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
|
||||
Point v1 = VoronoiUtils::p(vd_edge->vertex0()).cast<coord_t>();
|
||||
Point v2 = VoronoiUtils::p(vd_edge->vertex1()).cast<coord_t>();
|
||||
Point v1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex0()).cast<coord_t>();
|
||||
Point v2 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()).cast<coord_t>();
|
||||
transferEdge(v1, v2, *vd_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
|
||||
graph.makeRib(prev_edge, start_source_point, end_source_point, vd_edge->next() == ending_vonoroi_edge);
|
||||
graph.makeRib(prev_edge, start_source_point, end_source_point, vd_edge->next() == ending_voronoi_edge);
|
||||
}
|
||||
|
||||
assert(VoronoiUtils::p(starting_vonoroi_edge->vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_vonoroi_edge->vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(starting_vonoroi_edge->vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_vonoroi_edge->vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
transferEdge(VoronoiUtils::p(ending_vonoroi_edge->vertex0()).cast<coord_t>(), end_source_point, *ending_vonoroi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
transferEdge(Geometry::VoronoiUtils::to_point(ending_voronoi_edge->vertex0()).cast<coord_t>(), end_source_point, *ending_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
prev_edge->to->data.distance_to_boundary = 0;
|
||||
}
|
||||
|
||||
// For some input polygons, as in GH issues #8474 and #8514 resulting Voronoi diagram is degenerated because it is not planar.
|
||||
// When this degenerated Voronoi diagram is processed, the resulting half-edge structure contains some edges that don't have
|
||||
// a twin edge. Based on this, we created a fast mechanism that detects those causes and tries to recompute the Voronoi
|
||||
// diagram on slightly rotated input polygons that usually make the Voronoi generator generate a non-degenerated Voronoi diagram.
|
||||
if (!degenerated_voronoi_diagram && has_missing_twin_edge(this->graph)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected degenerated Voronoi diagram, input polygons will be rotated back and forth.";
|
||||
degenerated_voronoi_diagram = true;
|
||||
vertex_mapping = try_to_fix_degenerated_voronoi_diagram_by_rotation(voronoi_diagram, polys, polys_copy, segments, fix_angle);
|
||||
|
||||
assert(!detect_missing_voronoi_vertex(voronoi_diagram, segments));
|
||||
if (detect_missing_voronoi_vertex(voronoi_diagram, segments))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected missing Voronoi vertex after the rotation of input.";
|
||||
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
|
||||
this->graph.edges.clear();
|
||||
this->graph.nodes.clear();
|
||||
this->vd_edge_to_he_edge.clear();
|
||||
this->vd_node_to_he_node.clear();
|
||||
|
||||
goto process_voronoi_diagram;
|
||||
}
|
||||
|
||||
if (degenerated_voronoi_diagram) {
|
||||
assert(!has_missing_twin_edge(this->graph));
|
||||
|
||||
if (has_missing_twin_edge(this->graph))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected degenerated Voronoi diagram even after the rotation of input.";
|
||||
}
|
||||
|
||||
if (degenerated_voronoi_diagram)
|
||||
rotate_back_skeletal_trapezoidation_graph_after_fix(this->graph, fix_angle, vertex_mapping);
|
||||
|
||||
#ifdef ARACHNE_DEBUG
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
#endif
|
||||
|
|
@ -742,7 +486,7 @@ process_voronoi_diagram:
|
|||
|
||||
graph.collapseSmallEdges();
|
||||
|
||||
// Set [incident_edge] the the first possible edge that way we can iterate over all reachable edges from node.incident_edge,
|
||||
// Set [incident_edge] the first possible edge that way we can iterate over all reachable edges from node.incident_edge,
|
||||
// without needing to iterate backward
|
||||
for (edge_t& edge : graph.edges)
|
||||
if (!edge.prev)
|
||||
|
|
@ -751,7 +495,7 @@ process_voronoi_diagram:
|
|||
|
||||
void SkeletalTrapezoidation::separatePointyQuadEndNodes()
|
||||
{
|
||||
ankerl::unordered_dense::set<node_t*> visited_nodes;
|
||||
NodeSet visited_nodes;
|
||||
for (edge_t& edge : graph.edges)
|
||||
{
|
||||
if (edge.prev)
|
||||
|
|
@ -2221,16 +1965,16 @@ void SkeletalTrapezoidation::addToolpathSegment(const ExtrusionJunction& from, c
|
|||
|
||||
void SkeletalTrapezoidation::connectJunctions(ptr_vector_t<LineJunctions>& edge_junctions)
|
||||
{
|
||||
ankerl::unordered_dense::set<edge_t*> unprocessed_quad_starts(graph.edges.size() * 5 / 2);
|
||||
EdgeSet unprocessed_quad_starts(graph.edges.size() * 5 / 2);
|
||||
for (edge_t& edge : graph.edges)
|
||||
{
|
||||
if (!edge.prev)
|
||||
{
|
||||
unprocessed_quad_starts.insert(&edge);
|
||||
unprocessed_quad_starts.emplace(&edge);
|
||||
}
|
||||
}
|
||||
|
||||
ankerl::unordered_dense::set<edge_t*> passed_odd_edges;
|
||||
EdgeSet passed_odd_edges;
|
||||
|
||||
while (!unprocessed_quad_starts.empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@
|
|||
#include <boost/polygon/voronoi.hpp>
|
||||
|
||||
#include <memory> // smart pointers
|
||||
#include <ankerl/unordered_dense.h>
|
||||
#include <utility> // pair
|
||||
|
||||
#include <ankerl/unordered_dense.h>
|
||||
|
||||
#include "utils/HalfEdgeGraph.hpp"
|
||||
#include "utils/PolygonsSegmentIndex.hpp"
|
||||
#include "utils/ExtrusionJunction.hpp"
|
||||
|
|
@ -23,8 +24,9 @@
|
|||
//#define ARACHNE_DEBUG
|
||||
//#define ARACHNE_DEBUG_VORONOI
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
namespace Slic3r::Arachne {
|
||||
|
||||
using VD = Slic3r::Geometry::VoronoiDiagram;
|
||||
|
||||
/*!
|
||||
* Main class of the dynamic beading strategies.
|
||||
|
|
@ -47,8 +49,6 @@ deposition modeling" by Kuipers et al.
|
|||
*/
|
||||
class SkeletalTrapezoidation
|
||||
{
|
||||
using pos_t = double;
|
||||
using vd_t = boost::polygon::voronoi_diagram<pos_t>;
|
||||
using graph_t = SkeletalTrapezoidationGraph;
|
||||
using edge_t = STHalfEdge;
|
||||
using node_t = STHalfEdgeNode;
|
||||
|
|
@ -79,7 +79,11 @@ class SkeletalTrapezoidation
|
|||
const BeadingStrategy& beading_strategy;
|
||||
|
||||
public:
|
||||
using Segment = PolygonsSegmentIndex;
|
||||
using Segment = PolygonsSegmentIndex;
|
||||
using NodeSet = ankerl::unordered_dense::set<node_t *>;
|
||||
using EdgeSet = ankerl::unordered_dense::set<edge_t *>;
|
||||
using EdgeMap = ankerl::unordered_dense::map<const VD::edge_type *, edge_t *>;
|
||||
using NodeMap = ankerl::unordered_dense::map<const VD::vertex_type *, node_t *>;
|
||||
|
||||
/*!
|
||||
* Construct a new trapezoidation problem to solve.
|
||||
|
|
@ -163,9 +167,9 @@ protected:
|
|||
* mapping each voronoi VD edge to the corresponding halfedge HE edge
|
||||
* In case the result segment is discretized, we map the VD edge to the *last* HE edge
|
||||
*/
|
||||
ankerl::unordered_dense::map<vd_t::edge_type*, edge_t*> vd_edge_to_he_edge;
|
||||
ankerl::unordered_dense::map<vd_t::vertex_type*, node_t*> vd_node_to_he_node;
|
||||
node_t& makeNode(vd_t::vertex_type& vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
||||
EdgeMap vd_edge_to_he_edge;
|
||||
NodeMap vd_node_to_he_node;
|
||||
node_t &makeNode(const VD::vertex_type &vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
||||
|
||||
/*!
|
||||
* (Eventual) returned 'polylines per index' result (from generateToolpaths):
|
||||
|
|
@ -176,7 +180,7 @@ protected:
|
|||
* Transfer an edge from the VD to the HE and perform discretization of parabolic edges (and vertex-vertex edges)
|
||||
* \p prev_edge serves as input and output. May be null as input.
|
||||
*/
|
||||
void transferEdge(Point from, Point to, vd_t::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments);
|
||||
void transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments);
|
||||
|
||||
/*!
|
||||
* Discretize a Voronoi edge that represents the medial axis of a vertex-
|
||||
|
|
@ -203,7 +207,7 @@ protected:
|
|||
* \return A number of coordinates along the edge where the edge is broken
|
||||
* up into discrete pieces.
|
||||
*/
|
||||
std::vector<Point> discretize(const vd_t::edge_type& segment, const std::vector<Segment>& segments);
|
||||
Points discretize(const VD::edge_type& segment, const std::vector<Segment>& segments);
|
||||
|
||||
/*!
|
||||
* Compute the range of line segments that surround a cell of the skeletal
|
||||
|
|
@ -229,33 +233,7 @@ protected:
|
|||
* /return Whether the cell is inside of the polygon. If it's outside of the
|
||||
* polygon we should skip processing it altogether.
|
||||
*/
|
||||
bool computePointCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments);
|
||||
|
||||
/*!
|
||||
* Compute the range of line segments that surround a cell of the skeletal
|
||||
* graph that belongs to a line segment of the medial axis.
|
||||
*
|
||||
* This should only be used on cells that belong to a central line segment
|
||||
* of the skeletal graph, e.g. trapezoid cells, not triangular cells.
|
||||
*
|
||||
* The resulting line segments is just the first and the last segment. They
|
||||
* are linked to the neighboring segments, so you can iterate over the
|
||||
* segments until you reach the last segment.
|
||||
* \param cell The cell to compute the range of line segments for.
|
||||
* \param[out] start_source_point The start point of the source segment of
|
||||
* this cell.
|
||||
* \param[out] end_source_point The end point of the source segment of this
|
||||
* cell.
|
||||
* \param[out] starting_vd_edge The edge of the Voronoi diagram where the
|
||||
* loop around the cell starts.
|
||||
* \param[out] ending_vd_edge The edge of the Voronoi diagram where the loop
|
||||
* around the cell ends.
|
||||
* \param points All vertices of the input Polygons.
|
||||
* \param segments All edges of the input Polygons.
|
||||
* /return Whether the cell is inside of the polygon. If it's outside of the
|
||||
* polygon we should skip processing it altogether.
|
||||
*/
|
||||
void computeSegmentCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments);
|
||||
static bool computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments);
|
||||
|
||||
/*!
|
||||
* For VD cells associated with an input polygon vertex, we need to separate the node at the end and start of the cell into two
|
||||
|
|
|
|||
|
|
@ -27,5 +27,24 @@ public:
|
|||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
namespace boost::polygon {
|
||||
|
||||
template<> struct geometry_concept<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef coord_t coordinate_type;
|
||||
typedef Slic3r::Point point_type;
|
||||
|
||||
static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir)
|
||||
{
|
||||
return dir.to_int() ? CSegment.to() : CSegment.from();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost::polygon
|
||||
|
||||
#endif//UTILS_POLYGONS_SEGMENT_INDEX_H
|
||||
|
|
|
|||
|
|
@ -1,251 +0,0 @@
|
|||
//Copyright (c) 2021 Ultimaker B.V.
|
||||
//CuraEngine is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
#include <stack>
|
||||
#include <optional>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "linearAlg2D.hpp"
|
||||
#include "VoronoiUtils.hpp"
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
|
||||
Vec2i64 VoronoiUtils::p(const vd_t::vertex_type *node)
|
||||
{
|
||||
const double x = node->x();
|
||||
const double y = node->y();
|
||||
assert(std::isfinite(x) && std::isfinite(y));
|
||||
assert(x <= double(std::numeric_limits<int64_t>::max()) && x >= std::numeric_limits<int64_t>::lowest());
|
||||
assert(y <= double(std::numeric_limits<int64_t>::max()) && y >= std::numeric_limits<int64_t>::lowest());
|
||||
return {int64_t(x + 0.5 - (x < 0)), int64_t(y + 0.5 - (y < 0))}; // Round to the nearest integer coordinates.
|
||||
}
|
||||
|
||||
Point VoronoiUtils::getSourcePoint(const vd_t::cell_type& cell, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(cell.contains_point());
|
||||
if(!cell.contains_point())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source point!";
|
||||
|
||||
switch (cell.source_category()) {
|
||||
case boost::polygon::SOURCE_CATEGORY_SINGLE_POINT:
|
||||
assert(false && "Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!\n");
|
||||
BOOST_LOG_TRIVIAL(error) << "Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!";
|
||||
break;
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT:
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()].to();
|
||||
break;
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT:
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()].from();
|
||||
break;
|
||||
default:
|
||||
assert(false && "getSourcePoint should only be called on point cells!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
assert(false && "cell.source_category() is equal to an invalid value!\n");
|
||||
BOOST_LOG_TRIVIAL(error) << "cell.source_category() is equal to an invalid value!";
|
||||
return {};
|
||||
}
|
||||
|
||||
PolygonsPointIndex VoronoiUtils::getSourcePointIndex(const vd_t::cell_type& cell, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(cell.contains_point());
|
||||
if(!cell.contains_point())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source point!";
|
||||
|
||||
assert(cell.source_category() != boost::polygon::SOURCE_CATEGORY_SINGLE_POINT);
|
||||
switch (cell.source_category()) {
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT: {
|
||||
assert(cell.source_index() < segments.size());
|
||||
PolygonsPointIndex ret = segments[cell.source_index()];
|
||||
++ret;
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT: {
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false && "getSourcePoint should only be called on point cells!\n");
|
||||
break;
|
||||
}
|
||||
PolygonsPointIndex ret = segments[cell.source_index()];
|
||||
return ++ret;
|
||||
}
|
||||
|
||||
const VoronoiUtils::Segment &VoronoiUtils::getSourceSegment(const vd_t::cell_type &cell, const std::vector<Segment> &segments)
|
||||
{
|
||||
assert(cell.contains_segment());
|
||||
if (!cell.contains_segment())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source segment!";
|
||||
|
||||
return segments[cell.source_index()];
|
||||
}
|
||||
|
||||
class PointMatrix
|
||||
{
|
||||
public:
|
||||
double matrix[4];
|
||||
|
||||
PointMatrix()
|
||||
{
|
||||
matrix[0] = 1;
|
||||
matrix[1] = 0;
|
||||
matrix[2] = 0;
|
||||
matrix[3] = 1;
|
||||
}
|
||||
|
||||
PointMatrix(double rotation)
|
||||
{
|
||||
rotation = rotation / 180 * M_PI;
|
||||
matrix[0] = cos(rotation);
|
||||
matrix[1] = -sin(rotation);
|
||||
matrix[2] = -matrix[1];
|
||||
matrix[3] = matrix[0];
|
||||
}
|
||||
|
||||
PointMatrix(const Point p)
|
||||
{
|
||||
matrix[0] = p.x();
|
||||
matrix[1] = p.y();
|
||||
double f = sqrt((matrix[0] * matrix[0]) + (matrix[1] * matrix[1]));
|
||||
matrix[0] /= f;
|
||||
matrix[1] /= f;
|
||||
matrix[2] = -matrix[1];
|
||||
matrix[3] = matrix[0];
|
||||
}
|
||||
|
||||
static PointMatrix scale(double s)
|
||||
{
|
||||
PointMatrix ret;
|
||||
ret.matrix[0] = s;
|
||||
ret.matrix[3] = s;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point apply(const Point p) const
|
||||
{
|
||||
return Point(coord_t(p.x() * matrix[0] + p.y() * matrix[1]), coord_t(p.x() * matrix[2] + p.y() * matrix[3]));
|
||||
}
|
||||
|
||||
Point unapply(const Point p) const
|
||||
{
|
||||
return Point(coord_t(p.x() * matrix[0] + p.y() * matrix[2]), coord_t(p.x() * matrix[1] + p.y() * matrix[3]));
|
||||
}
|
||||
};
|
||||
std::vector<Point> VoronoiUtils::discretizeParabola(const Point& p, const Segment& segment, Point s, Point e, coord_t approximate_step_size, float transitioning_angle)
|
||||
{
|
||||
std::vector<Point> discretized;
|
||||
// x is distance of point projected on the segment ab
|
||||
// xx is point projected on the segment ab
|
||||
const Point a = segment.from();
|
||||
const Point b = segment.to();
|
||||
const Point ab = b - a;
|
||||
const Point as = s - a;
|
||||
const Point ae = e - a;
|
||||
const coord_t ab_size = ab.cast<int64_t>().norm();
|
||||
const coord_t sx = as.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t ex = ae.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t sxex = ex - sx;
|
||||
|
||||
assert((as.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
assert((ae.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
const Point ap = p - a;
|
||||
const coord_t px = ap.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
|
||||
assert((ap.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
Point pxx;
|
||||
Line(a, b).distance_to_infinite_squared(p, &pxx);
|
||||
const Point ppxx = pxx - p;
|
||||
const coord_t d = ppxx.cast<int64_t>().norm();
|
||||
const PointMatrix rot = PointMatrix(ppxx.rotate_90_degree_ccw());
|
||||
|
||||
if (d == 0)
|
||||
{
|
||||
discretized.emplace_back(s);
|
||||
discretized.emplace_back(e);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
const float marking_bound = atan(transitioning_angle * 0.5);
|
||||
int64_t msx = - marking_bound * int64_t(d); // projected marking_start
|
||||
int64_t mex = marking_bound * int64_t(d); // projected marking_end
|
||||
|
||||
assert(msx <= std::numeric_limits<coord_t>::max());
|
||||
assert(double(msx) * double(msx) <= double(std::numeric_limits<int64_t>::max()));
|
||||
assert(mex <= std::numeric_limits<coord_t>::max());
|
||||
assert(double(msx) * double(msx) / double(2 * d) + double(d / 2) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
const coord_t marking_start_end_h = msx * msx / (2 * d) + d / 2;
|
||||
Point marking_start = rot.unapply(Point(coord_t(msx), marking_start_end_h)) + pxx;
|
||||
Point marking_end = rot.unapply(Point(coord_t(mex), marking_start_end_h)) + pxx;
|
||||
const int dir = (sx > ex) ? -1 : 1;
|
||||
if (dir < 0)
|
||||
{
|
||||
std::swap(marking_start, marking_end);
|
||||
std::swap(msx, mex);
|
||||
}
|
||||
|
||||
bool add_marking_start = msx * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && msx * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
bool add_marking_end = mex * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && mex * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
|
||||
const Point apex = rot.unapply(Point(0, d / 2)) + pxx;
|
||||
bool add_apex = int64_t(sx - px) * int64_t(dir) < 0 && int64_t(ex - px) * int64_t(dir) > 0;
|
||||
|
||||
assert(!(add_marking_start && add_marking_end) || add_apex);
|
||||
if(add_marking_start && add_marking_end && !add_apex)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(warning) << "Failing to discretize parabola! Must add an apex or one of the endpoints.";
|
||||
}
|
||||
|
||||
const coord_t step_count = static_cast<coord_t>(static_cast<float>(std::abs(ex - sx)) / approximate_step_size + 0.5);
|
||||
|
||||
discretized.emplace_back(s);
|
||||
for (coord_t step = 1; step < step_count; step++)
|
||||
{
|
||||
assert(double(sxex) * double(step) <= double(std::numeric_limits<int64_t>::max()));
|
||||
const int64_t x = int64_t(sx) + int64_t(sxex) * int64_t(step) / int64_t(step_count) - int64_t(px);
|
||||
assert(double(x) * double(x) <= double(std::numeric_limits<int64_t>::max()));
|
||||
assert(double(x) * double(x) / double(2 * d) + double(d / 2) <= double(std::numeric_limits<int64_t>::max()));
|
||||
const int64_t y = int64_t(x) * int64_t(x) / int64_t(2 * d) + int64_t(d / 2);
|
||||
|
||||
if (add_marking_start && msx * int64_t(dir) < int64_t(x) * int64_t(dir))
|
||||
{
|
||||
discretized.emplace_back(marking_start);
|
||||
add_marking_start = false;
|
||||
}
|
||||
if (add_apex && int64_t(x) * int64_t(dir) > 0)
|
||||
{
|
||||
discretized.emplace_back(apex);
|
||||
add_apex = false; // only add the apex just before the
|
||||
}
|
||||
if (add_marking_end && mex * int64_t(dir) < int64_t(x) * int64_t(dir))
|
||||
{
|
||||
discretized.emplace_back(marking_end);
|
||||
add_marking_end = false;
|
||||
}
|
||||
assert(x <= std::numeric_limits<coord_t>::max() && x >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(y <= std::numeric_limits<coord_t>::max() && y >= std::numeric_limits<coord_t>::lowest());
|
||||
const Point result = rot.unapply(Point(x, y)) + pxx;
|
||||
discretized.emplace_back(result);
|
||||
}
|
||||
if (add_apex)
|
||||
{
|
||||
discretized.emplace_back(apex);
|
||||
}
|
||||
if (add_marking_end)
|
||||
{
|
||||
discretized.emplace_back(marking_end);
|
||||
}
|
||||
discretized.emplace_back(e);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
}//namespace Slic3r::Arachne
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
//Copyright (c) 2020 Ultimaker B.V.
|
||||
//CuraEngine is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
|
||||
#ifndef UTILS_VORONOI_UTILS_H
|
||||
#define UTILS_VORONOI_UTILS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <boost/polygon/voronoi.hpp>
|
||||
|
||||
#include "PolygonsSegmentIndex.hpp"
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
|
||||
/*!
|
||||
*/
|
||||
class VoronoiUtils
|
||||
{
|
||||
public:
|
||||
using Segment = PolygonsSegmentIndex;
|
||||
using voronoi_data_t = double;
|
||||
using vd_t = boost::polygon::voronoi_diagram<voronoi_data_t>;
|
||||
|
||||
static Point getSourcePoint(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
static const Segment &getSourceSegment(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
static PolygonsPointIndex getSourcePointIndex(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
|
||||
static Vec2i64 p(const vd_t::vertex_type *node);
|
||||
|
||||
/*!
|
||||
* Discretize a parabola based on (approximate) step size.
|
||||
* The \p approximate_step_size is measured parallel to the \p source_segment, not along the parabola.
|
||||
*/
|
||||
static std::vector<Point> discretizeParabola(const Point &source_point, const Segment &source_segment, Point start, Point end, coord_t approximate_step_size, float transitioning_angle);
|
||||
|
||||
static inline bool is_finite(const VoronoiUtils::vd_t::vertex_type &vertex)
|
||||
{
|
||||
return std::isfinite(vertex.x()) && std::isfinite(vertex.y());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
#endif // UTILS_VORONOI_UTILS_H
|
||||
|
|
@ -101,8 +101,14 @@ void update_selected_items_inflation(ArrangePolygons& selected, const DynamicPri
|
|||
Points bedpts = get_shrink_bedpts(print_cfg, params);
|
||||
BoundingBox bedbb = Polygon(bedpts).bounding_box();
|
||||
// set obj distance for auto seq_print
|
||||
if (params.min_obj_distance == 0 && params.is_seq_print)
|
||||
params.min_obj_distance = scaled(params.cleareance_radius + 0.001);
|
||||
if (params.is_seq_print) {
|
||||
bool all_objects_are_short = std::all_of(selected.begin(), selected.end(), [&](ArrangePolygon& ap) { return ap.height < params.nozzle_height; });
|
||||
if (all_objects_are_short) {
|
||||
params.min_obj_distance = std::max(params.min_obj_distance, scaled(double(MAX_OUTER_NOZZLE_DIAMETER)/2+0.001));
|
||||
}
|
||||
else
|
||||
params.min_obj_distance = std::max(params.min_obj_distance, scaled(params.cleareance_radius + 0.001)); // +0.001mm to avoid clearance check fail due to rounding error
|
||||
}
|
||||
double brim_max = 0;
|
||||
bool plate_has_tree_support = false;
|
||||
std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon& ap) {
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ struct ArrangeParams {
|
|||
float clearance_height_to_rod = 0;
|
||||
float clearance_height_to_lid = 0;
|
||||
float cleareance_radius = 0;
|
||||
float nozzle_height = 0;
|
||||
float printable_height = 256.0;
|
||||
Vec2d align_center{ 0.5,0.5 };
|
||||
|
||||
|
|
|
|||
|
|
@ -194,9 +194,12 @@ set(lisbslic3r_sources
|
|||
Geometry/Curves.hpp
|
||||
Geometry/MedialAxis.cpp
|
||||
Geometry/MedialAxis.hpp
|
||||
Geometry/Voronoi.cpp
|
||||
Geometry/Voronoi.hpp
|
||||
Geometry/VoronoiOffset.cpp
|
||||
Geometry/VoronoiOffset.hpp
|
||||
Geometry/VoronoiUtils.hpp
|
||||
Geometry/VoronoiUtils.cpp
|
||||
Geometry/VoronoiUtilsCgal.cpp
|
||||
Geometry/VoronoiUtilsCgal.hpp
|
||||
Geometry/VoronoiVisualUtils.hpp
|
||||
|
|
@ -238,6 +241,8 @@ set(lisbslic3r_sources
|
|||
NSVGUtils.hpp
|
||||
ObjectID.cpp
|
||||
ObjectID.hpp
|
||||
ParameterUtils.cpp
|
||||
ParameterUtils.hpp
|
||||
PerimeterGenerator.cpp
|
||||
PerimeterGenerator.hpp
|
||||
PlaceholderParser.cpp
|
||||
|
|
@ -431,8 +436,6 @@ set(lisbslic3r_sources
|
|||
Arachne/utils/PolygonsSegmentIndex.hpp
|
||||
Arachne/utils/PolylineStitcher.hpp
|
||||
Arachne/utils/PolylineStitcher.cpp
|
||||
Arachne/utils/VoronoiUtils.hpp
|
||||
Arachne/utils/VoronoiUtils.cpp
|
||||
Arachne/SkeletalTrapezoidation.hpp
|
||||
Arachne/SkeletalTrapezoidation.cpp
|
||||
Arachne/SkeletalTrapezoidationEdge.hpp
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ struct CSGPart {
|
|||
Transform3f trafo;
|
||||
CSGType operation;
|
||||
CSGStackOp stack_operation;
|
||||
std::string name;
|
||||
|
||||
CSGPart(AnyPtr<const indexed_triangle_set> ptr = {},
|
||||
CSGType op = CSGType::Union,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ bool model_to_csgmesh(const ModelObject &mo,
|
|||
CSGPart part{&(vol->mesh().its),
|
||||
vol->is_model_part() ? CSGType::Union : CSGType::Difference,
|
||||
(trafo * vol->get_matrix()).cast<float>()};
|
||||
|
||||
part.name = vol->name;
|
||||
*out = std::move(part);
|
||||
++out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "libslic3r/MeshBoolean.hpp"
|
||||
|
||||
namespace Slic3r { namespace csg {
|
||||
enum class BooleanFailReason { OK, MeshEmpty, NotBoundAVolume, SelfIntersect, NoIntersection};
|
||||
|
||||
// This method can be overriden when a specific CSGPart type supports caching
|
||||
// of the voxel grid
|
||||
|
|
@ -256,12 +257,13 @@ void perform_csgmesh_booleans_mcut(MeshBoolean::mcut::McutMeshPtr& mcutm,
|
|||
|
||||
|
||||
template<class It, class Visitor>
|
||||
It check_csgmesh_booleans(const Range<It> &csgrange, Visitor &&vfn)
|
||||
std::tuple<BooleanFailReason,std::string> check_csgmesh_booleans(const Range<It> &csgrange, Visitor &&vfn)
|
||||
{
|
||||
using namespace detail_cgal;
|
||||
|
||||
BooleanFailReason fail_reason = BooleanFailReason::OK;
|
||||
std::string fail_part_name;
|
||||
std::vector<CGALMeshPtr> cgalmeshes(csgrange.size());
|
||||
auto check_part = [&csgrange, &cgalmeshes](size_t i)
|
||||
auto check_part = [&csgrange, &cgalmeshes,&fail_reason,&fail_part_name](size_t i)
|
||||
{
|
||||
auto it = csgrange.begin();
|
||||
std::advance(it, i);
|
||||
|
|
@ -275,14 +277,26 @@ It check_csgmesh_booleans(const Range<It> &csgrange, Visitor &&vfn)
|
|||
}
|
||||
|
||||
try {
|
||||
if (!m || MeshBoolean::cgal::empty(*m))
|
||||
if (!m || MeshBoolean::cgal::empty(*m)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check_csgmesh_booleans fails! mesh " << i << "/" << csgrange.size() << " is empty, cannot do boolean!";
|
||||
fail_reason= BooleanFailReason::MeshEmpty;
|
||||
fail_part_name = csgpart.name;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MeshBoolean::cgal::does_bound_a_volume(*m))
|
||||
if (!MeshBoolean::cgal::does_bound_a_volume(*m)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check_csgmesh_booleans fails! mesh "<<i<<"/"<<csgrange.size()<<" does_bound_a_volume is false, cannot do boolean!";
|
||||
fail_reason= BooleanFailReason::NotBoundAVolume;
|
||||
fail_part_name = csgpart.name;
|
||||
return;
|
||||
}
|
||||
|
||||
if (MeshBoolean::cgal::does_self_intersect(*m))
|
||||
if (MeshBoolean::cgal::does_self_intersect(*m)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check_csgmesh_booleans fails! mesh " << i << "/" << csgrange.size() << " does_self_intersect is true, cannot do boolean!";
|
||||
fail_reason= BooleanFailReason::SelfIntersect;
|
||||
fail_part_name = csgpart.name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (...) { return; }
|
||||
|
||||
|
|
@ -290,31 +304,33 @@ It check_csgmesh_booleans(const Range<It> &csgrange, Visitor &&vfn)
|
|||
};
|
||||
execution::for_each(ex_tbb, size_t(0), csgrange.size(), check_part);
|
||||
|
||||
It ret = csgrange.end();
|
||||
for (size_t i = 0; i < csgrange.size(); ++i) {
|
||||
if (!cgalmeshes[i]) {
|
||||
auto it = csgrange.begin();
|
||||
std::advance(it, i);
|
||||
vfn(it);
|
||||
//It ret = csgrange.end();
|
||||
//for (size_t i = 0; i < csgrange.size(); ++i) {
|
||||
// if (!cgalmeshes[i]) {
|
||||
// auto it = csgrange.begin();
|
||||
// std::advance(it, i);
|
||||
// vfn(it);
|
||||
|
||||
if (ret == csgrange.end())
|
||||
ret = it;
|
||||
}
|
||||
}
|
||||
// if (ret == csgrange.end())
|
||||
// ret = it;
|
||||
// }
|
||||
//}
|
||||
|
||||
return ret;
|
||||
return { fail_reason,fail_part_name };
|
||||
}
|
||||
|
||||
template<class It>
|
||||
It check_csgmesh_booleans(const Range<It> &csgrange, bool use_mcut=false)
|
||||
std::tuple<BooleanFailReason, std::string> check_csgmesh_booleans(const Range<It> &csgrange, bool use_mcut=false)
|
||||
{
|
||||
if(!use_mcut)
|
||||
return check_csgmesh_booleans(csgrange, [](auto &) {});
|
||||
else {
|
||||
using namespace detail_mcut;
|
||||
BooleanFailReason fail_reason = BooleanFailReason::OK;
|
||||
std::string fail_part_name;
|
||||
|
||||
std::vector<McutMeshPtr> McutMeshes(csgrange.size());
|
||||
auto check_part = [&csgrange, &McutMeshes](size_t i) {
|
||||
auto check_part = [&csgrange, &McutMeshes,&fail_reason,&fail_part_name](size_t i) {
|
||||
auto it = csgrange.begin();
|
||||
std::advance(it, i);
|
||||
auto& csgpart = *it;
|
||||
|
|
@ -327,27 +343,18 @@ It check_csgmesh_booleans(const Range<It> &csgrange, bool use_mcut=false)
|
|||
}
|
||||
|
||||
try {
|
||||
if (!m || MeshBoolean::mcut::empty(*m))
|
||||
if (!m || MeshBoolean::mcut::empty(*m)) {
|
||||
fail_reason=BooleanFailReason::MeshEmpty;
|
||||
fail_part_name = csgpart.name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (...) { return; }
|
||||
|
||||
McutMeshes[i] = std::move(m);
|
||||
};
|
||||
execution::for_each(ex_tbb, size_t(0), csgrange.size(), check_part);
|
||||
|
||||
It ret = csgrange.end();
|
||||
for (size_t i = 0; i < csgrange.size(); ++i) {
|
||||
if (!McutMeshes[i]) {
|
||||
auto it = csgrange.begin();
|
||||
std::advance(it, i);
|
||||
|
||||
if (ret == csgrange.end())
|
||||
ret = it;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return { fail_reason,fail_part_name };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
static const double slope_inner_outer_wall_gap = 0.4;
|
||||
|
||||
void ExtrusionPath::intersect_expolygons(const ExPolygons &collection, ExtrusionEntityCollection* retval) const
|
||||
{
|
||||
this->_inflate_collection(intersection_pl(Polylines{ polyline }, collection), retval);
|
||||
|
|
@ -409,11 +411,8 @@ ExtrusionLoopSloped::ExtrusionLoopSloped(ExtrusionPaths& original_paths,
|
|||
: ExtrusionLoop(role)
|
||||
{
|
||||
// create slopes
|
||||
const auto add_slop = [this, slope_max_segment_length, seam_gap](const ExtrusionPath& path, const Polyline& poly,
|
||||
double ratio_begin, double ratio_end) {
|
||||
if (poly.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto add_slop = [this, slope_max_segment_length, seam_gap](const ExtrusionPath &path, const Polyline &poly, double ratio_begin, double ratio_end) {
|
||||
if (poly.empty()) { return; }
|
||||
|
||||
// Ensure `slope_max_segment_length`
|
||||
Polyline detailed_poly;
|
||||
|
|
@ -421,7 +420,7 @@ ExtrusionLoopSloped::ExtrusionLoopSloped(ExtrusionPaths& original_paths,
|
|||
detailed_poly.append(poly.first_point());
|
||||
|
||||
// Recursively split the line into half until no longer than `slope_max_segment_length`
|
||||
const std::function<void(const Line&)> handle_line = [slope_max_segment_length, &detailed_poly, &handle_line](const Line& line) {
|
||||
const std::function<void(const Line &)> handle_line = [slope_max_segment_length, &detailed_poly, &handle_line](const Line &line) {
|
||||
if (line.length() <= slope_max_segment_length) {
|
||||
detailed_poly.append(line.b);
|
||||
} else {
|
||||
|
|
@ -432,13 +431,10 @@ ExtrusionLoopSloped::ExtrusionLoopSloped(ExtrusionPaths& original_paths,
|
|||
}
|
||||
};
|
||||
|
||||
for (const auto& l : poly.lines()) {
|
||||
handle_line(l);
|
||||
}
|
||||
for (const auto &l : poly.lines()) { handle_line(l); }
|
||||
}
|
||||
|
||||
starts.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{ratio_begin, ratio_begin},
|
||||
ExtrusionPathSloped::Slope{ratio_end, ratio_end});
|
||||
starts.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{ratio_begin, ratio_begin}, ExtrusionPathSloped::Slope{ratio_end, ratio_end});
|
||||
|
||||
if (is_approx(ratio_end, 1.) && seam_gap > 0) {
|
||||
// Remove the segments that has no extrusion
|
||||
|
|
@ -456,10 +452,8 @@ ExtrusionLoopSloped::ExtrusionLoopSloped(ExtrusionPaths& original_paths,
|
|||
detailed_poly.clear();
|
||||
}
|
||||
}
|
||||
if (!detailed_poly.empty()) {
|
||||
ends.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{1., 1. - ratio_begin},
|
||||
ExtrusionPathSloped::Slope{1., 1. - ratio_end});
|
||||
}
|
||||
if (!detailed_poly.empty()) { ends.emplace_back(detailed_poly, path, ExtrusionPathSloped::Slope{1., 1. - ratio_begin}, ExtrusionPathSloped::Slope{1., 1. - ratio_end}); }
|
||||
|
||||
};
|
||||
|
||||
double remaining_length = slope_min_length;
|
||||
|
|
@ -509,6 +503,61 @@ std::vector<const ExtrusionPath*> ExtrusionLoopSloped::get_all_paths() const {
|
|||
return r;
|
||||
}
|
||||
|
||||
void ExtrusionLoopSloped::clip_slope(double distance, bool inter_perimeter)
|
||||
{
|
||||
|
||||
this->clip_end(distance);
|
||||
this->clip_front(distance*2);
|
||||
}
|
||||
|
||||
void ExtrusionLoopSloped::clip_end(const double distance)
|
||||
{
|
||||
double clip_dist = distance;
|
||||
std::vector<ExtrusionPathSloped> &ends_slope = this->ends;
|
||||
while (clip_dist > 0 && !ends_slope.empty()) {
|
||||
ExtrusionPathSloped &last_path = ends_slope.back();
|
||||
double len = last_path.length();
|
||||
if (len <= clip_dist) {
|
||||
ends_slope.pop_back();
|
||||
clip_dist -= len;
|
||||
} else {
|
||||
last_path.polyline.clip_end(clip_dist);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExtrusionLoopSloped::clip_front(const double distance)
|
||||
{
|
||||
double clip_dist = distance;
|
||||
if (this->role() == erPerimeter)
|
||||
clip_dist = scale_(this->slope_path_length()) * slope_inner_outer_wall_gap;
|
||||
|
||||
std::vector<ExtrusionPathSloped> &start_slope = this->starts;
|
||||
|
||||
Polyline front_inward;
|
||||
while (distance > 0 && !start_slope.empty()) {
|
||||
ExtrusionPathSloped &first_path = start_slope.front();
|
||||
double len = first_path.length();
|
||||
if (len <= clip_dist) {
|
||||
start_slope.erase(start_slope.begin());
|
||||
clip_dist -= len;
|
||||
} else {
|
||||
first_path.polyline.reverse();
|
||||
first_path.polyline.clip_end(clip_dist);
|
||||
first_path.polyline.reverse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double ExtrusionLoopSloped::slope_path_length() {
|
||||
double total_length = 0.0;
|
||||
for (ExtrusionPathSloped start_ep : this->starts) {
|
||||
total_length += unscale_(start_ep.length());
|
||||
}
|
||||
return total_length;
|
||||
}
|
||||
|
||||
std::string ExtrusionEntity::role_to_string(ExtrusionRole role)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class ExtrusionPath : public ExtrusionEntity
|
|||
{
|
||||
public:
|
||||
Polyline polyline;
|
||||
int overhang_degree = 0;
|
||||
double overhang_degree = 0;
|
||||
int curve_degree = 0;
|
||||
// Volumetric velocity. mm^3 of plastic per mm of linear head motion. Used by the G-code generator.
|
||||
double mm3_per_mm;
|
||||
|
|
@ -163,7 +163,8 @@ public:
|
|||
ExtrusionPath() : mm3_per_mm(-1), width(-1), height(-1), m_role(erNone), m_no_extrusion(false) {}
|
||||
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role), m_no_extrusion(false) {}
|
||||
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height, bool no_extrusion = false) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role), m_no_extrusion(no_extrusion) {}
|
||||
ExtrusionPath(int overhang_degree, int curve_degree, ExtrusionRole role, double mm3_per_mm, float width, float height) : overhang_degree(overhang_degree), curve_degree(curve_degree), mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {}
|
||||
ExtrusionPath(double overhang_degree, int curve_degree, ExtrusionRole role, double mm3_per_mm, float width, float height) : overhang_degree(overhang_degree), curve_degree(curve_degree), mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {}
|
||||
|
||||
ExtrusionPath(const ExtrusionPath &rhs)
|
||||
: polyline(rhs.polyline)
|
||||
, overhang_degree(rhs.overhang_degree)
|
||||
|
|
@ -277,8 +278,8 @@ public:
|
|||
};
|
||||
int get_overhang_degree() const {
|
||||
// only perimeter has overhang degree. Other return 0;
|
||||
if (is_perimeter(m_role) || is_bridge(m_role))
|
||||
return overhang_degree;
|
||||
if (is_perimeter(m_role))
|
||||
return (int)overhang_degree;
|
||||
return 0;
|
||||
};
|
||||
void set_curve_degree(int curve) {
|
||||
|
|
@ -513,6 +514,10 @@ public:
|
|||
ExtrusionLoopRole role = elrDefault);
|
||||
|
||||
[[nodiscard]] std::vector<const ExtrusionPath*> get_all_paths() const;
|
||||
void clip_slope(double distance, bool inter_perimeter = false );
|
||||
void clip_end(const double distance);
|
||||
void clip_front(const double distance);
|
||||
double slope_path_length();
|
||||
};
|
||||
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
|
|
@ -525,7 +530,7 @@ inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, Ex
|
|||
}
|
||||
}
|
||||
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, int overhang_degree, int curva_degree, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &polylines, double overhang_degree, int curva_degree, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
{
|
||||
dst.reserve(dst.size() + polylines.size());
|
||||
for (Polyline &polyline : polylines)
|
||||
|
|
@ -546,7 +551,7 @@ inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &&polylines, E
|
|||
polylines.clear();
|
||||
}
|
||||
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &&polylines, int overhang_degree, int curva_degree, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &&polylines, double overhang_degree, int curva_degree, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
{
|
||||
dst.reserve(dst.size() + polylines.size());
|
||||
for (Polyline &polyline : polylines)
|
||||
|
|
@ -557,6 +562,16 @@ inline void extrusion_paths_append(ExtrusionPaths &dst, Polylines &&polylines, i
|
|||
polylines.clear();
|
||||
}
|
||||
|
||||
inline void extrusion_paths_append(ExtrusionPaths &dst, Polyline &&polyline, double overhang_degree, int curva_degree, ExtrusionRole role, double mm3_per_mm, float width, float height)
|
||||
{
|
||||
dst.reserve(dst.size() + 1);
|
||||
if (polyline.is_valid()) {
|
||||
dst.push_back(ExtrusionPath(overhang_degree, curva_degree, role, mm3_per_mm, width, height));
|
||||
dst.back().polyline = std::move(polyline);
|
||||
}
|
||||
polyline.clear();
|
||||
}
|
||||
|
||||
inline void extrusion_entities_append_paths(ExtrusionEntitiesPtr &dst, Polylines &polylines, ExtrusionRole role, double mm3_per_mm, float width, float height, bool can_reverse = true)
|
||||
{
|
||||
dst.reserve(dst.size() + polylines.size());
|
||||
|
|
|
|||
|
|
@ -65,7 +65,10 @@ struct SurfaceFillParams
|
|||
|
||||
// Index of this entry in a linear vector.
|
||||
size_t idx = 0;
|
||||
|
||||
// infill speed settings
|
||||
float sparse_infill_speed = 0;
|
||||
float top_surface_speed = 0;
|
||||
float solid_infill_speed = 0;
|
||||
|
||||
bool operator<(const SurfaceFillParams &rhs) const {
|
||||
#define RETURN_COMPARE_NON_EQUAL(KEY) if (this->KEY < rhs.KEY) return true; if (this->KEY > rhs.KEY) return false;
|
||||
|
|
@ -89,6 +92,10 @@ struct SurfaceFillParams
|
|||
RETURN_COMPARE_NON_EQUAL(flow.nozzle_diameter());
|
||||
RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, bridge);
|
||||
RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, extrusion_role);
|
||||
RETURN_COMPARE_NON_EQUAL(sparse_infill_speed);
|
||||
RETURN_COMPARE_NON_EQUAL(top_surface_speed);
|
||||
RETURN_COMPARE_NON_EQUAL(solid_infill_speed);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +112,10 @@ struct SurfaceFillParams
|
|||
this->anchor_length == rhs.anchor_length &&
|
||||
this->anchor_length_max == rhs.anchor_length_max &&
|
||||
this->flow == rhs.flow &&
|
||||
this->extrusion_role == rhs.extrusion_role;
|
||||
this->extrusion_role == rhs.extrusion_role &&
|
||||
this->sparse_infill_speed == rhs.sparse_infill_speed &&
|
||||
this->top_surface_speed == rhs.top_surface_speed &&
|
||||
this->solid_infill_speed == rhs.solid_infill_speed;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -490,7 +500,15 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
|||
//Orca: enable thick bridge based on config
|
||||
layerm.bridging_flow(extrusion_role, is_thick_bridge) :
|
||||
layerm.flow(extrusion_role, (surface.thickness == -1) ? layer.height : surface.thickness);
|
||||
|
||||
// record speed params
|
||||
if (!params.bridge) {
|
||||
if (params.extrusion_role == erInternalInfill)
|
||||
params.sparse_infill_speed = region_config.sparse_infill_speed;
|
||||
else if (params.extrusion_role == erTopSolidInfill)
|
||||
params.top_surface_speed = region_config.top_surface_speed;
|
||||
else if (params.extrusion_role == erSolidInfill)
|
||||
params.solid_infill_speed = region_config.internal_solid_infill_speed;
|
||||
}
|
||||
// Calculate flow spacing for infill pattern generation.
|
||||
if (surface.is_solid() || is_bridge) {
|
||||
params.spacing = params.flow.spacing();
|
||||
|
|
|
|||
|
|
@ -186,15 +186,18 @@ static Polylines makeGrid(coordf_t z, coordf_t gridSize, coordf_t boundWidth, co
|
|||
// dont_adjust [avoid filling space evenly]
|
||||
// monotonic [fill strictly left to right]
|
||||
// complete [complete each loop]
|
||||
|
||||
|
||||
void Fill3DHoneycomb::_fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
const FillParams ¶ms,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon expolygon,
|
||||
Polylines &polylines_out)
|
||||
{
|
||||
// no rotation is supported for this infill pattern
|
||||
// Support infill angle
|
||||
auto infill_angle = float(this->angle);
|
||||
if (std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle);
|
||||
BoundingBox bb = expolygon.contour.bounding_box();
|
||||
|
||||
// Note: with equally-scaled X/Y/Z, the pattern will create a vertically-stretched
|
||||
|
|
@ -216,7 +219,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
|||
// Z scale is adjusted to make the layer patterns consistent / symmetric
|
||||
// This means that the resultant infill won't be an ideal truncated octahedron,
|
||||
// but it should look better than the equivalent quantised version
|
||||
|
||||
|
||||
coordf_t layerHeight = scale_(thickness_layers);
|
||||
// ceiling to an integer value of layers per Z
|
||||
// (with a little nudge in case it's close to perfect)
|
||||
|
|
@ -248,7 +251,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
|||
// (a module is 2*$gridSize since one $gridSize half-module is
|
||||
// growing while the other $gridSize half-module is shrinking)
|
||||
bb.merge(align_to_grid(bb.min, Point(gridSize*4, gridSize*4)));
|
||||
|
||||
|
||||
// generate pattern
|
||||
Polylines polylines =
|
||||
makeGrid(
|
||||
|
|
@ -257,7 +260,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
|||
bb.size()(0),
|
||||
bb.size()(1),
|
||||
!params.dont_adjust);
|
||||
|
||||
|
||||
// move pattern in place
|
||||
for (Polyline &pl : polylines){
|
||||
pl.translate(bb.min);
|
||||
|
|
@ -266,11 +269,21 @@ void Fill3DHoneycomb::_fill_surface_single(
|
|||
// clip pattern to boundaries, chain the clipped polylines
|
||||
polylines = intersection_pl(polylines, to_polygons(expolygon));
|
||||
|
||||
// connect lines if needed
|
||||
if (params.dont_connect() || polylines.size() <= 1)
|
||||
// copy from fliplines
|
||||
if (!polylines.empty()) {
|
||||
int infill_start_idx = polylines_out.size(); // only rotate what belongs to us.
|
||||
// connect lines
|
||||
if (params.dont_connect() || polylines.size() <= 1)
|
||||
append(polylines_out, chain_polylines(std::move(polylines)));
|
||||
else
|
||||
else
|
||||
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
||||
|
||||
// rotate back
|
||||
if (std::abs(infill_angle) >= EPSILON) {
|
||||
for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it)
|
||||
it->rotate(infill_angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
bool load_stl(const char *path, Model *model, const char *object_name_in, ImportstlProgressFn stlFn)
|
||||
bool load_stl(const char *path, Model *model, const char *object_name_in, ImportstlProgressFn stlFn, int custom_header_length)
|
||||
{
|
||||
TriangleMesh mesh;
|
||||
std::string design_id;
|
||||
|
||||
if (! mesh.ReadSTLFile(path, true, stlFn)) {
|
||||
// die "Failed to open $file\n" if !-e $path;
|
||||
if (!mesh.ReadSTLFile(path, true, stlFn, custom_header_length)) {
|
||||
// die "Failed to open $file\n" if !-e $path;
|
||||
return false;
|
||||
}
|
||||
if (mesh.empty()) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TriangleMesh;
|
|||
class ModelObject;
|
||||
|
||||
// Load an STL file into a provided model.
|
||||
extern bool load_stl(const char *path, Model *model, const char *object_name = nullptr, ImportstlProgressFn stlFn = nullptr);
|
||||
extern bool load_stl(const char *path, Model *model, const char *object_name = nullptr, ImportstlProgressFn stlFn = nullptr, int custom_header_length = 80);
|
||||
|
||||
extern bool store_stl(const char *path, TriangleMesh *mesh, bool binary);
|
||||
extern bool store_stl(const char *path, ModelObject *model_object, bool binary);
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ static constexpr const char* LOCK_ATTR = "locked";
|
|||
static constexpr const char* BED_TYPE_ATTR = "bed_type";
|
||||
static constexpr const char* PRINT_SEQUENCE_ATTR = "print_sequence";
|
||||
static constexpr const char* FIRST_LAYER_PRINT_SEQUENCE_ATTR = "first_layer_print_sequence";
|
||||
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_ATTR = "other_layers_print_sequence";
|
||||
static constexpr const char* OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR = "other_layers_print_sequence_nums";
|
||||
static constexpr const char* SPIRAL_VASE_MODE = "spiral_mode";
|
||||
static constexpr const char* GCODE_FILE_ATTR = "gcode_file";
|
||||
static constexpr const char* THUMBNAIL_FILE_ATTR = "thumbnail_file";
|
||||
|
|
@ -1491,6 +1493,8 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
plate->is_label_object_enabled = it->second->is_label_object_enabled;
|
||||
plate->skipped_objects = it->second->skipped_objects;
|
||||
plate->slice_filaments_info = it->second->slice_filaments_info;
|
||||
plate->printer_model_id = it->second->printer_model_id;
|
||||
plate->nozzle_diameters = it->second->nozzle_diameters;
|
||||
plate->warnings = it->second->warnings;
|
||||
plate->thumbnail_file = it->second->thumbnail_file;
|
||||
if (plate->thumbnail_file.empty()) {
|
||||
|
|
@ -4096,6 +4100,19 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
};
|
||||
m_curr_plater->config.set_key_value("first_layer_print_sequence", new ConfigOptionInts(get_vector_from_string(value)));
|
||||
}
|
||||
else if (key == OTHER_LAYERS_PRINT_SEQUENCE_ATTR) {
|
||||
auto get_vector_from_string = [](const std::string &str) -> std::vector<int> {
|
||||
std::stringstream stream(str);
|
||||
int value;
|
||||
std::vector<int> results;
|
||||
while (stream >> value) { results.push_back(value); }
|
||||
return results;
|
||||
};
|
||||
m_curr_plater->config.set_key_value("other_layers_print_sequence", new ConfigOptionInts(get_vector_from_string(value)));
|
||||
}
|
||||
else if (key == OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR) {
|
||||
m_curr_plater->config.set_key_value("other_layers_print_sequence_nums", new ConfigOptionInt(stoi(value)));
|
||||
}
|
||||
else if (key == SPIRAL_VASE_MODE) {
|
||||
bool spiral_mode = false;
|
||||
std::istringstream(value) >> std::boolalpha >> spiral_mode;
|
||||
|
|
@ -4185,6 +4202,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
if (m_curr_plater)
|
||||
std::istringstream(value) >> std::boolalpha >> m_curr_plater->is_label_object_enabled;
|
||||
}
|
||||
else if (key == PRINTER_MODEL_ID_ATTR)
|
||||
{
|
||||
if (m_curr_plater)
|
||||
m_curr_plater->printer_model_id = value;
|
||||
}
|
||||
else if (key == NOZZLE_DIAMETERS_ATTR)
|
||||
{
|
||||
if (m_curr_plater)
|
||||
m_curr_plater->nozzle_diameters = value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -7415,6 +7442,24 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
stream << "\"/>\n";
|
||||
}
|
||||
|
||||
|
||||
ConfigOptionInts *other_layers_print_sequence_opt = plate_data->config.option<ConfigOptionInts>("other_layers_print_sequence");
|
||||
if (other_layers_print_sequence_opt != nullptr) {
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OTHER_LAYERS_PRINT_SEQUENCE_ATTR << "\" " << VALUE_ATTR << "=\"";
|
||||
const std::vector<int> &values = other_layers_print_sequence_opt->values;
|
||||
for (int i = 0; i < values.size(); ++i) {
|
||||
stream << values[i];
|
||||
if (i != (values.size() - 1))
|
||||
stream << " ";
|
||||
}
|
||||
stream << "\"/>\n";
|
||||
}
|
||||
|
||||
const ConfigOptionInt *sequence_nums_opt = dynamic_cast<const ConfigOptionInt *>(plate_data->config.option("other_layers_print_sequence_nums"));
|
||||
if (sequence_nums_opt != nullptr) {
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OTHER_LAYERS_PRINT_SEQUENCE_NUMS_ATTR << "\" " << VALUE_ATTR << "=\"" << sequence_nums_opt->getInt() << "\"/>\n";
|
||||
}
|
||||
|
||||
ConfigOption* spiral_mode_opt = plate_data->config.option("spiral_mode");
|
||||
if (spiral_mode_opt)
|
||||
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SPIRAL_VASE_MODE << "\" " << VALUE_ATTR << "=\"" << spiral_mode_opt->getBool() << "\"/>\n";
|
||||
|
|
@ -7780,18 +7825,22 @@ bool _BBS_3MF_Exporter::_add_auxiliary_dir_to_archive(mz_zip_archive &archive, c
|
|||
int root_dir_len = dir.string().length() + 1;
|
||||
//boost file access
|
||||
while (!directories.empty()) {
|
||||
boost::filesystem::directory_iterator iterator(directories.front());
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::directory_iterator iterator(directories.front(), ec);
|
||||
directories.pop_front();
|
||||
for (auto &dir_entry : iterator)
|
||||
if (ec) continue;
|
||||
for (; iterator != end(iterator); iterator.increment(ec))
|
||||
{
|
||||
if (ec) break;
|
||||
auto dir_entry = *iterator;
|
||||
std::string src_file;
|
||||
std::string dst_in_3mf;
|
||||
if (boost::filesystem::is_directory(dir_entry.path()))
|
||||
if (boost::filesystem::is_directory(dir_entry.path(), ec))
|
||||
{
|
||||
directories.push_back(dir_entry.path());
|
||||
continue;
|
||||
}
|
||||
if (boost::filesystem::is_regular_file(dir_entry.path()) && !m_skip_auxiliary)
|
||||
if (boost::filesystem::is_regular_file(dir_entry.path(), ec) && !m_skip_auxiliary)
|
||||
{
|
||||
src_file = dir_entry.path().string();
|
||||
dst_in_3mf = dir_entry.path().string();
|
||||
|
|
|
|||
|
|
@ -639,6 +639,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
|||
}
|
||||
|
||||
gcodegen.placeholder_parser().set("current_extruder", new_extruder_id);
|
||||
gcodegen.placeholder_parser().set("retraction_distance_when_cut", gcodegen.m_config.retraction_distances_when_cut.get_at(new_extruder_id));
|
||||
gcodegen.placeholder_parser().set("long_retraction_when_cut", gcodegen.m_config.long_retractions_when_cut.get_at(new_extruder_id));
|
||||
|
||||
// Process the start filament gcode.
|
||||
std::string start_filament_gcode_str;
|
||||
|
|
@ -1425,8 +1427,21 @@ namespace DoExport {
|
|||
total_cost += weight * extruder->filament_cost() * 0.001;
|
||||
}
|
||||
|
||||
total_cost += config.time_cost.getFloat() * (normal_print_time/3600.0);
|
||||
|
||||
for (auto volume : result.print_statistics.support_volumes_per_extruder) {
|
||||
total_extruded_volume += volume.second;
|
||||
|
||||
size_t extruder_id = volume.first;
|
||||
auto extruder = std::find_if(extruders.begin(), extruders.end(), [extruder_id](const Extruder& extr) {return extr.id() == extruder_id; });
|
||||
if (extruder == extruders.end())
|
||||
continue;
|
||||
|
||||
double s = PI * sqr(0.5* extruder->filament_diameter());
|
||||
double weight = volume.second * extruder->filament_density() * 0.001;
|
||||
total_used_filament += volume.second/s;
|
||||
total_weight += weight;
|
||||
total_cost += weight * extruder->filament_cost() * 0.001;
|
||||
}
|
||||
|
||||
print_statistics.total_extruded_volume = total_extruded_volume;
|
||||
print_statistics.total_used_filament = total_used_filament;
|
||||
print_statistics.total_weight = total_weight;
|
||||
|
|
@ -1613,6 +1628,15 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
|||
m_processor.result().timelapse_warning_code = m_timelapse_warning_code;
|
||||
m_processor.result().support_traditional_timelapse = m_support_traditional_timelapse;
|
||||
|
||||
bool activate_long_retraction_when_cut = false;
|
||||
for (const auto& extruder : m_writer.extruders())
|
||||
activate_long_retraction_when_cut |= (
|
||||
m_config.long_retractions_when_cut.get_at(extruder.id())
|
||||
&& m_config.retraction_distances_when_cut.get_at(extruder.id()) > 0
|
||||
);
|
||||
|
||||
m_processor.result().long_retraction_when_cut = activate_long_retraction_when_cut;
|
||||
|
||||
{ //BBS:check bed and filament compatible
|
||||
const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type");
|
||||
assert(bed_type_def != nullptr);
|
||||
|
|
@ -2275,6 +2299,12 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
this->placeholder_parser().set("initial_no_support_tool", initial_non_support_extruder_id);
|
||||
this->placeholder_parser().set("initial_no_support_extruder", initial_non_support_extruder_id);
|
||||
this->placeholder_parser().set("current_extruder", initial_extruder_id);
|
||||
//set the key for compatibilty
|
||||
this->placeholder_parser().set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(initial_extruder_id));
|
||||
this->placeholder_parser().set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(initial_extruder_id));
|
||||
|
||||
this->placeholder_parser().set("retraction_distances_when_cut", new ConfigOptionFloats(m_config.retraction_distances_when_cut));
|
||||
this->placeholder_parser().set("long_retractions_when_cut",new ConfigOptionBools(m_config.long_retractions_when_cut));
|
||||
//Set variable for total layer count so it can be used in custom gcode.
|
||||
this->placeholder_parser().set("total_layer_count", m_layer_count);
|
||||
// Useful for sequential prints.
|
||||
|
|
@ -2295,6 +2325,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
|
||||
{
|
||||
BoundingBoxf bbox_bed(print.config().printable_area.values);
|
||||
Vec2f plate_offset = m_writer.get_xy_offset();
|
||||
this->placeholder_parser().set("print_bed_min", new ConfigOptionFloats({ bbox_bed.min.x(), bbox_bed.min.y()}));
|
||||
this->placeholder_parser().set("print_bed_max", new ConfigOptionFloats({ bbox_bed.max.x(), bbox_bed.max.y()}));
|
||||
this->placeholder_parser().set("print_bed_size", new ConfigOptionFloats({ bbox_bed.size().x(), bbox_bed.size().y() }));
|
||||
|
|
@ -2322,12 +2353,37 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
pts->values.emplace_back(print.translate_to_print_space(pt));
|
||||
bbox = BoundingBoxf((pts->values));
|
||||
}
|
||||
BoundingBoxf bbox_head_wrap_zone (print.config().head_wrap_detect_zone.values);
|
||||
this->placeholder_parser().set("first_layer_print_convex_hull", pts.release());
|
||||
this->placeholder_parser().set("first_layer_print_min", new ConfigOptionFloats({bbox.min.x(), bbox.min.y()}));
|
||||
this->placeholder_parser().set("first_layer_print_max", new ConfigOptionFloats({bbox.max.x(), bbox.max.y()}));
|
||||
this->placeholder_parser().set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() }));
|
||||
this->placeholder_parser().set("in_head_wrap_detect_zone",bbox_head_wrap_zone.overlap(bbox));
|
||||
|
||||
{
|
||||
// use first layer convex_hull union with each object's bbox to check whether in head detect zone
|
||||
Polygons object_projections;
|
||||
for (auto& obj : print.objects()) {
|
||||
for (auto& instance : obj->instances()) {
|
||||
const auto& bbox = instance.get_bounding_box();
|
||||
Point min_p{ coord_t(scale_(bbox.min.x())),coord_t(scale_(bbox.min.y())) };
|
||||
Point max_p{ coord_t(scale_(bbox.max.x())),coord_t(scale_(bbox.max.y())) };
|
||||
Polygon instance_projection = {
|
||||
{min_p.x(),min_p.y()},
|
||||
{max_p.x(),min_p.y()},
|
||||
{max_p.x(),max_p.y()},
|
||||
{min_p.x(),max_p.y()}
|
||||
};
|
||||
object_projections.emplace_back(std::move(instance_projection));
|
||||
}
|
||||
}
|
||||
object_projections.emplace_back(print.first_layer_convex_hull());
|
||||
|
||||
Polygons project_polys = union_(object_projections);
|
||||
Polygon head_wrap_detect_zone;
|
||||
for (auto& point : print.config().head_wrap_detect_zone.values)
|
||||
head_wrap_detect_zone.append(scale_(point).cast<coord_t>() + scale_(plate_offset).cast<coord_t>());
|
||||
|
||||
this->placeholder_parser().set("in_head_wrap_detect_zone", !intersection_pl(project_polys, {head_wrap_detect_zone}).empty());
|
||||
}
|
||||
|
||||
BoundingBoxf mesh_bbox(m_config.bed_mesh_min, m_config.bed_mesh_max);
|
||||
auto mesh_margin = m_config.adaptive_bed_mesh_margin.value;
|
||||
|
|
@ -4705,6 +4761,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
|
|||
|
||||
// Calculate the sloped loop
|
||||
ExtrusionLoopSloped new_loop(paths, seam_gap, slope_min_length, slope_max_segment_length, start_slope_ratio, loop.loop_role());
|
||||
new_loop.clip_slope(seam_gap);
|
||||
|
||||
// Then extrude it
|
||||
for (const auto& p : new_loop.get_all_paths()) {
|
||||
|
|
@ -4985,6 +5042,30 @@ static std::map<int, std::string> overhang_speed_key_map =
|
|||
{5, "bridge_speed"},
|
||||
};
|
||||
|
||||
double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_degree) {
|
||||
|
||||
//BBS: protection: overhang degree is float, make sure it not excess degree range
|
||||
if (path_degree <= 0)
|
||||
return normal_speed;
|
||||
|
||||
if (path_degree >= 5 )
|
||||
return m_config.get_abs_value(overhang_speed_key_map[5].c_str());
|
||||
|
||||
int lower_degree_bound = int(path_degree);
|
||||
if (path_degree==lower_degree_bound)
|
||||
return m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str());
|
||||
int upper_degree_bound = lower_degree_bound + 1;
|
||||
|
||||
double lower_speed_bound = lower_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str());
|
||||
double upper_speed_bound = upper_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[upper_degree_bound].c_str());
|
||||
|
||||
lower_speed_bound = lower_speed_bound == 0 ? normal_speed : lower_speed_bound;
|
||||
upper_speed_bound = upper_speed_bound == 0 ? normal_speed : upper_speed_bound;
|
||||
|
||||
double speed_out = lower_speed_bound + (upper_speed_bound - lower_speed_bound) * (path_degree - lower_degree_bound);
|
||||
return speed_out;
|
||||
}
|
||||
|
||||
std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed)
|
||||
{
|
||||
std::string gcode;
|
||||
|
|
@ -5092,12 +5173,11 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
|
||||
// set speed
|
||||
if (speed == -1) {
|
||||
int overhang_degree = path.get_overhang_degree();
|
||||
if (path.role() == erPerimeter) {
|
||||
speed = m_config.get_abs_value("inner_wall_speed");
|
||||
if (m_config.overhang_speed_classic.value && m_config.enable_overhang_speed.value && overhang_degree > 0 &&
|
||||
overhang_degree <= 5) {
|
||||
double new_speed = m_config.get_abs_value(overhang_speed_key_map[overhang_degree].c_str());
|
||||
if (m_config.overhang_speed_classic.value && m_config.enable_overhang_speed.value) {
|
||||
double new_speed = 0;
|
||||
new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree);
|
||||
speed = new_speed == 0.0 ? speed : new_speed;
|
||||
}
|
||||
|
||||
|
|
@ -5106,9 +5186,9 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
}
|
||||
} else if (path.role() == erExternalPerimeter) {
|
||||
speed = m_config.get_abs_value("outer_wall_speed");
|
||||
if (m_config.overhang_speed_classic.value && m_config.enable_overhang_speed.value &&
|
||||
overhang_degree > 0 && overhang_degree <= 5) {
|
||||
double new_speed = m_config.get_abs_value(overhang_speed_key_map[overhang_degree].c_str());
|
||||
if (m_config.overhang_speed_classic.value && m_config.enable_overhang_speed.value ) {
|
||||
double new_speed = 0;
|
||||
new_speed = get_overhang_degree_corr_speed(speed, path.overhang_degree);
|
||||
speed = new_speed == 0.0 ? speed : new_speed;
|
||||
}
|
||||
if (sloped) {
|
||||
|
|
@ -5405,6 +5485,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
for (const Line& line : path.polyline.lines()) {
|
||||
std::string tempDescription = description;
|
||||
const double line_length = line.length() * SCALING_FACTOR;
|
||||
if (line_length < EPSILON)
|
||||
continue;
|
||||
path_length += line_length;
|
||||
auto dE = e_per_mm * line_length;
|
||||
if (m_small_area_infill_flow_compensator && m_config.small_area_infill_flow_compensation.value) {
|
||||
|
|
@ -5444,6 +5526,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
for (size_t point_index = start_index + 1; point_index < end_index + 1; point_index++) {
|
||||
const Line line = Line(path.polyline.points[point_index - 1], path.polyline.points[point_index]);
|
||||
const double line_length = line.length() * SCALING_FACTOR;
|
||||
if (line_length < EPSILON)
|
||||
continue;
|
||||
auto dE = e_per_mm * line_length;
|
||||
if (m_small_area_infill_flow_compensator && m_config.small_area_infill_flow_compensation.value) {
|
||||
auto oldE = dE;
|
||||
|
|
@ -5464,6 +5548,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
case EMovePathType::Arc_move_ccw: {
|
||||
const ArcSegment& arc = fitting_result[fitting_index].arc_data;
|
||||
const double arc_length = fitting_result[fitting_index].arc_data.length * SCALING_FACTOR;
|
||||
if (arc_length < EPSILON)
|
||||
continue;
|
||||
const Vec2d center_offset = this->point_to_gcode(arc.center) - this->point_to_gcode(arc.start_point);
|
||||
auto dE = e_per_mm * arc_length;
|
||||
if (m_small_area_infill_flow_compensator && m_config.small_area_infill_flow_compensation.value) {
|
||||
|
|
@ -5545,6 +5631,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
}
|
||||
|
||||
const double line_length = (p - prev).norm();
|
||||
if(line_length < EPSILON)
|
||||
continue;
|
||||
path_length += line_length;
|
||||
double new_speed = pre_processed_point.speed * 60.0;
|
||||
if (last_set_speed != new_speed) {
|
||||
|
|
@ -5971,6 +6059,8 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b
|
|||
// if we are running a single-extruder setup, just set the extruder and return nothing
|
||||
if (!m_writer.multiple_extruders) {
|
||||
this->placeholder_parser().set("current_extruder", extruder_id);
|
||||
this->placeholder_parser().set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(extruder_id));
|
||||
this->placeholder_parser().set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(extruder_id));
|
||||
|
||||
std::string gcode;
|
||||
// Append the filament start G-code.
|
||||
|
|
@ -6162,6 +6252,8 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b
|
|||
}
|
||||
|
||||
this->placeholder_parser().set("current_extruder", extruder_id);
|
||||
this->placeholder_parser().set("retraction_distance_when_cut", m_config.retraction_distances_when_cut.get_at(extruder_id));
|
||||
this->placeholder_parser().set("long_retraction_when_cut", m_config.long_retractions_when_cut.get_at(extruder_id));
|
||||
|
||||
// Append the filament start G-code.
|
||||
const std::string &filament_start_gcode = m_config.filament_start_gcode.get_at(extruder_id);
|
||||
|
|
|
|||
|
|
@ -577,6 +577,7 @@ private:
|
|||
int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const;
|
||||
|
||||
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
|
||||
double get_overhang_degree_corr_speed(float speed, double path_degree);
|
||||
void print_machine_envelope(GCodeOutputStream &file, Print &print);
|
||||
void _print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
|
|
|
|||
|
|
@ -762,6 +762,15 @@ void GCodeProcessor::UsedFilaments::reset()
|
|||
|
||||
wipe_tower_cache = 0.0f;
|
||||
wipe_tower_volume_per_extruder.clear();
|
||||
|
||||
support_volume_cache = 0.0f;
|
||||
support_volume_per_extruder.clear();
|
||||
}
|
||||
|
||||
void GCodeProcessor::UsedFilaments::increase_support_caches(double extruded_volume)
|
||||
{
|
||||
support_volume_cache += extruded_volume;
|
||||
role_cache += extruded_volume;
|
||||
}
|
||||
|
||||
void GCodeProcessor::UsedFilaments::increase_model_caches(double extruded_volume)
|
||||
|
|
@ -774,6 +783,7 @@ void GCodeProcessor::UsedFilaments::increase_model_caches(double extruded_volume
|
|||
void GCodeProcessor::UsedFilaments::increase_wipe_tower_caches(double extruded_volume)
|
||||
{
|
||||
wipe_tower_cache += extruded_volume;
|
||||
role_cache += extruded_volume;
|
||||
}
|
||||
|
||||
void GCodeProcessor::UsedFilaments::process_color_change_cache()
|
||||
|
|
@ -808,6 +818,18 @@ void GCodeProcessor::UsedFilaments::process_wipe_tower_cache(GCodeProcessor* pro
|
|||
}
|
||||
}
|
||||
|
||||
void GCodeProcessor::UsedFilaments::process_support_cache(GCodeProcessor* processor)
|
||||
{
|
||||
size_t active_extruder_id = processor->m_extruder_id;
|
||||
if (support_volume_cache != 0.0f){
|
||||
if (support_volume_per_extruder.find(active_extruder_id) != support_volume_per_extruder.end())
|
||||
support_volume_per_extruder[active_extruder_id] += support_volume_cache;
|
||||
else
|
||||
support_volume_per_extruder[active_extruder_id] = support_volume_cache;
|
||||
support_volume_cache = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeProcessor::UsedFilaments::update_flush_per_filament(size_t extrude_id, float flush_volume)
|
||||
{
|
||||
if (flush_per_filament.find(extrude_id) != flush_per_filament.end())
|
||||
|
|
@ -842,6 +864,7 @@ void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
|
|||
process_model_cache(processor);
|
||||
process_role_cache(processor);
|
||||
process_wipe_tower_cache(processor);
|
||||
process_support_cache(processor);
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
|
@ -885,6 +908,7 @@ void GCodeProcessorResult::reset() {
|
|||
toolpath_outside = false;
|
||||
//BBS: add label_object_enabled
|
||||
label_object_enabled = false;
|
||||
long_retraction_when_cut = false;
|
||||
timelapse_warning_code = 0;
|
||||
printable_height = 0.0f;
|
||||
settings_ids.reset();
|
||||
|
|
@ -2932,7 +2956,10 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
|
||||
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
||||
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
||||
if (m_wipe_tower) {
|
||||
|
||||
if(m_extrusion_role == ExtrusionRole::erSupportMaterial || m_extrusion_role == ExtrusionRole::erSupportMaterialInterface || m_extrusion_role ==ExtrusionRole::erSupportTransition)
|
||||
m_used_filaments.increase_support_caches(volume_extruded_filament);
|
||||
else if (m_extrusion_role==ExtrusionRole::erWipeTower) {
|
||||
m_used_filaments.increase_wipe_tower_caches(volume_extruded_filament);
|
||||
}
|
||||
else {
|
||||
|
|
@ -3406,7 +3433,10 @@ void GCodeProcessor::process_G2_G3(const GCodeReader::GCodeLine& line)
|
|||
if (type == EMoveType::Extrude) {
|
||||
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
|
||||
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
|
||||
if (m_wipe_tower) {
|
||||
|
||||
if(m_extrusion_role == ExtrusionRole::erSupportMaterial || m_extrusion_role == ExtrusionRole::erSupportMaterialInterface || m_extrusion_role ==ExtrusionRole::erSupportTransition)
|
||||
m_used_filaments.increase_support_caches(volume_extruded_filament);
|
||||
else if (m_extrusion_role == ExtrusionRole::erWipeTower) {
|
||||
//BBS: save wipe tower volume to the cache
|
||||
m_used_filaments.increase_wipe_tower_caches(volume_extruded_filament);
|
||||
}
|
||||
|
|
@ -4511,6 +4541,7 @@ void GCodeProcessor::process_filaments(CustomGCode::Type code)
|
|||
|
||||
if (code == CustomGCode::ToolChange) {
|
||||
m_used_filaments.process_model_cache(this);
|
||||
m_used_filaments.process_support_cache(this);
|
||||
//BBS: reset remaining filament
|
||||
m_remaining_volume = m_nozzle_volume;
|
||||
}
|
||||
|
|
@ -4544,6 +4575,7 @@ void GCodeProcessor::update_estimated_times_stats()
|
|||
m_result.print_statistics.volumes_per_color_change = m_used_filaments.volumes_per_color_change;
|
||||
m_result.print_statistics.volumes_per_extruder = m_used_filaments.volumes_per_extruder;
|
||||
m_result.print_statistics.wipe_tower_volumes_per_extruder = m_used_filaments.wipe_tower_volume_per_extruder;
|
||||
m_result.print_statistics.support_volumes_per_extruder = m_used_filaments.support_volume_per_extruder;
|
||||
m_result.print_statistics.flush_per_filament = m_used_filaments.flush_per_filament;
|
||||
m_result.print_statistics.used_filaments_per_role = m_used_filaments.filaments_per_role;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace Slic3r {
|
|||
#define BED_TEMP_TOO_HIGH_THAN_FILAMENT "bed_temperature_too_high_than_filament"
|
||||
#define NOT_SUPPORT_TRADITIONAL_TIMELAPSE "not_support_traditional_timelapse"
|
||||
#define NOT_GENERATE_TIMELAPSE "not_generate_timelapse"
|
||||
#define LONG_RETRACTION_WHEN_CUT "activate_long_retraction_when_cut"
|
||||
|
||||
enum class EMoveType : unsigned char
|
||||
{
|
||||
|
|
@ -74,6 +75,7 @@ namespace Slic3r {
|
|||
std::vector<double> volumes_per_color_change;
|
||||
std::map<size_t, double> volumes_per_extruder;
|
||||
std::map<size_t, double> wipe_tower_volumes_per_extruder;
|
||||
std::map<size_t, double> support_volumes_per_extruder;
|
||||
//BBS: the flush amount of every filament
|
||||
std::map<size_t, double> flush_per_filament;
|
||||
std::map<ExtrusionRole, std::pair<double, double>> used_filaments_per_role;
|
||||
|
|
@ -195,6 +197,8 @@ namespace Slic3r {
|
|||
bool toolpath_outside;
|
||||
//BBS: add object_label_enabled
|
||||
bool label_object_enabled;
|
||||
//BBS : extra retraction when change filament,experiment func
|
||||
bool long_retraction_when_cut {0};
|
||||
int timelapse_warning_code {0};
|
||||
bool support_traditional_timelapse{true};
|
||||
float printable_height;
|
||||
|
|
@ -231,6 +235,7 @@ namespace Slic3r {
|
|||
bed_exclude_area = other.bed_exclude_area;
|
||||
toolpath_outside = other.toolpath_outside;
|
||||
label_object_enabled = other.label_object_enabled;
|
||||
long_retraction_when_cut = other.long_retraction_when_cut;
|
||||
timelapse_warning_code = other.timelapse_warning_code;
|
||||
printable_height = other.printable_height;
|
||||
settings_ids = other.settings_ids;
|
||||
|
|
@ -500,6 +505,9 @@ namespace Slic3r {
|
|||
double wipe_tower_cache;
|
||||
std::map<size_t, double>wipe_tower_volume_per_extruder;
|
||||
|
||||
double support_volume_cache;
|
||||
std::map<size_t, double>support_volume_per_extruder;
|
||||
|
||||
//BBS: the flush amount of every filament
|
||||
std::map<size_t, double> flush_per_filament;
|
||||
|
||||
|
|
@ -508,12 +516,15 @@ namespace Slic3r {
|
|||
|
||||
void reset();
|
||||
|
||||
void increase_support_caches(double extruded_volume);
|
||||
void increase_model_caches(double extruded_volume);
|
||||
void increase_wipe_tower_caches(double extruded_volume);
|
||||
|
||||
void process_color_change_cache();
|
||||
void process_model_cache(GCodeProcessor* processor);
|
||||
void process_wipe_tower_cache(GCodeProcessor* processor);
|
||||
void process_support_cache(GCodeProcessor* processor);
|
||||
|
||||
void update_flush_per_filament(size_t extrude_id, float flush_length);
|
||||
void process_role_cache(GCodeProcessor* processor);
|
||||
void process_caches(GCodeProcessor* processor);
|
||||
|
|
|
|||
|
|
@ -164,13 +164,19 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
|
|||
if (found && dist < max_xy_dist_for_smoothing) {
|
||||
// Interpolate between the point on this layer and the point on the previous layer
|
||||
SpiralVase::SpiralPoint target = SpiralVaseHelpers::add(SpiralVaseHelpers::scale(nearestp, 1 - factor), SpiralVaseHelpers::scale(p, factor));
|
||||
line.set(reader, X, target.x);
|
||||
line.set(reader, Y, target.y);
|
||||
|
||||
// Remove tiny movement
|
||||
// We need to figure out the distance of this new line!
|
||||
float modified_dist_XY = SpiralVaseHelpers::distance(last_point, target);
|
||||
// Scale the extrusion amount according to change in length
|
||||
line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
|
||||
last_point = target;
|
||||
if (modified_dist_XY < 0.001)
|
||||
line.clear();
|
||||
else {
|
||||
line.set(reader, X, target.x);
|
||||
line.set(reader, Y, target.y);
|
||||
// Scale the extrusion amount according to change in length
|
||||
line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
|
||||
last_point = target;
|
||||
}
|
||||
} else {
|
||||
last_point = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "Print.hpp"
|
||||
#include "ToolOrdering.hpp"
|
||||
#include "Layer.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "ParameterUtils.hpp"
|
||||
|
||||
// #define SLIC3R_DEBUG
|
||||
|
||||
|
|
@ -21,9 +23,74 @@ namespace Slic3r {
|
|||
|
||||
const static bool g_wipe_into_objects = false;
|
||||
|
||||
|
||||
// Shortest hamilton path problem
|
||||
static std::vector<unsigned int> solve_extruder_order(const std::vector<std::vector<float>>& wipe_volumes, std::vector<unsigned int> all_extruders, unsigned int start_extruder_id)
|
||||
{
|
||||
auto start_iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id);
|
||||
bool add_start_extruder_flag = false;
|
||||
if (start_iter == all_extruders.end())
|
||||
all_extruders.insert(all_extruders.begin(), start_extruder_id), add_start_extruder_flag = true;
|
||||
else
|
||||
std::swap(*all_extruders.begin(), *start_iter);
|
||||
|
||||
unsigned int iterations = (1 << all_extruders.size());
|
||||
unsigned int final_state = iterations - 1;
|
||||
std::vector<std::vector<float>>cache(iterations, std::vector<float>(all_extruders.size(),0x7fffffff));
|
||||
std::vector<std::vector<int>>prev(iterations, std::vector<int>(all_extruders.size(), -1));
|
||||
cache[1][0] = 0.;
|
||||
for (unsigned int state = 0; state < iterations; ++state) {
|
||||
if (state & 1) {
|
||||
for (unsigned int target = 0; target < all_extruders.size(); ++target) {
|
||||
if (state >> target & 1) {
|
||||
for (unsigned int mid_point = 0; mid_point < all_extruders.size(); ++mid_point) {
|
||||
if(state>>mid_point&1){
|
||||
auto tmp = cache[state - (1 << target)][mid_point] + wipe_volumes[all_extruders[mid_point]][all_extruders[target]];
|
||||
if (cache[state][target] >tmp) {
|
||||
cache[state][target] = tmp;
|
||||
prev[state][target] = mid_point;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get res
|
||||
float cost = std::numeric_limits<float>::max();
|
||||
int final_dst =0;
|
||||
for (unsigned int dst = 0; dst < all_extruders.size(); ++dst) {
|
||||
if (all_extruders[dst] != start_extruder_id && cost > cache[final_state][dst]) {
|
||||
cost = cache[final_state][dst];
|
||||
final_dst = dst;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<unsigned int>path;
|
||||
unsigned int curr_state = final_state;
|
||||
int curr_point = final_dst;
|
||||
while (curr_point != -1) {
|
||||
path.emplace_back(all_extruders[curr_point]);
|
||||
auto mid_point = prev[curr_state][curr_point];
|
||||
curr_state -= (1 << curr_point);
|
||||
curr_point = mid_point;
|
||||
};
|
||||
|
||||
if (add_start_extruder_flag)
|
||||
path.pop_back();
|
||||
|
||||
std::reverse(path.begin(), path.end());
|
||||
return path;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> get_extruders_order(const std::vector<std::vector<float>> &wipe_volumes, std::vector<unsigned int> all_extruders, unsigned int start_extruder_id)
|
||||
{
|
||||
if (all_extruders.size() > 1) {
|
||||
#define USE_DP_OPTIMIZE
|
||||
#ifdef USE_DP_OPTIMIZE
|
||||
return solve_extruder_order(wipe_volumes, all_extruders, start_extruder_id);
|
||||
#else
|
||||
if (all_extruders.size() > 1) {
|
||||
int begin_index = 0;
|
||||
auto iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id);
|
||||
if (iter != all_extruders.end()) {
|
||||
|
|
@ -52,6 +119,8 @@ std::vector<unsigned int> get_extruders_order(const std::vector<std::vector<floa
|
|||
return volumes_to_extruder_order.second;
|
||||
}
|
||||
return all_extruders;
|
||||
|
||||
#endif // OPTIMIZE
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -769,14 +838,77 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
|
|||
wipe_volumes.push_back(std::vector<float>(number_of_extruders, print_config->prime_volume));
|
||||
}
|
||||
|
||||
auto extruders_to_hash_key = [](const std::vector<unsigned int>& extruders, unsigned int initial_extruder_id)->uint32_t {
|
||||
uint32_t hash_key = 0;
|
||||
// high 16 bit define initial extruder ,low 16 bit define extruder set
|
||||
hash_key |= (1 << (16 + initial_extruder_id));
|
||||
for (auto item : extruders)
|
||||
hash_key |= (1 << item);
|
||||
return hash_key;
|
||||
};
|
||||
|
||||
std::vector<LayerPrintSequence> other_layers_seqs;
|
||||
const ConfigOptionInts *other_layers_print_sequence_op = print_config->option<ConfigOptionInts>("other_layers_print_sequence");
|
||||
const ConfigOptionInt *other_layers_print_sequence_nums_op = print_config->option<ConfigOptionInt>("other_layers_print_sequence_nums");
|
||||
if (other_layers_print_sequence_op && other_layers_print_sequence_nums_op) {
|
||||
const std::vector<int> &print_sequence = other_layers_print_sequence_op->values;
|
||||
int sequence_nums = other_layers_print_sequence_nums_op->value;
|
||||
other_layers_seqs = get_other_layers_print_sequence(sequence_nums, print_sequence);
|
||||
}
|
||||
|
||||
// other_layers_seq: the layer_idx and extruder_idx are base on 1
|
||||
auto get_custom_seq = [&other_layers_seqs](int layer_idx, std::vector<int>& out_seq) -> bool {
|
||||
for (size_t idx = other_layers_seqs.size() - 1; idx != size_t(-1); --idx) {
|
||||
const auto &other_layers_seq = other_layers_seqs[idx];
|
||||
if (layer_idx + 1 >= other_layers_seq.first.first && layer_idx + 1 <= other_layers_seq.first.second) {
|
||||
out_seq = other_layers_seq.second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
unsigned int current_extruder_id = -1;
|
||||
for (int i = 0; i < m_layer_tools.size(); ++i) {
|
||||
LayerTools& lt = m_layer_tools[i];
|
||||
if (lt.extruders.empty())
|
||||
continue;
|
||||
// todo: The algorithm complexity is too high(o(n2)), currently only 12 colors are supported
|
||||
if (i != 0 && lt.extruders.size() <= 12) {
|
||||
lt.extruders = get_extruders_order(wipe_volumes, lt.extruders, current_extruder_id);
|
||||
|
||||
std::vector<int> custom_extruder_seq;
|
||||
if (get_custom_seq(i, custom_extruder_seq) && !custom_extruder_seq.empty()) {
|
||||
std::vector<unsigned int> unsign_custom_extruder_seq;
|
||||
for (int extruder : custom_extruder_seq) {
|
||||
unsigned int unsign_extruder = static_cast<unsigned int>(extruder) - 1;
|
||||
auto it = std::find(lt.extruders.begin(), lt.extruders.end(), unsign_extruder);
|
||||
if (it != lt.extruders.end()) {
|
||||
unsign_custom_extruder_seq.emplace_back(unsign_extruder);
|
||||
}
|
||||
}
|
||||
assert(lt.extruders.size() == unsign_custom_extruder_seq.size());
|
||||
lt.extruders = unsign_custom_extruder_seq;
|
||||
current_extruder_id = lt.extruders.back();
|
||||
continue;
|
||||
}
|
||||
|
||||
// The algorithm complexity is O(n2*2^n)
|
||||
if (i != 0) {
|
||||
auto hash_key = extruders_to_hash_key(lt.extruders, current_extruder_id);
|
||||
auto iter = m_tool_order_cache.find(hash_key);
|
||||
if (iter == m_tool_order_cache.end()) {
|
||||
lt.extruders = get_extruders_order(wipe_volumes, lt.extruders, current_extruder_id);
|
||||
std::vector<uint8_t> hash_val;
|
||||
hash_val.reserve(lt.extruders.size());
|
||||
for (auto item : lt.extruders)
|
||||
hash_val.emplace_back(static_cast<uint8_t>(item));
|
||||
m_tool_order_cache[hash_key] = hash_val;
|
||||
}
|
||||
else {
|
||||
std::vector<unsigned int>extruder_order;
|
||||
extruder_order.reserve(iter->second.size());
|
||||
for (auto item : iter->second)
|
||||
extruder_order.emplace_back(static_cast<unsigned int>(item));
|
||||
lt.extruders = std::move(extruder_order);
|
||||
}
|
||||
}
|
||||
current_extruder_id = lt.extruders.back();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,9 @@ public:
|
|||
// (print->config().print_sequence == PrintSequence::ByObject is false).
|
||||
ToolOrdering(const Print& print, unsigned int first_extruder, bool prime_multi_material = false);
|
||||
|
||||
void clear() { m_layer_tools.clear(); }
|
||||
void clear() {
|
||||
m_layer_tools.clear(); m_tool_order_cache.clear();
|
||||
}
|
||||
|
||||
// Only valid for non-sequential print:
|
||||
// Assign a pointer to a custom G-code to the respective ToolOrdering::LayerTools.
|
||||
|
|
@ -207,7 +209,7 @@ private:
|
|||
unsigned int m_last_printing_extruder = (unsigned int)-1;
|
||||
// All extruders, which extrude some material over m_layer_tools.
|
||||
std::vector<unsigned int> m_all_printing_extruders;
|
||||
|
||||
std::unordered_map<uint32_t, std::vector<uint8_t>> m_tool_order_cache;
|
||||
const PrintConfig* m_print_config_ptr = nullptr;
|
||||
const PrintObject* m_print_object_ptr = nullptr;
|
||||
bool m_is_BBL_printer = false;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public:
|
|||
const std::string_view comment() const
|
||||
{ size_t pos = m_raw.find(';'); return (pos == std::string::npos) ? std::string_view() : std::string_view(m_raw).substr(pos + 1); }
|
||||
|
||||
void clear() { m_raw.clear(); }
|
||||
bool has(Axis axis) const { return (m_mask & (1 << int(axis))) != 0; }
|
||||
float value(Axis axis) const { return m_axis[axis]; }
|
||||
bool has(char axis) const;
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ MedialAxis::MedialAxis(double min_width, double max_width, const ExPolygon &expo
|
|||
|
||||
void MedialAxis::build(ThickPolylines* polylines)
|
||||
{
|
||||
construct_voronoi(m_lines.begin(), m_lines.end(), &m_vd);
|
||||
m_vd.construct_voronoi(m_lines.begin(), m_lines.end());
|
||||
Slic3r::Voronoi::annotate_inside_outside(m_vd, m_lines);
|
||||
// static constexpr double threshold_alpha = M_PI / 12.; // 30 degrees
|
||||
// std::vector<Vec2d> skeleton_edges = Slic3r::Voronoi::skeleton_edges_rough(vd, lines, threshold_alpha);
|
||||
|
|
|
|||
354
src/libslic3r/Geometry/Voronoi.cpp
Normal file
354
src/libslic3r/Geometry/Voronoi.cpp
Normal file
|
|
@ -0,0 +1,354 @@
|
|||
#include "Voronoi.hpp"
|
||||
|
||||
#include "libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp"
|
||||
#include "libslic3r/Geometry/VoronoiUtils.hpp"
|
||||
#include "libslic3r/Geometry/VoronoiUtilsCgal.hpp"
|
||||
#include "libslic3r/MultiMaterialSegmentation.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
namespace Slic3r::Geometry {
|
||||
|
||||
using PolygonsSegmentIndexConstIt = std::vector<Arachne::PolygonsSegmentIndex>::const_iterator;
|
||||
using LinesIt = Lines::iterator;
|
||||
using ColoredLinesConstIt = ColoredLines::const_iterator;
|
||||
|
||||
// Explicit template instantiation.
|
||||
template void VoronoiDiagram::construct_voronoi(LinesIt, LinesIt, bool);
|
||||
template void VoronoiDiagram::construct_voronoi(ColoredLinesConstIt, ColoredLinesConstIt, bool);
|
||||
template void VoronoiDiagram::construct_voronoi(PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt, bool);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
void>::type
|
||||
VoronoiDiagram::construct_voronoi(const SegmentIterator segment_begin, const SegmentIterator segment_end, const bool try_to_repair_if_needed) {
|
||||
boost::polygon::construct_voronoi(segment_begin, segment_end, &m_voronoi_diagram);
|
||||
if (try_to_repair_if_needed) {
|
||||
if (m_issue_type = detect_known_issues(*this, segment_begin, segment_end); m_issue_type != IssueType::NO_ISSUE_DETECTED) {
|
||||
if (m_issue_type == IssueType::MISSING_VORONOI_VERTEX) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected missing Voronoi vertex, input polygons will be rotated back and forth.";
|
||||
} else if (m_issue_type == IssueType::NON_PLANAR_VORONOI_DIAGRAM) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected non-planar Voronoi diagram, input polygons will be rotated back and forth.";
|
||||
} else if (m_issue_type == IssueType::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected Voronoi edge intersecting input segment, input polygons will be rotated back and forth.";
|
||||
} else if (m_issue_type == IssueType::FINITE_EDGE_WITH_NON_FINITE_VERTEX) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected finite Voronoi vertex with non finite vertex, input polygons will be rotated back and forth.";
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected unknown Voronoi diagram issue, input polygons will be rotated back and forth.";
|
||||
}
|
||||
|
||||
if (m_issue_type = try_to_repair_degenerated_voronoi_diagram(segment_begin, segment_end); m_issue_type != IssueType::NO_ISSUE_DETECTED) {
|
||||
if (m_issue_type == IssueType::MISSING_VORONOI_VERTEX) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected missing Voronoi vertex even after the rotation of input.";
|
||||
} else if (m_issue_type == IssueType::NON_PLANAR_VORONOI_DIAGRAM) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected non-planar Voronoi diagram even after the rotation of input.";
|
||||
} else if (m_issue_type == IssueType::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected Voronoi edge intersecting input segment even after the rotation of input.";
|
||||
} else if (m_issue_type == IssueType::FINITE_EDGE_WITH_NON_FINITE_VERTEX) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected finite Voronoi vertex with non finite vertex even after the rotation of input.";
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected unknown Voronoi diagram issue even after the rotation of input.";
|
||||
}
|
||||
|
||||
m_state = State::REPAIR_UNSUCCESSFUL;
|
||||
} else {
|
||||
m_state = State::REPAIR_SUCCESSFUL;
|
||||
}
|
||||
} else {
|
||||
m_state = State::REPAIR_NOT_NEEDED;
|
||||
m_issue_type = IssueType::NO_ISSUE_DETECTED;
|
||||
}
|
||||
} else {
|
||||
m_state = State::UNKNOWN;
|
||||
m_issue_type = IssueType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void VoronoiDiagram::clear()
|
||||
{
|
||||
if (m_is_modified) {
|
||||
m_vertices.clear();
|
||||
m_edges.clear();
|
||||
m_cells.clear();
|
||||
m_is_modified = false;
|
||||
} else {
|
||||
m_voronoi_diagram.clear();
|
||||
}
|
||||
|
||||
m_state = State::UNKNOWN;
|
||||
m_issue_type = IssueType::UNKNOWN;
|
||||
}
|
||||
|
||||
void VoronoiDiagram::copy_to_local(voronoi_diagram_type &voronoi_diagram) {
|
||||
m_edges.clear();
|
||||
m_cells.clear();
|
||||
m_vertices.clear();
|
||||
|
||||
// Copy Voronoi edges.
|
||||
m_edges.reserve(voronoi_diagram.num_edges());
|
||||
for (const edge_type &edge : voronoi_diagram.edges()) {
|
||||
m_edges.emplace_back(edge.is_linear(), edge.is_primary());
|
||||
m_edges.back().color(edge.color());
|
||||
}
|
||||
|
||||
// Copy Voronoi cells.
|
||||
m_cells.reserve(voronoi_diagram.num_cells());
|
||||
for (const cell_type &cell : voronoi_diagram.cells()) {
|
||||
m_cells.emplace_back(cell.source_index(), cell.source_category());
|
||||
m_cells.back().color(cell.color());
|
||||
|
||||
if (cell.incident_edge()) {
|
||||
size_t incident_edge_idx = cell.incident_edge() - voronoi_diagram.edges().data();
|
||||
m_cells.back().incident_edge(&m_edges[incident_edge_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy Voronoi vertices.
|
||||
m_vertices.reserve(voronoi_diagram.num_vertices());
|
||||
for (const vertex_type &vertex : voronoi_diagram.vertices()) {
|
||||
m_vertices.emplace_back(vertex.x(), vertex.y());
|
||||
m_vertices.back().color(vertex.color());
|
||||
|
||||
if (vertex.incident_edge()) {
|
||||
size_t incident_edge_idx = vertex.incident_edge() - voronoi_diagram.edges().data();
|
||||
m_vertices.back().incident_edge(&m_edges[incident_edge_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
// Assign all pointers for each Voronoi edge.
|
||||
for (const edge_type &old_edge : voronoi_diagram.edges()) {
|
||||
size_t edge_idx = &old_edge - voronoi_diagram.edges().data();
|
||||
edge_type &new_edge = m_edges[edge_idx];
|
||||
|
||||
if (old_edge.cell()) {
|
||||
size_t cell_idx = old_edge.cell() - voronoi_diagram.cells().data();
|
||||
new_edge.cell(&m_cells[cell_idx]);
|
||||
}
|
||||
|
||||
if (old_edge.vertex0()) {
|
||||
size_t vertex0_idx = old_edge.vertex0() - voronoi_diagram.vertices().data();
|
||||
new_edge.vertex0(&m_vertices[vertex0_idx]);
|
||||
}
|
||||
|
||||
if (old_edge.twin()) {
|
||||
size_t twin_edge_idx = old_edge.twin() - voronoi_diagram.edges().data();
|
||||
new_edge.twin(&m_edges[twin_edge_idx]);
|
||||
}
|
||||
|
||||
if (old_edge.next()) {
|
||||
size_t next_edge_idx = old_edge.next() - voronoi_diagram.edges().data();
|
||||
new_edge.next(&m_edges[next_edge_idx]);
|
||||
}
|
||||
|
||||
if (old_edge.prev()) {
|
||||
size_t prev_edge_idx = old_edge.prev() - voronoi_diagram.edges().data();
|
||||
new_edge.prev(&m_edges[prev_edge_idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
VoronoiDiagram::detect_known_issues(const VoronoiDiagram &voronoi_diagram, SegmentIterator segment_begin, SegmentIterator segment_end)
|
||||
{
|
||||
if (has_finite_edge_with_non_finite_vertex(voronoi_diagram)) {
|
||||
return IssueType::FINITE_EDGE_WITH_NON_FINITE_VERTEX;
|
||||
} else if (const IssueType cell_issue_type = detect_known_voronoi_cell_issues(voronoi_diagram, segment_begin, segment_end); cell_issue_type != IssueType::NO_ISSUE_DETECTED) {
|
||||
return cell_issue_type;
|
||||
} else if (!VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram, segment_begin, segment_end)) {
|
||||
// Detection of non-planar Voronoi diagram detects at least GH issues #8474, #8514 and #8446.
|
||||
return IssueType::NON_PLANAR_VORONOI_DIAGRAM;
|
||||
}
|
||||
|
||||
return IssueType::NO_ISSUE_DETECTED;
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
VoronoiDiagram::detect_known_voronoi_cell_issues(const VoronoiDiagram &voronoi_diagram,
|
||||
const SegmentIterator segment_begin,
|
||||
const SegmentIterator segment_end)
|
||||
{
|
||||
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
using Point = typename boost::polygon::segment_point_type<Segment>::type;
|
||||
using SegmentCellRange = SegmentCellRange<Point>;
|
||||
|
||||
for (VD::cell_type cell : voronoi_diagram.cells()) {
|
||||
if (cell.is_degenerate() || !cell.contains_segment())
|
||||
continue; // Skip degenerated cell that has no spoon. Also, skip a cell that doesn't contain a segment.
|
||||
|
||||
if (const SegmentCellRange cell_range = VoronoiUtils::compute_segment_cell_range(cell, segment_begin, segment_end); cell_range.is_valid()) {
|
||||
// Detection if Voronoi edge is intersecting input segment.
|
||||
// It detects this type of issue at least in GH issues #8446, #8474 and #8514.
|
||||
|
||||
const Segment &source_segment = Geometry::VoronoiUtils::get_source_segment(cell, segment_begin, segment_end);
|
||||
const Vec2d source_segment_from = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::LOW).template cast<double>();
|
||||
const Vec2d source_segment_to = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::HIGH).template cast<double>();
|
||||
const Vec2d source_segment_vec = source_segment_to - source_segment_from;
|
||||
|
||||
// All Voronoi vertices must be on the left side of the source segment, otherwise the Voronoi diagram is invalid.
|
||||
for (const VD::edge_type *edge = cell_range.edge_begin; edge != cell_range.edge_end; edge = edge->next()) {
|
||||
if (edge->is_infinite()) {
|
||||
// When there is a missing Voronoi vertex, we may encounter an infinite Voronoi edge.
|
||||
// This happens, for example, in GH issue #8846.
|
||||
return IssueType::MISSING_VORONOI_VERTEX;
|
||||
} else if (const Vec2d edge_v1(edge->vertex1()->x(), edge->vertex1()->y()); Slic3r::cross2(source_segment_vec, edge_v1 - source_segment_from) < 0) {
|
||||
return IssueType::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// When there is a missing Voronoi vertex (especially at one of the endpoints of the input segment),
|
||||
// the returned cell_range is marked as invalid.
|
||||
// It detects this type of issue at least in GH issue #8846.
|
||||
return IssueType::MISSING_VORONOI_VERTEX;
|
||||
}
|
||||
}
|
||||
|
||||
return IssueType::NO_ISSUE_DETECTED;
|
||||
}
|
||||
|
||||
bool VoronoiDiagram::has_finite_edge_with_non_finite_vertex(const VoronoiDiagram &voronoi_diagram)
|
||||
{
|
||||
for (const voronoi_diagram_type::edge_type &edge : voronoi_diagram.edges()) {
|
||||
if (edge.is_finite()) {
|
||||
assert(edge.vertex0() != nullptr && edge.vertex1() != nullptr);
|
||||
if (edge.vertex0() == nullptr || edge.vertex1() == nullptr || !VoronoiUtils::is_finite(*edge.vertex0()) || !VoronoiUtils::is_finite(*edge.vertex1()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
VoronoiDiagram::try_to_repair_degenerated_voronoi_diagram(const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
IssueType issue_type = m_issue_type;
|
||||
|
||||
const std::vector<double> fix_angles = {PI / 6, PI / 5, PI / 7, PI / 11};
|
||||
for (const double fix_angle : fix_angles) {
|
||||
issue_type = try_to_repair_degenerated_voronoi_diagram_by_rotation(segment_begin, segment_end, fix_angle);
|
||||
if (issue_type == IssueType::NO_ISSUE_DETECTED) {
|
||||
return issue_type;
|
||||
}
|
||||
}
|
||||
|
||||
return issue_type;
|
||||
}
|
||||
|
||||
inline VD::vertex_type::color_type encode_input_segment_endpoint(const VD::cell_type::source_index_type cell_source_index, const boost::polygon::direction_1d dir)
|
||||
{
|
||||
return (cell_source_index + 1) << 1 | (dir.to_int() ? 1 : 0);
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
inline typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type
|
||||
decode_input_segment_endpoint(const VD::vertex_type::color_type color, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
using SegmentType = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
using PointType = typename boost::polygon::segment_traits<SegmentType>::point_type;
|
||||
|
||||
const size_t segment_idx = (color >> 1) - 1;
|
||||
const SegmentIterator segment_it = segment_begin + segment_idx;
|
||||
const PointType source_point = boost::polygon::segment_traits<SegmentType>::get(*segment_it, ((color & 1) ? boost::polygon::HIGH :
|
||||
boost::polygon::LOW));
|
||||
return source_point;
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
VoronoiDiagram::try_to_repair_degenerated_voronoi_diagram_by_rotation(const SegmentIterator segment_begin,
|
||||
const SegmentIterator segment_end,
|
||||
const double fix_angle)
|
||||
{
|
||||
using SegmentType = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
using PointType = typename boost::polygon::segment_traits<SegmentType>::point_type;
|
||||
|
||||
// Copy all segments and rotate their vertices.
|
||||
std::vector<VoronoiDiagram::Segment> segments_rotated;
|
||||
segments_rotated.reserve(std::distance(segment_begin, segment_end));
|
||||
for (auto segment_it = segment_begin; segment_it != segment_end; ++segment_it) {
|
||||
PointType from = boost::polygon::segment_traits<SegmentType>::get(*segment_it, boost::polygon::LOW);
|
||||
PointType to = boost::polygon::segment_traits<SegmentType>::get(*segment_it, boost::polygon::HIGH);
|
||||
segments_rotated.emplace_back(from.rotated(fix_angle), to.rotated(fix_angle));
|
||||
}
|
||||
|
||||
VoronoiDiagram::voronoi_diagram_type voronoi_diagram_rotated;
|
||||
boost::polygon::construct_voronoi(segments_rotated.begin(), segments_rotated.end(), &voronoi_diagram_rotated);
|
||||
|
||||
this->copy_to_local(voronoi_diagram_rotated);
|
||||
const IssueType issue_type = detect_known_issues(*this, segments_rotated.begin(), segments_rotated.end());
|
||||
|
||||
// We want to remap all Voronoi vertices at the endpoints of input segments
|
||||
// to ensure that Voronoi vertices at endpoints will be preserved after rotation.
|
||||
// So we assign every Voronoi vertices color to map this Vertex into input segments.
|
||||
for (cell_type cell : m_cells) {
|
||||
if (cell.is_degenerate())
|
||||
continue;
|
||||
|
||||
if (cell.contains_segment()) {
|
||||
if (const SegmentCellRange cell_range = VoronoiUtils::compute_segment_cell_range(cell, segments_rotated.begin(), segments_rotated.end()); cell_range.is_valid()) {
|
||||
if (cell_range.edge_end->vertex1()->color() == 0) {
|
||||
// Vertex 1 of edge_end points to the starting endpoint of the input segment (from() or line.a).
|
||||
VD::vertex_type::color_type color = encode_input_segment_endpoint(cell.source_index(), boost::polygon::LOW);
|
||||
cell_range.edge_end->vertex1()->color(color);
|
||||
}
|
||||
|
||||
if (cell_range.edge_begin->vertex0()->color() == 0) {
|
||||
// Vertex 0 of edge_end points to the ending endpoint of the input segment (to() or line.b).
|
||||
VD::vertex_type::color_type color = encode_input_segment_endpoint(cell.source_index(), boost::polygon::HIGH);
|
||||
cell_range.edge_begin->vertex0()->color(color);
|
||||
}
|
||||
} else {
|
||||
// This could happen when there is a missing Voronoi vertex even after rotation.
|
||||
assert(cell_range.is_valid());
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME @hejllukas: Implement mapping also for source points and not just for source segments.
|
||||
}
|
||||
|
||||
// Rotate all Voronoi vertices back.
|
||||
// When a Voronoi vertex can be mapped to the input segment endpoint, then we don't need to do rotation back.
|
||||
for (vertex_type &vertex : m_vertices) {
|
||||
if (vertex.color() == 0) {
|
||||
// This vertex isn't mapped to any vertex, so we rotate it back.
|
||||
vertex = VoronoiUtils::make_rotated_vertex(vertex, -fix_angle);
|
||||
} else {
|
||||
// This vertex can be mapped to the input segment endpoint.
|
||||
PointType endpoint = decode_input_segment_endpoint(vertex.color(), segment_begin, segment_end);
|
||||
vertex_type endpoint_vertex{double(endpoint.x()), double(endpoint.y())};
|
||||
endpoint_vertex.incident_edge(vertex.incident_edge());
|
||||
endpoint_vertex.color(vertex.color());
|
||||
vertex = endpoint_vertex;
|
||||
}
|
||||
}
|
||||
|
||||
// We have to clear all marked vertices because some algorithms expect that all vertices have a color equal to 0.
|
||||
for (vertex_type &vertex : m_vertices)
|
||||
vertex.color(0);
|
||||
|
||||
m_voronoi_diagram.clear();
|
||||
m_is_modified = true;
|
||||
|
||||
return issue_type;
|
||||
}
|
||||
|
||||
} // namespace Slic3r::Geometry
|
||||
|
|
@ -4,10 +4,8 @@
|
|||
#include "../Line.hpp"
|
||||
#include "../Polyline.hpp"
|
||||
|
||||
#define BOOST_VORONOI_USE_GMP 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Suppress warning C4146 in OpenVDB: unary minus operator applied to unsigned type, result still unsigned
|
||||
// Suppress warning C4146 in OpenVDB: unary minus operator applied to unsigned type, result still unsigned
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4146)
|
||||
#endif // _MSC_VER
|
||||
|
|
@ -16,18 +14,182 @@
|
|||
#pragma warning(pop)
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace Slic3r {
|
||||
namespace Slic3r::Geometry {
|
||||
|
||||
namespace Geometry {
|
||||
|
||||
class VoronoiDiagram : public boost::polygon::voronoi_diagram<double> {
|
||||
class VoronoiDiagram
|
||||
{
|
||||
public:
|
||||
typedef double coord_type;
|
||||
typedef boost::polygon::point_data<coordinate_type> point_type;
|
||||
typedef boost::polygon::segment_data<coordinate_type> segment_type;
|
||||
typedef boost::polygon::rectangle_data<coordinate_type> rect_type;
|
||||
using coord_type = double;
|
||||
using voronoi_diagram_type = boost::polygon::voronoi_diagram<coord_type>;
|
||||
using point_type = boost::polygon::point_data<voronoi_diagram_type::coordinate_type>;
|
||||
using segment_type = boost::polygon::segment_data<voronoi_diagram_type::coordinate_type>;
|
||||
using rect_type = boost::polygon::rectangle_data<voronoi_diagram_type::coordinate_type>;
|
||||
|
||||
using coordinate_type = voronoi_diagram_type::coordinate_type;
|
||||
using vertex_type = voronoi_diagram_type::vertex_type;
|
||||
using edge_type = voronoi_diagram_type::edge_type;
|
||||
using cell_type = voronoi_diagram_type::cell_type;
|
||||
|
||||
using const_vertex_iterator = voronoi_diagram_type::const_vertex_iterator;
|
||||
using const_edge_iterator = voronoi_diagram_type::const_edge_iterator;
|
||||
using const_cell_iterator = voronoi_diagram_type::const_cell_iterator;
|
||||
|
||||
using vertex_container_type = voronoi_diagram_type::vertex_container_type;
|
||||
using edge_container_type = voronoi_diagram_type::edge_container_type;
|
||||
using cell_container_type = voronoi_diagram_type::cell_container_type;
|
||||
|
||||
enum class IssueType {
|
||||
NO_ISSUE_DETECTED,
|
||||
FINITE_EDGE_WITH_NON_FINITE_VERTEX,
|
||||
MISSING_VORONOI_VERTEX,
|
||||
NON_PLANAR_VORONOI_DIAGRAM,
|
||||
VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT,
|
||||
UNKNOWN // Repairs are disabled in the constructor.
|
||||
};
|
||||
|
||||
enum class State {
|
||||
REPAIR_NOT_NEEDED, // The original Voronoi diagram doesn't have any issue.
|
||||
REPAIR_SUCCESSFUL, // The original Voronoi diagram has some issues, but it was repaired.
|
||||
REPAIR_UNSUCCESSFUL, // The original Voronoi diagram has some issues, but it wasn't repaired.
|
||||
UNKNOWN // Repairs are disabled in the constructor.
|
||||
};
|
||||
|
||||
VoronoiDiagram() = default;
|
||||
|
||||
virtual ~VoronoiDiagram() = default;
|
||||
|
||||
IssueType get_issue_type() const { return m_issue_type; }
|
||||
|
||||
State get_state() const { return m_state; }
|
||||
|
||||
bool is_valid() const { return m_state != State::REPAIR_UNSUCCESSFUL; }
|
||||
|
||||
void clear();
|
||||
|
||||
const vertex_container_type &vertices() const { return m_is_modified ? m_vertices : m_voronoi_diagram.vertices(); }
|
||||
|
||||
const edge_container_type &edges() const { return m_is_modified ? m_edges : m_voronoi_diagram.edges(); }
|
||||
|
||||
const cell_container_type &cells() const { return m_is_modified ? m_cells : m_voronoi_diagram.cells(); }
|
||||
|
||||
std::size_t num_vertices() const { return m_is_modified ? m_vertices.size() : m_voronoi_diagram.num_vertices(); }
|
||||
|
||||
std::size_t num_edges() const { return m_is_modified ? m_edges.size() : m_voronoi_diagram.num_edges(); }
|
||||
|
||||
std::size_t num_cells() const { return m_is_modified ? m_cells.size() : m_voronoi_diagram.num_cells(); }
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
void>::type
|
||||
construct_voronoi(SegmentIterator segment_begin, SegmentIterator segment_end, bool try_to_repair_if_needed = true);
|
||||
|
||||
template<typename PointIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_point_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<PointIterator>::value_type>::type>::type>::type,
|
||||
void>::type
|
||||
construct_voronoi(const PointIterator first, const PointIterator last)
|
||||
{
|
||||
boost::polygon::construct_voronoi(first, last, &m_voronoi_diagram);
|
||||
m_state = State::UNKNOWN;
|
||||
m_issue_type = IssueType::UNKNOWN;
|
||||
}
|
||||
|
||||
template<typename PointIterator, typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_and<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_point_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<PointIterator>::value_type>::type>::type>::type,
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<typename boost::polygon::geometry_concept<
|
||||
typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type>::type,
|
||||
void>::type
|
||||
construct_voronoi(const PointIterator p_first, const PointIterator p_last, const SegmentIterator s_first, const SegmentIterator s_last)
|
||||
{
|
||||
boost::polygon::construct_voronoi(p_first, p_last, s_first, s_last, &m_voronoi_diagram);
|
||||
m_state = State::UNKNOWN;
|
||||
m_issue_type = IssueType::UNKNOWN;
|
||||
}
|
||||
|
||||
// Try to detect cases when some Voronoi vertex is missing, when the Voronoi diagram
|
||||
// is not planar or some Voronoi edge is intersecting input segment.
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
IssueType>::type
|
||||
detect_known_issues(const VoronoiDiagram &voronoi_diagram, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
try_to_repair_degenerated_voronoi_diagram_by_rotation(SegmentIterator segment_begin, SegmentIterator segment_end, double fix_angle);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
VoronoiDiagram::IssueType>::type
|
||||
try_to_repair_degenerated_voronoi_diagram(SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
private:
|
||||
struct Segment
|
||||
{
|
||||
Point from;
|
||||
Point to;
|
||||
|
||||
Segment() = delete;
|
||||
explicit Segment(const Point &from, const Point &to) : from(from), to(to) {}
|
||||
};
|
||||
|
||||
void copy_to_local(voronoi_diagram_type &voronoi_diagram);
|
||||
|
||||
// Detect issues related to Voronoi cells, or that can be detected by iterating over Voronoi cells.
|
||||
// The first type of issue that can be detected is a missing Voronoi vertex, especially when it is
|
||||
// missing at one of the endpoints of the input segment.
|
||||
// The second type of issue that can be detected is a Voronoi edge that intersects the input segment.
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
IssueType>::type
|
||||
detect_known_voronoi_cell_issues(const VoronoiDiagram &voronoi_diagram, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
static bool has_finite_edge_with_non_finite_vertex(const VoronoiDiagram &voronoi_diagram);
|
||||
|
||||
voronoi_diagram_type m_voronoi_diagram;
|
||||
vertex_container_type m_vertices;
|
||||
edge_container_type m_edges;
|
||||
cell_container_type m_cells;
|
||||
bool m_is_modified = false;
|
||||
State m_state = State::UNKNOWN;
|
||||
IssueType m_issue_type = IssueType::UNKNOWN;
|
||||
|
||||
public:
|
||||
using SegmentIt = std::vector<Slic3r::Geometry::VoronoiDiagram::Segment>::iterator;
|
||||
|
||||
friend struct boost::polygon::segment_traits<Slic3r::Geometry::VoronoiDiagram::Segment>;
|
||||
};
|
||||
|
||||
} } // namespace Slicer::Geometry
|
||||
} // namespace Slic3r::Geometry
|
||||
|
||||
namespace boost::polygon {
|
||||
template<> struct geometry_concept<Slic3r::Geometry::VoronoiDiagram::Segment>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::Geometry::VoronoiDiagram::Segment>
|
||||
{
|
||||
using coordinate_type = coord_t;
|
||||
using point_type = Slic3r::Point;
|
||||
using segment_type = Slic3r::Geometry::VoronoiDiagram::Segment;
|
||||
|
||||
static inline point_type get(const segment_type &segment, direction_1d dir) { return dir.to_int() ? segment.to : segment.from; }
|
||||
};
|
||||
} // namespace boost::polygon
|
||||
|
||||
#endif // slic3r_Geometry_Voronoi_hpp_
|
||||
|
|
|
|||
|
|
@ -782,9 +782,6 @@ void annotate_inside_outside(VD &vd, const Lines &lines)
|
|||
|
||||
for (const VD::edge_type &edge : vd.edges())
|
||||
if (edge.vertex1() == nullptr) {
|
||||
if (edge.vertex0() == nullptr)
|
||||
continue;
|
||||
|
||||
// Infinite Voronoi edge separating two Point sites or a Point site and a Segment site.
|
||||
// Infinite edge is always outside and it references at least one valid vertex.
|
||||
assert(edge.is_infinite());
|
||||
|
|
@ -891,9 +888,6 @@ void annotate_inside_outside(VD &vd, const Lines &lines)
|
|||
for (const VD::edge_type &edge : vd.edges()) {
|
||||
assert((edge_category(edge) == EdgeCategory::Unknown) == (edge_category(edge.twin()) == EdgeCategory::Unknown));
|
||||
if (edge_category(edge) == EdgeCategory::Unknown) {
|
||||
if (!edge.is_finite())
|
||||
continue;
|
||||
|
||||
assert(edge.is_finite());
|
||||
const VD::cell_type &cell = *edge.cell();
|
||||
const VD::cell_type &cell2 = *edge.twin()->cell();
|
||||
|
|
|
|||
283
src/libslic3r/Geometry/VoronoiUtils.cpp
Normal file
283
src/libslic3r/Geometry/VoronoiUtils.cpp
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <Arachne/utils/PolygonsSegmentIndex.hpp>
|
||||
#include <MultiMaterialSegmentation.hpp>
|
||||
|
||||
#include "VoronoiUtils.hpp"
|
||||
|
||||
namespace Slic3r::Geometry {
|
||||
|
||||
using PolygonsSegmentIndexConstIt = std::vector<Arachne::PolygonsSegmentIndex>::const_iterator;
|
||||
using LinesIt = Lines::iterator;
|
||||
using ColoredLinesIt = ColoredLines::iterator;
|
||||
using ColoredLinesConstIt = ColoredLines::const_iterator;
|
||||
|
||||
// Explicit template instantiation.
|
||||
template LinesIt::reference VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &, LinesIt, LinesIt);
|
||||
template VD::SegmentIt::reference VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
||||
template ColoredLinesIt::reference VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
||||
template ColoredLinesConstIt::reference VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &, ColoredLinesConstIt, ColoredLinesConstIt);
|
||||
template PolygonsSegmentIndexConstIt::reference VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, LinesIt, LinesIt);
|
||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, ColoredLinesIt, ColoredLinesIt);
|
||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, ColoredLinesConstIt, ColoredLinesConstIt);
|
||||
template Point VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, LinesIt, LinesIt);
|
||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, VD::SegmentIt, VD::SegmentIt);
|
||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, ColoredLinesConstIt, ColoredLinesConstIt);
|
||||
template SegmentCellRange<Point> VoronoiUtils::compute_segment_cell_range(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||
template Points VoronoiUtils::discretize_parabola(const Point &, const Arachne::PolygonsSegmentIndex &, const Point &, const Point &, coord_t, float);
|
||||
template Arachne::PolygonsPointIndex VoronoiUtils::get_source_point_index(const VoronoiDiagram::cell_type &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
typename std::iterator_traits<SegmentIterator>::reference>::type
|
||||
VoronoiUtils::get_source_segment(const VoronoiDiagram::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
if (!cell.contains_segment())
|
||||
throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source segment!");
|
||||
|
||||
if (cell.source_index() >= size_t(std::distance(segment_begin, segment_end)))
|
||||
throw Slic3r::OutOfRange("Voronoi cell source index is out of range!");
|
||||
|
||||
return *(segment_begin + cell.source_index());
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type
|
||||
VoronoiUtils::get_source_point(const VoronoiDiagram::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
|
||||
if (!cell.contains_point())
|
||||
throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source point!");
|
||||
|
||||
if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) {
|
||||
assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
|
||||
const SegmentIterator segment_it = segment_begin + cell.source_index();
|
||||
return boost::polygon::segment_traits<Segment>::get(*segment_it, boost::polygon::LOW);
|
||||
} else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT) {
|
||||
assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
|
||||
const SegmentIterator segment_it = segment_begin + cell.source_index();
|
||||
return boost::polygon::segment_traits<Segment>::get(*segment_it, boost::polygon::HIGH);
|
||||
} else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT) {
|
||||
throw Slic3r::RuntimeError("Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!");
|
||||
} else {
|
||||
throw Slic3r::InvalidArgument("Function get_source_point() should only be called on point cells!");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
Arachne::PolygonsPointIndex>::type
|
||||
VoronoiUtils::get_source_point_index(const VD::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
if (!cell.contains_point())
|
||||
throw Slic3r::InvalidArgument("Voronoi cell doesn't contain a source point!");
|
||||
|
||||
if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) {
|
||||
assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
|
||||
const SegmentIterator segment_it = segment_begin + cell.source_index();
|
||||
return (*segment_it);
|
||||
} else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT) {
|
||||
assert(int(cell.source_index()) < std::distance(segment_begin, segment_end));
|
||||
const SegmentIterator segment_it = segment_begin + cell.source_index();
|
||||
return (*segment_it).next();
|
||||
} else if (cell.source_category() == boost::polygon::SOURCE_CATEGORY_SINGLE_POINT) {
|
||||
throw Slic3r::RuntimeError("Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!");
|
||||
} else {
|
||||
throw Slic3r::InvalidArgument("Function get_source_point_index() should only be called on point cells!");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Segment>
|
||||
typename boost::polygon::enable_if<typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<Segment>::type>::type>::type,
|
||||
Points>::type
|
||||
VoronoiUtils::discretize_parabola(const Point &source_point, const Segment &source_segment, const Point &start, const Point &end, const coord_t approximate_step_size, float transitioning_angle)
|
||||
{
|
||||
Points discretized;
|
||||
// x is distance of point projected on the segment ab
|
||||
// xx is point projected on the segment ab
|
||||
const Point a = source_segment.from();
|
||||
const Point b = source_segment.to();
|
||||
const Point ab = b - a;
|
||||
const Point as = start - a;
|
||||
const Point ae = end - a;
|
||||
const coord_t ab_size = ab.cast<int64_t>().norm();
|
||||
const coord_t sx = as.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t ex = ae.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t sxex = ex - sx;
|
||||
|
||||
const Point ap = source_point - a;
|
||||
const coord_t px = ap.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
|
||||
Point pxx;
|
||||
Line(a, b).distance_to_infinite_squared(source_point, &pxx);
|
||||
const Point ppxx = pxx - source_point;
|
||||
const coord_t d = ppxx.cast<int64_t>().norm();
|
||||
|
||||
const Vec2d rot = perp(ppxx).cast<double>().normalized();
|
||||
const double rot_cos_theta = rot.x();
|
||||
const double rot_sin_theta = rot.y();
|
||||
|
||||
if (d == 0) {
|
||||
discretized.emplace_back(start);
|
||||
discretized.emplace_back(end);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
const double marking_bound = atan(transitioning_angle * 0.5);
|
||||
int64_t msx = -marking_bound * int64_t(d); // projected marking_start
|
||||
int64_t mex = marking_bound * int64_t(d); // projected marking_end
|
||||
|
||||
const coord_t marking_start_end_h = msx * msx / (2 * d) + d / 2;
|
||||
Point marking_start = Point(coord_t(msx), marking_start_end_h).rotated(rot_cos_theta, rot_sin_theta) + pxx;
|
||||
Point marking_end = Point(coord_t(mex), marking_start_end_h).rotated(rot_cos_theta, rot_sin_theta) + pxx;
|
||||
const int dir = (sx > ex) ? -1 : 1;
|
||||
if (dir < 0) {
|
||||
std::swap(marking_start, marking_end);
|
||||
std::swap(msx, mex);
|
||||
}
|
||||
|
||||
bool add_marking_start = msx * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && msx * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
bool add_marking_end = mex * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && mex * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
|
||||
const Point apex = Point(0, d / 2).rotated(rot_cos_theta, rot_sin_theta) + pxx;
|
||||
bool add_apex = int64_t(sx - px) * int64_t(dir) < 0 && int64_t(ex - px) * int64_t(dir) > 0;
|
||||
|
||||
assert(!add_marking_start || !add_marking_end || add_apex);
|
||||
if (add_marking_start && add_marking_end && !add_apex)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Failing to discretize parabola! Must add an apex or one of the endpoints.";
|
||||
|
||||
const coord_t step_count = lround(static_cast<double>(std::abs(ex - sx)) / approximate_step_size);
|
||||
discretized.emplace_back(start);
|
||||
for (coord_t step = 1; step < step_count; ++step) {
|
||||
const int64_t x = int64_t(sx) + int64_t(sxex) * int64_t(step) / int64_t(step_count) - int64_t(px);
|
||||
const int64_t y = int64_t(x) * int64_t(x) / int64_t(2 * d) + int64_t(d / 2);
|
||||
|
||||
if (add_marking_start && msx * int64_t(dir) < int64_t(x) * int64_t(dir)) {
|
||||
discretized.emplace_back(marking_start);
|
||||
add_marking_start = false;
|
||||
}
|
||||
|
||||
if (add_apex && int64_t(x) * int64_t(dir) > 0) {
|
||||
discretized.emplace_back(apex);
|
||||
add_apex = false; // only add the apex just before the
|
||||
}
|
||||
|
||||
if (add_marking_end && mex * int64_t(dir) < int64_t(x) * int64_t(dir)) {
|
||||
discretized.emplace_back(marking_end);
|
||||
add_marking_end = false;
|
||||
}
|
||||
|
||||
assert(is_in_range<coord_t>(x) && is_in_range<coord_t>(y));
|
||||
const Point result = Point(x, y).rotated(rot_cos_theta, rot_sin_theta) + pxx;
|
||||
discretized.emplace_back(result);
|
||||
}
|
||||
|
||||
if (add_apex)
|
||||
discretized.emplace_back(apex);
|
||||
|
||||
if (add_marking_end)
|
||||
discretized.emplace_back(marking_end);
|
||||
|
||||
discretized.emplace_back(end);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
Geometry::SegmentCellRange<
|
||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
||||
VoronoiUtils::compute_segment_cell_range(const VD::cell_type &cell, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
using Point = typename boost::polygon::segment_point_type<Segment>::type;
|
||||
using SegmentCellRange = SegmentCellRange<Point>;
|
||||
|
||||
const Segment &source_segment = Geometry::VoronoiUtils::get_source_segment(cell, segment_begin, segment_end);
|
||||
const Point from = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::LOW);
|
||||
const Point to = boost::polygon::segment_traits<Segment>::get(source_segment, boost::polygon::HIGH);
|
||||
const Vec2i64 from_i64 = from.template cast<int64_t>();
|
||||
const Vec2i64 to_i64 = to.template cast<int64_t>();
|
||||
|
||||
// FIXME @hejllukas: Ensure that there is no infinite edge during iteration between edge_begin and edge_end.
|
||||
SegmentCellRange cell_range(to, from);
|
||||
|
||||
// Find starting edge and end edge
|
||||
bool seen_possible_start = false;
|
||||
bool after_start = false;
|
||||
bool ending_edge_is_set_before_start = false;
|
||||
const VD::edge_type *edge = cell.incident_edge();
|
||||
do {
|
||||
if (edge->is_infinite())
|
||||
continue;
|
||||
|
||||
Vec2i64 v0 = Geometry::VoronoiUtils::to_point(edge->vertex0());
|
||||
Vec2i64 v1 = Geometry::VoronoiUtils::to_point(edge->vertex1());
|
||||
assert(v0 != to_i64 || v1 != from_i64);
|
||||
|
||||
if (v0 == to_i64 && !after_start) { // Use the last edge which starts in source_segment.to
|
||||
cell_range.edge_begin = edge;
|
||||
seen_possible_start = true;
|
||||
} else if (seen_possible_start) {
|
||||
after_start = true;
|
||||
}
|
||||
|
||||
if (v1 == from_i64 && (!cell_range.edge_end || ending_edge_is_set_before_start)) {
|
||||
ending_edge_is_set_before_start = !after_start;
|
||||
cell_range.edge_end = edge;
|
||||
}
|
||||
} while (edge = edge->next(), edge != cell.incident_edge());
|
||||
|
||||
return cell_range;
|
||||
}
|
||||
|
||||
Vec2i64 VoronoiUtils::to_point(const VD::vertex_type *vertex)
|
||||
{
|
||||
assert(vertex != nullptr);
|
||||
return VoronoiUtils::to_point(*vertex);
|
||||
}
|
||||
|
||||
Vec2i64 VoronoiUtils::to_point(const VD::vertex_type &vertex)
|
||||
{
|
||||
const double x = vertex.x(), y = vertex.y();
|
||||
|
||||
assert(std::isfinite(x) && std::isfinite(y));
|
||||
assert(is_in_range<int64_t>(x) && is_in_range<int64_t>(y));
|
||||
|
||||
return {std::llround(x), std::llround(y)};
|
||||
}
|
||||
|
||||
bool VoronoiUtils::is_finite(const VD::vertex_type &vertex)
|
||||
{
|
||||
return std::isfinite(vertex.x()) && std::isfinite(vertex.y());
|
||||
}
|
||||
|
||||
VD::vertex_type VoronoiUtils::make_rotated_vertex(VD::vertex_type &vertex, const double angle)
|
||||
{
|
||||
const double cos_a = std::cos(angle);
|
||||
const double sin_a = std::sin(angle);
|
||||
|
||||
const double rotated_x = (cos_a * vertex.x() - sin_a * vertex.y());
|
||||
const double rotated_y = (cos_a * vertex.y() + sin_a * vertex.x());
|
||||
|
||||
VD::vertex_type rotated_vertex{rotated_x, rotated_y};
|
||||
rotated_vertex.incident_edge(vertex.incident_edge());
|
||||
rotated_vertex.color(vertex.color());
|
||||
|
||||
return rotated_vertex;
|
||||
}
|
||||
|
||||
} // namespace Slic3r::Geometry
|
||||
120
src/libslic3r/Geometry/VoronoiUtils.hpp
Normal file
120
src/libslic3r/Geometry/VoronoiUtils.hpp
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
#ifndef slic3r_VoronoiUtils_hpp_
|
||||
#define slic3r_VoronoiUtils_hpp_
|
||||
|
||||
#include "libslic3r/Geometry/Voronoi.hpp"
|
||||
#include "libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp"
|
||||
|
||||
using VD = Slic3r::Geometry::VoronoiDiagram;
|
||||
|
||||
namespace Slic3r::Geometry {
|
||||
|
||||
// Represent trapezoid Voronoi cell around segment.
|
||||
template<typename PT> struct SegmentCellRange
|
||||
{
|
||||
const PT segment_start_point; // The start point of the source segment of this cell.
|
||||
const PT segment_end_point; // The end point of the source segment of this cell.
|
||||
const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts.
|
||||
const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends.
|
||||
|
||||
SegmentCellRange() = delete;
|
||||
explicit SegmentCellRange(const PT &segment_start_point, const PT &segment_end_point)
|
||||
: segment_start_point(segment_start_point), segment_end_point(segment_end_point)
|
||||
{}
|
||||
|
||||
bool is_valid() const { return edge_begin && edge_end && edge_begin != edge_end; }
|
||||
};
|
||||
|
||||
class VoronoiUtils
|
||||
{
|
||||
public:
|
||||
static Vec2i64 to_point(const VD::vertex_type *vertex);
|
||||
|
||||
static Vec2i64 to_point(const VD::vertex_type &vertex);
|
||||
|
||||
static bool is_finite(const VD::vertex_type &vertex);
|
||||
|
||||
static VD::vertex_type make_rotated_vertex(VD::vertex_type &vertex, double angle);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
typename std::iterator_traits<SegmentIterator>::reference>::type
|
||||
get_source_segment(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type
|
||||
get_source_point(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
Arachne::PolygonsPointIndex>::type
|
||||
get_source_point_index(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
/**
|
||||
* Discretize a parabola based on (approximate) step size.
|
||||
*
|
||||
* Adapted from CuraEngine VoronoiUtils::discretizeParabola by Tim Kuipers @BagelOrb and @Ghostkeeper.
|
||||
*
|
||||
* @param approximate_step_size is measured parallel to the source_segment, not along the parabola.
|
||||
*/
|
||||
template<typename Segment>
|
||||
static typename boost::polygon::enable_if<typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<Segment>::type>::type>::type,
|
||||
Points>::type
|
||||
discretize_parabola(const Point &source_point, const Segment &source_segment, const Point &start, const Point &end, coord_t approximate_step_size, float transitioning_angle);
|
||||
|
||||
/**
|
||||
* Compute the range of line segments that surround a cell of the skeletal
|
||||
* graph that belongs to a line segment of the medial axis.
|
||||
*
|
||||
* This should only be used on cells that belong to a central line segment
|
||||
* of the skeletal graph, e.g. trapezoid cells, not triangular cells.
|
||||
*
|
||||
* The resulting line segments is just the first and the last segment. They
|
||||
* are linked to the neighboring segments, so you can iterate over the
|
||||
* segments until you reach the last segment.
|
||||
*
|
||||
* Adapted from CuraEngine VoronoiUtils::computePointCellRange by Tim Kuipers @BagelOrb,
|
||||
* Jaime van Kessel @nallath, Remco Burema @rburema and @Ghostkeeper.
|
||||
*
|
||||
* @param cell The cell to compute the range of line segments for.
|
||||
* @param segment_begin Begin iterator for all edges of the input Polygons.
|
||||
* @param segment_end End iterator for all edges of the input Polygons.
|
||||
* @return Range of line segments that surround the cell.
|
||||
*/
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
Geometry::SegmentCellRange<
|
||||
typename boost::polygon::segment_point_type<typename std::iterator_traits<SegmentIterator>::value_type>::type>>::type
|
||||
compute_segment_cell_range(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
|
||||
template<typename T> static bool is_in_range(double value)
|
||||
{
|
||||
return double(std::numeric_limits<T>::lowest()) <= value && value <= double(std::numeric_limits<T>::max());
|
||||
}
|
||||
|
||||
template<typename T> static bool is_in_range(const VD::vertex_type &vertex)
|
||||
{
|
||||
return VoronoiUtils::is_finite(vertex) && is_in_range<T>(vertex.x()) && is_in_range<T>(vertex.y());
|
||||
}
|
||||
|
||||
template<typename T> static bool is_in_range(const VD::edge_type &edge)
|
||||
{
|
||||
if (edge.vertex0() == nullptr || edge.vertex1() == nullptr)
|
||||
return false;
|
||||
|
||||
return is_in_range<T>(*edge.vertex0()) && is_in_range<T>(*edge.vertex1());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Slic3r::Geometry
|
||||
|
||||
#endif // slic3r_VoronoiUtils_hpp_
|
||||
|
|
@ -4,7 +4,9 @@
|
|||
#include <CGAL/Surface_sweep_2_algorithms.h>
|
||||
|
||||
#include "libslic3r/Geometry/Voronoi.hpp"
|
||||
#include "libslic3r/Arachne/utils/VoronoiUtils.hpp"
|
||||
#include "libslic3r/Geometry/VoronoiUtils.hpp"
|
||||
#include "libslic3r/Arachne/utils/PolygonsSegmentIndex.hpp"
|
||||
#include "libslic3r/MultiMaterialSegmentation.hpp"
|
||||
|
||||
#include "VoronoiUtilsCgal.hpp"
|
||||
|
||||
|
|
@ -12,18 +14,145 @@ using VD = Slic3r::Geometry::VoronoiDiagram;
|
|||
|
||||
namespace Slic3r::Geometry {
|
||||
|
||||
using CGAL_Point = CGAL::Exact_predicates_exact_constructions_kernel::Point_2;
|
||||
using CGAL_Segment = CGAL::Arr_segment_traits_2<CGAL::Exact_predicates_exact_constructions_kernel>::Curve_2;
|
||||
using PolygonsSegmentIndexConstIt = std::vector<Arachne::PolygonsSegmentIndex>::const_iterator;
|
||||
using LinesIt = Lines::iterator;
|
||||
using ColoredLinesConstIt = ColoredLines::const_iterator;
|
||||
|
||||
inline static CGAL_Point to_cgal_point(const VD::vertex_type &pt) { return {pt.x(), pt.y()}; }
|
||||
// Explicit template instantiation.
|
||||
template bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VD &, LinesIt, LinesIt);
|
||||
template bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VD &, VD::SegmentIt, VD::SegmentIt);
|
||||
template bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VD &, ColoredLinesConstIt, ColoredLinesConstIt);
|
||||
template bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VD &, PolygonsSegmentIndexConstIt, PolygonsSegmentIndexConstIt);
|
||||
|
||||
// The tangent vector of the parabola is computed based on the Proof of the reflective property.
|
||||
// https://en.wikipedia.org/wiki/Parabola#Proof_of_the_reflective_property
|
||||
// https://math.stackexchange.com/q/2439647/2439663#comment5039739_2439663
|
||||
namespace impl {
|
||||
using K = CGAL::Simple_cartesian<double>;
|
||||
using FK = CGAL::Simple_cartesian<CGAL::Interval_nt_advanced>;
|
||||
using EK = CGAL::Simple_cartesian<CGAL::MP_Float>;
|
||||
using C2E = CGAL::Cartesian_converter<K, EK>;
|
||||
using C2F = CGAL::Cartesian_converter<K, FK>;
|
||||
class Epick : public CGAL::Filtered_kernel_adaptor<CGAL::Type_equality_wrapper<K::Base<Epick>::Type, Epick>, true> {};
|
||||
|
||||
template<typename K>
|
||||
inline typename K::Vector_2 calculate_parabolic_tangent_vector(
|
||||
// Test point on the parabola, where the tangent will be calculated.
|
||||
const typename K::Point_2 &p,
|
||||
// Focus point of the parabola.
|
||||
const typename K::Point_2 &f,
|
||||
// Points of a directrix of the parabola.
|
||||
const typename K::Point_2 &u,
|
||||
const typename K::Point_2 &v,
|
||||
// On which side of the parabolic segment endpoints the focus point is, which determines the orientation of the tangent.
|
||||
const typename K::Orientation &tangent_orientation)
|
||||
{
|
||||
using RT = typename K::RT;
|
||||
using Vector_2 = typename K::Vector_2;
|
||||
|
||||
const Vector_2 directrix_vec = v - u;
|
||||
const RT directrix_vec_sqr_length = CGAL::scalar_product(directrix_vec, directrix_vec);
|
||||
Vector_2 focus_vec = (f - u) * directrix_vec_sqr_length - directrix_vec * CGAL::scalar_product(directrix_vec, p - u);
|
||||
Vector_2 tangent_vec = focus_vec.perpendicular(tangent_orientation);
|
||||
return tangent_vec;
|
||||
}
|
||||
|
||||
template<typename K> struct ParabolicTangentToSegmentOrientationPredicate
|
||||
{
|
||||
using Point_2 = typename K::Point_2;
|
||||
using Vector_2 = typename K::Vector_2;
|
||||
using Orientation = typename K::Orientation;
|
||||
using result_type = typename K::Orientation;
|
||||
|
||||
result_type operator()(
|
||||
// Test point on the parabola, where the tangent will be calculated.
|
||||
const Point_2 &p,
|
||||
// End of the linear segment (p, q), for which orientation towards the tangent to parabola will be evaluated.
|
||||
const Point_2 &q,
|
||||
// Focus point of the parabola.
|
||||
const Point_2 &f,
|
||||
// Points of a directrix of the parabola.
|
||||
const Point_2 &u,
|
||||
const Point_2 &v,
|
||||
// On which side of the parabolic segment endpoints the focus point is, which determines the orientation of the tangent.
|
||||
const Orientation &tangent_orientation) const
|
||||
{
|
||||
assert(tangent_orientation == CGAL::Orientation::LEFT_TURN || tangent_orientation == CGAL::Orientation::RIGHT_TURN);
|
||||
|
||||
Vector_2 tangent_vec = calculate_parabolic_tangent_vector<K>(p, f, u, v, tangent_orientation);
|
||||
Vector_2 linear_vec = q - p;
|
||||
|
||||
return CGAL::sign(tangent_vec.x() * linear_vec.y() - tangent_vec.y() * linear_vec.x());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename K> struct ParabolicTangentToParabolicTangentOrientationPredicate
|
||||
{
|
||||
using Point_2 = typename K::Point_2;
|
||||
using Vector_2 = typename K::Vector_2;
|
||||
using Orientation = typename K::Orientation;
|
||||
using result_type = typename K::Orientation;
|
||||
|
||||
result_type operator()(
|
||||
// Common point on both parabolas, where the tangent will be calculated.
|
||||
const Point_2 &p,
|
||||
// Focus point of the first parabola.
|
||||
const Point_2 &f_0,
|
||||
// Points of a directrix of the first parabola.
|
||||
const Point_2 &u_0,
|
||||
const Point_2 &v_0,
|
||||
// On which side of the parabolic segment endpoints the focus point is, which determines the orientation of the tangent.
|
||||
const Orientation &tangent_orientation_0,
|
||||
// Focus point of the second parabola.
|
||||
const Point_2 &f_1,
|
||||
// Points of a directrix of the second parabola.
|
||||
const Point_2 &u_1,
|
||||
const Point_2 &v_1,
|
||||
// On which side of the parabolic segment endpoints the focus point is, which determines the orientation of the tangent.
|
||||
const Orientation &tangent_orientation_1) const
|
||||
{
|
||||
assert(tangent_orientation_0 == CGAL::Orientation::LEFT_TURN || tangent_orientation_0 == CGAL::Orientation::RIGHT_TURN);
|
||||
assert(tangent_orientation_1 == CGAL::Orientation::LEFT_TURN || tangent_orientation_1 == CGAL::Orientation::RIGHT_TURN);
|
||||
|
||||
Vector_2 tangent_vec_0 = calculate_parabolic_tangent_vector<K>(p, f_0, u_0, v_0, tangent_orientation_0);
|
||||
Vector_2 tangent_vec_1 = calculate_parabolic_tangent_vector<K>(p, f_1, u_1, v_1, tangent_orientation_1);
|
||||
|
||||
return CGAL::sign(tangent_vec_0.x() * tangent_vec_1.y() - tangent_vec_0.y() * tangent_vec_1.x());
|
||||
}
|
||||
};
|
||||
|
||||
using ParabolicTangentToSegmentOrientationPredicateFiltered = CGAL::Filtered_predicate<ParabolicTangentToSegmentOrientationPredicate<EK>, ParabolicTangentToSegmentOrientationPredicate<FK>, C2E, C2F>;
|
||||
using ParabolicTangentToParabolicTangentOrientationPredicateFiltered = CGAL::Filtered_predicate<ParabolicTangentToParabolicTangentOrientationPredicate<EK>, ParabolicTangentToParabolicTangentOrientationPredicate<FK>, C2E, C2F>;
|
||||
} // namespace impl
|
||||
|
||||
using ParabolicTangentToSegmentOrientation = impl::ParabolicTangentToSegmentOrientationPredicateFiltered;
|
||||
using ParabolicTangentToParabolicTangentOrientation = impl::ParabolicTangentToParabolicTangentOrientationPredicateFiltered;
|
||||
using CGAL_Point = impl::K::Point_2;
|
||||
|
||||
inline CGAL_Point to_cgal_point(const VD::vertex_type *pt) { return {pt->x(), pt->y()}; }
|
||||
inline CGAL_Point to_cgal_point(const Point &pt) { return {pt.x(), pt.y()}; }
|
||||
inline CGAL_Point to_cgal_point(const Vec2d &pt) { return {pt.x(), pt.y()}; }
|
||||
|
||||
inline Linef make_linef(const VD::edge_type &edge)
|
||||
{
|
||||
const VD::vertex_type *v0 = edge.vertex0();
|
||||
const VD::vertex_type *v1 = edge.vertex1();
|
||||
return {Vec2d(v0->x(), v0->y()), Vec2d(v1->x(), v1->y())};
|
||||
}
|
||||
|
||||
[[maybe_unused]] inline bool is_equal(const VD::vertex_type &vertex_first, const VD::vertex_type &vertex_second) { return vertex_first.x() == vertex_second.x() && vertex_first.y() == vertex_second.y(); }
|
||||
|
||||
// FIXME Lukas H.: Also includes parabolic segments.
|
||||
bool VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(const VD &voronoi_diagram)
|
||||
{
|
||||
using CGAL_E_Point = CGAL::Exact_predicates_exact_constructions_kernel::Point_2;
|
||||
using CGAL_E_Segment = CGAL::Arr_segment_traits_2<CGAL::Exact_predicates_exact_constructions_kernel>::Curve_2;
|
||||
auto to_cgal_point = [](const VD::vertex_type &pt) -> CGAL_E_Point { return {pt.x(), pt.y()}; };
|
||||
|
||||
assert(std::all_of(voronoi_diagram.edges().cbegin(), voronoi_diagram.edges().cend(),
|
||||
[](const VD::edge_type &edge) { return edge.color() == 0; }));
|
||||
|
||||
std::vector<CGAL_Segment> segments;
|
||||
std::vector<CGAL_E_Segment> segments;
|
||||
segments.reserve(voronoi_diagram.num_edges());
|
||||
|
||||
for (const VD::edge_type &edge : voronoi_diagram.edges()) {
|
||||
|
|
@ -31,7 +160,7 @@ bool VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(const VD &voronoi_
|
|||
continue;
|
||||
|
||||
if (edge.is_finite() && edge.is_linear() && edge.vertex0() != nullptr && edge.vertex1() != nullptr &&
|
||||
Arachne::VoronoiUtils::is_finite(*edge.vertex0()) && Arachne::VoronoiUtils::is_finite(*edge.vertex1())) {
|
||||
VoronoiUtils::is_finite(*edge.vertex0()) && VoronoiUtils::is_finite(*edge.vertex1())) {
|
||||
segments.emplace_back(to_cgal_point(*edge.vertex0()), to_cgal_point(*edge.vertex1()));
|
||||
edge.color(1);
|
||||
assert(edge.twin() != nullptr);
|
||||
|
|
@ -42,42 +171,136 @@ bool VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(const VD &voronoi_
|
|||
for (const VD::edge_type &edge : voronoi_diagram.edges())
|
||||
edge.color(0);
|
||||
|
||||
std::vector<CGAL_Point> intersections_pt;
|
||||
std::vector<CGAL_E_Point> intersections_pt;
|
||||
CGAL::compute_intersection_points(segments.begin(), segments.end(), std::back_inserter(intersections_pt));
|
||||
return intersections_pt.empty();
|
||||
}
|
||||
|
||||
static bool check_if_three_vectors_are_ccw(const CGAL_Point &common_pt, const CGAL_Point &pt_1, const CGAL_Point &pt_2, const CGAL_Point &test_pt) {
|
||||
CGAL::Orientation orientation = CGAL::orientation(common_pt, pt_1, pt_2);
|
||||
struct ParabolicSegment
|
||||
{
|
||||
const Point focus;
|
||||
const Line directrix;
|
||||
// Two points on the parabola;
|
||||
const Linef segment;
|
||||
// Indicate if focus point is on the left side or right side relative to parabolic segment endpoints.
|
||||
const CGAL::Orientation is_focus_on_left;
|
||||
};
|
||||
|
||||
template<typename SegmentIterator>
|
||||
inline static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
ParabolicSegment>::type
|
||||
get_parabolic_segment(const VD::edge_type &edge, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
using Segment = typename std::iterator_traits<SegmentIterator>::value_type;
|
||||
assert(edge.is_curved());
|
||||
|
||||
const VD::cell_type *left_cell = edge.cell();
|
||||
const VD::cell_type *right_cell = edge.twin()->cell();
|
||||
|
||||
const Point focus_pt = VoronoiUtils::get_source_point(*(left_cell->contains_point() ? left_cell : right_cell), segment_begin, segment_end);
|
||||
const Segment &directrix = VoronoiUtils::get_source_segment(*(left_cell->contains_point() ? right_cell : left_cell), segment_begin, segment_end);
|
||||
CGAL::Orientation focus_side = CGAL::opposite(CGAL::orientation(to_cgal_point(edge.vertex0()), to_cgal_point(edge.vertex1()), to_cgal_point(focus_pt)));
|
||||
|
||||
assert(focus_side == CGAL::Orientation::LEFT_TURN || focus_side == CGAL::Orientation::RIGHT_TURN);
|
||||
|
||||
const Point directrix_from = boost::polygon::segment_traits<Segment>::get(directrix, boost::polygon::LOW);
|
||||
const Point directrix_to = boost::polygon::segment_traits<Segment>::get(directrix, boost::polygon::HIGH);
|
||||
return {focus_pt, Line(directrix_from, directrix_to), make_linef(edge), focus_side};
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
inline static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
CGAL::Orientation>::type
|
||||
orientation_of_two_edges(const VD::edge_type &edge_a, const VD::edge_type &edge_b, const SegmentIterator segment_begin, const SegmentIterator segment_end)
|
||||
{
|
||||
assert(is_equal(*edge_a.vertex0(), *edge_b.vertex0()));
|
||||
CGAL::Orientation orientation;
|
||||
if (edge_a.is_linear() && edge_b.is_linear()) {
|
||||
orientation = CGAL::orientation(to_cgal_point(edge_a.vertex0()), to_cgal_point(edge_a.vertex1()), to_cgal_point(edge_b.vertex1()));
|
||||
} else if (edge_a.is_curved() && edge_b.is_curved()) {
|
||||
const ParabolicSegment parabolic_a = get_parabolic_segment(edge_a, segment_begin, segment_end);
|
||||
const ParabolicSegment parabolic_b = get_parabolic_segment(edge_b, segment_begin, segment_end);
|
||||
orientation = ParabolicTangentToParabolicTangentOrientation{}(to_cgal_point(parabolic_a.segment.a),
|
||||
to_cgal_point(parabolic_a.focus),
|
||||
to_cgal_point(parabolic_a.directrix.a),
|
||||
to_cgal_point(parabolic_a.directrix.b),
|
||||
parabolic_a.is_focus_on_left,
|
||||
to_cgal_point(parabolic_b.focus),
|
||||
to_cgal_point(parabolic_b.directrix.a),
|
||||
to_cgal_point(parabolic_b.directrix.b),
|
||||
parabolic_b.is_focus_on_left);
|
||||
return orientation;
|
||||
} else {
|
||||
assert(edge_a.is_curved() != edge_b.is_curved());
|
||||
|
||||
const VD::edge_type &linear_edge = edge_a.is_curved() ? edge_b : edge_a;
|
||||
const VD::edge_type ¶bolic_edge = edge_a.is_curved() ? edge_a : edge_b;
|
||||
const ParabolicSegment parabolic = get_parabolic_segment(parabolic_edge, segment_begin, segment_end);
|
||||
orientation = ParabolicTangentToSegmentOrientation{}(to_cgal_point(parabolic.segment.a), to_cgal_point(linear_edge.vertex1()),
|
||||
to_cgal_point(parabolic.focus),
|
||||
to_cgal_point(parabolic.directrix.a),
|
||||
to_cgal_point(parabolic.directrix.b),
|
||||
parabolic.is_focus_on_left);
|
||||
|
||||
if (edge_b.is_curved())
|
||||
orientation = CGAL::opposite(orientation);
|
||||
}
|
||||
|
||||
return orientation;
|
||||
}
|
||||
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
bool>::type
|
||||
check_if_three_edges_are_ccw(const VD::edge_type &edge_first,
|
||||
const VD::edge_type &edge_second,
|
||||
const VD::edge_type &edge_third,
|
||||
const SegmentIterator segment_begin,
|
||||
const SegmentIterator segment_end)
|
||||
{
|
||||
assert(is_equal(*edge_first.vertex0(), *edge_second.vertex0()) && is_equal(*edge_second.vertex0(), *edge_third.vertex0()));
|
||||
|
||||
CGAL::Orientation orientation = orientation_of_two_edges(edge_first, edge_second, segment_begin, segment_end);
|
||||
if (orientation == CGAL::Orientation::COLLINEAR) {
|
||||
// The first two edges are collinear, so the third edge must be on the right side on the first of them.
|
||||
return CGAL::orientation(common_pt, pt_1, test_pt) == CGAL::Orientation::RIGHT_TURN;
|
||||
return orientation_of_two_edges(edge_first, edge_third, segment_begin, segment_end) == CGAL::Orientation::RIGHT_TURN;
|
||||
} else if (orientation == CGAL::Orientation::LEFT_TURN) {
|
||||
// CCW oriented angle between vectors (common_pt, pt1) and (common_pt, pt2) is bellow PI.
|
||||
// So we need to check if test_pt isn't between them.
|
||||
CGAL::Orientation orientation1 = CGAL::orientation(common_pt, pt_1, test_pt);
|
||||
CGAL::Orientation orientation2 = CGAL::orientation(common_pt, pt_2, test_pt);
|
||||
CGAL::Orientation orientation1 = orientation_of_two_edges(edge_first, edge_third, segment_begin, segment_end);
|
||||
CGAL::Orientation orientation2 = orientation_of_two_edges(edge_second, edge_third, segment_begin, segment_end);
|
||||
return (orientation1 != CGAL::Orientation::LEFT_TURN || orientation2 != CGAL::Orientation::RIGHT_TURN);
|
||||
} else {
|
||||
assert(orientation == CGAL::Orientation::RIGHT_TURN);
|
||||
// CCW oriented angle between vectors (common_pt, pt1) and (common_pt, pt2) is upper PI.
|
||||
// So we need to check if test_pt is between them.
|
||||
CGAL::Orientation orientation1 = CGAL::orientation(common_pt, pt_1, test_pt);
|
||||
CGAL::Orientation orientation2 = CGAL::orientation(common_pt, pt_2, test_pt);
|
||||
CGAL::Orientation orientation1 = orientation_of_two_edges(edge_first, edge_third, segment_begin, segment_end);
|
||||
CGAL::Orientation orientation2 = orientation_of_two_edges(edge_second, edge_third, segment_begin, segment_end);
|
||||
return (orientation1 == CGAL::Orientation::RIGHT_TURN || orientation2 == CGAL::Orientation::LEFT_TURN);
|
||||
}
|
||||
}
|
||||
|
||||
bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VoronoiDiagram &voronoi_diagram)
|
||||
template<typename SegmentIterator>
|
||||
typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
bool>::type
|
||||
VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VD &voronoi_diagram,
|
||||
const SegmentIterator segment_begin,
|
||||
const SegmentIterator segment_end)
|
||||
{
|
||||
for (const VD::vertex_type &vertex : voronoi_diagram.vertices()) {
|
||||
std::vector<const VD::edge_type *> edges;
|
||||
const VD::edge_type *edge = vertex.incident_edge();
|
||||
|
||||
do {
|
||||
// FIXME Lukas H.: Also process parabolic segments.
|
||||
if (edge->is_finite() && edge->is_linear() && edge->vertex0() != nullptr && edge->vertex1() != nullptr &&
|
||||
Arachne::VoronoiUtils::is_finite(*edge->vertex0()) && Arachne::VoronoiUtils::is_finite(*edge->vertex1()))
|
||||
if (edge->is_finite() && edge->vertex0() != nullptr && edge->vertex1() != nullptr && VoronoiUtils::is_finite(*edge->vertex0()) && VoronoiUtils::is_finite(*edge->vertex1()))
|
||||
edges.emplace_back(edge);
|
||||
|
||||
edge = edge->rot_next();
|
||||
|
|
@ -86,12 +309,11 @@ bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VoronoiDiagram &vor
|
|||
// Checking for CCW make sense for three and more edges.
|
||||
if (edges.size() > 2) {
|
||||
for (auto edge_it = edges.begin() ; edge_it != edges.end(); ++edge_it) {
|
||||
const Geometry::VoronoiDiagram::edge_type *prev_edge = edge_it == edges.begin() ? edges.back() : *std::prev(edge_it);
|
||||
const Geometry::VoronoiDiagram::edge_type *curr_edge = *edge_it;
|
||||
const Geometry::VoronoiDiagram::edge_type *next_edge = std::next(edge_it) == edges.end() ? edges.front() : *std::next(edge_it);
|
||||
const VD::edge_type *prev_edge = edge_it == edges.begin() ? edges.back() : *std::prev(edge_it);
|
||||
const VD::edge_type *curr_edge = *edge_it;
|
||||
const VD::edge_type *next_edge = std::next(edge_it) == edges.end() ? edges.front() : *std::next(edge_it);
|
||||
|
||||
if (!check_if_three_vectors_are_ccw(to_cgal_point(*prev_edge->vertex0()), to_cgal_point(*prev_edge->vertex1()),
|
||||
to_cgal_point(*curr_edge->vertex1()), to_cgal_point(*next_edge->vertex1())))
|
||||
if (!check_if_three_edges_are_ccw(*prev_edge, *curr_edge, *next_edge, segment_begin, segment_end))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -100,5 +322,4 @@ bool VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(const VoronoiDiagram &vor
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Slic3r::Geometry
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define slic3r_VoronoiUtilsCgal_hpp_
|
||||
|
||||
#include "Voronoi.hpp"
|
||||
#include "../Arachne/utils/PolygonsSegmentIndex.hpp"
|
||||
|
||||
namespace Slic3r::Geometry {
|
||||
class VoronoiDiagram;
|
||||
|
|
@ -13,8 +14,12 @@ public:
|
|||
static bool is_voronoi_diagram_planar_intersection(const VoronoiDiagram &voronoi_diagram);
|
||||
|
||||
// Check if the Voronoi diagram is planar using verification that all neighboring edges are ordered CCW for each vertex.
|
||||
static bool is_voronoi_diagram_planar_angle(const VoronoiDiagram &voronoi_diagram);
|
||||
|
||||
template<typename SegmentIterator>
|
||||
static typename boost::polygon::enable_if<
|
||||
typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<
|
||||
typename boost::polygon::geometry_concept<typename std::iterator_traits<SegmentIterator>::value_type>::type>::type>::type,
|
||||
bool>::type
|
||||
is_voronoi_diagram_planar_angle(const VoronoiDiagram &voronoi_diagram, SegmentIterator segment_begin, SegmentIterator segment_end);
|
||||
};
|
||||
} // namespace Slic3r::Geometry
|
||||
|
||||
|
|
|
|||
|
|
@ -201,12 +201,12 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
|
|||
const auto &vertices = cgalmesh.vertices();
|
||||
int vsize = int(vertices.size());
|
||||
|
||||
for (const auto &vi : vertices) {
|
||||
for (auto &vi : vertices) {
|
||||
auto &v = cgalmesh.point(vi); // Don't ask...
|
||||
its.vertices.emplace_back(to_vec3f(v));
|
||||
}
|
||||
|
||||
for (const auto &face : faces) {
|
||||
for (auto &face : faces) {
|
||||
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));
|
||||
|
||||
int i = 0;
|
||||
|
|
@ -782,7 +782,7 @@ void do_boolean(McutMesh& srcMesh, const McutMesh& cutMesh, const std::string& b
|
|||
auto src_part = triangle_mesh_to_mcut(src_parts[i]);
|
||||
for (size_t j = 0; j < cut_parts.size(); j++) {
|
||||
auto cut_part = triangle_mesh_to_mcut(cut_parts[j]);
|
||||
bool success = do_boolean_single(*src_part, *cut_part, boolean_opts);
|
||||
do_boolean_single(*src_part, *cut_part, boolean_opts);
|
||||
}
|
||||
TriangleMesh tri_part = mcut_to_triangle_mesh(*src_part);
|
||||
its_merge(all_its, tri_part.its);
|
||||
|
|
@ -811,7 +811,9 @@ void make_boolean(const TriangleMesh &src_mesh, const TriangleMesh &cut_mesh, st
|
|||
triangle_mesh_to_mcut(cut_mesh, cutMesh);
|
||||
//dst_mesh = make_boolean(srcMesh, cutMesh, boolean_opts);
|
||||
do_boolean(srcMesh, cutMesh, boolean_opts);
|
||||
dst_mesh.push_back(mcut_to_triangle_mesh(srcMesh));
|
||||
TriangleMesh tri_src = mcut_to_triangle_mesh(srcMesh);
|
||||
if (!tri_src.empty())
|
||||
dst_mesh.push_back(std::move(tri_src));
|
||||
}
|
||||
|
||||
} // namespace mcut
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ Model& Model::assign_copy(const Model &rhs)
|
|||
this->design_info = rhs.design_info;
|
||||
this->model_info = rhs.model_info;
|
||||
this->stl_design_id = rhs.stl_design_id;
|
||||
this->stl_design_country = rhs.stl_design_country;
|
||||
this->profile_info = rhs.profile_info;
|
||||
|
||||
this->mk_name = rhs.mk_name;
|
||||
|
|
@ -138,6 +139,7 @@ Model& Model::assign_copy(Model &&rhs)
|
|||
//BBS: add auxiliary path logic
|
||||
// BBS: backup, all in one temp dir
|
||||
this->stl_design_id = rhs.stl_design_id;
|
||||
this->stl_design_country = rhs.stl_design_country;
|
||||
this->mk_name = rhs.mk_name;
|
||||
this->mk_version = rhs.mk_version;
|
||||
this->backup_path = std::move(rhs.backup_path);
|
||||
|
|
@ -217,6 +219,8 @@ Model Model::read_from_file(const std::string& input_file, DynamicPrintConfig* c
|
|||
result = load_step(input_file.c_str(), &model, is_cb_cancel, stepFn, stepIsUtf8Fn);
|
||||
else if (boost::algorithm::iends_with(input_file, ".stl"))
|
||||
result = load_stl(input_file.c_str(), &model, nullptr, stlFn);
|
||||
else if (boost::algorithm::iends_with(input_file, ".oltp"))
|
||||
result = load_stl(input_file.c_str(), &model, nullptr, stlFn,256);
|
||||
else if (boost::algorithm::iends_with(input_file, ".obj"))
|
||||
result = load_obj(input_file.c_str(), &model, message);
|
||||
else if (boost::algorithm::iends_with(input_file, ".svg"))
|
||||
|
|
@ -954,6 +958,7 @@ void Model::load_from(Model& model)
|
|||
next_object_backup_id = model.next_object_backup_id;
|
||||
design_info = model.design_info;
|
||||
stl_design_id = model.stl_design_id;
|
||||
stl_design_country = model.stl_design_country;
|
||||
model_info = model.model_info;
|
||||
profile_info = model.profile_info;
|
||||
mk_name = model.mk_name;
|
||||
|
|
@ -1508,13 +1513,16 @@ BoundingBoxf3 ModelObject::instance_bounding_box(const ModelInstance &instance,
|
|||
|
||||
//BBS: add convex bounding box
|
||||
BoundingBoxf3 ModelObject::instance_convex_hull_bounding_box(size_t instance_idx, bool dont_translate) const
|
||||
{
|
||||
return instance_convex_hull_bounding_box(this->instances[instance_idx], dont_translate);
|
||||
}
|
||||
|
||||
BoundingBoxf3 ModelObject::instance_convex_hull_bounding_box(const ModelInstance* instance, bool dont_translate) const
|
||||
{
|
||||
BoundingBoxf3 bb;
|
||||
const Transform3d& inst_matrix = dont_translate ?
|
||||
this->instances[instance_idx]->get_transformation().get_matrix_no_offset() :
|
||||
this->instances[instance_idx]->get_transformation().get_matrix();
|
||||
for (ModelVolume *v : this->volumes)
|
||||
{
|
||||
const Transform3d inst_matrix = dont_translate ? instance->get_transformation().get_matrix_no_offset() :
|
||||
instance->get_transformation().get_matrix();
|
||||
for (ModelVolume* v : this->volumes) {
|
||||
if (v->is_model_part())
|
||||
bb.merge(v->get_convex_hull().transformed_bounding_box(inst_matrix * v->get_matrix()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,6 +482,7 @@ public:
|
|||
|
||||
//BBS: add instance convex hull bounding box
|
||||
BoundingBoxf3 instance_convex_hull_bounding_box(size_t instance_idx, bool dont_translate = false) const;
|
||||
BoundingBoxf3 instance_convex_hull_bounding_box(const ModelInstance* instance, bool dont_translate = false) const;
|
||||
|
||||
// Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane.
|
||||
// This method is cheap in that it does not make any unnecessary copy of the volume meshes.
|
||||
|
|
@ -1510,6 +1511,7 @@ public:
|
|||
|
||||
// DesignInfo of Model
|
||||
std::string stl_design_id;
|
||||
std::string stl_design_country;
|
||||
std::shared_ptr<ModelDesignInfo> design_info = nullptr;
|
||||
std::shared_ptr<ModelInfo> model_info = nullptr;
|
||||
std::shared_ptr<ModelProfileInfo> profile_info = nullptr;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r::
|
|||
ap.has_tree_support = true;
|
||||
}
|
||||
|
||||
ap.height = obj->bounding_box_exact().size().z();
|
||||
auto size = obj->instance_convex_hull_bounding_box(instance).size();
|
||||
ap.height = size.z();
|
||||
ap.name = obj->name;
|
||||
return ap;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -6,13 +6,41 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
|
||||
class PrintObject;
|
||||
class ExPolygon;
|
||||
using ExPolygons = std::vector<ExPolygon>;
|
||||
|
||||
struct ColoredLine
|
||||
{
|
||||
Line line;
|
||||
int color;
|
||||
int poly_idx = -1;
|
||||
int local_line_idx = -1;
|
||||
};
|
||||
|
||||
using ColoredLines = std::vector<ColoredLine>;
|
||||
|
||||
// Returns MMU segmentation based on painting in MMU segmentation gizmo
|
||||
std::vector<std::vector<ExPolygons>> multi_material_segmentation_by_painting(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
namespace boost::polygon {
|
||||
template<> struct geometry_concept<Slic3r::ColoredLine>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::ColoredLine>
|
||||
{
|
||||
typedef coord_t coordinate_type;
|
||||
typedef Slic3r::Point point_type;
|
||||
|
||||
static inline point_type get(const Slic3r::ColoredLine &line, const direction_1d &dir)
|
||||
{
|
||||
return dir.to_int() ? line.line.b : line.line.a;
|
||||
}
|
||||
};
|
||||
} // namespace boost::polygon
|
||||
|
||||
#endif // slic3r_MultiMaterialSegmentation_hpp_
|
||||
|
|
|
|||
45
src/libslic3r/ParameterUtils.cpp
Normal file
45
src/libslic3r/ParameterUtils.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "ParameterUtils.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
std::vector<LayerPrintSequence> get_other_layers_print_sequence(int sequence_nums, const std::vector<int> &sequence)
|
||||
{
|
||||
std::vector<LayerPrintSequence> res;
|
||||
if (sequence_nums == 0 || sequence.empty())
|
||||
return res;
|
||||
|
||||
assert(sequence.size() % sequence_nums == 0);
|
||||
|
||||
res.reserve(sequence_nums);
|
||||
size_t item_nums = sequence.size() / sequence_nums;
|
||||
|
||||
for (int i = 0; i < sequence_nums; ++i) {
|
||||
std::vector<int> item;
|
||||
item.assign(sequence.begin() + i * item_nums, sequence.begin() + ((i + 1) * item_nums));
|
||||
|
||||
assert(item.size() > 2);
|
||||
std::pair<std::pair<int, int>, std::vector<int>> res_item;
|
||||
res_item.first.first = item[0];
|
||||
res_item.first.second = item[1];
|
||||
res_item.second.assign(item.begin() + 2, item.end());
|
||||
res.emplace_back(std::move(res_item));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void get_other_layers_print_sequence(const std::vector<LayerPrintSequence> &customize_sequences, int &sequence_nums, std::vector<int> &sequence)
|
||||
{
|
||||
sequence_nums = 0;
|
||||
sequence.clear();
|
||||
if (customize_sequences.empty()) { return; }
|
||||
|
||||
sequence_nums = (int) customize_sequences.size();
|
||||
for (const auto &customize_sequence : customize_sequences) {
|
||||
sequence.push_back(customize_sequence.first.first);
|
||||
sequence.push_back(customize_sequence.first.second);
|
||||
sequence.insert(sequence.end(), customize_sequence.second.begin(), customize_sequence.second.end());
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace Slic3r
|
||||
14
src/libslic3r/ParameterUtils.hpp
Normal file
14
src/libslic3r/ParameterUtils.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef slic3r_Parameter_Utils_hpp_
|
||||
#define slic3r_Parameter_Utils_hpp_
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace Slic3r {
|
||||
using LayerPrintSequence = std::pair<std::pair<int, int>, std::vector<int>>;
|
||||
std::vector<LayerPrintSequence> get_other_layers_print_sequence(int sequence_nums, const std::vector<int> &sequence);
|
||||
void get_other_layers_print_sequence(const std::vector<LayerPrintSequence> &customize_sequences, int &sequence_nums, std::vector<int> &sequence);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_Parameter_Utils_hpp_
|
||||
|
|
@ -20,13 +20,15 @@
|
|||
#include "Geometry/ConvexHull.hpp"
|
||||
#include "ExPolygonCollection.hpp"
|
||||
#include "Geometry.hpp"
|
||||
|
||||
#include "Line.hpp"
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "libslic3r/AABBTreeLines.hpp"
|
||||
static const int overhang_sampling_number = 6;
|
||||
static const double narrow_loop_length_threshold = 10;
|
||||
static const double min_degree_gap = 0.1;
|
||||
static const int max_overhang_degree = overhang_sampling_number - 1;
|
||||
//BBS: when the width of expolygon is smaller than
|
||||
//ext_perimeter_width + ext_perimeter_spacing * (1 - SMALLER_EXT_INSET_OVERLAP_TOLERANCE),
|
||||
//we think it's small detail area and will generate smaller line width for it
|
||||
|
|
@ -222,6 +224,188 @@ static void lowpass_filter_by_paths_overhang_degree(ExtrusionPaths& paths) {
|
|||
}
|
||||
}
|
||||
|
||||
struct PolylineWithDegree
|
||||
{
|
||||
PolylineWithDegree(Polyline polyline, double overhang_degree) : polyline(polyline), overhang_degree(overhang_degree){};
|
||||
Polyline polyline;
|
||||
double overhang_degree = 0;
|
||||
};
|
||||
|
||||
static std::deque<PolylineWithDegree> split_polyline_by_degree(const Polyline &polyline_with_insert_points, const std::deque<double> &points_overhang)
|
||||
{
|
||||
std::deque<PolylineWithDegree> out;
|
||||
Polyline left;
|
||||
Polyline right;
|
||||
Polyline temp_copy = polyline_with_insert_points;
|
||||
|
||||
size_t poly_size = polyline_with_insert_points.size();
|
||||
// BBS: merge degree in limited range
|
||||
//find first degee base
|
||||
double degree_base = int(points_overhang[points_overhang.size() - 1] / min_degree_gap) * min_degree_gap + min_degree_gap;
|
||||
degree_base = degree_base > max_overhang_degree ? max_overhang_degree : degree_base;
|
||||
double short_poly_len = 0;
|
||||
for (int point_idx = points_overhang.size() - 2; point_idx > 0; --point_idx) {
|
||||
|
||||
double degree = points_overhang[point_idx];
|
||||
|
||||
if ( degree <= degree_base && degree >= degree_base - min_degree_gap )
|
||||
continue;
|
||||
|
||||
temp_copy.split_at_index(point_idx, &left, &right);
|
||||
|
||||
temp_copy = std::move(left);
|
||||
out.push_back(PolylineWithDegree(right, degree_base));
|
||||
|
||||
degree_base = int(degree / min_degree_gap) * min_degree_gap + min_degree_gap;
|
||||
degree_base = degree_base > max_overhang_degree ? max_overhang_degree : degree_base;
|
||||
}
|
||||
|
||||
if (!temp_copy.empty()) {
|
||||
out.push_back(PolylineWithDegree(temp_copy, degree_base));
|
||||
}
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
static void insert_point_to_line( double left_point_degree,
|
||||
Point left_point,
|
||||
double right_point_degree,
|
||||
Point right_point,
|
||||
std::deque<double> &points_overhang,
|
||||
Polyline& polyline,
|
||||
double mini_length)
|
||||
{
|
||||
Line line_temp(left_point, right_point);
|
||||
double line_length = line_temp.length();
|
||||
if (std::abs(left_point_degree - right_point_degree) <= 0.5 * min_degree_gap || line_length<scale_(1.5))
|
||||
return;
|
||||
|
||||
Point middle_pt((left_point + right_point) / 2);
|
||||
std::deque<double> left_points_overhang;
|
||||
std::deque<double> right_points_overhang;
|
||||
|
||||
double middle_degree = (left_point_degree + right_point_degree) / 2;
|
||||
Polyline left_polyline;
|
||||
Polyline right_polyline;
|
||||
|
||||
insert_point_to_line(left_point_degree, left_point, middle_degree, middle_pt, left_points_overhang, left_polyline, mini_length);
|
||||
insert_point_to_line(middle_degree, middle_pt, right_point_degree, right_point, right_points_overhang, right_polyline, mini_length);
|
||||
|
||||
if (!left_polyline.empty()) {
|
||||
polyline.points.insert(polyline.points.end(), std::make_move_iterator(left_polyline.points.begin()), std::make_move_iterator(left_polyline.points.end()));
|
||||
points_overhang.insert(points_overhang.end(), std::make_move_iterator(left_points_overhang.begin()), std::make_move_iterator(left_points_overhang.end()));
|
||||
}
|
||||
|
||||
polyline.append(middle_pt);
|
||||
points_overhang.emplace_back(middle_degree);
|
||||
|
||||
if (!right_polyline.empty()) {
|
||||
polyline.points.insert(polyline.points.end(), std::make_move_iterator(right_polyline.points.begin()), std::make_move_iterator(right_polyline.points.end()));
|
||||
points_overhang.insert(points_overhang.end(), std::make_move_iterator(right_points_overhang.begin()), std::make_move_iterator(right_points_overhang.end()));
|
||||
}
|
||||
}
|
||||
|
||||
class OverhangDistancer
|
||||
{
|
||||
std::vector<Linef> lines;
|
||||
AABBTreeIndirect::Tree<2, double> tree;
|
||||
|
||||
public:
|
||||
OverhangDistancer(const Polygons layer_polygons)
|
||||
{
|
||||
for (const Polygon &island : layer_polygons) {
|
||||
for (const auto &line : island.lines()) {
|
||||
lines.emplace_back(line.a.cast<double>(), line.b.cast<double>());
|
||||
}
|
||||
}
|
||||
tree = AABBTreeLines::build_aabb_tree_over_indexed_lines(lines);
|
||||
}
|
||||
|
||||
float distance_from_perimeter(const Vec2f &point) const
|
||||
{
|
||||
Vec2d p = point.cast<double>();
|
||||
size_t hit_idx_out{};
|
||||
Vec2d hit_point_out = Vec2d::Zero();
|
||||
auto distance = AABBTreeLines::squared_distance_to_indexed_lines(lines, tree, p, hit_idx_out, hit_point_out);
|
||||
if (distance < 0) { return std::numeric_limits<float>::max(); }
|
||||
|
||||
distance = sqrt(distance);
|
||||
return distance;
|
||||
}
|
||||
};
|
||||
|
||||
static std::deque<PolylineWithDegree> detect_overahng_degree(Polygons lower_polygons,
|
||||
Polylines middle_overhang_polyines,
|
||||
const double &lower_bound,
|
||||
const double &upper_bound,
|
||||
Polylines &too_short_polylines)
|
||||
{
|
||||
// BBS: collect lower_polygons points
|
||||
//Polylines;
|
||||
Points lower_polygon_points;
|
||||
std::vector<size_t> polygons_bound;
|
||||
|
||||
std::unique_ptr<OverhangDistancer> prev_layer_distancer;
|
||||
prev_layer_distancer = std::make_unique<OverhangDistancer>(lower_polygons);
|
||||
std::deque<PolylineWithDegree> out;
|
||||
std::deque<double> points_overhang;
|
||||
//BBS: get overhang degree and split path
|
||||
for (size_t polyline_idx = 0; polyline_idx < middle_overhang_polyines.size(); ++polyline_idx) {
|
||||
//filter too short polyline
|
||||
Polyline middle_poly = middle_overhang_polyines[polyline_idx];
|
||||
if (middle_poly.length() < scale_(1.0)) {
|
||||
too_short_polylines.push_back(middle_poly);
|
||||
continue;
|
||||
}
|
||||
|
||||
Polyline polyline_with_insert_points;
|
||||
points_overhang.clear();
|
||||
double last_degree = 0;
|
||||
// BBS : calculate overhang dist
|
||||
for (size_t point_idx = 0; point_idx < middle_poly.points.size(); ++point_idx) {
|
||||
Point pt = middle_poly.points[point_idx];
|
||||
|
||||
float overhang_dist = prev_layer_distancer->distance_from_perimeter(pt.cast<float>());
|
||||
overhang_dist = overhang_dist > upper_bound ? upper_bound : overhang_dist;
|
||||
// BBS : calculate overhang degree
|
||||
int max_overhang = max_overhang_degree;
|
||||
int min_overhang = 0;
|
||||
double t = (overhang_dist - lower_bound) / (upper_bound - lower_bound);
|
||||
t = t > 1.0 ? 1: t;
|
||||
t = t < EPSILON ? 0 : t;
|
||||
double this_degree = (1.0 - t) * min_overhang + t * max_overhang;
|
||||
// BBS: intert points
|
||||
if (point_idx > 0) {
|
||||
insert_point_to_line(last_degree, middle_poly.points[point_idx - 1], this_degree, pt, points_overhang, polyline_with_insert_points,
|
||||
upper_bound - lower_bound);
|
||||
}
|
||||
points_overhang.push_back(this_degree);
|
||||
|
||||
polyline_with_insert_points.append(pt);
|
||||
last_degree = this_degree;
|
||||
|
||||
}
|
||||
|
||||
// BBS : split path by degree
|
||||
std::deque<PolylineWithDegree> polyline_with_merged_degree = split_polyline_by_degree(polyline_with_insert_points, points_overhang);
|
||||
out.insert(out.end(), std::make_move_iterator(polyline_with_merged_degree.begin()), std::make_move_iterator(polyline_with_merged_degree.end()));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
std::pair<double, double> PerimeterGenerator::dist_boundary(double width)
|
||||
{
|
||||
std::pair<double, double> out;
|
||||
float nozzle_diameter = print_config->nozzle_diameter.get_at(config->wall_filament - 1);
|
||||
float start_offset = -0.5 * width;
|
||||
float end_offset = 0.5 * nozzle_diameter;
|
||||
double degree_0 = scale_(start_offset + 0.5 * (end_offset - start_offset) / (overhang_sampling_number - 1));
|
||||
out.first = 0;
|
||||
out.second = scale_(end_offset) - degree_0;
|
||||
return out;
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
static bool detect_steep_overhang(const PrintRegionConfig *config,
|
||||
bool is_contour,
|
||||
|
|
@ -297,24 +481,28 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
|
|||
ExtrusionPaths paths;
|
||||
|
||||
// BBS: get lower polygons series, width, mm3_per_mm
|
||||
const std::map<int, Polygons> *lower_polygons_series;
|
||||
const std::vector<Polygons> *lower_polygons_series;
|
||||
const std::pair<double, double> *overhang_dist_boundary;
|
||||
double extrusion_mm3_per_mm;
|
||||
double extrusion_width;
|
||||
if (is_external) {
|
||||
if (is_small_width) {
|
||||
//BBS: smaller width external perimeter
|
||||
lower_polygons_series = &perimeter_generator.m_smaller_external_lower_polygons_series;
|
||||
overhang_dist_boundary = &perimeter_generator.m_smaller_external_overhang_dist_boundary;
|
||||
extrusion_mm3_per_mm = perimeter_generator.smaller_width_ext_mm3_per_mm();
|
||||
extrusion_width = perimeter_generator.smaller_ext_perimeter_flow.width();
|
||||
} else {
|
||||
//BBS: normal external perimeter
|
||||
lower_polygons_series = &perimeter_generator.m_external_lower_polygons_series;
|
||||
overhang_dist_boundary = &perimeter_generator.m_external_overhang_dist_boundary;
|
||||
extrusion_mm3_per_mm = perimeter_generator.ext_mm3_per_mm();
|
||||
extrusion_width = perimeter_generator.ext_perimeter_flow.width();
|
||||
}
|
||||
} else {
|
||||
//BBS: normal perimeter
|
||||
lower_polygons_series = &perimeter_generator.m_lower_polygons_series;
|
||||
overhang_dist_boundary = &perimeter_generator.m_lower_overhang_dist_boundary;
|
||||
extrusion_mm3_per_mm = perimeter_generator.mm3_per_mm();
|
||||
extrusion_width = perimeter_generator.perimeter_flow.width();
|
||||
}
|
||||
|
|
@ -349,50 +537,72 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
|
|||
|
||||
Polylines remain_polines;
|
||||
|
||||
//BBS: don't calculate overhang degree when enable fuzzy skin. It's unmeaning
|
||||
if (perimeter_generator.config->overhang_speed_classic && perimeter_generator.config->enable_overhang_speed && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None) {
|
||||
for (auto it = lower_polygons_series->begin();
|
||||
it != lower_polygons_series->end(); it++)
|
||||
{
|
||||
Polygons lower_polygons_series_clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(it->second, bbox);
|
||||
Polygons lower_polygons_series_clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(lower_polygons_series->back(), bbox);
|
||||
|
||||
Polylines inside_polines = (it == lower_polygons_series->begin()) ? intersection_pl({polygon}, lower_polygons_series_clipped) :
|
||||
intersection_pl(remain_polines, lower_polygons_series_clipped);
|
||||
Polylines inside_polines = intersection_pl({polygon}, lower_polygons_series_clipped);
|
||||
|
||||
|
||||
remain_polines = diff_pl({polygon}, lower_polygons_series_clipped);
|
||||
|
||||
bool detect_overhang_degree = perimeter_generator.config->overhang_speed_classic && perimeter_generator.config->enable_overhang_speed && perimeter_generator.config->fuzzy_skin == FuzzySkinType::None;
|
||||
|
||||
if (!detect_overhang_degree) {
|
||||
if (!inside_polines.empty())
|
||||
extrusion_paths_append(
|
||||
paths,
|
||||
std::move(inside_polines),
|
||||
it->first,
|
||||
0,
|
||||
int(0),
|
||||
role,
|
||||
extrusion_mm3_per_mm,
|
||||
extrusion_width,
|
||||
(float)perimeter_generator.layer_height);
|
||||
|
||||
remain_polines = (it == lower_polygons_series->begin()) ? diff_pl({polygon}, lower_polygons_series_clipped) :
|
||||
diff_pl(remain_polines, lower_polygons_series_clipped);
|
||||
|
||||
if (remain_polines.size() == 0)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
auto it = lower_polygons_series->end();
|
||||
it--;
|
||||
Polygons lower_polygons_series_clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(it->second, bbox);
|
||||
Polygons lower_polygons_series_clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(lower_polygons_series->front(), bbox);
|
||||
|
||||
Polylines inside_polines = intersection_pl({polygon}, lower_polygons_series_clipped);
|
||||
extrusion_paths_append(
|
||||
paths,
|
||||
std::move(inside_polines),
|
||||
int(0),
|
||||
int(0),
|
||||
role,
|
||||
extrusion_mm3_per_mm,
|
||||
extrusion_width,
|
||||
(float)perimeter_generator.layer_height);
|
||||
Polylines middle_overhang_polyines = diff_pl({inside_polines}, lower_polygons_series_clipped);
|
||||
//BBS: add zero_degree_path
|
||||
Polylines zero_degree_polines = intersection_pl({inside_polines}, lower_polygons_series_clipped);
|
||||
if (!zero_degree_polines.empty())
|
||||
extrusion_paths_append(
|
||||
paths,
|
||||
std::move(zero_degree_polines),
|
||||
0,
|
||||
int(0),
|
||||
role,
|
||||
extrusion_mm3_per_mm,
|
||||
extrusion_width,
|
||||
(float)perimeter_generator.layer_height);
|
||||
//BBS: detect middle line overhang
|
||||
if (!middle_overhang_polyines.empty()) {
|
||||
Polylines too_short_polylines;
|
||||
std::deque<PolylineWithDegree> polylines_degree_collection = detect_overahng_degree(lower_polygons_series->front(),
|
||||
middle_overhang_polyines,
|
||||
overhang_dist_boundary->first,
|
||||
overhang_dist_boundary->second,
|
||||
too_short_polylines);
|
||||
if (!too_short_polylines.empty())
|
||||
extrusion_paths_append(paths,
|
||||
std::move(too_short_polylines),
|
||||
0,
|
||||
int(0),
|
||||
role,
|
||||
extrusion_mm3_per_mm,
|
||||
extrusion_width,
|
||||
(float) perimeter_generator.layer_height);
|
||||
// BBS: add path with overhang degree
|
||||
for (PolylineWithDegree polylines_collection : polylines_degree_collection) {
|
||||
extrusion_paths_append(paths,
|
||||
std::move(polylines_collection.polyline),
|
||||
polylines_collection.overhang_degree,
|
||||
int(0),
|
||||
role,
|
||||
extrusion_mm3_per_mm,
|
||||
extrusion_width, (float) perimeter_generator.layer_height);
|
||||
}
|
||||
}
|
||||
|
||||
remain_polines = diff_pl({polygon}, lower_polygons_series_clipped);
|
||||
}
|
||||
|
||||
// get 100% overhang paths by checking what parts of this loop fall
|
||||
// outside the grown lower slices (thus where the distance between
|
||||
// the loop centerline and original lower slices is >= half nozzle diameter
|
||||
|
|
@ -407,9 +617,6 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
|
|||
// We allow polyline reversal because Clipper may have randomly reversed polylines during clipping.
|
||||
if(paths.empty()) continue;
|
||||
chain_and_reorder_extrusion_paths(paths, &paths.front().first_point());
|
||||
// smothing the overhang degree
|
||||
// merge small path between paths which have same overhang degree
|
||||
lowpass_filter_by_paths_overhang_degree(paths);
|
||||
} else {
|
||||
ExtrusionPath path(role);
|
||||
//BBS.
|
||||
|
|
@ -1489,12 +1696,16 @@ void PerimeterGenerator::process_classic()
|
|||
|
||||
// prepare grown lower layer slices for overhang detection
|
||||
m_lower_polygons_series = generate_lower_polygons_series(this->perimeter_flow.width());
|
||||
if (ext_perimeter_width == perimeter_width)
|
||||
m_lower_overhang_dist_boundary = dist_boundary(this->perimeter_flow.width());
|
||||
if (ext_perimeter_width == perimeter_width){
|
||||
m_external_lower_polygons_series = m_lower_polygons_series;
|
||||
else
|
||||
m_external_overhang_dist_boundary=m_lower_overhang_dist_boundary;
|
||||
} else {
|
||||
m_external_lower_polygons_series = generate_lower_polygons_series(this->ext_perimeter_flow.width());
|
||||
m_external_overhang_dist_boundary = dist_boundary(this->ext_perimeter_flow.width());
|
||||
}
|
||||
m_smaller_external_lower_polygons_series = generate_lower_polygons_series(this->smaller_ext_perimeter_flow.width());
|
||||
|
||||
m_smaller_external_overhang_dist_boundary = dist_boundary(this->smaller_ext_perimeter_flow.width());
|
||||
// we need to process each island separately because we might have different
|
||||
// extra perimeters for each one
|
||||
Surfaces all_surfaces = this->slices->surfaces;
|
||||
|
|
@ -2702,7 +2913,7 @@ bool PerimeterGeneratorLoop::is_internal_contour() const
|
|||
return true;
|
||||
}
|
||||
|
||||
std::map<int, Polygons> PerimeterGenerator::generate_lower_polygons_series(float width)
|
||||
std::vector<Polygons> PerimeterGenerator::generate_lower_polygons_series(float width)
|
||||
{
|
||||
float nozzle_diameter = print_config->nozzle_diameter.get_at(config->wall_filament - 1);
|
||||
float start_offset = -0.5 * width;
|
||||
|
|
@ -2711,23 +2922,18 @@ std::map<int, Polygons> PerimeterGenerator::generate_lower_polygons_series(float
|
|||
assert(overhang_sampling_number >= 3);
|
||||
// generate offsets
|
||||
std::vector<float> offset_series;
|
||||
offset_series.reserve(overhang_sampling_number - 1);
|
||||
for (int i = 0; i < overhang_sampling_number - 1; i++) {
|
||||
offset_series.push_back(start_offset + (i + 0.5) * (end_offset - start_offset) / (overhang_sampling_number - 1));
|
||||
}
|
||||
// BBS: increase start_offset a little to avoid to calculate 90 degree as overhang
|
||||
offset_series[0] = start_offset + 0.5 * (end_offset - start_offset) / (overhang_sampling_number - 1);
|
||||
offset_series[overhang_sampling_number - 2] = end_offset;
|
||||
offset_series.back() = 0.1 * nozzle_diameter;
|
||||
offset_series.reserve(2);
|
||||
|
||||
std::map<int, Polygons> lower_polygons_series;
|
||||
offset_series.push_back(start_offset + 0.5 * (end_offset - start_offset) / (overhang_sampling_number - 1));
|
||||
offset_series.push_back(end_offset);
|
||||
std::vector<Polygons> lower_polygons_series;
|
||||
if (this->lower_slices == NULL) {
|
||||
return lower_polygons_series;
|
||||
}
|
||||
|
||||
// offset expolygon to generate series of polygons
|
||||
for (int i = 0; i < offset_series.size(); i++) {
|
||||
lower_polygons_series.insert(std::pair<int, Polygons>(i, offset(*this->lower_slices, float(scale_(offset_series[i])))));
|
||||
lower_polygons_series.emplace_back(offset(*this->lower_slices, float(scale_(offset_series[i]))));
|
||||
}
|
||||
return lower_polygons_series;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,13 @@ public:
|
|||
|
||||
//BBS
|
||||
Flow smaller_ext_perimeter_flow;
|
||||
std::map<int, Polygons> m_lower_polygons_series;
|
||||
std::map<int, Polygons> m_external_lower_polygons_series;
|
||||
std::map<int, Polygons> m_smaller_external_lower_polygons_series;
|
||||
std::vector<Polygons> m_lower_polygons_series;
|
||||
std::vector<Polygons> m_external_lower_polygons_series;
|
||||
std::vector<Polygons> m_smaller_external_lower_polygons_series;
|
||||
std::pair<double, double> m_lower_overhang_dist_boundary;
|
||||
std::pair<double, double> m_external_overhang_dist_boundary;
|
||||
std::pair<double, double> m_smaller_external_overhang_dist_boundary;
|
||||
|
||||
|
||||
PerimeterGenerator(
|
||||
// Input:
|
||||
|
|
@ -79,10 +83,11 @@ public:
|
|||
Polygons lower_slices_polygons() const { return m_lower_slices_polygons; }
|
||||
|
||||
private:
|
||||
std::map<int, Polygons> generate_lower_polygons_series(float width);
|
||||
std::vector<Polygons> generate_lower_polygons_series(float width);
|
||||
void split_top_surfaces(const ExPolygons &orig_polygons, ExPolygons &top_fills, ExPolygons &non_top_polygons, ExPolygons &fill_clip) const;
|
||||
void apply_extra_perimeters(ExPolygons& infill_area);
|
||||
void process_no_bridge(Surfaces& all_surfaces, coord_t perimeter_spacing, coord_t ext_perimeter_width);
|
||||
std::pair<double, double> dist_boundary(double width);
|
||||
|
||||
private:
|
||||
bool m_spiral_vase;
|
||||
|
|
|
|||
|
|
@ -801,7 +801,7 @@ static std::vector<std::string> s_Preset_print_options {
|
|||
"tree_support_branch_angle", "tree_support_angle_slow", "tree_support_wall_count", "tree_support_top_rate", "tree_support_branch_distance", "tree_support_tip_diameter",
|
||||
"tree_support_branch_diameter", "tree_support_branch_diameter_angle", "tree_support_branch_diameter_double_wall",
|
||||
"detect_narrow_internal_solid_infill",
|
||||
"gcode_add_line_number", "enable_arc_fitting", "infill_combination", /*"adaptive_layer_height",*/
|
||||
"gcode_add_line_number", "enable_arc_fitting", "precise_z_height", "infill_combination", /*"adaptive_layer_height",*/
|
||||
"support_bottom_interface_spacing", "enable_overhang_speed", "slowdown_for_curled_perimeters", "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed",
|
||||
"initial_layer_infill_speed", "only_one_wall_top",
|
||||
"timelapse_type",
|
||||
|
|
@ -850,7 +850,8 @@ static std::vector<std::string> s_Preset_filament_options {
|
|||
"filament_loading_speed", "filament_loading_speed_start", "filament_load_time",
|
||||
"filament_unloading_speed", "filament_unloading_speed_start", "filament_unload_time", "filament_toolchange_delay", "filament_cooling_moves",
|
||||
"filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters",
|
||||
"filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", "activate_chamber_temp_control"
|
||||
"filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", "activate_chamber_temp_control",
|
||||
"filament_long_retractions_when_cut","filament_retraction_distances_when_cut"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_machine_limits_options {
|
||||
|
|
@ -867,6 +868,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
|||
"fan_kickstart", "fan_speedup_time", "fan_speedup_overhangs",
|
||||
"single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "printing_by_object_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "change_extrusion_role_gcode",
|
||||
"printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
|
||||
"nozzle_height",
|
||||
"default_print_profile", "inherits",
|
||||
"silent_mode",
|
||||
// BBS
|
||||
|
|
@ -882,7 +884,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
|||
"cooling_tube_retraction",
|
||||
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
|
||||
"z_offset",
|
||||
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode", "support_multi_bed_types","bed_mesh_min","bed_mesh_max","bed_mesh_probe_distance", "adaptive_bed_mesh_margin"
|
||||
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode", "support_multi_bed_types","bed_mesh_min","bed_mesh_max","bed_mesh_probe_distance", "adaptive_bed_mesh_margin", "enable_long_retraction_when_cut","long_retractions_when_cut","retraction_distances_when_cut"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_sla_print_options {
|
||||
|
|
@ -1184,6 +1186,8 @@ void PresetCollection::load_presets(
|
|||
preset.setting_id.clear();
|
||||
//BBS: add config related logs
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(", preset type %1%, name %2%, path %3%, is_system %4%, is_default %5% is_visible %6%")%Preset::get_type_string(m_type) %preset.name %preset.file %preset.is_system %preset.is_default %preset.is_visible;
|
||||
// add alias for custom filament preset
|
||||
set_custom_preset_alias(preset);
|
||||
} catch (const std::ifstream::failure &err) {
|
||||
++m_errors;
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("The user-config cannot be loaded: %1%. Reason: %2%")%preset.file %err.what();
|
||||
|
|
@ -2139,6 +2143,7 @@ bool PresetCollection::clone_presets(std::vector<Preset const *> const &presets,
|
|||
auto old_name = this->get_edited_preset().name;
|
||||
for (auto preset : new_presets) {
|
||||
preset.alias.clear();
|
||||
set_custom_preset_alias(preset);
|
||||
preset.base_id.clear();
|
||||
auto it = this->find_preset_internal(preset.name);
|
||||
assert((it == m_presets.end() || it->name != preset.name) || force_rewritten);
|
||||
|
|
@ -2200,6 +2205,10 @@ std::map<std::string, std::vector<Preset const *>> PresetCollection::get_filamen
|
|||
{
|
||||
std::map<std::string, std::vector<Preset const *>> filament_presets;
|
||||
for (auto &preset : m_presets) {
|
||||
if (preset.is_user()) {
|
||||
if (preset.inherits() == "") { filament_presets[preset.filament_id].push_back(&preset); }
|
||||
continue;
|
||||
}
|
||||
if (get_preset_base(preset) == &preset) { filament_presets[preset.filament_id].push_back(&preset); }
|
||||
}
|
||||
return filament_presets;
|
||||
|
|
@ -2456,10 +2465,13 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string&
|
|||
auto it = Slic3r::lower_bound_by_predicate(m_map_alias_to_profile_name.begin(), m_map_alias_to_profile_name.end(), [&alias](auto &l){ return l.first < alias; });
|
||||
// Continue over all profile names with the same alias.
|
||||
it != m_map_alias_to_profile_name.end() && it->first == alias; ++ it)
|
||||
if (auto it_preset = this->find_preset_internal(it->second);
|
||||
it_preset != m_presets.end() && it_preset->name == it->second &&
|
||||
for (const std::string &preset_name : it->second) {
|
||||
if (auto it_preset = this->find_preset_internal(preset_name);
|
||||
it_preset != m_presets.end() && it_preset->name == preset_name &&
|
||||
it_preset->is_visible && (it_preset->is_compatible || size_t(it_preset - m_presets.begin()) == m_idx_selected))
|
||||
return it_preset->name;
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
||||
|
|
@ -2471,6 +2483,28 @@ const std::string* PresetCollection::get_preset_name_renamed(const std::string &
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PresetCollection::is_alias_exist(const std::string &alias, Preset* preset)
|
||||
{
|
||||
auto it = m_map_alias_to_profile_name.find(alias);
|
||||
if (m_map_alias_to_profile_name.end() == it) return false;
|
||||
if (!preset) return true;
|
||||
|
||||
auto compatible_printers = dynamic_cast<ConfigOptionStrings *>(preset->config.option("compatible_printers"));
|
||||
if (compatible_printers == nullptr) return true;
|
||||
|
||||
for (const std::string &printer_name : compatible_printers->values) {
|
||||
auto printer_iter = m_printer_hold_alias.find(printer_name);
|
||||
if (m_printer_hold_alias.end() != printer_iter) {
|
||||
auto alias_iter = m_printer_hold_alias[printer_name].find(alias);
|
||||
if (m_printer_hold_alias[printer_name].end() != alias_iter) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << " The alias already exists: " << alias << " and the preset name: " << preset->name;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string& PresetCollection::get_suffix_modified() {
|
||||
return g_suffix_modified;
|
||||
}
|
||||
|
|
@ -2803,9 +2837,11 @@ void PresetCollection::update_vendor_ptrs_after_copy(const VendorMap &new_vendor
|
|||
void PresetCollection::update_map_alias_to_profile_name()
|
||||
{
|
||||
m_map_alias_to_profile_name.clear();
|
||||
for (const Preset &preset : m_presets)
|
||||
m_map_alias_to_profile_name.emplace_back(preset.alias, preset.name);
|
||||
std::sort(m_map_alias_to_profile_name.begin(), m_map_alias_to_profile_name.end(), [](auto &l, auto &r) { return l.first < r.first; });
|
||||
for (const Preset &preset : m_presets) {
|
||||
m_map_alias_to_profile_name[preset.alias].push_back(preset.name);
|
||||
}
|
||||
// now m_map_alias_to_profile_name is map, not need sort
|
||||
//std::sort(m_map_alias_to_profile_name.begin(), m_map_alias_to_profile_name.end(), [](auto &l, auto &r) { return l.first < r.first; });
|
||||
}
|
||||
|
||||
void PresetCollection::update_map_system_profile_renamed()
|
||||
|
|
@ -2823,6 +2859,47 @@ void PresetCollection::update_map_system_profile_renamed()
|
|||
}
|
||||
}
|
||||
|
||||
void PresetCollection::set_custom_preset_alias(Preset &preset)
|
||||
{
|
||||
if (m_type == Preset::Type::TYPE_FILAMENT && preset.config.has(BBL_JSON_KEY_INHERITS) && preset.config.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS)->value.empty()) {
|
||||
std::string alias_name;
|
||||
std::string preset_name = preset.name;
|
||||
if (alias_name.empty()) {
|
||||
size_t end_pos = preset_name.find_first_of("@");
|
||||
if (end_pos != std::string::npos) {
|
||||
alias_name = preset_name.substr(0, end_pos);
|
||||
boost::trim_right(alias_name);
|
||||
}
|
||||
}
|
||||
if (alias_name.empty() || is_alias_exist(alias_name, &preset))
|
||||
preset.alias = "";
|
||||
else {
|
||||
preset.alias = std::move(alias_name);
|
||||
m_map_alias_to_profile_name[preset.alias].push_back(preset.name);
|
||||
set_printer_hold_alias(preset.alias, preset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PresetCollection::set_printer_hold_alias(const std::string &alias, Preset &preset)
|
||||
{
|
||||
auto compatible_printers = dynamic_cast<ConfigOptionStrings *>(preset.config.option("compatible_printers"));
|
||||
if (compatible_printers == nullptr) return;
|
||||
for (const std::string &printer_name : compatible_printers->values) {
|
||||
auto printer_iter = m_printer_hold_alias.find(printer_name);
|
||||
if (m_printer_hold_alias.end() == printer_iter) {
|
||||
m_printer_hold_alias[printer_name].insert(alias);
|
||||
} else {
|
||||
auto alias_iter = m_printer_hold_alias[printer_name].find(alias);
|
||||
if (m_printer_hold_alias[printer_name].end() == alias_iter) {
|
||||
m_printer_hold_alias[printer_name].insert(alias);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << printer_name << "already has alias: " << alias << " and the preset name: " << preset.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string PresetCollection::name() const
|
||||
{
|
||||
switch (this->type()) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <deque>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
|
@ -554,6 +555,8 @@ public:
|
|||
|
||||
const std::string& get_preset_name_by_alias(const std::string& alias) const;
|
||||
const std::string* get_preset_name_renamed(const std::string &old_name) const;
|
||||
bool is_alias_exist(const std::string &alias, Preset* preset = nullptr);
|
||||
void set_printer_hold_alias(const std::string &alias, Preset &preset);
|
||||
|
||||
// used to update preset_choice from Tab
|
||||
const std::deque<Preset>& get_presets() const { return m_presets; }
|
||||
|
|
@ -705,6 +708,8 @@ protected:
|
|||
// Update m_map_system_profile_renamed from loaded system profiles.
|
||||
void update_map_system_profile_renamed();
|
||||
|
||||
void set_custom_preset_alias(Preset &preset);
|
||||
|
||||
private:
|
||||
// Find a preset position in the sorted list of presets.
|
||||
// The "-- default -- " preset is always the first, so it needs
|
||||
|
|
@ -748,7 +753,8 @@ private:
|
|||
// so that the addresses of the presets don't change during resizing of the container.
|
||||
std::deque<Preset> m_presets;
|
||||
// System profiles may have aliases. Map to the full profile name.
|
||||
std::vector<std::pair<std::string, std::string>> m_map_alias_to_profile_name;
|
||||
std::map<std::string, std::vector<std::string>> m_map_alias_to_profile_name;
|
||||
std::unordered_map<std::string, std::unordered_set<std::string>> m_printer_hold_alias;
|
||||
// Map from old system profile name to a current system profile name.
|
||||
std::map<std::string, std::string> m_map_system_profile_renamed;
|
||||
// Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user.
|
||||
|
|
|
|||
|
|
@ -1895,7 +1895,6 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
|
|||
if (filament_presets.size() < this->filament_presets.size()) {
|
||||
filament_presets.push_back(this->filament_presets[filament_presets.size()]);
|
||||
filament_colors.push_back(filament_color);
|
||||
ams_multi_color_filment.push_back(filament_multi_color);
|
||||
++unknowns;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1945,6 +1944,96 @@ void PresetBundle::set_calibrate_printer(std::string name)
|
|||
}
|
||||
}
|
||||
|
||||
std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str)
|
||||
{
|
||||
std::set<std::string> printer_names;
|
||||
if ("0.0" == nozzle_diameter_str || nozzle_diameter_str.empty()) {
|
||||
nozzle_diameter_str = "0.4";
|
||||
}
|
||||
std::ostringstream stream;
|
||||
|
||||
for (auto printer_it = this->printers.begin(); printer_it != this->printers.end(); printer_it++) {
|
||||
if (!printer_it->is_system) continue;
|
||||
|
||||
ConfigOption * printer_model_opt = printer_it->config.option("printer_model");
|
||||
ConfigOptionString *printer_model_str = dynamic_cast<ConfigOptionString *>(printer_model_opt);
|
||||
if (!printer_model_str) continue;
|
||||
|
||||
// use printer_model as printer type
|
||||
if (printer_model_str->value != printer_type) continue;
|
||||
|
||||
if (printer_it->name.find(nozzle_diameter_str) != std::string::npos) printer_names.insert(printer_it->name);
|
||||
}
|
||||
assert(printer_names.size() == 1);
|
||||
|
||||
for (auto& printer_name : printer_names) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " printer name: " << printer_name;
|
||||
}
|
||||
|
||||
return printer_names;
|
||||
}
|
||||
|
||||
bool PresetBundle::check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
const std::string &printer_type, std::string& nozzle_diameter_str, std::string &setting_id, std::string &tag_uid, std::string &nozzle_temp_min, std::string &nozzle_temp_max, std::string& preset_setting_id)
|
||||
{
|
||||
bool is_equation = true;
|
||||
|
||||
std::map<std::string, std::vector<Preset const *>> filament_list = filaments.get_filament_presets();
|
||||
std::set<std::string> printer_names = get_printer_names_by_printer_type_and_nozzle(printer_type, nozzle_diameter_str);
|
||||
|
||||
for (const Preset *preset : filament_list.find(setting_id)->second) {
|
||||
if (tag_uid == "0" || (tag_uid.size() == 16 && tag_uid.substr(12, 2) == "01")) continue;
|
||||
if (preset && !preset->is_user()) continue;
|
||||
ConfigOption * printer_opt = const_cast<Preset *>(preset)->config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
bool compared = false;
|
||||
for (const std::string &printer_str : printer_strs->values) {
|
||||
if (printer_names.find(printer_str) != printer_names.end()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "nozzle temp matching: preset name: " << preset->name << " printer name: " << printer_str;
|
||||
// Compare only once
|
||||
if (!compared) {
|
||||
compared = true;
|
||||
bool min_temp_equation = false, max_temp_equation = false;
|
||||
int min_nozzle_temp = std::stoi(nozzle_temp_min);
|
||||
int max_nozzle_temp = std::stoi(nozzle_temp_max);
|
||||
ConfigOption *opt_min = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
|
||||
min_nozzle_temp = opt_min_ints->get_at(0);
|
||||
if (std::to_string(min_nozzle_temp) == nozzle_temp_min)
|
||||
min_temp_equation = true;
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "tray min temp: " << nozzle_temp_min << " preset min temp: " << min_nozzle_temp;
|
||||
nozzle_temp_min = std::to_string(min_nozzle_temp);
|
||||
}
|
||||
}
|
||||
ConfigOption *opt_max = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_high");
|
||||
if (opt_max) {
|
||||
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
|
||||
max_nozzle_temp = opt_max_ints->get_at(0);
|
||||
if (std::to_string(max_nozzle_temp) == nozzle_temp_max)
|
||||
max_temp_equation = true;
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "tray max temp: " << nozzle_temp_max << " preset min temp: " << max_nozzle_temp;
|
||||
nozzle_temp_max = std::to_string(max_nozzle_temp);
|
||||
}
|
||||
}
|
||||
if (min_temp_equation && max_temp_equation) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: no changed";
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: has changed";
|
||||
preset_setting_id = preset->setting_id;
|
||||
is_equation = false;
|
||||
}
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_equation;
|
||||
}
|
||||
|
||||
//BBS: check whether this is the only edited filament
|
||||
bool PresetBundle::is_the_only_edited_filament(unsigned int filament_index)
|
||||
{
|
||||
|
|
@ -3544,8 +3633,10 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_vendor_configs_
|
|||
}
|
||||
if (alias_name.empty())
|
||||
loaded.alias = preset_name;
|
||||
else
|
||||
else {
|
||||
loaded.alias = std::move(alias_name);
|
||||
filaments.set_printer_hold_alias(loaded.alias, loaded);
|
||||
}
|
||||
loaded.renamed_from = std::move(renamed_from);
|
||||
if (! substitution_context.empty())
|
||||
substitutions.push_back({
|
||||
|
|
|
|||
|
|
@ -125,6 +125,15 @@ public:
|
|||
void set_is_validation_mode(bool mode) { validation_mode = mode; }
|
||||
void set_vendor_to_validate(std::string vendor) { vendor_to_validate = vendor; }
|
||||
|
||||
std::set<std::string> get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str);
|
||||
bool check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(const std::string &printer_type,
|
||||
std::string & nozzle_diameter_str,
|
||||
std::string & setting_id,
|
||||
std::string & tag_uid,
|
||||
std::string & nozzle_temp_min,
|
||||
std::string & nozzle_temp_max,
|
||||
std::string & preset_setting_id);
|
||||
|
||||
PresetCollection prints;
|
||||
PresetCollection sla_prints;
|
||||
PresetCollection filaments;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
"extruder_clearance_height_to_rod",
|
||||
"extruder_clearance_height_to_lid",
|
||||
"extruder_clearance_radius",
|
||||
"nozzle_height",
|
||||
"extruder_colour",
|
||||
"extruder_offset",
|
||||
"filament_flow_ratio",
|
||||
|
|
@ -213,6 +214,12 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
"activate_chamber_temp_control",
|
||||
"manual_filament_change",
|
||||
"disable_m73",
|
||||
"use_firmware_retraction",
|
||||
"enable_long_retraction_when_cut",
|
||||
"long_retractions_when_cut",
|
||||
"retraction_distances_when_cut",
|
||||
"filament_long_retractions_when_cut",
|
||||
"filament_retraction_distances_when_cut"
|
||||
};
|
||||
|
||||
static std::unordered_set<std::string> steps_ignore;
|
||||
|
|
@ -244,6 +251,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
|| opt_key == "nozzle_diameter"
|
||||
|| opt_key == "filament_shrink"
|
||||
|| opt_key == "resolution"
|
||||
|| opt_key == "precise_z_height"
|
||||
// Spiral Vase forces different kind of slicing than the normal model:
|
||||
// In Spiral Vase mode, holes are closed and only the largest area contour is kept at each layer.
|
||||
// Therefore toggling the Spiral Vase on / off requires complete reslicing.
|
||||
|
|
@ -280,6 +288,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
|| opt_key == "prime_tower_width"
|
||||
|| opt_key == "prime_tower_brim_width"
|
||||
|| opt_key == "first_layer_print_sequence"
|
||||
|| opt_key == "other_layers_print_sequence"
|
||||
|| opt_key == "other_layers_print_sequence_nums"
|
||||
|| opt_key == "wipe_tower_bridging"
|
||||
|| opt_key == "wipe_tower_no_sparse_layers"
|
||||
|| opt_key == "flush_volumes_matrix"
|
||||
|
|
@ -460,8 +470,8 @@ std::vector<unsigned int> Print::extruders(bool conside_custom_gcode) const
|
|||
if (conside_custom_gcode) {
|
||||
//BBS
|
||||
int num_extruders = m_config.filament_colour.size();
|
||||
for (auto plate_data : m_model.plates_custom_gcodes) {
|
||||
for (auto item : plate_data.second.gcodes) {
|
||||
if (m_model.plates_custom_gcodes.find(m_model.curr_plate_index) != m_model.plates_custom_gcodes.end()) {
|
||||
for (auto item : m_model.plates_custom_gcodes.at(m_model.curr_plate_index).gcodes) {
|
||||
if (item.type == CustomGCode::Type::ToolChange && item.extruder <= num_extruders)
|
||||
extruders.push_back((unsigned int)(item.extruder - 1));
|
||||
}
|
||||
|
|
@ -576,6 +586,11 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
|
|||
polygons->clear();
|
||||
std::vector<size_t> intersecting_idxs;
|
||||
|
||||
bool all_objects_are_short = print.is_all_objects_are_short();
|
||||
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
|
||||
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
|
||||
float obj_distance = all_objects_are_short ? scale_(0.5*MAX_OUTER_NOZZLE_DIAMETER-0.1) : scale_(0.5*print.config().extruder_clearance_radius.value-0.1);
|
||||
|
||||
for (const PrintObject *print_object : print.objects()) {
|
||||
assert(! print_object->model_object()->instances.empty());
|
||||
assert(! print_object->instances().empty());
|
||||
|
|
@ -601,11 +616,7 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
|
|||
// Now we check that no instance of convex_hull intersects any of the previously checked object instances.
|
||||
for (const PrintInstance &instance : print_object->instances()) {
|
||||
Polygon convex_hull_no_offset = convex_hull0, convex_hull;
|
||||
auto tmp = offset(convex_hull_no_offset,
|
||||
// Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects
|
||||
// exactly by satisfying the extruder_clearance_radius, this test will not trigger collision.
|
||||
float(scale_(0.5 * print.config().extruder_clearance_radius.value - 0.1)),
|
||||
jtRound, scale_(0.1));
|
||||
auto tmp = offset(convex_hull_no_offset, obj_distance, jtRound, scale_(0.1));
|
||||
if (!tmp.empty()) { // tmp may be empty due to clipper's bug, see STUDIO-2452
|
||||
convex_hull = tmp.front();
|
||||
// instance.shift is a position of a centered object, while model object may not be centered.
|
||||
|
|
@ -840,7 +851,7 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (height < inst->print_object->height())
|
||||
if (height < inst->print_object->max_z())
|
||||
too_tall_instances[inst] = std::make_pair(print_instance_with_bounding_box[k].hull_polygon, unscaled<double>(height));
|
||||
}
|
||||
|
||||
|
|
@ -1088,7 +1099,7 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
|
||||
if (m_config.spiral_mode) {
|
||||
size_t total_copies_count = 0;
|
||||
for (const PrintObject *object : m_objects)
|
||||
for (const PrintObject* object : m_objects)
|
||||
total_copies_count += object->instances().size();
|
||||
// #4043
|
||||
if (total_copies_count > 1 && m_config.print_sequence != PrintSequence::ByObject)
|
||||
|
|
@ -1117,7 +1128,7 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
for (size_t print_object_idx = 0; print_object_idx < m_objects.size(); ++ print_object_idx) {
|
||||
const PrintObject &print_object = *m_objects[print_object_idx];
|
||||
//FIXME It is quite expensive to generate object layers just to get the print height!
|
||||
if (auto layers = generate_object_layers(print_object.slicing_parameters(), layer_height_profile(print_object_idx));
|
||||
if (auto layers = generate_object_layers(print_object.slicing_parameters(), layer_height_profile(print_object_idx), print_object.config().precise_z_height.value);
|
||||
! layers.empty() && layers.back() > this->config().printable_height + EPSILON) {
|
||||
return
|
||||
// Test whether the last slicing plane is below or above the print volume.
|
||||
|
|
@ -1220,6 +1231,13 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
|
|||
|
||||
// BBS: remove obsolete logics and _L()
|
||||
if (has_custom_layering) {
|
||||
std::vector<std::vector<coordf_t>> layer_z_series;
|
||||
layer_z_series.assign(m_objects.size(), std::vector<coordf_t>());
|
||||
|
||||
for (size_t idx_object = 0; idx_object < m_objects.size(); ++idx_object) {
|
||||
layer_z_series[idx_object] = generate_object_layers(m_objects[idx_object]->slicing_parameters(), layer_height_profiles[idx_object], m_objects[idx_object]->config().precise_z_height.value);
|
||||
}
|
||||
|
||||
for (size_t idx_object = 0; idx_object < m_objects.size(); ++idx_object) {
|
||||
if (idx_object == tallest_object_idx) continue;
|
||||
// Check that the layer height profiles are equal. This will happen when one object is
|
||||
|
|
@ -2472,7 +2490,8 @@ int Print::get_hrc_by_nozzle_type(const NozzleType&type)
|
|||
static std::map<std::string, int>nozzle_type_to_hrc;
|
||||
if (nozzle_type_to_hrc.empty()) {
|
||||
fs::path file_path = fs::path(resources_dir()) / "info" / "nozzle_info.json";
|
||||
std::ifstream in(file_path.string());
|
||||
boost::nowide::ifstream in(file_path.string());
|
||||
//std::ifstream in(file_path.string());
|
||||
json j;
|
||||
try {
|
||||
j = json::parse(in);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ class SupportLayer;
|
|||
class TreeSupportData;
|
||||
class TreeSupport;
|
||||
|
||||
#define MARGIN_HEIGHT 1.5
|
||||
#define MAX_OUTER_NOZZLE_DIAMETER 4
|
||||
// BBS: move from PrintObjectSlice.cpp
|
||||
struct VolumeSlices
|
||||
{
|
||||
|
|
@ -331,6 +333,7 @@ public:
|
|||
// Height is used for slicing, for sorting the objects by height for sequential printing and for checking vertical clearence in sequential print mode.
|
||||
// The height is snug.
|
||||
coord_t height() const { return m_size.z(); }
|
||||
double max_z() const { return m_max_z; }
|
||||
// Centering offset of the sliced mesh from the scaled and rotated mesh of the model.
|
||||
const Point& center_offset() const { return m_center_offset; }
|
||||
|
||||
|
|
@ -505,6 +508,7 @@ private:
|
|||
|
||||
// XYZ in scaled coordinates
|
||||
Vec3crd m_size;
|
||||
double m_max_z;
|
||||
PrintObjectConfig m_config;
|
||||
// Translation in Z + Rotation + Scaling / Mirroring.
|
||||
Transform3d m_trafo = Transform3d::Identity();
|
||||
|
|
@ -954,7 +958,11 @@ public:
|
|||
// Unset types are just ignored.
|
||||
static int get_compatible_filament_type(const std::set<int>& types);
|
||||
|
||||
protected:
|
||||
bool is_all_objects_are_short() const {
|
||||
return std::all_of(this->objects().begin(), this->objects().end(), [&](PrintObject* obj) { return obj->height() < scale_(this->config().nozzle_height.value); });
|
||||
}
|
||||
|
||||
protected:
|
||||
// Invalidates the step, and its depending steps in Print.
|
||||
bool invalidate_step(PrintStep step);
|
||||
|
||||
|
|
|
|||
|
|
@ -235,11 +235,16 @@ static t_config_option_keys print_config_diffs(
|
|||
bool overriden = opt_new->overriden_by(opt_new_filament);
|
||||
if (overriden || *opt_old != *opt_new) {
|
||||
auto opt_copy = opt_new->clone();
|
||||
opt_copy->apply_override(opt_new_filament);
|
||||
if (!((opt_key == "long_retractions_when_cut" || opt_key == "retraction_distances_when_cut")
|
||||
&& new_full_config.option<ConfigOptionInt>("enable_long_retraction_when_cut")->value != LongRectrationLevel::EnableFilament)) // ugly code, remove it later if firmware supports
|
||||
opt_copy->apply_override(opt_new_filament);
|
||||
bool changed = *opt_old != *opt_copy;
|
||||
if (changed)
|
||||
print_diff.emplace_back(opt_key);
|
||||
if (changed || overriden) {
|
||||
if ((opt_key == "long_retractions_when_cut" || opt_key == "retraction_distances_when_cut")
|
||||
&& new_full_config.option<ConfigOptionInt>("enable_long_retraction_when_cut")->value != LongRectrationLevel::EnableFilament)
|
||||
continue;
|
||||
// filament_overrides will be applied to the placeholder parser, which layers these parameters over full_print_config.
|
||||
filament_overrides.set_key_value(opt_key, opt_copy);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -370,11 +370,11 @@ static const t_config_enum_values s_keys_map_BedType = {
|
|||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(BedType)
|
||||
|
||||
// BBS
|
||||
static const t_config_enum_values s_keys_map_FirstLayerSeq = {
|
||||
static const t_config_enum_values s_keys_map_LayerSeq = {
|
||||
{ "Auto", flsAuto },
|
||||
{ "Customize", flsCutomize },
|
||||
};
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FirstLayerSeq)
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(LayerSeq)
|
||||
|
||||
static t_config_enum_values s_keys_map_NozzleType {
|
||||
{ "undefine", int(NozzleType::ntUndefine) },
|
||||
|
|
@ -770,16 +770,37 @@ void PrintConfigDef::init_fff_params()
|
|||
def->max = 16;
|
||||
def->set_default_value(new ConfigOptionInts{0});
|
||||
|
||||
def = this->add("other_layers_print_sequence", coInts);
|
||||
def->label = L("Other layers print sequence");
|
||||
def->min = 0;
|
||||
def->max = 16;
|
||||
def->set_default_value(new ConfigOptionInts{0});
|
||||
|
||||
def = this->add("other_layers_print_sequence_nums", coInt);
|
||||
def->label = L("The number of other layers print sequence");
|
||||
def->set_default_value(new ConfigOptionInt{0});
|
||||
|
||||
def = this->add("first_layer_sequence_choice", coEnum);
|
||||
def->category = L("Quality");
|
||||
def->label = L("First layer filament sequence");
|
||||
def->enum_keys_map = &ConfigOptionEnum<FirstLayerSeq>::get_enum_values();
|
||||
def->enum_keys_map = &ConfigOptionEnum<LayerSeq>::get_enum_values();
|
||||
def->enum_values.push_back("Auto");
|
||||
def->enum_values.push_back("Customize");
|
||||
def->enum_labels.push_back(L("Auto"));
|
||||
def->enum_labels.push_back(L("Customize"));
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionEnum<FirstLayerSeq>(flsAuto));
|
||||
def->set_default_value(new ConfigOptionEnum<LayerSeq>(flsAuto));
|
||||
|
||||
def = this->add("other_layers_sequence_choice", coEnum);
|
||||
def->category = L("Quality");
|
||||
def->label = L("Other layers filament sequence");
|
||||
def->enum_keys_map = &ConfigOptionEnum<LayerSeq>::get_enum_values();
|
||||
def->enum_values.push_back("Auto");
|
||||
def->enum_values.push_back("Customize");
|
||||
def->enum_labels.push_back(L("Auto"));
|
||||
def->enum_labels.push_back(L("Customize"));
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionEnum<LayerSeq>(flsAuto));
|
||||
|
||||
def = this->add("before_layer_change_gcode", coString);
|
||||
def->label = L("Before layer change G-code");
|
||||
|
|
@ -1580,6 +1601,14 @@ void PrintConfigDef::init_fff_params()
|
|||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(40));
|
||||
|
||||
def = this->add("nozzle_height", coFloat);
|
||||
def->label = L("Nozzle height");
|
||||
def->tooltip = L("The height of nozzle tip.");
|
||||
def->sidetext = L("mm");
|
||||
def->min = 0;
|
||||
def->mode = comDevelop;
|
||||
def->set_default_value(new ConfigOptionFloat(4));
|
||||
|
||||
def = this->add("bed_mesh_min", coPoint);
|
||||
def->label = L("Bed mesh min");
|
||||
def->tooltip = L(
|
||||
|
|
@ -2390,6 +2419,15 @@ def = this->add("filament_loading_speed", coFloats);
|
|||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(30));
|
||||
|
||||
// BBS
|
||||
def = this->add("precise_z_height", coBool);
|
||||
def->label = L("Precise Z height");
|
||||
def->tooltip = L("Enable this to get precise z height of object after slicing. "
|
||||
"It will get the precise object height by fine-tuning the layer heights of the last few layers. "
|
||||
"Note that this is an experimental parameter.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(0));
|
||||
|
||||
// BBS
|
||||
def = this->add("enable_arc_fitting", coBool);
|
||||
def->label = L("Arc fitting");
|
||||
|
|
@ -3393,6 +3431,25 @@ def = this->add("filament_loading_speed", coFloats);
|
|||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionFloats { 0.8 });
|
||||
|
||||
def = this->add("enable_long_retraction_when_cut",coInt);
|
||||
def->mode = comDevelop;
|
||||
def->set_default_value(new ConfigOptionInt {0});
|
||||
|
||||
def = this->add("long_retractions_when_cut", coBools);
|
||||
def->label = L("Long retraction when cut(experimental)");
|
||||
def->tooltip = L("Experimental feature.Retracting and cutting off the filament at a longer distance during changes to minimize purge."
|
||||
"While this reduces flush significantly, it may also raise the risk of nozzle clogs or other printing problems.");
|
||||
def->mode = comDevelop;
|
||||
def->set_default_value(new ConfigOptionBools {false});
|
||||
|
||||
def = this->add("retraction_distances_when_cut",coFloats);
|
||||
def->label = L("Retraction distance when cut");
|
||||
def->tooltip = L("Experimental feature.Retraction length before cutting off during filament change");
|
||||
def->mode = comDevelop;
|
||||
def->min = 10;
|
||||
def->max = 18;
|
||||
def->set_default_value(new ConfigOptionFloats {18});
|
||||
|
||||
def = this->add("retract_length_toolchange", coFloats);
|
||||
def->label = L("Length");
|
||||
//def->full_label = L("Retraction Length (Toolchange)");
|
||||
|
|
@ -4929,7 +4986,10 @@ def = this->add("filament_loading_speed", coFloats);
|
|||
// bools
|
||||
"retract_when_changing_layer", "wipe",
|
||||
// percents
|
||||
"retract_before_wipe"}) {
|
||||
"retract_before_wipe",
|
||||
"long_retractions_when_cut",
|
||||
"retraction_distances_when_cut"
|
||||
}) {
|
||||
auto it_opt = options.find(opt_key);
|
||||
assert(it_opt != options.end());
|
||||
def = this->add_nullable(std::string("filament_") + opt_key, it_opt->second.type);
|
||||
|
|
@ -4940,9 +5000,13 @@ def = this->add("filament_loading_speed", coFloats);
|
|||
def->enum_keys_map = it_opt->second.enum_keys_map;
|
||||
def->enum_labels = it_opt->second.enum_labels;
|
||||
def->enum_values = it_opt->second.enum_values;
|
||||
def->min = it_opt->second.min;
|
||||
def->max = it_opt->second.max;
|
||||
//BBS: shown specific filament retract config because we hide the machine retract into comDevelop mode
|
||||
if ((strcmp(opt_key, "retraction_length") == 0) ||
|
||||
(strcmp(opt_key, "z_hop") == 0))
|
||||
(strcmp(opt_key, "z_hop") == 0)||
|
||||
(strcmp(opt_key, "long_retractions_when_cut") == 0)||
|
||||
(strcmp(opt_key, "retraction_distances_when_cut") == 0))
|
||||
def->mode = comSimple;
|
||||
else
|
||||
def->mode = comAdvanced;
|
||||
|
|
@ -4973,17 +5037,19 @@ void PrintConfigDef::init_extruder_option_keys()
|
|||
"retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed",
|
||||
"retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
|
||||
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour",
|
||||
"default_filament_profile"
|
||||
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"
|
||||
};
|
||||
|
||||
m_extruder_retract_keys = {
|
||||
"deretraction_speed",
|
||||
"long_retractions_when_cut",
|
||||
"retract_before_wipe",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
"retract_lift_enforce",
|
||||
"retract_restart_extra",
|
||||
"retract_when_changing_layer",
|
||||
"retraction_distances_when_cut",
|
||||
"retraction_length",
|
||||
"retraction_minimum_travel",
|
||||
"retraction_speed",
|
||||
|
|
@ -5002,17 +5068,19 @@ void PrintConfigDef::init_filament_option_keys()
|
|||
"retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed",
|
||||
"retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance",
|
||||
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour",
|
||||
"default_filament_profile"/*,"filament_seam_gap"*/
|
||||
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/
|
||||
};
|
||||
|
||||
m_filament_retract_keys = {
|
||||
"deretraction_speed",
|
||||
"long_retractions_when_cut",
|
||||
"retract_before_wipe",
|
||||
"retract_lift_above",
|
||||
"retract_lift_below",
|
||||
"retract_lift_enforce",
|
||||
"retract_restart_extra",
|
||||
"retract_when_changing_layer",
|
||||
"retraction_distances_when_cut",
|
||||
"retraction_length",
|
||||
"retraction_minimum_travel",
|
||||
"retraction_speed",
|
||||
|
|
@ -5792,7 +5860,8 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
"remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration",
|
||||
"support_transition_line_width", "support_transition_speed", "bed_temperature", "bed_temperature_initial_layer",
|
||||
"can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector", "adaptive_layer_height",
|
||||
"z_hop_type", "z_lift_type", "bed_temperature_difference",
|
||||
"z_hop_type", "z_lift_type", "bed_temperature_difference","long_retraction_when_cut",
|
||||
"retraction_distance_when_cut",
|
||||
"extruder_type",
|
||||
"internal_bridge_support_thickness","extruder_clearance_max_radius", "top_area_threshold", "reduce_wall_solid_infill"
|
||||
};
|
||||
|
|
@ -6287,6 +6356,8 @@ std::map<std::string, std::string> validate(const FullPrintConfig &cfg, bool und
|
|||
if (cfg.extruder_clearance_height_to_lid <= 0) {
|
||||
error_message.emplace("extruder_clearance_height_to_lid", L("invalid value ") + std::to_string(cfg.extruder_clearance_height_to_lid));
|
||||
}
|
||||
if (cfg.nozzle_height <= 0)
|
||||
error_message.emplace("nozzle_height", L("invalid value ") + std::to_string(cfg.nozzle_height));
|
||||
|
||||
// --extrusion-multiplier
|
||||
for (double em : cfg.filament_flow_ratio.values)
|
||||
|
|
@ -6848,6 +6919,12 @@ CLIMiscConfigDef::CLIMiscConfigDef()
|
|||
def->tooltip = "MakerLab version to generate this 3mf";
|
||||
def->cli_params = "version";
|
||||
def->set_default_value(new ConfigOptionString());
|
||||
|
||||
def = this->add("allow_newer_file", coBool);
|
||||
def->label = "Allow 3mf with newer version to be sliced";
|
||||
def->tooltip = "Allow 3mf with newer version to be sliced";
|
||||
def->cli_params = "option";
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
}
|
||||
|
||||
const CLIActionsConfigDef cli_actions_config_def;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,13 @@ enum SupportMaterialStyle {
|
|||
smsDefault, smsGrid, smsSnug, smsTreeSlim, smsTreeStrong, smsTreeHybrid, smsOrganic,
|
||||
};
|
||||
|
||||
enum LongRectrationLevel
|
||||
{
|
||||
Disabled=0,
|
||||
EnableMachine,
|
||||
EnableFilament
|
||||
};
|
||||
|
||||
enum SupportMaterialInterfacePattern {
|
||||
smipAuto, smipRectilinear, smipConcentric, smipRectilinearInterlaced, smipGrid
|
||||
};
|
||||
|
|
@ -268,7 +275,7 @@ enum BedType {
|
|||
};
|
||||
|
||||
// BBS
|
||||
enum FirstLayerSeq {
|
||||
enum LayerSeq {
|
||||
flsAuto,
|
||||
flsCutomize
|
||||
};
|
||||
|
|
@ -854,6 +861,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionFloat, top_surface_jerk))
|
||||
((ConfigOptionFloat, initial_layer_jerk))
|
||||
((ConfigOptionFloat, travel_jerk))
|
||||
((ConfigOptionBool, precise_z_height))
|
||||
)
|
||||
|
||||
// This object is mapped to Perl as Slic3r::Config::PrintRegion.
|
||||
|
|
@ -1051,6 +1059,9 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionPercents, retract_before_wipe))
|
||||
((ConfigOptionFloats, retraction_length))
|
||||
((ConfigOptionFloats, retract_length_toolchange))
|
||||
((ConfigOptionInt, enable_long_retraction_when_cut))
|
||||
((ConfigOptionFloats, retraction_distances_when_cut))
|
||||
((ConfigOptionBools, long_retractions_when_cut))
|
||||
((ConfigOptionFloats, z_hop))
|
||||
// BBS
|
||||
((ConfigOptionEnumsGeneric, z_hop_types))
|
||||
|
|
@ -1156,12 +1167,15 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
|||
((ConfigOptionEnum<PrintSequence>,print_sequence))
|
||||
((ConfigOptionEnum<PrintOrder>, print_order))
|
||||
((ConfigOptionInts, first_layer_print_sequence))
|
||||
((ConfigOptionInts, other_layers_print_sequence))
|
||||
((ConfigOptionInt, other_layers_print_sequence_nums))
|
||||
((ConfigOptionBools, slow_down_for_layer_cooling))
|
||||
((ConfigOptionInts, close_fan_the_first_x_layers))
|
||||
((ConfigOptionEnum<DraftShield>, draft_shield))
|
||||
((ConfigOptionFloat, extruder_clearance_height_to_rod))//BBs
|
||||
((ConfigOptionFloat, extruder_clearance_height_to_lid))//BBS
|
||||
((ConfigOptionFloat, extruder_clearance_radius))
|
||||
((ConfigOptionFloat, nozzle_height))
|
||||
((ConfigOptionStrings, extruder_colour))
|
||||
((ConfigOptionPoints, extruder_offset))
|
||||
((ConfigOptionBools, reduce_fan_stop_start_freq))
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Transfor
|
|||
// snug height and an approximate bounding box in XY.
|
||||
BoundingBoxf3 bbox = model_object->raw_bounding_box();
|
||||
Vec3d bbox_center = bbox.center();
|
||||
|
||||
// We may need to rotate the bbox / bbox_center from the original instance to the current instance.
|
||||
double z_diff = Geometry::rotation_diff_z(model_object->instances.front()->get_rotation(), instances.front().model_instance->get_rotation());
|
||||
if (std::abs(z_diff) > EPSILON) {
|
||||
|
|
@ -109,7 +110,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Transfor
|
|||
m_center_offset = Point::new_scale(bbox_center.x(), bbox_center.y());
|
||||
// Size of the transformed mesh. This bounding may not be snug in XY plane, but it is snug in Z.
|
||||
m_size = (bbox.size() * (1. / SCALING_FACTOR)).cast<coord_t>();
|
||||
m_size.z() = coord_t(model_object->max_z() * (1. / SCALING_FACTOR));
|
||||
m_max_z = scaled(model_object->instance_bounding_box(0).max(2));
|
||||
|
||||
this->set_instances(std::move(instances));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -810,7 +810,7 @@ void PrintObject::slice()
|
|||
m_print->throw_if_canceled();
|
||||
m_typed_slices = false;
|
||||
this->clear_layers();
|
||||
m_layers = new_layers(this, generate_object_layers(m_slicing_params, layer_height_profile));
|
||||
m_layers = new_layers(this, generate_object_layers(m_slicing_params, layer_height_profile, m_config.precise_z_height.value));
|
||||
this->slice_volumes();
|
||||
m_print->throw_if_canceled();
|
||||
int firstLayerReplacedBy = 0;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ struct FilamentInfo
|
|||
float used_g;
|
||||
int tray_id; // start with 0
|
||||
float distance;
|
||||
int ctype = 0;
|
||||
std::vector<std::string> colors = std::vector<std::string>();
|
||||
int mapping_result = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -631,10 +631,104 @@ void adjust_layer_height_profile(
|
|||
#endif /* _DEBUG */
|
||||
}
|
||||
|
||||
bool adjust_layer_series_to_align_object_height(const SlicingParameters &slicing_params, std::vector<coordf_t>& layer_series)
|
||||
{
|
||||
coordf_t object_height = slicing_params.object_print_z_height();
|
||||
if (is_approx(layer_series.back(), object_height))
|
||||
return true;
|
||||
|
||||
// need at least 5 + 1(first_layer) layers to adjust the height
|
||||
size_t layer_size = layer_series.size();
|
||||
if (layer_size < 12)
|
||||
return false;
|
||||
|
||||
std::vector<coordf_t> last_5_layers_heght;
|
||||
for (size_t i = 0; i < 5; ++i) {
|
||||
last_5_layers_heght.emplace_back(layer_series[layer_size - 10 + 2 * i + 1] - layer_series[layer_size - 10 + 2 * i]);
|
||||
}
|
||||
|
||||
coordf_t gap = abs(layer_series.back() - object_height);
|
||||
std::vector<bool> can_adjust(5, true); // to record whether every layer can adjust layer height
|
||||
bool taller_than_object = layer_series.back() < object_height;
|
||||
|
||||
auto get_valid_size = [&can_adjust]() -> int {
|
||||
int valid_size = 0;
|
||||
for (auto b_adjust : can_adjust) {
|
||||
valid_size += b_adjust ? 1 : 0;
|
||||
}
|
||||
return valid_size;
|
||||
};
|
||||
|
||||
auto adjust_layer_height = [&slicing_params, &last_5_layers_heght, &can_adjust, &get_valid_size, &taller_than_object](coordf_t gap) -> coordf_t {
|
||||
coordf_t delta_gap = gap / get_valid_size();
|
||||
coordf_t remain_gap = 0;
|
||||
for (size_t i = 0; i < last_5_layers_heght.size(); ++i) {
|
||||
coordf_t& l_height = last_5_layers_heght[i];
|
||||
if (taller_than_object) {
|
||||
if (can_adjust[i] && is_approx(l_height, slicing_params.max_layer_height)) {
|
||||
remain_gap += delta_gap;
|
||||
can_adjust[i] = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (can_adjust[i] && l_height + delta_gap > slicing_params.max_layer_height) {
|
||||
remain_gap += l_height + delta_gap - slicing_params.max_layer_height;
|
||||
l_height = slicing_params.max_layer_height;
|
||||
can_adjust[i] = false;
|
||||
}
|
||||
else {
|
||||
l_height += delta_gap;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (can_adjust[i] && is_approx(l_height, slicing_params.min_layer_height)) {
|
||||
remain_gap += delta_gap;
|
||||
can_adjust[i] = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (can_adjust[i] && l_height - delta_gap < slicing_params.min_layer_height) {
|
||||
remain_gap += slicing_params.min_layer_height + delta_gap - l_height;
|
||||
l_height = slicing_params.min_layer_height;
|
||||
can_adjust[i] = false;
|
||||
}
|
||||
else {
|
||||
l_height -= delta_gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
return remain_gap;
|
||||
};
|
||||
|
||||
while (gap > 0) {
|
||||
int valid_size = get_valid_size();
|
||||
if (valid_size == 0) {
|
||||
// 5 layers can not adjust z within valid layer height
|
||||
return false;
|
||||
}
|
||||
|
||||
gap = adjust_layer_height(gap);
|
||||
if (is_approx(gap, 0.0)) {
|
||||
// adjust succeed
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < last_5_layers_heght.size(); ++i) {
|
||||
if (i > 0) {
|
||||
layer_series[layer_size - 10 + 2 * i] = layer_series[layer_size - 10 + 2 * i - 1];
|
||||
}
|
||||
layer_series[layer_size - 10 + 2 * i + 1] = layer_series[layer_size - 10 + 2 * i] + last_5_layers_heght[i];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Produce object layers as pairs of low / high layer boundaries, stored into a linear vector.
|
||||
std::vector<coordf_t> generate_object_layers(
|
||||
const SlicingParameters &slicing_params,
|
||||
const std::vector<coordf_t> &layer_height_profile)
|
||||
const std::vector<coordf_t> &layer_height_profile,
|
||||
bool is_precise_z_height)
|
||||
{
|
||||
assert(! layer_height_profile.empty());
|
||||
|
||||
|
|
@ -683,7 +777,8 @@ std::vector<coordf_t> generate_object_layers(
|
|||
out.push_back(print_z);
|
||||
}
|
||||
|
||||
//FIXME Adjust the last layer to align with the top object layer exactly?
|
||||
if (is_precise_z_height)
|
||||
adjust_layer_series_to_align_object_height(slicing_params, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,8 @@ void adjust_layer_height_profile(
|
|||
// The object layers are based at z=0, ignoring the raft layers.
|
||||
std::vector<coordf_t> generate_object_layers(
|
||||
const SlicingParameters &slicing_params,
|
||||
const std::vector<coordf_t> &layer_height_profile);
|
||||
const std::vector<coordf_t> &layer_height_profile,
|
||||
bool is_precise_z_height);
|
||||
|
||||
// Check whether the layer height profile describes a fixed layer height profile.
|
||||
bool check_object_layers_fixed(
|
||||
|
|
|
|||
|
|
@ -224,21 +224,21 @@ bool TriangleMesh::from_stl(stl_file& stl, bool repair)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TriangleMesh::ReadSTLFile(const char* input_file, bool repair, ImportstlProgressFn stlFn)
|
||||
{
|
||||
bool TriangleMesh::ReadSTLFile(const char *input_file, bool repair, ImportstlProgressFn stlFn, int custom_header_length)
|
||||
{
|
||||
stl_file stl;
|
||||
if (! stl_open(&stl, input_file, stlFn))
|
||||
if (!stl_open(&stl, input_file, stlFn, custom_header_length))
|
||||
return false;
|
||||
return from_stl(stl, repair);
|
||||
}
|
||||
|
||||
bool TriangleMesh::write_ascii(const char* output_file)
|
||||
{
|
||||
{
|
||||
return its_write_stl_ascii(output_file, "", this->its);
|
||||
}
|
||||
|
||||
bool TriangleMesh::write_binary(const char* output_file)
|
||||
{
|
||||
{
|
||||
return its_write_stl_binary(output_file, "", this->its);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public:
|
|||
explicit TriangleMesh(indexed_triangle_set &&M, const RepairedMeshErrors& repaired_errors = RepairedMeshErrors());
|
||||
void clear() { this->its.clear(); this->m_stats.clear(); }
|
||||
bool from_stl(stl_file& stl, bool repair = true);
|
||||
bool ReadSTLFile(const char* input_file, bool repair = true, ImportstlProgressFn stlFn = nullptr);
|
||||
bool ReadSTLFile(const char *input_file, bool repair = true, ImportstlProgressFn stlFn = nullptr, int custom_header_length = 80);
|
||||
bool write_ascii(const char* output_file);
|
||||
bool write_binary(const char* output_file);
|
||||
float volume();
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#define CLI_OBJECT_ARRANGE_FAILED -21
|
||||
#define CLI_OBJECT_ORIENT_FAILED -22
|
||||
#define CLI_MODIFIED_PARAMS_TO_PRINTER -23
|
||||
#define CLI_FILE_VERSION_NOT_SUPPORTED -24
|
||||
|
||||
|
||||
#define CLI_NO_SUITABLE_OBJECTS -50
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ struct Calib_Params
|
|||
CalibMode mode;
|
||||
};
|
||||
|
||||
enum FlowRatioCalibrationType {
|
||||
COMPLETE_CALIBRATION = 0,
|
||||
FINE_CALIBRATION,
|
||||
};
|
||||
|
||||
class X1CCalibInfos
|
||||
{
|
||||
public:
|
||||
|
|
@ -78,6 +83,7 @@ struct PrinterCaliInfo
|
|||
bool cali_finished = true;
|
||||
float cache_flow_ratio;
|
||||
std::vector<CaliPresetInfo> selected_presets;
|
||||
FlowRatioCalibrationType cache_flow_rate_calibration_type = FlowRatioCalibrationType::COMPLETE_CALIBRATION;
|
||||
};
|
||||
|
||||
class PACalibResult
|
||||
|
|
|
|||
|
|
@ -251,8 +251,11 @@ void AMSMaterialsSetting::create_panel_normal(wxWindow* parent)
|
|||
m_panel_SN->Fit();
|
||||
|
||||
wxBoxSizer* m_tip_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_tip_readonly = new wxStaticText(parent, wxID_ANY, _L("Setting AMS slot information while printing is not supported"), wxDefaultPosition, wxSize(-1, AMS_MATERIALS_SETTING_INPUT_SIZE.y));
|
||||
m_tip_readonly = new Label(parent, _L("Setting AMS slot information while printing is not supported"));
|
||||
m_tip_readonly->SetForegroundColour(*wxBLACK);
|
||||
m_tip_readonly->SetBackgroundColour(*wxWHITE);
|
||||
m_tip_readonly->SetMinSize(wxSize(FromDIP(380), -1));
|
||||
m_tip_readonly->SetMaxSize(wxSize(FromDIP(380), -1));
|
||||
m_tip_readonly->Hide();
|
||||
m_tip_sizer->Add(m_tip_readonly, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(20));
|
||||
|
||||
|
|
@ -409,6 +412,7 @@ void AMSMaterialsSetting::enable_confirm_button(bool en)
|
|||
else {
|
||||
m_tip_readonly->SetLabelText(_L("Setting Virtual slot information while printing is not supported"));
|
||||
}
|
||||
m_tip_readonly->Wrap(FromDIP(380));
|
||||
m_tip_readonly->Show(!en);
|
||||
}
|
||||
}
|
||||
|
|
@ -443,7 +447,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
|||
}
|
||||
|
||||
// set k / n value
|
||||
if (obj->get_printer_series() != PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version <= -1 && obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||
// set extrusion cali ratio
|
||||
int cali_tray_id = ams_id * 4 + tray_id;
|
||||
|
||||
|
|
@ -561,7 +565,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
wxString k_text = m_input_k_val->GetTextCtrl()->GetValue();
|
||||
wxString n_text = m_input_n_val->GetTextCtrl()->GetValue();
|
||||
|
||||
if ((obj->get_printer_series() != PrinterSeries::SERIES_X1) && !ExtrusionCalibration::check_k_validation(k_text)) {
|
||||
if (obj->cali_version <= -1 && (obj->get_printer_series() != PrinterSeries::SERIES_X1) && !ExtrusionCalibration::check_k_validation(k_text)) {
|
||||
wxString k_tips = _L("Please input a valid value (K in 0~0.3)");
|
||||
wxString kn_tips = _L("Please input a valid value (K in 0~0.3, N in 0.6~2.0)");
|
||||
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
|
|
@ -586,7 +590,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
;
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
PACalibIndexInfo select_index_info;
|
||||
select_index_info.tray_id = tray_id;
|
||||
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
|
|
@ -625,7 +629,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
;
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
PACalibIndexInfo select_index_info;
|
||||
select_index_info.tray_id = cali_tray_id;
|
||||
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
|
|
@ -728,7 +732,7 @@ void AMSMaterialsSetting::update_widgets()
|
|||
else
|
||||
m_panel_normal->Hide();
|
||||
m_panel_kn->Show();
|
||||
} else if (obj && (obj->ams_support_virtual_tray || (obj->get_printer_series() == PrinterSeries::SERIES_X1))) {
|
||||
} else if (obj && (obj->ams_support_virtual_tray || obj->cali_version >= 0)) {
|
||||
m_panel_normal->Show();
|
||||
m_panel_kn->Show();
|
||||
} else {
|
||||
|
|
@ -774,8 +778,12 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||
|
||||
|
||||
std::set<std::string> filament_id_set;
|
||||
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
||||
std::ostringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), nozzle_diameter_str);
|
||||
|
||||
if (preset_bundle) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
|
||||
for (auto filament_it = preset_bundle->filaments.begin(); filament_it != preset_bundle->filaments.end(); filament_it++) {
|
||||
|
|
@ -787,79 +795,64 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||
if (preset_bundle->filaments.get_preset_base(*filament_it) != &preset || (!filament_it->is_system && !obj->is_support_user_preset)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ConfigOption * printer_opt = filament_it->config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
for (auto printer_str : printer_strs->values) {
|
||||
if (printer_names.find(printer_str) != printer_names.end()) {
|
||||
if (filament_id_set.find(filament_it->filament_id) != filament_id_set.end()) {
|
||||
continue;
|
||||
} else {
|
||||
filament_id_set.insert(filament_it->filament_id);
|
||||
// name matched
|
||||
if (filament_it->is_system) {
|
||||
filament_items.push_back(filament_it->alias);
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[filament_it->alias] = filament_infos;
|
||||
} else {
|
||||
char target = '@';
|
||||
size_t pos = filament_it->name.find(target);
|
||||
if (pos != std::string::npos) {
|
||||
std::string user_preset_alias = filament_it->name.substr(0, pos - 1);
|
||||
wxString wx_user_preset_alias = wxString(user_preset_alias.c_str(), wxConvUTF8);
|
||||
user_preset_alias = wx_user_preset_alias.ToStdString();
|
||||
|
||||
for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) {
|
||||
// filter by system preset
|
||||
if (!printer_it->is_system) continue;
|
||||
// get printer_model
|
||||
ConfigOption* printer_model_opt = printer_it->config.option("printer_model");
|
||||
ConfigOptionString* printer_model_str = dynamic_cast<ConfigOptionString*>(printer_model_opt);
|
||||
if (!printer_model_str )
|
||||
continue;
|
||||
|
||||
// use printer_model as printer type
|
||||
if (printer_model_str->value != MachineObject::get_preset_printer_model_name(obj->printer_type))
|
||||
continue;
|
||||
ConfigOption* printer_opt = filament_it->config.option("compatible_printers");
|
||||
ConfigOptionStrings* printer_strs = dynamic_cast<ConfigOptionStrings*>(printer_opt);
|
||||
for (auto printer_str : printer_strs->values) {
|
||||
if (printer_it->name == printer_str) {
|
||||
if (filament_id_set.find(filament_it->filament_id) != filament_id_set.end()) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
filament_id_set.insert(filament_it->filament_id);
|
||||
// name matched
|
||||
if (filament_it->is_system) {
|
||||
filament_items.push_back(filament_it->alias);
|
||||
filament_items.push_back(user_preset_alias);
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[filament_it->alias] = filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[user_preset_alias] = filament_infos;
|
||||
}
|
||||
else {
|
||||
char target = '@';
|
||||
size_t pos = filament_it->name.find(target);
|
||||
if (pos != std::string::npos) {
|
||||
std::string user_preset_alias = filament_it->name.substr(0, pos-1);
|
||||
wxString wx_user_preset_alias = wxString(user_preset_alias.c_str(), wxConvUTF8);
|
||||
user_preset_alias = wx_user_preset_alias.ToStdString();
|
||||
|
||||
filament_items.push_back(user_preset_alias);
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[user_preset_alias] = filament_infos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (filament_it->filament_id == ams_filament_id) {
|
||||
selection_idx = idx;
|
||||
|
||||
// update if nozzle_temperature_range is found
|
||||
ConfigOption* opt_min = filament_it->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
ConfigOptionInts* opt_min_ints = dynamic_cast<ConfigOptionInts*>(opt_min);
|
||||
if (opt_min_ints) {
|
||||
wxString text_nozzle_temp_min = wxString::Format("%d", opt_min_ints->get_at(0));
|
||||
m_input_nozzle_min->GetTextCtrl()->SetValue(text_nozzle_temp_min);
|
||||
}
|
||||
}
|
||||
ConfigOption* opt_max = filament_it->config.option("nozzle_temperature_range_high");
|
||||
if (opt_max) {
|
||||
ConfigOptionInts* opt_max_ints = dynamic_cast<ConfigOptionInts*>(opt_max);
|
||||
if (opt_max_ints) {
|
||||
wxString text_nozzle_temp_max = wxString::Format("%d", opt_max_ints->get_at(0));
|
||||
m_input_nozzle_max->GetTextCtrl()->SetValue(text_nozzle_temp_max);
|
||||
}
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (filament_it->filament_id == ams_filament_id) {
|
||||
selection_idx = idx;
|
||||
|
||||
// update if nozzle_temperature_range is found
|
||||
ConfigOption *opt_min = filament_it->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
|
||||
if (opt_min_ints) {
|
||||
wxString text_nozzle_temp_min = wxString::Format("%d", opt_min_ints->get_at(0));
|
||||
m_input_nozzle_min->GetTextCtrl()->SetValue(text_nozzle_temp_min);
|
||||
}
|
||||
}
|
||||
ConfigOption *opt_max = filament_it->config.option("nozzle_temperature_range_high");
|
||||
if (opt_max) {
|
||||
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
|
||||
if (opt_max_ints) {
|
||||
wxString text_nozzle_temp_max = wxString::Format("%d", opt_max_ints->get_at(0));
|
||||
m_input_nozzle_max->GetTextCtrl()->SetValue(text_nozzle_temp_max);
|
||||
}
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -884,7 +877,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||
m_readonly_filament->Hide();
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
m_title_pa_profile->Show();
|
||||
m_comboBox_cali_result->Show();
|
||||
m_input_k_val->Disable();
|
||||
|
|
@ -943,12 +936,26 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||
m_filament_type = "";
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
if (preset_bundle) {
|
||||
std::ostringstream stream;
|
||||
if (obj)
|
||||
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type),
|
||||
nozzle_diameter_str);
|
||||
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
|
||||
if (!m_comboBox_filament->GetValue().IsEmpty()) {
|
||||
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
|
||||
std::string filament_id = filament_item.filament_id;
|
||||
if (it->filament_id.compare(filament_id) == 0) {
|
||||
|
||||
bool has_compatible_printer = false;
|
||||
std::string preset_name = it->name;
|
||||
for (std::string printer_name : printer_names) {
|
||||
if (preset_name.find(printer_name) != std::string::npos) {
|
||||
has_compatible_printer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!it->is_system && !has_compatible_printer) continue;
|
||||
// ) if nozzle_temperature_range is found
|
||||
ConfigOption* opt_min = it->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
|
|
@ -1039,7 +1046,7 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||
m_pa_profile_items.clear();
|
||||
m_comboBox_cali_result->SetValue(wxEmptyString);
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString);
|
||||
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
||||
for (auto cali_item : cali_history) {
|
||||
|
|
@ -1442,7 +1449,7 @@ void ColorPickerPopup::on_custom_clr_picker(wxMouseEvent& event)
|
|||
m_clrData->GetColour().Red(),
|
||||
m_clrData->GetColour().Green(),
|
||||
m_clrData->GetColour().Blue(),
|
||||
254
|
||||
255
|
||||
);
|
||||
|
||||
if (picker_color.Alpha() == 0) {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ protected:
|
|||
wxStaticBitmap * bitmap_min_degree;
|
||||
Button * m_button_reset;
|
||||
Button * m_button_confirm;
|
||||
wxStaticText* m_tip_readonly;
|
||||
Label* m_tip_readonly;
|
||||
Button * m_button_close;
|
||||
wxColourData * m_clrData;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,29 +21,31 @@ void AMSSetting::create()
|
|||
auto m_static_ams_settings = new wxStaticText(this, wxID_ANY, _L("AMS Settings"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_static_ams_settings->SetFont(::Label::Head_14);
|
||||
m_static_ams_settings->SetForegroundColour(AMS_SETTING_GREY800);
|
||||
m_sizer_main->Add(0,0,0,wxTOP,FromDIP(10));
|
||||
m_sizer_main->Add(m_static_ams_settings, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(24));
|
||||
|
||||
|
||||
m_panel_body = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL);
|
||||
m_panel_body->SetBackgroundColour(*wxWHITE);
|
||||
wxBoxSizer *m_sizerl_body = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_panel_Insert_material = new wxPanel(m_panel_body, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL);
|
||||
m_panel_Insert_material->SetBackgroundColour(*wxWHITE);
|
||||
wxBoxSizer* m_sizer_main_Insert_material = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
// checkbox area 1
|
||||
wxBoxSizer *m_sizer_Insert_material = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_checkbox_Insert_material_auto_read = new ::CheckBox(m_panel_body);
|
||||
m_checkbox_Insert_material_auto_read = new ::CheckBox(m_panel_Insert_material);
|
||||
m_checkbox_Insert_material_auto_read->Bind(wxEVT_TOGGLEBUTTON, &AMSSetting::on_insert_material_read, this);
|
||||
m_sizer_Insert_material->Add(m_checkbox_Insert_material_auto_read, 0, wxTOP, 1);
|
||||
|
||||
m_sizer_Insert_material->Add(0, 0, 0, wxLEFT, 12);
|
||||
|
||||
m_title_Insert_material_auto_read = new wxStaticText(m_panel_body, wxID_ANY, _L("Insertion update"),
|
||||
m_title_Insert_material_auto_read = new wxStaticText(m_panel_Insert_material, wxID_ANY, _L("Insertion update"),
|
||||
wxDefaultPosition, wxDefaultSize, 0);
|
||||
|
||||
m_title_Insert_material_auto_read->SetFont(::Label::Head_13);
|
||||
m_title_Insert_material_auto_read->SetForegroundColour(AMS_SETTING_GREY800);
|
||||
m_title_Insert_material_auto_read->Wrap(AMS_SETTING_BODY_WIDTH);
|
||||
m_sizer_Insert_material->Add(m_title_Insert_material_auto_read, 1, wxALL | wxEXPAND, 0);
|
||||
m_sizer_Insert_material->Add(m_title_Insert_material_auto_read, 0, wxALL | wxEXPAND, 0);
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,7 +55,7 @@ void AMSSetting::create()
|
|||
m_sizer_Insert_material_tip->Add(0, 0, 0, wxLEFT, 10);
|
||||
|
||||
// tip line1
|
||||
m_tip_Insert_material_line1 = new Label(m_panel_body,
|
||||
m_tip_Insert_material_line1 = new Label(m_panel_Insert_material,
|
||||
_L("The AMS will automatically read the filament information when inserting a new Bambu Lab filament. This takes about 20 seconds.")
|
||||
);
|
||||
m_tip_Insert_material_line1->SetFont(::Label::Body_13);
|
||||
|
|
@ -64,8 +66,8 @@ void AMSSetting::create()
|
|||
m_sizer_Insert_material_tip_inline->Add(m_tip_Insert_material_line1, 0, wxEXPAND, 0);
|
||||
|
||||
// tip line2
|
||||
m_tip_Insert_material_line2 = new Label(m_panel_body,
|
||||
_L("Note: if new filament is inserted during printing, the AMS will not automatically read any information until printing is completed.")
|
||||
m_tip_Insert_material_line2 = new Label(m_panel_Insert_material,
|
||||
_L("Note: if a new filament is inserted during printing, the AMS will not automatically read any information until printing is completed.")
|
||||
);
|
||||
m_tip_Insert_material_line2->SetFont(::Label::Body_13);
|
||||
m_tip_Insert_material_line2->SetForegroundColour(AMS_SETTING_GREY700);
|
||||
|
|
@ -74,8 +76,8 @@ void AMSSetting::create()
|
|||
m_tip_Insert_material_line2->Hide();
|
||||
m_sizer_Insert_material_tip_inline->Add(m_tip_Insert_material_line2, 0, wxEXPAND | wxTOP, 8);
|
||||
|
||||
// tip line2
|
||||
m_tip_Insert_material_line3 = new Label(m_panel_body,
|
||||
// tip line3
|
||||
m_tip_Insert_material_line3 = new Label(m_panel_Insert_material,
|
||||
_L("When inserting a new filament, the AMS will not automatically read its information, leaving it blank for you to enter manually.")
|
||||
);
|
||||
m_tip_Insert_material_line3->SetFont(::Label::Body_13);
|
||||
|
|
@ -87,7 +89,10 @@ void AMSSetting::create()
|
|||
|
||||
m_sizer_Insert_material_tip->Add(m_sizer_Insert_material_tip_inline, 1, wxALIGN_CENTER, 0);
|
||||
|
||||
|
||||
m_sizer_main_Insert_material->Add(m_sizer_Insert_material, 0, wxEXPAND | wxTOP, FromDIP(4));
|
||||
m_sizer_main_Insert_material->Add(m_sizer_Insert_material_tip, 0, wxEXPAND | wxLEFT | wxTOP, 18);
|
||||
m_panel_Insert_material->SetSizer(m_sizer_main_Insert_material);
|
||||
|
||||
// checkbox area 2
|
||||
wxBoxSizer *m_sizer_starting = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_checkbox_starting_auto_read = new ::CheckBox(m_panel_body);
|
||||
|
|
@ -205,10 +210,7 @@ void AMSSetting::create()
|
|||
m_sizer_remain_block->Add(m_sizer_remain_tip, 0, wxLEFT, 18);
|
||||
m_sizer_remain_block->Add(0, 0, 0, wxTOP, 15);
|
||||
|
||||
m_sizerl_body->Add(m_sizer_Insert_material, 0, wxEXPAND, 0);
|
||||
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
|
||||
m_sizerl_body->Add(m_sizer_Insert_material_tip, 0, wxEXPAND | wxLEFT, 18);
|
||||
m_sizerl_body->Add(0, 0, 0, wxTOP, 15);
|
||||
m_sizerl_body->Add(m_panel_Insert_material, 0, 0, 0);
|
||||
m_sizerl_body->Add(m_sizer_starting, 0, wxEXPAND | wxTOP, FromDIP(8));
|
||||
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
|
||||
m_sizerl_body->Add(m_sizer_starting_tip, 0, wxLEFT, 18);
|
||||
|
|
@ -224,7 +226,10 @@ void AMSSetting::create()
|
|||
m_panel_body->SetSizer(m_sizerl_body);
|
||||
m_panel_body->Layout();
|
||||
m_sizerl_body->Fit(m_panel_body);
|
||||
m_sizer_main->Add(m_panel_body, 1, wxALL | wxEXPAND, FromDIP(24));
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
|
||||
m_sizer_main->Add(m_static_ams_settings, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(24));
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
|
||||
m_sizer_main->Add(m_panel_body, 1, wxBottom | wxLEFT | wxRIGHT | wxEXPAND, FromDIP(24));
|
||||
|
||||
this->SetSizer(m_sizer_main);
|
||||
this->Layout();
|
||||
|
|
@ -245,18 +250,34 @@ void AMSSetting::create()
|
|||
});
|
||||
}
|
||||
|
||||
void AMSSetting::update_insert_material_read_mode(bool selected)
|
||||
void AMSSetting::update_insert_material_read_mode(bool selected, std::string version)
|
||||
{
|
||||
m_checkbox_Insert_material_auto_read->SetValue(selected);
|
||||
if (selected) {
|
||||
m_tip_Insert_material_line1->Show();
|
||||
m_tip_Insert_material_line2->Show();
|
||||
m_tip_Insert_material_line3->Hide();
|
||||
} else {
|
||||
if (!version.empty() && version >= AMS_F1_SUPPORT_INSERTION_UPDATE_DEFAULT) {
|
||||
m_checkbox_Insert_material_auto_read->SetValue(true);
|
||||
m_checkbox_Insert_material_auto_read->Hide();
|
||||
m_title_Insert_material_auto_read->Hide();
|
||||
m_tip_Insert_material_line1->Hide();
|
||||
m_tip_Insert_material_line2->Hide();
|
||||
m_tip_Insert_material_line3->Show();
|
||||
m_tip_Insert_material_line3->Hide();
|
||||
m_panel_Insert_material->Hide();
|
||||
}
|
||||
else {
|
||||
m_panel_Insert_material->Show();
|
||||
m_checkbox_Insert_material_auto_read->SetValue(selected);
|
||||
m_checkbox_Insert_material_auto_read->Show();
|
||||
m_title_Insert_material_auto_read->Show();
|
||||
if (selected) {
|
||||
m_tip_Insert_material_line1->Show();
|
||||
m_tip_Insert_material_line2->Show();
|
||||
m_tip_Insert_material_line3->Hide();
|
||||
}
|
||||
else {
|
||||
m_tip_Insert_material_line1->Hide();
|
||||
m_tip_Insert_material_line2->Hide();
|
||||
m_tip_Insert_material_line3->Show();
|
||||
}
|
||||
}
|
||||
m_panel_Insert_material->Layout();
|
||||
m_sizer_Insert_material_tip_inline->Layout();
|
||||
Layout();
|
||||
Fit();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#define AMS_SETTING_GREY200 wxColour(248, 248, 248)
|
||||
#define AMS_SETTING_BODY_WIDTH FromDIP(380)
|
||||
#define AMS_SETTING_BUTTON_SIZE wxSize(FromDIP(150), FromDIP(24))
|
||||
#define AMS_F1_SUPPORT_INSERTION_UPDATE_DEFAULT std::string("00.00.07.89")
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ public:
|
|||
~AMSSetting();
|
||||
void create();
|
||||
|
||||
void update_insert_material_read_mode(bool selected);
|
||||
void update_insert_material_read_mode(bool selected, std::string version);
|
||||
void update_ams_img(std::string ams_icon_str);
|
||||
void update_starting_read_mode(bool selected);
|
||||
void update_remain_mode(bool selected);
|
||||
|
|
@ -49,6 +50,7 @@ protected:
|
|||
|
||||
protected:
|
||||
wxPanel * m_panel_body;
|
||||
wxPanel* m_panel_Insert_material;
|
||||
CheckBox * m_checkbox_Insert_material_auto_read;
|
||||
wxStaticText *m_title_Insert_material_auto_read;
|
||||
Label* m_tip_Insert_material_line1;
|
||||
|
|
|
|||
|
|
@ -58,11 +58,13 @@ void MaterialItem::msw_rescale() {
|
|||
m_transparent_mitem = ScalableBitmap(this, "transparent_material_item", FromDIP(32));
|
||||
}
|
||||
|
||||
void MaterialItem::set_ams_info(wxColour col, wxString txt)
|
||||
void MaterialItem::set_ams_info(wxColour col, wxString txt, int ctype, std::vector<wxColour> cols)
|
||||
{
|
||||
auto need_refresh = false;
|
||||
if (m_ams_cols != cols) { m_ams_cols = cols; need_refresh = true; }
|
||||
if (m_ams_ctype != ctype) { m_ams_ctype = ctype; need_refresh = true; }
|
||||
if (m_ams_coloul != col) { m_ams_coloul = col; need_refresh = true;}
|
||||
if (m_ams_name != txt) {m_ams_name = txt;need_refresh = true;}
|
||||
if (m_ams_name != txt) { m_ams_name = txt; need_refresh = true; }
|
||||
if (need_refresh) { Refresh();}
|
||||
}
|
||||
|
||||
|
|
@ -140,14 +142,11 @@ void MaterialItem::render(wxDC &dc)
|
|||
|
||||
auto mcolor = m_material_coloul;
|
||||
auto acolor = m_ams_coloul;
|
||||
change_the_opacity(acolor);
|
||||
if (!IsEnabled()) {
|
||||
mcolor = wxColour(0x90, 0x90, 0x90);
|
||||
acolor = wxColour(0x90, 0x90, 0x90);
|
||||
}
|
||||
else {
|
||||
mcolor = m_material_coloul;
|
||||
acolor = m_ams_coloul;
|
||||
}
|
||||
|
||||
// materials name
|
||||
dc.SetFont(::Label::Body_13);
|
||||
|
|
@ -183,8 +182,10 @@ void MaterialItem::render(wxDC &dc)
|
|||
|
||||
void MaterialItem::doRender(wxDC &dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
auto mcolor = m_material_coloul;
|
||||
auto acolor = m_ams_coloul;
|
||||
change_the_opacity(acolor);
|
||||
|
||||
if (mcolor.Alpha() == 0 || acolor.Alpha() == 0) {
|
||||
dc.DrawBitmap(m_transparent_mitem.bmp(), FromDIP(1), FromDIP(1));
|
||||
|
|
@ -194,10 +195,6 @@ void MaterialItem::doRender(wxDC &dc)
|
|||
mcolor = wxColour(0x90, 0x90, 0x90);
|
||||
acolor = wxColour(0x90, 0x90, 0x90);
|
||||
}
|
||||
else {
|
||||
mcolor = m_material_coloul;
|
||||
acolor = m_ams_coloul;
|
||||
}
|
||||
|
||||
//top
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
|
|
@ -205,18 +202,48 @@ void MaterialItem::doRender(wxDC &dc)
|
|||
dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(18), 5);
|
||||
|
||||
//bottom
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(wxColour(acolor)));
|
||||
dc.DrawRoundedRectangle(FromDIP(1), FromDIP(18), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(16), 5);
|
||||
if (m_ams_cols.size() > 1) {
|
||||
int left = FromDIP(1);
|
||||
int gwidth = std::round(MATERIAL_ITEM_REAL_SIZE.x / (m_ams_cols.size() - 1));
|
||||
//gradient
|
||||
if (m_ams_ctype == 0) {
|
||||
for (int i = 0; i < m_ams_cols.size() - 1; i++) {
|
||||
auto rect = wxRect(left, FromDIP(18), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(16));
|
||||
dc.GradientFillLinear(rect, m_ams_cols[i], m_ams_cols[i + 1], wxEAST);
|
||||
left += gwidth;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int cols_size = m_ams_cols.size();
|
||||
for (int i = 0; i < cols_size; i++) {
|
||||
dc.SetBrush(wxBrush(m_ams_cols[i]));
|
||||
float x = left + ((float)MATERIAL_ITEM_REAL_SIZE.x) * i / cols_size;
|
||||
if (i != cols_size - 1) {
|
||||
dc.DrawRoundedRectangle(x, FromDIP(18), ((float)MATERIAL_ITEM_REAL_SIZE.x) / cols_size + FromDIP(3), FromDIP(16), 3);
|
||||
}
|
||||
else {
|
||||
dc.DrawRoundedRectangle(x, FromDIP(18), ((float)MATERIAL_ITEM_REAL_SIZE.x) / cols_size , FromDIP(16), 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(wxColour(acolor)));
|
||||
dc.DrawRoundedRectangle(FromDIP(1), FromDIP(18), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(16), 5);
|
||||
////middle
|
||||
|
||||
////middle
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(acolor));
|
||||
dc.DrawRectangle(FromDIP(1), FromDIP(18), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(8));
|
||||
}
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(mcolor));
|
||||
dc.DrawRectangle(FromDIP(1), FromDIP(11), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(8));
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(acolor));
|
||||
dc.DrawRectangle(FromDIP(1), FromDIP(18), MATERIAL_ITEM_REAL_SIZE.x, FromDIP(8));
|
||||
|
||||
|
||||
////border
|
||||
#if __APPLE__
|
||||
|
|
@ -247,10 +274,10 @@ void MaterialItem::doRender(wxDC &dc)
|
|||
//arrow
|
||||
if ( (acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) &&
|
||||
(acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180)) {
|
||||
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), GetSize().x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetBmpSize().y);
|
||||
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), size.x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), size.y - m_arraw_bitmap_white.GetBmpSize().y);
|
||||
}
|
||||
else {
|
||||
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), GetSize().x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetBmpSize().y);
|
||||
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), size.x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(7), size.y - m_arraw_bitmap_gray.GetBmpSize().y);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -437,6 +464,10 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
|||
td.colour = AmsTray::decode_color(tray_data->color);
|
||||
td.name = tray_data->get_display_filament_type();
|
||||
td.filament_type = tray_data->get_filament_type();
|
||||
td.ctype = tray_data->ctype;
|
||||
for (auto col : tray_data->cols) {
|
||||
td.material_cols.push_back(AmsTray::decode_color(col));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,7 +549,7 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data, wxWindow*
|
|||
m_mapping_item_list.push_back(m_mapping_item);
|
||||
|
||||
if (tray_data[i].type == NORMAL) {
|
||||
if (is_match_material(tray_data[i].filament_type)) {
|
||||
if (is_match_material(tray_data[i].filament_type)) {
|
||||
m_mapping_item->set_data(tray_data[i].colour, tray_data[i].name, tray_data[i]);
|
||||
} else {
|
||||
m_mapping_item->set_data(wxColour(0xEE,0xEE,0xEE), tray_data[i].name, tray_data[i], true);
|
||||
|
|
@ -673,14 +704,38 @@ void MappingItem::set_data(wxColour colour, wxString name, TrayData data, bool u
|
|||
|
||||
void MappingItem::doRender(wxDC &dc)
|
||||
{
|
||||
dc.SetPen(m_coloul);
|
||||
dc.SetBrush(wxBrush(m_coloul));
|
||||
wxSize size = GetSize();
|
||||
wxColour color = m_coloul;
|
||||
change_the_opacity(color);
|
||||
|
||||
if (m_coloul.Alpha() == 0) {
|
||||
dc.DrawBitmap( m_transparent_mapping_item.bmp(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
|
||||
dc.SetPen(color);
|
||||
dc.SetBrush(wxBrush(color));
|
||||
|
||||
if (m_tray_data.material_cols.size() > 1) {
|
||||
int left = 0;
|
||||
int gwidth = std::round(MAPPING_ITEM_REAL_SIZE.x / (m_tray_data.material_cols.size() - 1));
|
||||
//gradient
|
||||
if (m_tray_data.ctype == 0) {
|
||||
for (int i = 0; i < m_tray_data.material_cols.size() - 1; i++) {
|
||||
auto rect = wxRect(left, (size.y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
|
||||
dc.GradientFillLinear(rect, m_tray_data.material_cols[i], m_tray_data.material_cols[i + 1], wxEAST);
|
||||
left += gwidth;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int cols_size = m_tray_data.material_cols.size();
|
||||
for (int i = 0; i < cols_size; i++) {
|
||||
dc.SetBrush(wxBrush(m_tray_data.material_cols[i]));
|
||||
float x = (float)MAPPING_ITEM_REAL_SIZE.x * i / cols_size;
|
||||
dc.DrawRectangle(x, (size.y - MAPPING_ITEM_REAL_SIZE.y) / 2, (float)MAPPING_ITEM_REAL_SIZE.x / cols_size, MAPPING_ITEM_REAL_SIZE.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (color.Alpha() == 0) {
|
||||
dc.DrawBitmap( m_transparent_mapping_item.bmp(), 0, (size.y - MAPPING_ITEM_REAL_SIZE.y) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawRectangle(0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
|
||||
dc.DrawRectangle(0, (size.y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -689,11 +744,11 @@ void MappingItem::doRender(wxDC &dc)
|
|||
dc.SetPen(side_colour);
|
||||
dc.SetBrush(wxBrush(side_colour));
|
||||
#ifdef __APPLE__
|
||||
dc.DrawRectangle(0, 0, FromDIP(4), GetSize().y);
|
||||
dc.DrawRectangle(GetSize().x - FromDIP(4), 0, FromDIP(4), GetSize().y);
|
||||
dc.DrawRectangle(0, 0, FromDIP(4), size.y);
|
||||
dc.DrawRectangle(size.x - FromDIP(4), 0, FromDIP(4), size.y);
|
||||
#else
|
||||
dc.DrawRectangle(0, 0, FromDIP(4), GetSize().y);
|
||||
dc.DrawRectangle(GetSize().x - FromDIP(4), 0, FromDIP(4), GetSize().y);
|
||||
dc.DrawRectangle(0, 0, FromDIP(4), size.y);
|
||||
dc.DrawRectangle(size.x - FromDIP(4), 0, FromDIP(4), size.y);
|
||||
#endif // __APPLE__
|
||||
}
|
||||
|
||||
|
|
@ -806,98 +861,52 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent)
|
|||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
wxBoxSizer* main_sizer;
|
||||
main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
close_img = ScalableBitmap(this, "hum_popup_close", 24);
|
||||
|
||||
main_sizer->Add(0, 0, 0, wxTOP, 28);
|
||||
m_staticText = new Label(this, _L("Current Cabin humidity"));
|
||||
m_staticText->SetFont(::Label::Head_24);
|
||||
|
||||
wxBoxSizer* m_sizer_body;
|
||||
m_sizer_body = new wxBoxSizer(wxHORIZONTAL);
|
||||
humidity_level_list = new AmsHumidityLevelList(this);
|
||||
curr_humidity_img = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("hum_level1_light", this, 132), wxDefaultPosition, wxSize(FromDIP(132), FromDIP(132)), 0);
|
||||
|
||||
m_img = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_humidity_tips", this, 125), wxDefaultPosition, wxSize(FromDIP(125), FromDIP(145)), 0);
|
||||
|
||||
m_sizer_body->Add(m_img, 0, wxEXPAND | wxALL, 2);
|
||||
|
||||
|
||||
m_sizer_body->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(18));
|
||||
|
||||
wxBoxSizer* m_sizer_tips = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_staticText1 = new Label(this, _L("Cabin humidity"));
|
||||
m_staticText1->SetFont(::Label::Head_13);
|
||||
m_staticText_note = new Label(this, _L("Please change the desiccant when it is too wet. The indicator may not represent accurately in following cases : when the lid is open or the desiccant pack is changed. it take hours to absorb the moisture, low temperatures also slow down the process."));
|
||||
m_staticText_note->SetMinSize(wxSize(FromDIP(680), -1));
|
||||
m_staticText_note->SetMaxSize(wxSize(FromDIP(680), -1));
|
||||
m_staticText_note->Wrap(FromDIP(680));
|
||||
|
||||
|
||||
m_staticText2 = new Label(this, _L("Green means that AMS humidity is normal, orange represent humidity is high, red represent humidity is too high.(Hygrometer: lower the better.)"));
|
||||
m_staticText2->SetFont(::Label::Body_13);
|
||||
m_staticText2->SetSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText2->SetMinSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText2->SetMaxSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText2->Wrap(FromDIP(357));
|
||||
|
||||
|
||||
m_staticText3 = new Label(this, _L("Desiccant status"));
|
||||
m_staticText3->SetFont(::Label::Head_13);
|
||||
|
||||
|
||||
m_staticText4 = new Label(this, _L("A desiccant status lower than two bars indicates that desiccant may be inactive. Please change the desiccant.(The bars: higher the better.)"));
|
||||
m_staticText4->SetFont(::Label::Body_13);
|
||||
m_staticText4->SetSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText4->SetMinSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText4->SetMaxSize(wxSize(FromDIP(357), -1));
|
||||
m_staticText4->Wrap(FromDIP(357));
|
||||
|
||||
m_sizer_tips->Add(m_staticText1, 0, wxLEFT|wxRIGHT, 3);
|
||||
m_sizer_tips->Add(0,0,0,wxTOP,2);
|
||||
m_sizer_tips->Add(m_staticText2, 0, wxLEFT|wxRIGHT, 3);
|
||||
m_sizer_tips->Add(0,0,0,wxTOP,8);
|
||||
m_sizer_tips->Add(m_staticText3, 0, wxLEFT|wxRIGHT, 3);
|
||||
m_sizer_tips->Add(0,0,0,wxTOP,2);
|
||||
m_sizer_tips->Add(m_staticText4, 0, wxLEFT|wxRIGHT, 3);
|
||||
|
||||
|
||||
m_sizer_body->Add(m_sizer_tips, 0, wxEXPAND, 0);
|
||||
|
||||
|
||||
main_sizer->Add(m_sizer_body, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
|
||||
|
||||
m_staticText_note = new Label(this, _L("Note: When the lid is open or the desiccant pack is changed, it can take hours or a night to absorb the moisture. Low temperatures also slow down the process. During this time, the indicator may not represent the chamber accurately."));
|
||||
m_staticText4->SetFont(::Label::Body_13);
|
||||
m_staticText_note->SetMinSize(wxSize(FromDIP(523), -1));
|
||||
m_staticText_note->SetMaxSize(wxSize(FromDIP(523), -1));
|
||||
m_staticText_note->Wrap(FromDIP(523));
|
||||
main_sizer->Add(m_staticText_note, 0, wxALL | wxLEFT | wxRIGHT, 22);
|
||||
|
||||
m_button_confirm = new Button(this, _L("OK"));
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Pressed), std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
||||
m_button_confirm->SetBackgroundColor(btn_bg_green);
|
||||
m_button_confirm->SetBorderColor(wxColour(0, 150, 136));
|
||||
m_button_confirm->SetTextColor(wxColour(0xFFFFFE));
|
||||
m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_button_confirm->SetCornerRadius(FromDIP(12));
|
||||
|
||||
|
||||
m_button_confirm->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
Dismiss();
|
||||
});
|
||||
|
||||
Bind(wxEVT_LEFT_UP, [this](auto& e) {
|
||||
|
||||
auto rect = ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
auto close_left = rect.x + GetSize().x - close_img.GetBmpWidth() - FromDIP(38);
|
||||
auto close_right = close_left + close_img.GetBmpWidth();
|
||||
auto close_top = rect.y + FromDIP(24);
|
||||
auto close_bottom = close_top + close_img.GetBmpHeight();
|
||||
|
||||
auto mouse_pos = ClientToScreen(e.GetPosition());
|
||||
auto rect = m_button_confirm->ClientToScreen(wxPoint(0, 0));
|
||||
if (mouse_pos.x > rect.x && mouse_pos.y > rect.y
|
||||
&& mouse_pos.x < (rect.x + m_button_confirm->GetSize().x)
|
||||
&& mouse_pos.y < (rect.y + m_button_confirm->GetSize().y))
|
||||
if (mouse_pos.x > close_left
|
||||
&& mouse_pos.y > close_top
|
||||
&& mouse_pos.x < close_right
|
||||
&& mouse_pos.y < close_bottom
|
||||
)
|
||||
{
|
||||
Dismiss();
|
||||
}
|
||||
});
|
||||
main_sizer->Add(m_button_confirm, 0, wxALIGN_CENTER | wxALL, 0);
|
||||
|
||||
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, 18);
|
||||
|
||||
});
|
||||
|
||||
main_sizer->Add(0, 0, 0, wxTOP, FromDIP(24));
|
||||
main_sizer->Add(m_staticText, 0, wxALIGN_CENTER, 0);
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(28));
|
||||
main_sizer->Add(curr_humidity_img, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(35));
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(15));
|
||||
main_sizer->Add(humidity_level_list, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(35));
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6));
|
||||
main_sizer->Add(m_staticText_note, 0, wxALIGN_CENTER, 0);
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(5));
|
||||
main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(25));
|
||||
SetSizer(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
|
|
@ -909,9 +918,7 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent)
|
|||
void AmsHumidityTipPopup::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::OnDismiss() {}
|
||||
|
|
@ -920,6 +927,50 @@ bool AmsHumidityTipPopup::ProcessLeftDown(wxMouseEvent& event) {
|
|||
return PopupWindow::ProcessLeftDown(event);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::set_humidity_level(int level)
|
||||
{
|
||||
current_humidity_level = level;
|
||||
if (current_humidity_level<= 0) {return;}
|
||||
|
||||
std::string mode_string = wxGetApp().dark_mode()?"_dark":"_light";
|
||||
|
||||
curr_humidity_img->SetBitmap(create_scaled_bitmap("hum_level" + std::to_string(current_humidity_level) + mode_string, this, 132));
|
||||
curr_humidity_img->Refresh();
|
||||
curr_humidity_img->Update();
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxSize size = GetSize();
|
||||
wxMemoryDC memdc;
|
||||
wxBitmap bmp(size.x, size.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
|
||||
|
||||
{
|
||||
wxGCDC dc2(memdc);
|
||||
doRender(dc2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
#else
|
||||
doRender(dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::doRender(wxDC& dc)
|
||||
{
|
||||
//close
|
||||
dc.DrawBitmap(close_img.bmp(), GetSize().x - close_img.GetBmpWidth() - FromDIP(38), FromDIP(24));
|
||||
|
||||
//background
|
||||
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
|
||||
}
|
||||
|
||||
AmsTutorialPopup::AmsTutorialPopup(wxWindow* parent)
|
||||
:PopupWindow(parent, wxBORDER_NONE)
|
||||
{
|
||||
|
|
@ -1507,7 +1558,11 @@ void AmsRMGroup::doRender(wxDC& dc)
|
|||
|
||||
int x = size.x / 2;
|
||||
int y = size.y / 2;
|
||||
int radius = size.x / 2 - FromDIP(2);
|
||||
int radius;
|
||||
if (wxGetApp().dark_mode())
|
||||
radius = size.x / 2 - int(size.x * 0.02);
|
||||
else
|
||||
radius = size.x / 2;
|
||||
endAngle += ev_angle;
|
||||
|
||||
|
||||
|
|
@ -1589,4 +1644,90 @@ void AmsRMGroup::doRender(wxDC& dc)
|
|||
dc.DrawText(m_group_index, (size.x - text_size.x) / 2, (size.y - text_size.y) / 2 + FromDIP(10));
|
||||
}
|
||||
|
||||
AmsHumidityLevelList::AmsHumidityLevelList(wxWindow* parent)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
SetSize(wxSize(FromDIP(680), FromDIP(104)));
|
||||
SetMinSize(wxSize(FromDIP(680), FromDIP(104)));
|
||||
SetMaxSize(wxSize(FromDIP(680), FromDIP(104)));
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
background_img = ScalableBitmap(this, "humidity_list_background", 104);
|
||||
|
||||
for (int i = 5; i > 0; i--) {
|
||||
hum_level_img_light.push_back(ScalableBitmap(this, ("hum_level" + std::to_string(i) + "_light"), 54));
|
||||
hum_level_img_dark.push_back(ScalableBitmap(this, ("hum_level" + std::to_string(i) + "_dark"), 54));
|
||||
}
|
||||
|
||||
Bind(wxEVT_PAINT, &AmsHumidityLevelList::paintEvent, this);
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
}
|
||||
|
||||
void AmsHumidityLevelList::msw_rescale()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AmsHumidityLevelList::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void AmsHumidityLevelList::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxSize size = GetSize();
|
||||
wxMemoryDC memdc;
|
||||
wxBitmap bmp(size.x, size.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
|
||||
|
||||
{
|
||||
wxGCDC dc2(memdc);
|
||||
doRender(dc2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
#else
|
||||
doRender(dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AmsHumidityLevelList::doRender(wxDC& dc)
|
||||
{
|
||||
dc.DrawBitmap(background_img.bmp(), 0,0);
|
||||
|
||||
auto width_center = GetSize().x / 2;
|
||||
auto left = width_center - FromDIP(27) - FromDIP(46) * 2 - FromDIP(54) * 2;
|
||||
|
||||
|
||||
//dry / wet
|
||||
dc.SetTextForeground(wxColour(0x989898));
|
||||
dc.SetFont(::Label::Head_20);
|
||||
|
||||
auto font_top = GetSize().y - dc.GetTextExtent(_L("DRY")).GetHeight();
|
||||
dc.DrawText(_L("DRY"), wxPoint(FromDIP(38), font_top / 2));
|
||||
dc.DrawText(_L("WET"), wxPoint(( GetSize().x - FromDIP(38) - dc.GetTextExtent(_L("DRY")).GetWidth()), font_top / 2));
|
||||
|
||||
|
||||
//level list
|
||||
|
||||
for (int i = 0; i < hum_level_img_light.size(); i++) {
|
||||
if (wxGetApp().dark_mode()) {
|
||||
dc.DrawBitmap(hum_level_img_dark[i].bmp(), left, (GetSize().y - FromDIP(54)) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawBitmap(hum_level_img_light[i].bmp(), left, (GetSize().y - FromDIP(54)) / 2);
|
||||
}
|
||||
|
||||
left += FromDIP(46) + FromDIP(54);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
|||
|
|
@ -55,9 +55,11 @@ struct TrayData
|
|||
{
|
||||
TrayType type;
|
||||
int id;
|
||||
int ctype = 0;
|
||||
std::string name;
|
||||
std::string filament_type;
|
||||
wxColour colour;
|
||||
std::vector<wxColour> material_cols = std::vector<wxColour>();
|
||||
};
|
||||
|
||||
class MaterialItem: public wxPanel
|
||||
|
|
@ -72,6 +74,8 @@ public:
|
|||
|
||||
wxColour m_ams_coloul;
|
||||
wxString m_ams_name;
|
||||
int m_ams_ctype = 0;
|
||||
std::vector<wxColour> m_ams_cols = std::vector<wxColour>();
|
||||
|
||||
ScalableBitmap m_arraw_bitmap_gray;
|
||||
ScalableBitmap m_arraw_bitmap_white;
|
||||
|
|
@ -81,7 +85,7 @@ public:
|
|||
bool m_warning{false};
|
||||
|
||||
void msw_rescale();
|
||||
void set_ams_info(wxColour col, wxString txt);
|
||||
void set_ams_info(wxColour col, wxString txt, int ctype=0, std::vector<wxColour> cols= std::vector<wxColour>());
|
||||
|
||||
void disable();
|
||||
void enable();
|
||||
|
|
@ -185,6 +189,33 @@ public:
|
|||
wxStaticText * m_tip_disable_ams;
|
||||
};
|
||||
|
||||
class AmsHumidityLevelList : public wxPanel
|
||||
{
|
||||
public:
|
||||
AmsHumidityLevelList(wxWindow* parent);
|
||||
~AmsHumidityLevelList() {};
|
||||
|
||||
ScalableBitmap background_img;
|
||||
ScalableBitmap hum_level1_img;
|
||||
ScalableBitmap hum_level2_img;
|
||||
ScalableBitmap hum_level3_img;
|
||||
ScalableBitmap hum_level4_img;
|
||||
|
||||
std::vector<ScalableBitmap> hum_level_img_light;
|
||||
std::vector<ScalableBitmap> hum_level_img_dark;
|
||||
|
||||
wxStaticBitmap* hum_level1_bitmap;
|
||||
wxStaticBitmap* hum_level2_bitmap;
|
||||
wxStaticBitmap* hum_level3_bitmap;
|
||||
wxStaticBitmap* hum_level4_bitmap;
|
||||
wxStaticBitmap* hum_level5_bitmap;
|
||||
|
||||
void msw_rescale();
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
};
|
||||
|
||||
class AmsHumidityTipPopup : public PopupWindow
|
||||
{
|
||||
public:
|
||||
|
|
@ -195,14 +226,19 @@ public:
|
|||
virtual void OnDismiss() wxOVERRIDE;
|
||||
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
|
||||
|
||||
void set_humidity_level(int level);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
|
||||
public:
|
||||
int current_humidity_level;
|
||||
|
||||
ScalableBitmap close_img;
|
||||
wxStaticBitmap* curr_humidity_img;
|
||||
AmsHumidityLevelList* humidity_level_list{nullptr};
|
||||
wxStaticBitmap* m_img;
|
||||
Label* m_staticText1;
|
||||
Label* m_staticText2;
|
||||
Label* m_staticText3;
|
||||
Label* m_staticText4;
|
||||
Label* m_staticText;;
|
||||
Label* m_staticText_note;
|
||||
Button* m_button_confirm;
|
||||
};
|
||||
|
||||
class AmsTutorialPopup : public PopupWindow
|
||||
|
|
|
|||
|
|
@ -238,12 +238,13 @@ void BackgroundSlicingProcess::process_fff()
|
|||
//BBS: add plate index into render params
|
||||
m_temp_output_path = this->get_current_plate()->get_tmp_gcode_path();
|
||||
m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
|
||||
finalize_gcode();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": export gcode finished");
|
||||
}
|
||||
if (this->set_step_started(bspsGCodeFinalize)) {
|
||||
if (! m_export_path.empty()) {
|
||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id));
|
||||
finalize_gcode();
|
||||
export_gcode();
|
||||
} else if (! m_upload_job.empty()) {
|
||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id));
|
||||
prepare_upload();
|
||||
|
|
@ -767,44 +768,34 @@ bool BackgroundSlicingProcess::invalidate_all_steps()
|
|||
return m_step_state.invalidate_all([this](){ this->stop_internal(); });
|
||||
}
|
||||
|
||||
//Call post-processing script for the last step during slicing
|
||||
void BackgroundSlicingProcess::finalize_gcode()
|
||||
{
|
||||
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
|
||||
|
||||
run_post_process_scripts(m_temp_output_path, false, "File", m_temp_output_path, m_fff_print->full_print_config());
|
||||
|
||||
m_print->set_status(100, _utf8(L("Successfully executed post-processing script")));
|
||||
}
|
||||
|
||||
// G-code is generated in m_temp_output_path.
|
||||
// Optionally run a post-processing script on a copy of m_temp_output_path.
|
||||
// Copy the final G-code to target location (possibly a SD card, if it is a removable media, then verify that the file was written without an error).
|
||||
void BackgroundSlicingProcess::finalize_gcode()
|
||||
void BackgroundSlicingProcess::export_gcode()
|
||||
{
|
||||
//BBS: don't support running user-defined post-processing scripts
|
||||
//m_print->set_status(95, _utf8(L("Running post-processing scripts")));
|
||||
|
||||
// Perform the final post-processing of the export path by applying the print statistics over the file name.
|
||||
std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path);
|
||||
std::string output_path = m_temp_output_path;
|
||||
|
||||
// Both output_path and export_path ar in-out parameters.
|
||||
// If post processed, output_path will differ from m_temp_output_path as run_post_process_scripts() will make a copy of the G-code to not
|
||||
// collide with the G-code viewer memory mapping of the unprocessed G-code. G-code viewer maps unprocessed G-code, because m_gcode_result
|
||||
// is calculated for the unprocessed G-code and it references lines in the memory mapped G-code file by line numbers.
|
||||
// export_path may be changed by the post-processing script as well if the post processing script decides so, see GH #6042.
|
||||
bool post_processed = run_post_process_scripts(output_path, true, "File", export_path, m_fff_print->full_print_config());
|
||||
auto remove_post_processed_temp_file = [post_processed, &output_path]() {
|
||||
if (post_processed)
|
||||
try {
|
||||
boost::filesystem::remove(output_path);
|
||||
} catch (const std::exception &ex) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Failed to remove temp file " << output_path << ": " << ex.what();
|
||||
}
|
||||
};
|
||||
|
||||
//FIXME localize the messages
|
||||
std::string error_message;
|
||||
int copy_ret_val = CopyFileResult::SUCCESS;
|
||||
try
|
||||
{
|
||||
copy_ret_val = copy_file(output_path, export_path, error_message, m_export_path_on_removable_media);
|
||||
remove_post_processed_temp_file();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
remove_post_processed_temp_file();
|
||||
throw Slic3r::ExportError(_utf8(L("Unknown error when export G-code.")));
|
||||
}
|
||||
switch (copy_ret_val) {
|
||||
|
|
@ -840,7 +831,6 @@ void BackgroundSlicingProcess::finalize_gcode()
|
|||
// BBS: to be checked. Whether use export_path or output_path.
|
||||
gcode_add_line_number(export_path, m_fff_print->full_print_config());
|
||||
|
||||
m_print->set_status(100, (boost::format(_utf8(L("Succeed to export G-code to %1%"))) % export_path).str());
|
||||
}
|
||||
|
||||
// A print host upload job has been scheduled, enqueue it to the printhost job queue
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ private:
|
|||
// If the background processing stop was requested, throw CanceledException.
|
||||
void throw_if_canceled() const { if (m_print->canceled()) throw CanceledException(); }
|
||||
void finalize_gcode();
|
||||
void export_gcode();
|
||||
void prepare_upload();
|
||||
// To be executed at the background thread.
|
||||
ThumbnailsList render_thumbnails(const ThumbnailsParams ¶ms);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace GUI {
|
|||
|
||||
#define HISTORY_WINDOW_SIZE wxSize(FromDIP(700), FromDIP(600))
|
||||
#define EDIT_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(160), FromDIP(24))
|
||||
#define NEW_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(250), FromDIP(24))
|
||||
#define HISTORY_WINDOW_ITEMS_COUNT 5
|
||||
static const wxString k_tips = "Please input a valid value (K in 0~0.3)";
|
||||
|
||||
|
|
@ -71,6 +72,21 @@ HistoryWindow::HistoryWindow(wxWindow* parent, const std::vector<PACalibResult>&
|
|||
auto scroll_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
scroll_window->SetSizer(scroll_sizer);
|
||||
|
||||
Button * mew_btn = new Button(scroll_window, _L("New"));
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
mew_btn->SetBackgroundColour(*wxWHITE);
|
||||
mew_btn->SetBackgroundColor(btn_bg_green);
|
||||
mew_btn->SetBorderColor(wxColour(0, 174, 66));
|
||||
mew_btn->SetTextColor(wxColour("#FFFFFE"));
|
||||
mew_btn->SetMinSize(wxSize(FromDIP(100), FromDIP(24)));
|
||||
mew_btn->SetMaxSize(wxSize(FromDIP(100), FromDIP(24)));
|
||||
mew_btn->SetCornerRadius(FromDIP(12));
|
||||
mew_btn->Bind(wxEVT_BUTTON, &HistoryWindow::on_click_new_button, this);
|
||||
|
||||
scroll_sizer->Add(mew_btn, 0, wxLEFT, FromDIP(20));
|
||||
scroll_sizer->AddSpacer(FromDIP(15));
|
||||
|
||||
wxPanel* comboBox_panel = new wxPanel(scroll_window);
|
||||
comboBox_panel->SetBackgroundColour(wxColour(238, 238, 238));
|
||||
auto comboBox_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
|
@ -346,6 +362,11 @@ float HistoryWindow::get_nozzle_value()
|
|||
return nozzle_value;
|
||||
}
|
||||
|
||||
void HistoryWindow::on_click_new_button(wxCommandEvent& event)
|
||||
{
|
||||
NewCalibrationHistoryDialog dlg(this, m_calib_results_history);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow* parent, const PACalibResult& result)
|
||||
: DPIDialog(parent, wxID_ANY, _L("Edit Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
|
|
@ -434,13 +455,9 @@ PACalibResult EditCalibrationHistoryDialog::get_result() {
|
|||
|
||||
void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
|
||||
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
||||
if (name.IsEmpty())
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return;
|
||||
if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
m_new_result.name = m_name_value->GetTextCtrl()->GetValue().ToUTF8().data();
|
||||
|
||||
float k = 0.0f;
|
||||
|
|
@ -465,5 +482,255 @@ void EditCalibrationHistoryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||
{
|
||||
}
|
||||
|
||||
wxArrayString NewCalibrationHistoryDialog::get_all_filaments(const MachineObject *obj)
|
||||
{
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
wxArrayString filament_items;
|
||||
std::set<std::string> filament_id_set;
|
||||
std::set<std::string> printer_names;
|
||||
std::ostringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
|
||||
for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) {
|
||||
// filter by system preset
|
||||
if (!printer_it->is_system)
|
||||
continue;
|
||||
// get printer_model
|
||||
ConfigOption * printer_model_opt = printer_it->config.option("printer_model");
|
||||
ConfigOptionString *printer_model_str = dynamic_cast<ConfigOptionString *>(printer_model_opt);
|
||||
if (!printer_model_str)
|
||||
continue;
|
||||
|
||||
// use printer_model as printer type
|
||||
if (printer_model_str->value != MachineObject::get_preset_printer_model_name(obj->printer_type))
|
||||
continue;
|
||||
|
||||
if (printer_it->name.find(nozzle_diameter_str) != std::string::npos)
|
||||
printer_names.insert(printer_it->name);
|
||||
}
|
||||
|
||||
if (preset_bundle) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
|
||||
for (auto filament_it = preset_bundle->filaments.begin(); filament_it != preset_bundle->filaments.end(); filament_it++) {
|
||||
// filter by system preset
|
||||
Preset &preset = *filament_it;
|
||||
/*The situation where the user preset is not displayed is as follows:
|
||||
1. Not a root preset
|
||||
2. Not system preset and the printer firmware does not support user preset */
|
||||
if (preset_bundle->filaments.get_preset_base(*filament_it) != &preset || (!filament_it->is_system && ! obj->is_support_user_preset)) { continue; }
|
||||
|
||||
ConfigOption * printer_opt = filament_it->config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
for (auto printer_str : printer_strs->values) {
|
||||
if (printer_names.find(printer_str) != printer_names.end()) {
|
||||
if (filament_id_set.find(filament_it->filament_id) != filament_id_set.end()) {
|
||||
continue;
|
||||
} else {
|
||||
filament_id_set.insert(filament_it->filament_id);
|
||||
// name matched
|
||||
if (filament_it->is_system) {
|
||||
filament_items.push_back(filament_it->alias);
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[filament_it->alias] = filament_infos;
|
||||
} else {
|
||||
char target = '@';
|
||||
size_t pos = filament_it->name.find(target);
|
||||
if (pos != std::string::npos) {
|
||||
std::string user_preset_alias = filament_it->name.substr(0, pos - 1);
|
||||
wxString wx_user_preset_alias = wxString(user_preset_alias.c_str(), wxConvUTF8);
|
||||
user_preset_alias = wx_user_preset_alias.ToStdString();
|
||||
|
||||
filament_items.push_back(user_preset_alias);
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
map_filament_items[user_preset_alias] = filament_infos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return filament_items;
|
||||
}
|
||||
|
||||
NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const std::vector<PACalibResult> history_results)
|
||||
: DPIDialog(parent, wxID_ANY, _L("New Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
, m_history_results(history_results)
|
||||
{
|
||||
Slic3r::DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev)
|
||||
return;
|
||||
MachineObject *obj = dev->get_selected_machine();
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto top_panel = new wxPanel(this);
|
||||
top_panel->SetBackgroundColour(*wxWHITE);
|
||||
auto panel_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
top_panel->SetSizer(panel_sizer);
|
||||
|
||||
auto flex_sizer = new wxFlexGridSizer(0, 2, FromDIP(15), FromDIP(30));
|
||||
flex_sizer->SetFlexibleDirection(wxBOTH);
|
||||
flex_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||
|
||||
Label *name_title = new Label(top_panel, _L("Name"));
|
||||
m_name_value = new TextInput(top_panel, "", "", "", wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||
|
||||
// Name
|
||||
flex_sizer->Add(name_title);
|
||||
flex_sizer->Add(m_name_value);
|
||||
|
||||
Label * preset_name_title = new Label(top_panel, _L("Filament"));
|
||||
m_comboBox_filament = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
||||
|
||||
wxArrayString filament_items = get_all_filaments(obj);
|
||||
m_comboBox_filament->Set(filament_items);
|
||||
m_comboBox_filament->SetSelection(-1);
|
||||
|
||||
// Filament
|
||||
flex_sizer->Add(preset_name_title);
|
||||
flex_sizer->Add(m_comboBox_filament);
|
||||
|
||||
Label *nozzle_diameter_title = new Label(top_panel, _L("Nozzle Diameter"));
|
||||
m_comboBox_nozzle_diameter = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
||||
static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f};
|
||||
for (int i = 0; i < nozzle_diameter_list.size(); i++) {
|
||||
m_comboBox_nozzle_diameter->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i]));
|
||||
if (abs(obj->nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) {
|
||||
m_comboBox_nozzle_diameter->SetSelection(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Nozzle Diameter
|
||||
flex_sizer->Add(nozzle_diameter_title);
|
||||
flex_sizer->Add(m_comboBox_nozzle_diameter);
|
||||
|
||||
Label *k_title = new Label(top_panel, _L("Factor K"));
|
||||
auto k_str = wxString::Format("%.3f", m_new_result.k_value);
|
||||
m_k_value = new TextInput(top_panel, k_str, "", "", wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||
|
||||
// Factor K
|
||||
flex_sizer->Add(k_title);
|
||||
flex_sizer->Add(m_k_value);
|
||||
|
||||
panel_sizer->Add(flex_sizer);
|
||||
|
||||
panel_sizer->AddSpacer(FromDIP(25));
|
||||
|
||||
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
Button * ok_btn = new Button(top_panel, _L("Ok"));
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
ok_btn->SetBackgroundColour(*wxWHITE);
|
||||
ok_btn->SetBackgroundColor(btn_bg_green);
|
||||
ok_btn->SetBorderColor(wxColour(0, 174, 66));
|
||||
ok_btn->SetTextColor(wxColour("#FFFFFE"));
|
||||
ok_btn->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
ok_btn->SetCornerRadius(FromDIP(12));
|
||||
Button *cancel_btn = new Button(top_panel, _L("Cancel"));
|
||||
cancel_btn->SetBackgroundColour(*wxWHITE);
|
||||
cancel_btn->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
cancel_btn->SetCornerRadius(FromDIP(12));
|
||||
ok_btn->Bind(wxEVT_BUTTON, &NewCalibrationHistoryDialog::on_ok, this);
|
||||
cancel_btn->Bind(wxEVT_BUTTON, &NewCalibrationHistoryDialog::on_cancel, this);
|
||||
btn_sizer->AddStretchSpacer();
|
||||
btn_sizer->Add(ok_btn);
|
||||
btn_sizer->AddSpacer(FromDIP(20));
|
||||
btn_sizer->Add(cancel_btn);
|
||||
panel_sizer->Add(btn_sizer, 0, wxEXPAND, 0);
|
||||
|
||||
main_sizer->Add(top_panel, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||
{
|
||||
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return;
|
||||
|
||||
float k = 0.0f;
|
||||
if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) {
|
||||
MessageDialog msg_dlg(nullptr, _L(k_tips), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
wxString k_str = wxString::Format("%.3f", k);
|
||||
m_k_value->GetTextCtrl()->SetValue(k_str);
|
||||
|
||||
double nozzle_value = 0.0;
|
||||
wxString nozzle_value_str = m_comboBox_nozzle_diameter->GetValue();
|
||||
nozzle_value_str.ToDouble(&nozzle_value);
|
||||
|
||||
std::string filament_name = m_comboBox_filament->GetValue().ToStdString();
|
||||
if (filament_name.empty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The filament must be selected."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
|
||||
std::string filament_id = filament_item.filament_id;
|
||||
std::string setting_id = filament_item.setting_id;
|
||||
|
||||
m_new_result.name = name.ToUTF8().data();
|
||||
m_new_result.k_value = k;
|
||||
m_new_result.tray_id = -1;
|
||||
m_new_result.cali_idx = -1;
|
||||
|
||||
m_new_result.nozzle_diameter = nozzle_value;
|
||||
m_new_result.filament_id = filament_id;
|
||||
m_new_result.setting_id = setting_id;
|
||||
|
||||
// Check for duplicate names from history
|
||||
{
|
||||
struct PACalibResult
|
||||
{
|
||||
size_t operator()(const std::pair<std::string, std::string> &item) const
|
||||
{
|
||||
return std::hash<string>()(item.first) * std::hash<string>()(item.second);
|
||||
}
|
||||
};
|
||||
std::unordered_set<std::pair<std::string, std::string>, PACalibResult> set;
|
||||
set.insert({m_new_result.name, m_new_result.filament_id});
|
||||
|
||||
for (auto &result : m_history_results) {
|
||||
if (!set.insert({result.name, result.filament_id}).second) {
|
||||
MessageDialog msg_dlg(nullptr,
|
||||
wxString::Format(_L("There is already a historical calibration result with the same name: %s. Only one of the results with the same name "
|
||||
"is saved. Are you sure you want to override the historical result?"),
|
||||
result.name),
|
||||
wxEmptyString, wxICON_WARNING | wxYES_NO);
|
||||
if (msg_dlg.ShowModal() != wxID_YES)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CalibUtils::set_PA_calib_result({m_new_result}, true);
|
||||
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void NewCalibrationHistoryDialog::on_cancel(wxCommandEvent &event)
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ protected:
|
|||
void enbale_action_buttons(bool enable);
|
||||
float get_nozzle_value();
|
||||
|
||||
void on_click_new_button(wxCommandEvent &event);
|
||||
|
||||
wxPanel* m_history_data_panel;
|
||||
ComboBox* m_comboBox_nozzle_dia;
|
||||
Label* m_tips;
|
||||
|
|
@ -55,6 +57,38 @@ protected:
|
|||
TextInput* m_k_value{ nullptr };
|
||||
};
|
||||
|
||||
class NewCalibrationHistoryDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
NewCalibrationHistoryDialog(wxWindow *parent, const std::vector<PACalibResult> history_results);
|
||||
~NewCalibrationHistoryDialog(){};
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override{};
|
||||
|
||||
protected:
|
||||
virtual void on_ok(wxCommandEvent &event);
|
||||
virtual void on_cancel(wxCommandEvent &event);
|
||||
|
||||
|
||||
wxArrayString get_all_filaments(const MachineObject *obj);
|
||||
|
||||
protected:
|
||||
PACalibResult m_new_result;
|
||||
std::vector<PACalibResult> m_history_results;
|
||||
|
||||
TextInput *m_name_value{nullptr};
|
||||
TextInput *m_k_value{nullptr};
|
||||
|
||||
ComboBox *m_comboBox_nozzle_diameter;
|
||||
ComboBox *m_comboBox_filament;
|
||||
|
||||
struct FilamentInfos
|
||||
{
|
||||
std::string filament_id;
|
||||
std::string setting_id;
|
||||
};
|
||||
std::map<std::string, FilamentInfos> map_filament_items;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,6 @@ static const float MIN_PA_K_VALUE = 0.0;
|
|||
static const float MAX_PA_K_VALUE = 0.3;
|
||||
static const float MIN_PA_K_VALUE_STEP = 0.001;
|
||||
|
||||
bool check_preset_name_valid(const wxString& name) {
|
||||
wxString error_message;
|
||||
if (name.IsEmpty()) {
|
||||
error_message = _L("Please enter the name you want to save to printer.");
|
||||
} else if (name.Length() > 40) {
|
||||
error_message = _L("The name cannot exceed 40 characters.");
|
||||
}
|
||||
if (!error_message.IsEmpty()) {
|
||||
MessageDialog error_msg_dlg(nullptr, error_message, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
error_msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) {
|
||||
std::map<int, Preset*> selected_filament_map;
|
||||
if (!obj) return selected_filament_map;
|
||||
|
|
@ -90,6 +75,28 @@ CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowI
|
|||
main_sizer->Fit(this);
|
||||
|
||||
Bind(EVT_CALIBRATION_JOB_FINISHED, &CalibrationWizard::on_cali_job_finished, this);
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
this->Bind(wxEVT_CHAR_HOOK, [this](auto& evt) {
|
||||
const int keyCode = evt.GetKeyCode();
|
||||
switch (keyCode)
|
||||
{
|
||||
case WXK_PAGEUP:
|
||||
{
|
||||
show_step(m_curr_step->prev);
|
||||
break;
|
||||
}
|
||||
case WXK_PAGEDOWN:
|
||||
{
|
||||
show_step(m_curr_step->next);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
evt.Skip();
|
||||
break;
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
CalibrationWizard::~CalibrationWizard()
|
||||
|
|
@ -295,6 +302,7 @@ void CalibrationWizard::recover_preset_info(MachineObject *obj)
|
|||
obj->cali_finished = back_info.cali_finished;
|
||||
obj->cache_flow_ratio = back_info.cache_flow_ratio;
|
||||
obj->selected_cali_preset = back_info.selected_presets;
|
||||
obj->flow_ratio_calibration_type = back_info.cache_flow_rate_calibration_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -306,6 +314,7 @@ void CalibrationWizard::back_preset_info(MachineObject *obj, bool cali_finish, b
|
|||
printer_cali_info.cali_finished = cali_finish;
|
||||
printer_cali_info.cache_flow_ratio = obj->cache_flow_ratio;
|
||||
printer_cali_info.selected_presets = obj->selected_cali_preset;
|
||||
printer_cali_info.cache_flow_rate_calibration_type = obj->flow_ratio_calibration_type;
|
||||
wxGetApp().app_config->save_printer_cali_infos(printer_cali_info, back_cali_flag);
|
||||
}
|
||||
|
||||
|
|
@ -698,34 +707,44 @@ void PressureAdvanceWizard::on_cali_save()
|
|||
msg_dlg.ShowModal();
|
||||
}
|
||||
else if (curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||
auto save_page = static_cast<CalibrationPASavePage*>(save_step->page);
|
||||
float new_k_value = 0.0f;
|
||||
float new_n_value = 0.0f;
|
||||
if (!save_page->get_p1p_result(&new_k_value, &new_n_value)) {
|
||||
return;
|
||||
}
|
||||
if (curr_obj->cali_version >= 0) {
|
||||
PACalibResult new_pa_cali_result;
|
||||
auto save_page = static_cast<CalibrationPASavePage *>(save_step->page);
|
||||
if (!save_page->get_manual_result(new_pa_cali_result)) {
|
||||
return;
|
||||
}
|
||||
CalibUtils::set_PA_calib_result({new_pa_cali_result}, false);
|
||||
} else {
|
||||
auto save_page = static_cast<CalibrationPASavePage *>(save_step->page);
|
||||
float new_k_value = 0.0f;
|
||||
float new_n_value = 0.0f;
|
||||
if (!save_page->get_p1p_result(&new_k_value, &new_n_value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float nozzle_dia = 0.4;
|
||||
BedType plate_type = BedType::btDefault;
|
||||
CalibrationPresetPage* preset_page = (static_cast<CalibrationPresetPage*>(preset_step->page));
|
||||
preset_page->get_preset_info(nozzle_dia, plate_type);
|
||||
std::map<int, Preset*> selected_filaments = get_cached_selected_filament(curr_obj);
|
||||
if (selected_filaments.empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get selected filaments error";
|
||||
return;
|
||||
}
|
||||
int tray_id = selected_filaments.begin()->first;
|
||||
std::string setting_id = selected_filaments.begin()->second->setting_id;
|
||||
float nozzle_dia = 0.4;
|
||||
BedType plate_type = BedType::btDefault;
|
||||
CalibrationPresetPage *preset_page = (static_cast<CalibrationPresetPage *>(preset_step->page));
|
||||
preset_page->get_preset_info(nozzle_dia, plate_type);
|
||||
std::map<int, Preset *> selected_filaments = get_cached_selected_filament(curr_obj);
|
||||
if (selected_filaments.empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get selected filaments error";
|
||||
return;
|
||||
}
|
||||
int tray_id = selected_filaments.begin()->first;
|
||||
std::string setting_id = selected_filaments.begin()->second->setting_id;
|
||||
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
}
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
}
|
||||
|
||||
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||
|
||||
}
|
||||
|
||||
MessageDialog msg_dlg(nullptr, _L("Flow Dynamics Calibration result has been saved to the printer"), wxEmptyString, wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
|
|
@ -1098,7 +1117,7 @@ void FlowRateWizard::on_cali_save()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!check_preset_name_valid(new_preset_name))
|
||||
if (!CalibUtils::validate_input_name(new_preset_name))
|
||||
return;
|
||||
|
||||
std::string old_preset_name;
|
||||
|
|
@ -1385,7 +1404,7 @@ void MaxVolumetricSpeedWizard::on_cali_save()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!check_preset_name_valid(new_preset_name))
|
||||
if (!CalibUtils::validate_input_name(new_preset_name))
|
||||
return;
|
||||
|
||||
std::map<std::string, ConfigOption *> key_value_map;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ CalibrationCaliPage::CalibrationCaliPage(wxWindow* parent, CalibMode cali_mode,
|
|||
create_page(this);
|
||||
|
||||
this->SetSizer(m_top_sizer);
|
||||
Layout();
|
||||
m_top_sizer->Fit(this);
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +64,6 @@ void CalibrationCaliPage::create_page(wxWindow* parent)
|
|||
|
||||
m_printing_panel->get_pause_resume_button()->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_pause_resume), NULL, this);
|
||||
m_printing_panel->get_abort_button()->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CalibrationCaliPage::on_subtask_abort), NULL, this);
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
void CalibrationCaliPage::on_subtask_pause_resume(wxCommandEvent& event)
|
||||
|
|
@ -395,6 +394,7 @@ void CalibrationCaliPage::update_subtask(MachineObject* obj)
|
|||
}
|
||||
|
||||
this->Layout();
|
||||
this->Fit();
|
||||
}
|
||||
|
||||
void CalibrationCaliPage::update_basic_print_data(bool def, float weight, int prediction)
|
||||
|
|
@ -424,6 +424,7 @@ void CalibrationCaliPage::reset_printing_values()
|
|||
m_printing_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
|
||||
update_basic_print_data(false);
|
||||
this->Layout();
|
||||
this->Fit();
|
||||
}
|
||||
|
||||
void CalibrationCaliPage::on_device_connected(MachineObject* obj)
|
||||
|
|
|
|||
|
|
@ -35,16 +35,16 @@ void CaliPresetCaliStagePanel::create_panel(wxWindow* parent)
|
|||
|
||||
m_complete_radioBox = new wxRadioButton(parent, wxID_ANY, _L("Complete Calibration"));
|
||||
m_complete_radioBox->SetForegroundColour(*wxBLACK);
|
||||
|
||||
m_complete_radioBox->SetValue(true);
|
||||
m_stage = CALI_MANUAL_STAGE_1;
|
||||
m_top_sizer->Add(m_complete_radioBox);
|
||||
m_top_sizer->AddSpacer(FromDIP(10));
|
||||
|
||||
m_fine_radioBox = new wxRadioButton(parent, wxID_ANY, _L("Fine Calibration based on flow ratio"));
|
||||
m_fine_radioBox->SetForegroundColour(*wxBLACK);
|
||||
m_top_sizer->Add(m_fine_radioBox);
|
||||
|
||||
auto input_panel = new wxPanel(parent);
|
||||
input_panel = new wxPanel(parent);
|
||||
input_panel->Hide();
|
||||
auto input_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
input_panel->SetSizer(input_sizer);
|
||||
|
|
@ -58,15 +58,16 @@ void CaliPresetCaliStagePanel::create_panel(wxWindow* parent)
|
|||
m_top_sizer->Add(input_panel);
|
||||
|
||||
m_top_sizer->AddSpacer(PRESET_GAP);
|
||||
|
||||
// events
|
||||
m_complete_radioBox->Bind(wxEVT_RADIOBUTTON, [this, input_panel](auto& e) {
|
||||
m_complete_radioBox->Bind(wxEVT_RADIOBUTTON, [this](auto& e) {
|
||||
m_stage_panel_parent->get_current_object()->flow_ratio_calibration_type = COMPLETE_CALIBRATION;
|
||||
input_panel->Show(false);
|
||||
m_stage = CALI_MANUAL_STAGE_1;
|
||||
GetParent()->Layout();
|
||||
GetParent()->Fit();
|
||||
});
|
||||
m_fine_radioBox->Bind(wxEVT_RADIOBUTTON, [this, input_panel](auto& e) {
|
||||
m_fine_radioBox->Bind(wxEVT_RADIOBUTTON, [this](auto& e) {
|
||||
m_stage_panel_parent->get_current_object()->flow_ratio_calibration_type = FINE_CALIBRATION;
|
||||
input_panel->Show();
|
||||
m_stage = CALI_MANUAL_STAGE_2;
|
||||
GetParent()->Layout();
|
||||
|
|
@ -127,6 +128,21 @@ void CaliPresetCaliStagePanel::set_flow_ratio_value(float flow_ratio)
|
|||
m_flow_ratio_value = flow_ratio;
|
||||
}
|
||||
|
||||
void CaliPresetCaliStagePanel::set_flow_ratio_calibration_type(FlowRatioCalibrationType type) {
|
||||
if (type == COMPLETE_CALIBRATION) {
|
||||
m_complete_radioBox->SetValue(true);
|
||||
m_stage = CaliPresetStage::CALI_MANUAL_STAGE_1;
|
||||
input_panel->Hide();
|
||||
}
|
||||
else if (type == FINE_CALIBRATION) {
|
||||
m_fine_radioBox->SetValue(true);
|
||||
m_stage = CaliPresetStage::CALI_MANUAL_STAGE_2;
|
||||
input_panel->Show();
|
||||
}
|
||||
GetParent()->Layout();
|
||||
GetParent()->Fit();
|
||||
}
|
||||
|
||||
CaliComboBox::CaliComboBox(wxWindow* parent,
|
||||
wxString title,
|
||||
wxArrayString values,
|
||||
|
|
@ -285,7 +301,6 @@ void CaliPresetCustomRangePanel::create_panel(wxWindow* parent)
|
|||
{
|
||||
wxBoxSizer* horiz_sizer;
|
||||
horiz_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
for (size_t i = 0; i < m_input_value_nums; ++i) {
|
||||
if (i > 0) {
|
||||
horiz_sizer->Add(FromDIP(10), 0, 0, wxEXPAND, 0);
|
||||
|
|
@ -299,6 +314,38 @@ void CaliPresetCustomRangePanel::create_panel(wxWindow* parent)
|
|||
item_sizer->Add(m_title_texts[i], 0, wxALL, 0);
|
||||
m_value_inputs[i] = new TextInput(parent, wxEmptyString, _L("\u2103"), "", wxDefaultPosition, CALIBRATION_FROM_TO_INPUT_SIZE, 0);
|
||||
m_value_inputs[i]->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||
m_value_inputs[i]->GetTextCtrl()->Bind(wxEVT_TEXT, [this, i](wxCommandEvent& event) {
|
||||
std::string number = m_value_inputs[i]->GetTextCtrl()->GetValue().ToStdString();
|
||||
std::string decimal_point;
|
||||
std::string expression = "^[-+]?[0-9]+([,.][0-9]+)?$";
|
||||
std::regex decimalRegex(expression);
|
||||
int decimal_number;
|
||||
if (std::regex_match(number, decimalRegex)) {
|
||||
std::smatch match;
|
||||
if (std::regex_search(number, match, decimalRegex)) {
|
||||
std::string decimalPart = match[1].str();
|
||||
if (decimalPart != "")
|
||||
decimal_number = decimalPart.length() - 1;
|
||||
else
|
||||
decimal_number = 0;
|
||||
}
|
||||
int max_decimal_length;
|
||||
if (i <= 1)
|
||||
max_decimal_length = 3;
|
||||
else if (i >= 2)
|
||||
max_decimal_length = 4;
|
||||
if (decimal_number > max_decimal_length) {
|
||||
int allowed_length = number.length() - decimal_number + max_decimal_length;
|
||||
number = number.substr(0, allowed_length);
|
||||
m_value_inputs[i]->GetTextCtrl()->SetValue(number);
|
||||
m_value_inputs[i]->GetTextCtrl()->SetInsertionPointEnd();
|
||||
}
|
||||
}
|
||||
// input is not a number, invalid.
|
||||
else
|
||||
BOOST_LOG_TRIVIAL(trace) << "The K input string is not a valid number when calibrating. ";
|
||||
|
||||
});
|
||||
item_sizer->Add(m_value_inputs[i], 0, wxALL, 0);
|
||||
horiz_sizer->Add(item_sizer, 0, wxEXPAND, 0);
|
||||
}
|
||||
|
|
@ -390,10 +437,8 @@ void CaliPresetTipsPanel::set_params(int nozzle_temp, int bed_temp, float max_vo
|
|||
wxString text_nozzle_temp = wxString::Format("%d", nozzle_temp);
|
||||
m_nozzle_temp->GetTextCtrl()->SetValue(text_nozzle_temp);
|
||||
|
||||
wxString bed_temp_text = wxString::Format("%d", bed_temp);
|
||||
if (bed_temp == 0)
|
||||
bed_temp_text = "-";
|
||||
m_bed_temp->SetLabel(bed_temp_text + _L(" \u2103"));
|
||||
std::string bed_temp_text = bed_temp==0 ? "-": std::to_string(bed_temp);
|
||||
m_bed_temp->SetLabel(wxString::FromUTF8(bed_temp_text + "°C"));
|
||||
|
||||
wxString flow_val_text = wxString::Format("%0.2f", max_volumetric);
|
||||
m_max_volumetric_speed->GetTextCtrl()->SetValue(flow_val_text);
|
||||
|
|
@ -676,6 +721,7 @@ void CalibrationPresetPage::create_page(wxWindow* parent)
|
|||
m_top_sizer->Add(m_step_panel, 0, wxEXPAND, 0);
|
||||
|
||||
m_cali_stage_panel = new CaliPresetCaliStagePanel(parent);
|
||||
m_cali_stage_panel->set_parent(this);
|
||||
m_top_sizer->Add(m_cali_stage_panel, 0);
|
||||
|
||||
m_selection_panel = new wxPanel(parent);
|
||||
|
|
@ -1040,11 +1086,6 @@ void CalibrationPresetPage::update_plate_type_collection(CalibrationMethod metho
|
|||
const ConfigOptionDef* bed_type_def = print_config_def.get("curr_bed_type");
|
||||
if (bed_type_def && bed_type_def->enum_keys_map) {
|
||||
for (int i = 0; i < bed_type_def->enum_labels.size(); i++) {
|
||||
if(btDefault + 1 + i == btPTE) {
|
||||
if (method == CalibrationMethod::CALI_METHOD_AUTO) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
m_comboBox_bed_type->AppendString(_L(bed_type_def->enum_labels[i]));
|
||||
}
|
||||
m_comboBox_bed_type->SetSelection(0);
|
||||
|
|
@ -1458,6 +1499,8 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
|
|||
{
|
||||
if (!obj) return;
|
||||
|
||||
//set flow ratio calibration type
|
||||
m_cali_stage_panel->set_flow_ratio_calibration_type(obj->flow_ratio_calibration_type);
|
||||
// set nozzle value from machine
|
||||
bool nozzle_is_set = false;
|
||||
for (int i = 0; i < NOZZLE_LIST_COUNT; i++) {
|
||||
|
|
@ -1482,8 +1525,8 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
|
|||
}
|
||||
|
||||
// set bed type collection from machine
|
||||
if (m_cali_mode == CalibMode::Calib_PA_Line)
|
||||
update_plate_type_collection(m_cali_method);
|
||||
//if (m_cali_mode == CalibMode::Calib_PA_Line)
|
||||
// update_plate_type_collection(m_cali_method);
|
||||
|
||||
// init default for filament source
|
||||
// TODO if user change ams/ext, need to update
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ enum FlowRatioCaliSource {
|
|||
FROM_COARSE_PAGE,
|
||||
};
|
||||
|
||||
class CalibrationPresetPage;
|
||||
|
||||
class CaliPresetCaliStagePanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
|
|
@ -30,14 +32,17 @@ public:
|
|||
void get_cali_stage(CaliPresetStage& stage, float& value);
|
||||
|
||||
void set_flow_ratio_value(float flow_ratio);
|
||||
|
||||
void set_parent(CalibrationPresetPage* parent) { m_stage_panel_parent = parent; }
|
||||
void set_flow_ratio_calibration_type(FlowRatioCalibrationType type);
|
||||
protected:
|
||||
CaliPresetStage m_stage;
|
||||
wxBoxSizer* m_top_sizer;
|
||||
wxRadioButton* m_complete_radioBox;
|
||||
wxRadioButton* m_fine_radioBox;
|
||||
TextInput * flow_ratio_input;
|
||||
wxPanel* input_panel;
|
||||
float m_flow_ratio_value;
|
||||
CalibrationPresetPage* m_stage_panel_parent;
|
||||
};
|
||||
|
||||
class CaliComboBox : public wxPanel
|
||||
|
|
@ -162,6 +167,7 @@ public:
|
|||
void stripWhiteSpace(std::string& str);
|
||||
void update_priner_status_msg(wxString msg, bool is_warning);
|
||||
void update(MachineObject* obj) override;
|
||||
void update_flow_ratio_type(FlowRatioCalibrationType type) { curr_obj->flow_ratio_calibration_type = type; }
|
||||
|
||||
void on_device_connected(MachineObject* obj) override;
|
||||
|
||||
|
|
@ -206,7 +212,7 @@ public:
|
|||
CalibMode get_pa_cali_method();
|
||||
|
||||
CaliPresetPageStatus get_page_status() { return m_page_status; }
|
||||
|
||||
MachineObject* get_current_object() { return curr_obj; }
|
||||
void msw_rescale() override;
|
||||
void on_sys_color_changed() override;
|
||||
|
||||
|
|
@ -306,4 +312,4 @@ public:
|
|||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -552,16 +552,8 @@ bool CaliPASaveManualPanel::get_result(PACalibResult& out_result) {
|
|||
}
|
||||
|
||||
wxString name = m_save_name_input->GetTextCtrl()->GetValue();
|
||||
if (name.IsEmpty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("Please enter the name you want to save to printer."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return false;
|
||||
}
|
||||
else if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
out_result.k_value = k;
|
||||
out_result.name = into_u8(name);
|
||||
|
|
@ -874,11 +866,11 @@ void CalibrationPASavePage::show_panels(CalibrationMethod method, const PrinterS
|
|||
}
|
||||
m_p1p_panel->Show(false);
|
||||
}
|
||||
else if (printer_ser == PrinterSeries::SERIES_P1P) {
|
||||
else if (curr_obj->cali_version >= 0) {
|
||||
m_auto_panel->Show(false);
|
||||
m_manual_panel->Show(false);
|
||||
m_p1p_panel->set_pa_cali_method(curr_obj->manual_pa_cali_method);
|
||||
m_p1p_panel->Show();
|
||||
m_manual_panel->set_pa_cali_method(curr_obj->manual_pa_cali_method);
|
||||
m_manual_panel->Show();
|
||||
m_p1p_panel->Show(false);
|
||||
} else {
|
||||
m_auto_panel->Show(false);
|
||||
m_manual_panel->Show(false);
|
||||
|
|
|
|||
|
|
@ -161,19 +161,24 @@ void CalibrationPAStartPage::on_device_connected(MachineObject* obj)
|
|||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, false);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
|
||||
// is support auto cali
|
||||
bool is_support_pa_auto = (obj->home_flag >> 16 & 1) == 1;
|
||||
if (!is_support_pa_auto) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
}
|
||||
else if (obj->get_printer_series() == PrinterSeries::SERIES_P1P || obj->get_printer_arch() == PrinterArch::ARCH_I3) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
if (obj->cali_version >= 0) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, true);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
}
|
||||
else
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, true);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, false);
|
||||
}
|
||||
|
||||
//is support auto cali
|
||||
bool is_support_pa_auto = (obj->home_flag >> 16 & 1) == 1;
|
||||
if (!is_support_pa_auto) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrationPAStartPage::msw_rescale()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <wx/clipbrd.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#include "GUI_App.hpp"
|
||||
#include <slic3r/GUI/StatusPanel.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
|
@ -65,6 +66,24 @@ CameraPopup::CameraPopup(wxWindow *parent)
|
|||
top_sizer->Add(m_text_vcamera, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));
|
||||
top_sizer->Add(m_switch_vcamera, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5));
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
m_text_liveview_retry = new wxStaticText(m_panel, wxID_ANY, _L("Liveview Retry"));
|
||||
m_text_liveview_retry->Wrap(-1);
|
||||
m_text_liveview_retry->SetFont(Label::Head_14);
|
||||
m_text_liveview_retry->SetForegroundColour(TEXT_COL);
|
||||
m_switch_liveview_retry = new SwitchButton(m_panel);
|
||||
bool auto_retry = wxGetApp().app_config->get("liveview", "auto_retry") != "false";
|
||||
m_switch_liveview_retry->SetValue(auto_retry);
|
||||
|
||||
top_sizer->Add(m_text_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));
|
||||
top_sizer->Add(m_switch_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5));
|
||||
|
||||
m_switch_liveview_retry->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &e) {
|
||||
wxGetApp().app_config->set("liveview", "auto_retry", e.IsChecked());
|
||||
e.Skip();
|
||||
});
|
||||
#endif
|
||||
|
||||
//resolution
|
||||
m_text_resolution = new wxStaticText(m_panel, wxID_ANY, _L("Resolution"));
|
||||
m_text_resolution->Wrap(-1);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ private:
|
|||
SwitchButton* m_switch_recording;
|
||||
wxStaticText* m_text_vcamera;
|
||||
SwitchButton* m_switch_vcamera;
|
||||
wxStaticText* m_text_liveview_retry;
|
||||
SwitchButton* m_switch_liveview_retry;
|
||||
wxStaticText* m_custom_camera_hint;
|
||||
TextInput* m_custom_camera_input;
|
||||
Button* m_custom_camera_input_confirm;
|
||||
|
|
|
|||
|
|
@ -56,24 +56,42 @@ void ConfigManipulation::toggle_line(const std::string& opt_key, const bool togg
|
|||
cb_toggle_line(opt_key, toggle);
|
||||
}
|
||||
|
||||
void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrintConfig *config) {
|
||||
if (is_msg_dlg_already_exist)
|
||||
return;
|
||||
|
||||
int temperature_range_low, temperature_range_high;
|
||||
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
|
||||
|
||||
wxString msg_text;
|
||||
bool need_check = false;
|
||||
if (temperature_range_low < 190 || temperature_range_high > 300) {
|
||||
msg_text += _L("The recommended minimum temperature is less than 190 degree or the recommended maximum temperature is greater than 300 degree.\n");
|
||||
need_check = true;
|
||||
}
|
||||
if (temperature_range_low > temperature_range_high) {
|
||||
msg_text += _L("The recommended minimum temperature cannot be higher than the recommended maximum temperature.\n");
|
||||
need_check = true;
|
||||
}
|
||||
if (need_check) {
|
||||
msg_text += _L("Please check.\n");
|
||||
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
|
||||
is_msg_dlg_already_exist = true;
|
||||
dialog.ShowModal();
|
||||
is_msg_dlg_already_exist = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigManipulation::check_nozzle_temperature_range(DynamicPrintConfig *config)
|
||||
{
|
||||
if (is_msg_dlg_already_exist)
|
||||
return;
|
||||
|
||||
int temperature_range_low = config->has("nozzle_temperature_range_low") ?
|
||||
config->opt_int("nozzle_temperature_range_low", (unsigned int)0) :
|
||||
0;
|
||||
int temperature_range_high = config->has("nozzle_temperature_range_high") ?
|
||||
config->opt_int("nozzle_temperature_range_high", (unsigned int)0) :
|
||||
0;
|
||||
int temperature_range_low, temperature_range_high;
|
||||
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
|
||||
|
||||
if (temperature_range_low != 0 &&
|
||||
temperature_range_high != 0 &&
|
||||
config->has("nozzle_temperature")) {
|
||||
if (config->opt_int("nozzle_temperature", 0) < temperature_range_low ||
|
||||
config->opt_int("nozzle_temperature", 0) > temperature_range_high)
|
||||
{
|
||||
if (config->has("nozzle_temperature")) {
|
||||
if (config->opt_int("nozzle_temperature", 0) < temperature_range_low || config->opt_int("nozzle_temperature", 0) > temperature_range_high) {
|
||||
wxString msg_text = _(L("Nozzle may be blocked when the temperature is out of recommended range.\n"
|
||||
"Please make sure whether to use the temperature to print.\n\n"));
|
||||
msg_text += wxString::Format(_L("Recommended nozzle temperature of this filament type is [%d, %d] degree centigrade"), temperature_range_low, temperature_range_high);
|
||||
|
|
@ -90,16 +108,10 @@ void ConfigManipulation::check_nozzle_temperature_initial_layer_range(DynamicPri
|
|||
if (is_msg_dlg_already_exist)
|
||||
return;
|
||||
|
||||
int temperature_range_low = config->has("nozzle_temperature_range_low") ?
|
||||
config->opt_int("nozzle_temperature_range_low", (unsigned int)0) :
|
||||
0;
|
||||
int temperature_range_high = config->has("nozzle_temperature_range_high") ?
|
||||
config->opt_int("nozzle_temperature_range_high", (unsigned int)0) :
|
||||
0;
|
||||
int temperature_range_low, temperature_range_high;
|
||||
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
|
||||
|
||||
if (temperature_range_low != 0 &&
|
||||
temperature_range_high != 0 &&
|
||||
config->has("nozzle_temperature_initial_layer")) {
|
||||
if (config->has("nozzle_temperature_initial_layer")) {
|
||||
if (config->opt_int("nozzle_temperature_initial_layer", 0) < temperature_range_low ||
|
||||
config->opt_int("nozzle_temperature_initial_layer", 0) > temperature_range_high)
|
||||
{
|
||||
|
|
@ -161,7 +173,7 @@ void ConfigManipulation::check_chamber_temperature(DynamicPrintConfig* config)
|
|||
}
|
||||
}
|
||||
|
||||
void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config)
|
||||
void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config, const bool is_plate_config)
|
||||
{
|
||||
// #ys_FIXME_to_delete
|
||||
//! Temporary workaround for the correct updates of the TextCtrl (like "layer_height"):
|
||||
|
|
@ -171,6 +183,8 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
|
|||
if (is_msg_dlg_already_exist)
|
||||
return;
|
||||
|
||||
bool is_object_config = (!is_global_config && !is_plate_config);
|
||||
|
||||
// layer_height shouldn't be equal to zero
|
||||
auto layer_height = config->opt_float("layer_height");
|
||||
auto gpreset = GUI::wxGetApp().preset_bundle->printers.get_edited_preset();
|
||||
|
|
@ -273,7 +287,8 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
|
|||
double sparse_infill_density = config->option<ConfigOptionPercent>("sparse_infill_density")->value;
|
||||
auto timelapse_type = config->opt_enum<TimelapseType>("timelapse_type");
|
||||
|
||||
if (config->opt_bool("spiral_mode") &&
|
||||
if (!is_plate_config &&
|
||||
config->opt_bool("spiral_mode") &&
|
||||
! (config->opt_int("wall_loops") == 1 &&
|
||||
config->opt_int("top_shell_layers") == 0 &&
|
||||
sparse_infill_density == 0 &&
|
||||
|
|
@ -284,24 +299,10 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
|
|||
config->opt_enum<WallDirection>("wall_direction") == WallDirection::Auto &&
|
||||
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional))
|
||||
{
|
||||
wxString msg_text = _(L("Spiral mode only works when wall loops is 1, support is disabled, top shell layers is 0, sparse infill density is 0 and timelapse type is traditional."));
|
||||
|
||||
auto printer_structure_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure");
|
||||
if (printer_structure_opt && printer_structure_opt->value == PrinterStructure::psI3) {
|
||||
msg_text += _(L(" But machines with I3 structure will not generate timelapse videos."));
|
||||
}
|
||||
|
||||
if (is_global_config)
|
||||
msg_text += "\n\n" + _(L("Change these settings automatically? \n"
|
||||
"Yes - Change these settings and enable spiral mode automatically\n"
|
||||
"No - Give up using spiral mode this time"));
|
||||
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
|
||||
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
|
||||
DynamicPrintConfig new_conf = *config;
|
||||
is_msg_dlg_already_exist = true;
|
||||
auto answer = dialog.ShowModal();
|
||||
auto answer = show_spiral_mode_settings_dialog(is_object_config);
|
||||
bool support = true;
|
||||
if (!is_global_config || answer == wxID_YES) {
|
||||
if (answer == wxID_YES) {
|
||||
new_conf.set_key_value("wall_loops", new ConfigOptionInt(1));
|
||||
new_conf.set_key_value("top_shell_layers", new ConfigOptionInt(0));
|
||||
new_conf.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
|
||||
|
|
@ -843,5 +844,42 @@ void ConfigManipulation::toggle_print_sla_options(DynamicPrintConfig* config)
|
|||
toggle_field("pad_object_connector_penetration", zero_elev);
|
||||
}
|
||||
|
||||
int ConfigManipulation::show_spiral_mode_settings_dialog(bool is_object_config)
|
||||
{
|
||||
wxString msg_text = _(L("Spiral mode only works when wall loops is 1, support is disabled, top shell layers is 0, sparse infill density is 0 and timelapse type is traditional."));
|
||||
auto printer_structure_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure");
|
||||
if (printer_structure_opt && printer_structure_opt->value == PrinterStructure::psI3) {
|
||||
msg_text += _(L(" But machines with I3 structure will not generate timelapse videos."));
|
||||
}
|
||||
if (!is_object_config)
|
||||
msg_text += "\n\n" + _(L("Change these settings automatically? \n"
|
||||
"Yes - Change these settings and enable spiral mode automatically\n"
|
||||
"No - Give up using spiral mode this time"));
|
||||
|
||||
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
|
||||
wxICON_WARNING | (!is_object_config ? wxYES | wxNO : wxOK));
|
||||
is_msg_dlg_already_exist = true;
|
||||
auto answer = dialog.ShowModal();
|
||||
is_msg_dlg_already_exist = false;
|
||||
if (is_object_config)
|
||||
answer = wxID_YES;
|
||||
return answer;
|
||||
}
|
||||
|
||||
bool ConfigManipulation::get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high)
|
||||
{
|
||||
bool range_low_exist = false, range_high_exist = false;
|
||||
if (config->has("nozzle_temperature_range_low")) {
|
||||
range_low = config->opt_int("nozzle_temperature_range_low", (unsigned int) 0);
|
||||
range_low_exist = true;
|
||||
}
|
||||
if (config->has("nozzle_temperature_range_high")) {
|
||||
range_high = config->opt_int("nozzle_temperature_range_high", (unsigned int) 0);
|
||||
range_high_exist = true;
|
||||
}
|
||||
return range_low_exist && range_high_exist;
|
||||
}
|
||||
|
||||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
|
|
|||
|
|
@ -69,11 +69,12 @@ public:
|
|||
void toggle_line(const std::string& field_key, const bool toggle);
|
||||
|
||||
// FFF print
|
||||
void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false);
|
||||
void update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false, const bool is_plate_config = false);
|
||||
void toggle_print_fff_options(DynamicPrintConfig* config, const bool is_global_config = false);
|
||||
void apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase*, ModelConfig*> const & configs);
|
||||
|
||||
//BBS: FFF filament nozzle temperature range
|
||||
void check_nozzle_recommended_temperature_range(DynamicPrintConfig *config);
|
||||
void check_nozzle_temperature_range(DynamicPrintConfig* config);
|
||||
void check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config);
|
||||
void check_filament_max_volumetric_speed(DynamicPrintConfig *config);
|
||||
|
|
@ -89,10 +90,10 @@ public:
|
|||
m_is_initialized_support_material_overhangs_queried = true;
|
||||
m_support_material_overhangs_queried = queried;
|
||||
}
|
||||
int show_spiral_mode_settings_dialog(bool is_object_config = false);
|
||||
|
||||
private:
|
||||
std::vector<int> get_temperature_range_by_filament_type(const std::string &filament_type);
|
||||
|
||||
bool get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high);
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
|||
|
|
@ -46,17 +46,6 @@ static const std::vector<std::string> filament_types = {"PLA", "PLA+", "PLA
|
|||
"PETGCF", "PTBA", "PTBA90A", "PEEK", "TPU93A", "TPU75D", "TPU", "TPU92A", "TPU98A", "Misc",
|
||||
"TPE", "GLAZE", "Nylon", "CPE", "METAL", "ABST", "Carbon Fiber"};
|
||||
|
||||
static const std::vector<std::string> system_filament_types = {"PLA", "ABS", "TPU", "PC", "ASA", "PA-CF", "PA6-CF", "PET-CF", "PETG", "PETG-CF",
|
||||
"PLA Aero", "PLA-CF", "PPA-CF", "PPA-GF", "PA", "HIPS", "PPS", "PPS-CF", "PVA"};
|
||||
|
||||
static std::unordered_map<std::string, std::string> system_filament_types_map = {{"PLA", "PLA"}, {"ABS", "ABS"}, {"TPU", "TPU"},
|
||||
{"PC", "PC"}, {"ASA", "ASA"}, {"PA-CF", "PA-CF"},
|
||||
{"PA6-CF", "PA6-CF"}, {"PET-CF", "PET-CF"}, {"PETG", "PETG"},
|
||||
{"PETG-CF", "PETG-CF"}, {"PLA Aero", "PLA-AERO"}, {"PLA-CF", "PLA-CF"},
|
||||
{"PPA-CF", "PPA-CF"}, {"PPA-GF", "PPA-GF"}, {"PA", "PA"},
|
||||
{"HIPS", "HIPS"}, {"PPS", "PPS"}, {"PPS-CF", "PPS-CF"},
|
||||
{"PVA", "PVA"}};
|
||||
|
||||
static const std::vector<std::string> printer_vendors = {"Anycubic", "Artillery", "BIBO", "BIQU", "Creality ENDER", "Creality CR", "Creality SERMOON",
|
||||
"FLSun", "gCreate", "Geeetech", "INAT", "Infinity3D", "Jubilee", "LNL3D",
|
||||
"LulzBot", "MakerGear", "Original Prusa", "Papapiu", "Print4Taste", "RatRig", "Rigid3D",
|
||||
|
|
@ -520,6 +509,20 @@ static char* read_json_file(const std::string &preset_path)
|
|||
return json_contents;
|
||||
}
|
||||
|
||||
static std::string get_printer_nozzle_diameter(std::string printer_name) {
|
||||
|
||||
size_t index = printer_name.find(" nozzle");
|
||||
if (std::string::npos == index) {
|
||||
return "";
|
||||
}
|
||||
std::string nozzle = printer_name.substr(0, index);
|
||||
size_t last_space_index = nozzle.find_last_of(" ");
|
||||
if (std::string::npos == index) {
|
||||
return "";
|
||||
}
|
||||
return nozzle.substr(last_space_index + 1);
|
||||
}
|
||||
|
||||
static void adjust_dialog_in_screen(DPIDialog* dialog) {
|
||||
wxSize screen_size = wxGetDisplaySize();
|
||||
int pos_x, pos_y, size_x, size_y, screen_width, screen_height, dialog_x, dialog_y;
|
||||
|
|
@ -547,6 +550,7 @@ CreateFilamentPresetDialog::CreateFilamentPresetDialog(wxWindow *parent)
|
|||
{
|
||||
m_create_type.base_filament = _L("Create Based on Current Filament");
|
||||
m_create_type.base_filament_preset = _L("Copy Current Filament Preset ");
|
||||
get_all_filament_presets();
|
||||
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
this->SetSize(wxSize(FromDIP(600), FromDIP(480)));
|
||||
|
|
@ -595,7 +599,6 @@ CreateFilamentPresetDialog::CreateFilamentPresetDialog(wxWindow *parent)
|
|||
m_main_sizer->Add(m_scrolled_preset_panel, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(10));
|
||||
m_main_sizer->Add(create_button_item(), 0, wxEXPAND | wxALL, FromDIP(10));
|
||||
|
||||
get_all_filament_presets();
|
||||
get_all_visible_printer_name();
|
||||
select_curr_radiobox(m_create_type_btns, 0);
|
||||
|
||||
|
|
@ -748,7 +751,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_type_item()
|
|||
horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
|
||||
|
||||
wxArrayString filament_type;
|
||||
for (const wxString &filament : system_filament_types) {
|
||||
for (const wxString &filament : m_system_filament_types_set) {
|
||||
filament_type.Add(filament);
|
||||
}
|
||||
|
||||
|
|
@ -851,13 +854,13 @@ wxBoxSizer *CreateFilamentPresetDialog::create_filament_preset_item()
|
|||
continue;
|
||||
}
|
||||
for (std::string &compatible_printer_name : compatible_printers->values) {
|
||||
if (m_visible_printers.find(compatible_printer_name) == m_visible_printers.end()) continue;
|
||||
size_t index = compatible_printer_name.find("nozzle");
|
||||
if (index < 4) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer name encounter exception and name is: " << compatible_printer_name;
|
||||
if (m_visible_printers.find(compatible_printer_name) == m_visible_printers.end()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "there is a comppatible printer no exist: " << compatible_printer_name
|
||||
<< "and the preset name is: " << preset->name;
|
||||
continue;
|
||||
}
|
||||
if (nozzle_diameter[compatible_printer_name.substr(index - 4, 3)] == 0) {
|
||||
std::string nozzle = get_printer_nozzle_diameter(compatible_printer_name);
|
||||
if (nozzle_diameter[nozzle] == 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer nozzle encounter exception and name is: " << compatible_printer_name;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1005,11 +1008,21 @@ wxBoxSizer *CreateFilamentPresetDialog::create_button_item()
|
|||
return;
|
||||
}
|
||||
|
||||
std::string filament_preset_name = vendor_name + " " + type_name + " " + serial_name;
|
||||
std::string filament_preset_name = vendor_name + " " + (type_name == "PLA-AERO" ? "PLA Aero" : type_name) + " " + serial_name;
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
if (preset_bundle->filaments.is_alias_exist(filament_preset_name)) {
|
||||
MessageDialog dlg(this,
|
||||
wxString::Format(_L("The Filament name %s you created already exists. \nIf you continue creating, the preset created will be displayed with its "
|
||||
"full name. Do you want to continue?"),
|
||||
from_u8(filament_preset_name)),
|
||||
wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
|
||||
if (wxID_YES != dlg.ShowModal()) { return; }
|
||||
}
|
||||
|
||||
std::string user_filament_id = get_filament_id(filament_preset_name);
|
||||
|
||||
const wxString &curr_create_type = curr_create_filament_type();
|
||||
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
if (curr_create_type == m_create_type.base_filament) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament create type filament ";
|
||||
for (const std::pair<::CheckBox *, std::pair<std::string, Preset *>> &checkbox_preset : m_filament_preset) {
|
||||
|
|
@ -1106,10 +1119,14 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices()
|
|||
for (std::pair<std::string, Preset*> filament_presets : m_all_presets_map) {
|
||||
Preset *preset = filament_presets.second;
|
||||
auto inherit = preset->config.option<ConfigOptionString>("inherits");
|
||||
if (inherit && !inherit->value.empty()) continue;
|
||||
if (inherit && !inherit->value.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " inherit user preset is:" << preset->name << " and inherits is: " << inherit->value;
|
||||
continue;
|
||||
}
|
||||
auto fila_type = preset->config.option<ConfigOptionStrings>("filament_type");
|
||||
if (!fila_type || fila_type->values.empty() || system_filament_types_map[type_name] != fila_type->values[0]) continue;
|
||||
if (!fila_type || fila_type->values.empty() || type_name != fila_type->values[0]) continue;
|
||||
m_filament_choice_map[preset->filament_id].push_back(preset);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " base user preset is:" << preset->name;
|
||||
}
|
||||
|
||||
int suffix = 0;
|
||||
|
|
@ -1119,10 +1136,10 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices()
|
|||
for (Preset* filament_preset : preset.second) {
|
||||
std::string preset_name = filament_preset->name;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament_id: " << filament_preset->filament_id << " preset name: " << filament_preset->name;
|
||||
size_t index_at = preset_name.find("@");
|
||||
size_t index_at = preset_name.find(" @");
|
||||
if (std::string::npos != index_at) {
|
||||
std::string cur_preset_name = preset_name.substr(0, index_at - 1);
|
||||
preset_name_set.insert(wxString::FromUTF8(cur_preset_name));
|
||||
std::string cur_preset_name = preset_name.substr(0, index_at);
|
||||
preset_name_set.insert(from_u8(cur_preset_name));
|
||||
}
|
||||
}
|
||||
assert(1 == preset_name_set.size());
|
||||
|
|
@ -1261,12 +1278,8 @@ void CreateFilamentPresetDialog::get_filament_presets_by_machine()
|
|||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " preset type is not selected type and preset name is: " << preset->name;
|
||||
continue;
|
||||
}
|
||||
size_t index = compatible_printer_name.find("nozzle");
|
||||
if (index < 4) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer name encounter exception and name is: " << compatible_printer_name;
|
||||
continue;
|
||||
}
|
||||
if (nozzle_diameter[compatible_printer_name.substr(index - 4, 3)] == 0) {
|
||||
std::string nozzle = get_printer_nozzle_diameter(compatible_printer_name);
|
||||
if (nozzle_diameter[nozzle] == 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " compatible printer nozzle encounter exception and name is: " << compatible_printer_name;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1310,8 +1323,11 @@ void CreateFilamentPresetDialog::get_all_filament_presets()
|
|||
const std::deque<Preset> &temp_filament_presets = preset_bundle->filaments.get_presets();
|
||||
for (const Preset& preset : temp_filament_presets) {
|
||||
if (preset.filament_id.empty() || "null" == preset.filament_id) continue;
|
||||
std::string filament_preset_name = preset.name;
|
||||
auto filament_type = preset.config.option<ConfigOptionStrings>("filament_type");
|
||||
if (filament_type && filament_type->values.size())
|
||||
m_system_filament_types_set.insert(filament_type->values[0]);
|
||||
if (!preset.is_visible) continue;
|
||||
std::string filament_preset_name = preset.name;
|
||||
Preset *filament_preset = new Preset(preset);
|
||||
m_all_presets_map[filament_preset_name] = filament_preset;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " loaded preset name is: " << filament_preset->name;
|
||||
|
|
@ -1352,14 +1368,18 @@ void CreateFilamentPresetDialog::sort_printer_by_nozzle(std::vector<std::pair<st
|
|||
std::unordered_map<std::string, float> nozzle_diameter = nozzle_diameter_map;
|
||||
std::sort(printer_name_to_filament_preset.begin(), printer_name_to_filament_preset.end(),
|
||||
[&nozzle_diameter](const std::pair<string, T> &a, const std::pair<string, T> &b) {
|
||||
size_t nozzle_index_a = a.first.find("nozzle");
|
||||
size_t nozzle_index_b = b.first.find("nozzle");
|
||||
size_t nozzle_index_a = a.first.find(" nozzle");
|
||||
size_t nozzle_index_b = b.first.find(" nozzle");
|
||||
if (nozzle_index_a == std::string::npos || nozzle_index_b == std::string::npos) return a.first < b.first;
|
||||
std::string nozzle_str_a;
|
||||
std::string nozzle_str_b;
|
||||
try {
|
||||
nozzle_str_a = a.first.substr(nozzle_index_a - 4, 3);
|
||||
nozzle_str_b = b.first.substr(nozzle_index_b - 4, 3);
|
||||
nozzle_str_a = a.first.substr(0, nozzle_index_a);
|
||||
nozzle_str_b = b.first.substr(0, nozzle_index_b);
|
||||
size_t last_space_index = nozzle_str_a.find_last_of(" ");
|
||||
nozzle_str_a = nozzle_str_a.substr(last_space_index + 1);
|
||||
last_space_index = nozzle_str_b.find_last_of(" ");
|
||||
nozzle_str_b = nozzle_str_b.substr(last_space_index + 1);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << "substr filed, and printer name is: " << a.first << " and " << b.first;
|
||||
return a.first < b.first;
|
||||
|
|
@ -2854,6 +2874,8 @@ bool CreatePrinterPresetDialog::data_init()
|
|||
|
||||
void CreatePrinterPresetDialog::set_current_visible_printer()
|
||||
{
|
||||
//The entire process of creating a custom printer only needs to be done once
|
||||
if (m_printer_name_to_preset.size() > 0) return;
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
const std::deque<Preset> &printer_presets = preset_bundle->printers.get_presets();
|
||||
wxArrayString printer_choice;
|
||||
|
|
@ -2861,7 +2883,7 @@ void CreatePrinterPresetDialog::set_current_visible_printer()
|
|||
for (const Preset &printer_preset : printer_presets) {
|
||||
if (printer_preset.is_system || !printer_preset.is_visible) continue;
|
||||
if (preset_bundle->printers.get_preset_base(printer_preset)->name != printer_preset.name) continue;
|
||||
printer_choice.push_back(wxString::FromUTF8(printer_preset.name));
|
||||
printer_choice.push_back(from_u8(printer_preset.name));
|
||||
m_printer_name_to_preset[printer_preset.name] = std::make_shared<Preset>(printer_preset);
|
||||
}
|
||||
m_select_printer->Set(printer_choice);
|
||||
|
|
@ -3189,6 +3211,7 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
|
|||
wxBoxSizer *success_text_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
wxStaticText *success_text;
|
||||
wxStaticText *next_step_text;
|
||||
bool sync_user_preset_need_enabled = wxGetApp().getAgent() && wxGetApp().app_config->get("sync_user_preset") == "false";
|
||||
switch (create_success_type) {
|
||||
case PRINTER:
|
||||
success_text = new wxStaticText(this, wxID_ANY, _L("Printer Created"));
|
||||
|
|
@ -3196,11 +3219,14 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
|
|||
break;
|
||||
case FILAMENT:
|
||||
success_text = new wxStaticText(this, wxID_ANY, _L("Filament Created"));
|
||||
next_step_text = new wxStaticText(this, wxID_ANY, _L("Please go to filament setting to edit your presets if you need.\nPlease note that nozzle temperature, hot bed temperature, and maximum volumetric speed have a significant impact on printing quality. Please set them carefully."));
|
||||
wxString prompt_text = _L("Please go to filament setting to edit your presets if you need.\nPlease note that nozzle temperature, hot bed temperature, and maximum "
|
||||
"volumetric speed has a significant impact on printing quality. Please set them carefully.");
|
||||
wxString sync_text = sync_user_preset_need_enabled ? _L("\n\nStudio has detected that your user presets synchronization function is not enabled, which may result in unsuccessful Filament settings on "
|
||||
"the Device page. \nClick \"Sync user presets\" to enable the synchronization function.") : "";
|
||||
next_step_text = new wxStaticText(this, wxID_ANY, prompt_text + sync_text);
|
||||
break;
|
||||
}
|
||||
success_text->SetFont(Label::Head_18);
|
||||
//next_step_text->SetFont(Label::Body_14);
|
||||
success_text_sizer->Add(success_text, 0, wxEXPAND, 0);
|
||||
success_text_sizer->Add(next_step_text, 0, wxEXPAND | wxTOP, FromDIP(5));
|
||||
horizontal_sizer->Add(success_text_sizer, 0, wxEXPAND | wxALL, FromDIP(5));
|
||||
|
|
@ -3214,8 +3240,7 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
|
|||
case PRINTER:
|
||||
m_button_ok = new Button(this, _L("Printer Setting"));
|
||||
break;
|
||||
case FILAMENT:
|
||||
m_button_ok = new Button(this, _L("OK"));
|
||||
case FILAMENT: m_button_ok = sync_user_preset_need_enabled ? new Button(this, _L("Sync user presets")) : new Button(this, _L("OK"));
|
||||
break;
|
||||
}
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
||||
|
|
@ -3232,9 +3257,15 @@ CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(wxWindow *parent, con
|
|||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
btn_sizer->Add(m_button_ok, 0, wxRIGHT, FromDIP(10));
|
||||
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_OK); });
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this, sync_user_preset_need_enabled](wxMouseEvent &e) {
|
||||
if (sync_user_preset_need_enabled) {
|
||||
wxGetApp().app_config->set("sync_user_preset", "true");
|
||||
wxGetApp().start_sync_user_preset();
|
||||
}
|
||||
EndModal(wxID_OK);
|
||||
});
|
||||
|
||||
if (PRINTER == create_success_type) {
|
||||
if (PRINTER == create_success_type || sync_user_preset_need_enabled) {
|
||||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||
|
|
@ -3339,6 +3370,10 @@ ExportConfigsDialog::~ExportConfigsDialog()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the Temp folder
|
||||
boost::filesystem::path temp_folder(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp");
|
||||
if (boost::filesystem::exists(temp_folder)) boost::filesystem::remove_all(temp_folder);
|
||||
}
|
||||
|
||||
void ExportConfigsDialog::on_dpi_changed(const wxRect &suggested_rect) {
|
||||
|
|
@ -3394,6 +3429,26 @@ bool ExportConfigsDialog::has_check_box_selected()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ExportConfigsDialog::earse_preset_fields_for_safe(Preset *preset)
|
||||
{
|
||||
if (preset->type != Preset::Type::TYPE_PRINTER) return true;
|
||||
|
||||
boost::filesystem::path file_path(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp" + "/" + (preset->name + ".json"));
|
||||
preset->file = file_path.make_preferred().string();
|
||||
|
||||
DynamicPrintConfig &config = preset->config;
|
||||
config.erase("print_host");
|
||||
config.erase("print_host_webui");
|
||||
config.erase("printhost_apikey");
|
||||
config.erase("printhost_cafile");
|
||||
config.erase("printhost_user");
|
||||
config.erase("printhost_password");
|
||||
config.erase("printhost_port");
|
||||
|
||||
preset->save(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ExportConfigsDialog::initial_file_path(const wxString &path, const std::string &sub_file_path)
|
||||
{
|
||||
std::string export_path = into_u8(path);
|
||||
|
|
@ -3655,11 +3710,15 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
|
|||
std::string printer_preset_name_ = printer_preset->name;
|
||||
|
||||
json bundle_structure;
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
std::string clock = get_curr_timestmp();
|
||||
bundle_structure["user_name"] = "";
|
||||
bundle_structure["user_id"] = "";
|
||||
bundle_structure["version"] = SoftFever_VERSION;
|
||||
bundle_structure["bundle_id"] = printer_preset_name_ + "_" + clock;
|
||||
if (agent) {
|
||||
bundle_structure["version"] = agent->get_version();
|
||||
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + printer_preset_name_ + "_" + clock;
|
||||
} else {
|
||||
bundle_structure["version"] = "";
|
||||
bundle_structure["bundle_id"] = "offline_" + printer_preset_name_ + "_" + clock;
|
||||
}
|
||||
bundle_structure["bundle_type"] = "printer config bundle";
|
||||
bundle_structure["printer_preset_name"] = printer_preset_name_;
|
||||
json printer_config = json::array();
|
||||
|
|
@ -3770,11 +3829,15 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_
|
|||
std::string filament_name = checkbox_filament_name.second;
|
||||
|
||||
json bundle_structure;
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
std::string clock = get_curr_timestmp();
|
||||
bundle_structure["user_name"] = "";
|
||||
bundle_structure["user_id"] = "";
|
||||
bundle_structure["version"] = SoftFever_VERSION;
|
||||
bundle_structure["bundle_id"] = filament_name + "_" + clock;
|
||||
if (agent) {
|
||||
bundle_structure["version"] = agent->get_version();
|
||||
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + filament_name + "_" + clock;
|
||||
} else {
|
||||
bundle_structure["version"] = "";
|
||||
bundle_structure["bundle_id"] = "offline_" + filament_name + "_" + clock;
|
||||
}
|
||||
bundle_structure["bundle_type"] = "filament config bundle";
|
||||
bundle_structure["filament_name"] = filament_name;
|
||||
std::unordered_map<std::string, json> vendor_structure;
|
||||
|
|
@ -4068,19 +4131,45 @@ wxBoxSizer *ExportConfigsDialog::create_select_printer(wxWindow *parent)
|
|||
|
||||
void ExportConfigsDialog::data_init()
|
||||
{
|
||||
// Delete the Temp folder
|
||||
boost::filesystem::path folder(data_dir() + "/" + PRESET_USER_DIR + "/" + "Temp");
|
||||
if (boost::filesystem::exists(folder)) boost::filesystem::remove_all(folder);
|
||||
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::path user_folder(data_dir() + "/" + PRESET_USER_DIR);
|
||||
bool temp_folder_exist = true;
|
||||
if (!boost::filesystem::exists(user_folder)) {
|
||||
if (!boost::filesystem::create_directories(user_folder, ec)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << user_folder << " "<<ec.message();
|
||||
temp_folder_exist = false;
|
||||
}
|
||||
}
|
||||
boost::filesystem::path temp_folder(user_folder / "Temp");
|
||||
if (!boost::filesystem::exists(temp_folder)) {
|
||||
if (!boost::filesystem::create_directories(temp_folder, ec)) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " create directory failed: " << temp_folder << " " << ec.message();
|
||||
temp_folder_exist = false;
|
||||
}
|
||||
}
|
||||
if (!temp_folder_exist) {
|
||||
MessageDialog dlg(this, _L("Failed to create temporary folder, please try Export Configs again."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
|
||||
dlg.ShowModal();
|
||||
EndModal(wxCANCEL);
|
||||
}
|
||||
|
||||
PresetBundle preset_bundle(*wxGetApp().preset_bundle);
|
||||
|
||||
const std::deque<Preset> & printer_presets = preset_bundle.printers.get_presets();
|
||||
for (const Preset &printer_preset : printer_presets) {
|
||||
|
||||
std::string preset_name = printer_preset.name;
|
||||
if (!printer_preset.is_visible || "Default Printer" == preset_name) continue;
|
||||
if (!printer_preset.is_visible || printer_preset.is_default || printer_preset.is_project_embedded) continue;
|
||||
if (preset_bundle.printers.select_preset_by_name(preset_name, false)) {
|
||||
preset_bundle.update_compatible(PresetSelectCompatibleType::Always);
|
||||
|
||||
const std::deque<Preset> &filament_presets = preset_bundle.filaments.get_presets();
|
||||
for (const Preset &filament_preset : filament_presets) {
|
||||
if (filament_preset.is_system || filament_preset.is_default) continue;
|
||||
if (filament_preset.is_system || filament_preset.is_default || filament_preset.is_project_embedded) continue;
|
||||
if (filament_preset.is_compatible) {
|
||||
Preset *new_filament_preset = new Preset(filament_preset);
|
||||
m_filament_presets[preset_name].push_back(new_filament_preset);
|
||||
|
|
@ -4089,7 +4178,7 @@ void ExportConfigsDialog::data_init()
|
|||
|
||||
const std::deque<Preset> &process_presets = preset_bundle.prints.get_presets();
|
||||
for (const Preset &process_preset : process_presets) {
|
||||
if (process_preset.is_system || process_preset.is_default) continue;
|
||||
if (process_preset.is_system || process_preset.is_default || process_preset.is_project_embedded) continue;
|
||||
if (process_preset.is_compatible) {
|
||||
Preset *new_prpcess_preset = new Preset(process_preset);
|
||||
m_process_presets[preset_name].push_back(new_prpcess_preset);
|
||||
|
|
@ -4097,6 +4186,7 @@ void ExportConfigsDialog::data_init()
|
|||
}
|
||||
|
||||
Preset *new_printer_preset = new Preset(printer_preset);
|
||||
earse_preset_fields_for_safe(new_printer_preset);
|
||||
m_printer_presets[preset_name] = new_printer_preset;
|
||||
}
|
||||
}
|
||||
|
|
@ -4159,9 +4249,10 @@ EditFilamentPresetDialog::EditFilamentPresetDialog(wxWindow *parent, FilamentInf
|
|||
if (vendor_names && !vendor_names->values.empty()) m_vendor_name = vendor_names->values[0];
|
||||
auto filament_types = dynamic_cast<ConfigOptionStrings *>(preset->config.option("filament_type"));
|
||||
if (filament_types && !filament_types->values.empty()) m_filament_type = filament_types->values[0];
|
||||
size_t index = m_filament_name.find(m_filament_type);
|
||||
if (std::string::npos != index && index + m_filament_type.size() < m_filament_name.size()) {
|
||||
m_filament_serial = m_filament_name.substr(index + m_filament_type.size());
|
||||
std::string filament_type = m_filament_type == "PLA-AERO" ? "PLA Aero" : m_filament_type;
|
||||
size_t index = m_filament_name.find(filament_type);
|
||||
if (std::string::npos != index && index + filament_type.size() < m_filament_name.size()) {
|
||||
m_filament_serial = m_filament_name.substr(index + filament_type.size());
|
||||
if (m_filament_serial.size() > 2 && m_filament_serial[0] == ' ') {
|
||||
m_filament_serial = m_filament_serial.substr(1);
|
||||
}
|
||||
|
|
@ -4639,8 +4730,7 @@ void CreatePresetForPrinterDialog::get_visible_printer_and_compatible_filament_p
|
|||
|
||||
if (filament_types && filament_types->values.empty()) continue;
|
||||
const std::string filament_type = filament_types->values[0];
|
||||
std::string filament_type_ = system_filament_types_map[m_filament_type];
|
||||
if (filament_type_.empty()) filament_type_ = m_filament_type;
|
||||
std::string filament_type_ = m_filament_type == "PLA Aero" ? "PLA-AERO" : m_filament_type;
|
||||
if (filament_type == filament_type_) {
|
||||
m_printer_compatible_filament_presets[printer_preset.name].push_back(std::make_shared<Preset>(filament_preset));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,12 +70,13 @@ private:
|
|||
std::unordered_map<std::string, std::vector<Preset *>> m_filament_choice_map;
|
||||
std::unordered_map<wxString, std::string> m_public_name_to_filament_id_map;
|
||||
std::unordered_map<std::string, Preset *> m_all_presets_map;
|
||||
std::unordered_set<std::string> m_system_filament_types_set;
|
||||
std::set<std::string> m_visible_printers;
|
||||
CreateType m_create_type;
|
||||
Button * m_button_create = nullptr;
|
||||
Button * m_button_cancel = nullptr;
|
||||
ComboBox * m_filament_vendor_combobox = nullptr;
|
||||
::CheckBox * m_can_not_find_vendor_checkbox = nullptr;
|
||||
::CheckBox * m_can_not_find_vendor_checkbox = nullptr;
|
||||
ComboBox * m_filament_type_combobox = nullptr;
|
||||
ComboBox * m_exist_vendor_combobox = nullptr;
|
||||
ComboBox * m_filament_preset_combobox = nullptr;
|
||||
|
|
@ -262,6 +263,7 @@ private:
|
|||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
void show_export_result(const ExportCase &export_case);
|
||||
bool has_check_box_selected();
|
||||
bool earse_preset_fields_for_safe(Preset *preset);
|
||||
std::string initial_file_path(const wxString &path, const std::string &sub_file_path);
|
||||
std::string initial_file_name(const wxString &path, const std::string file_name);
|
||||
wxBoxSizer *create_export_config_item(wxWindow *parent);
|
||||
|
|
@ -314,7 +316,6 @@ private:
|
|||
std::string m_filament_vendor;
|
||||
std::string m_filament_type;
|
||||
std::shared_ptr<PresetBundle> m_preset_bundle;
|
||||
std::string m_filamnt_type;
|
||||
ComboBox * m_selected_printer = nullptr;
|
||||
ComboBox * m_selected_filament = nullptr;
|
||||
Button * m_ok_btn = nullptr;
|
||||
|
|
|
|||
|
|
@ -807,7 +807,9 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
info.color = tray->second->color;
|
||||
info.type = tray->second->get_filament_type();
|
||||
info.id = tray_index;
|
||||
info.filament_id=tray->second->setting_id;
|
||||
info.filament_id = tray->second->setting_id;
|
||||
info.ctype = tray->second->ctype;
|
||||
info.colors = tray->second->cols;
|
||||
tray_filaments.emplace(std::make_pair(tray_index, info));
|
||||
}
|
||||
}
|
||||
|
|
@ -824,6 +826,8 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
|
||||
info.color = tray_it->second->color;
|
||||
info.type = tray_it->second->get_filament_type();
|
||||
info.ctype = tray_it->second->ctype;
|
||||
info.colors = tray_it->second->cols;
|
||||
}
|
||||
else {
|
||||
info.id = -1;
|
||||
|
|
@ -857,6 +861,9 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
if (filaments[i].type == tray_it->second->get_filament_type()) {
|
||||
info.color = tray_it->second->color;
|
||||
info.type = tray_it->second->get_filament_type();
|
||||
info.ctype = tray_it->second->ctype;
|
||||
std::vector<wxColour> cols;
|
||||
info.colors = tray_it->second->cols;
|
||||
} else {
|
||||
info.tray_id = -1;
|
||||
info.mapping_result = (int)MappingResult::MAPPING_RESULT_TYPE_MISMATCH;
|
||||
|
|
@ -944,7 +951,8 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
picked_src_idx = i;
|
||||
picked_tar_idx = j;
|
||||
}
|
||||
else if (min_val == distance_map[i][j].distance && filaments[i].filament_id == tray_filaments[j].filament_id) {
|
||||
else if (min_val == distance_map[i][j].distance&& filaments[picked_src_idx].filament_id!= tray_filaments[picked_tar_idx].filament_id && filaments[i].filament_id == tray_filaments[j].filament_id) {
|
||||
|
||||
picked_src_idx = i;
|
||||
picked_tar_idx = j;
|
||||
}
|
||||
|
|
@ -959,6 +967,8 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
result[picked_src_idx].type = tray->second.type;
|
||||
result[picked_src_idx].distance = tray->second.distance;
|
||||
result[picked_src_idx].filament_id = tray->second.filament_id;
|
||||
result[picked_src_idx].ctype = tray->second.ctype;
|
||||
result[picked_src_idx].colors = tray->second.colors;
|
||||
}
|
||||
else {
|
||||
FilamentInfo info;
|
||||
|
|
@ -998,6 +1008,8 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
result[i].tray_id = tray_info_list[i].tray_id;
|
||||
result[i].color = tray_info_list[i].color;
|
||||
result[i].type = tray_info_list[i].type;
|
||||
result[i].ctype = tray_info_list[i].ctype;
|
||||
result[i].colors = tray_info_list[i].colors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1132,24 +1144,26 @@ MachineObject::LIGHT_EFFECT MachineObject::light_effect_parse(std::string effect
|
|||
|
||||
std::string MachineObject::get_firmware_type_str()
|
||||
{
|
||||
if (firmware_type == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER)
|
||||
/*if (firmware_type == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER)
|
||||
return "engineer";
|
||||
else if (firmware_type == PrinterFirmwareType::FIRMWARE_TYPE_PRODUCTION)
|
||||
return "product";
|
||||
return "product";*/
|
||||
|
||||
// return engineer by default;
|
||||
return "engineer";
|
||||
// return product by default;
|
||||
// always return product, printer do not push this field
|
||||
return "product";
|
||||
}
|
||||
|
||||
std::string MachineObject::get_lifecycle_type_str()
|
||||
{
|
||||
if (lifecycle == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER)
|
||||
/*if (lifecycle == PrinterFirmwareType::FIRMWARE_TYPE_ENGINEER)
|
||||
return "engineer";
|
||||
else if (lifecycle == PrinterFirmwareType::FIRMWARE_TYPE_PRODUCTION)
|
||||
return "product";
|
||||
return "product";*/
|
||||
|
||||
// return engineer by default;
|
||||
return "engineer";
|
||||
// return product by default;
|
||||
// always return product, printer do not push this field
|
||||
return "product";
|
||||
}
|
||||
|
||||
bool MachineObject::is_in_upgrading()
|
||||
|
|
@ -1806,7 +1820,7 @@ int MachineObject::command_ams_calibrate(int ams_id)
|
|||
int MachineObject::command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << ams_id << ", tray_id = " << tray_id << ", tray_color = " << tray_color
|
||||
<< ", tray_type = " << tray_type << ", setting_id = " << setting_id;
|
||||
<< ", tray_type = " << tray_type << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max;
|
||||
json j;
|
||||
j["print"]["command"] = "ams_filament_setting";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
|
@ -1869,6 +1883,7 @@ int MachineObject::command_set_chamber_light(LIGHT_EFFECT effect, int on_time, i
|
|||
|
||||
int MachineObject::command_set_printer_nozzle(std::string nozzle_type, float diameter)
|
||||
{
|
||||
nozzle_setting_hold_count = HOLD_COUNT_MAX * 2;
|
||||
BOOST_LOG_TRIVIAL(info) << "command_set_printer_nozzle, nozzle_type = " << nozzle_type << " diameter = " << diameter;
|
||||
json j;
|
||||
j["system"]["command"] = "set_accessories";
|
||||
|
|
@ -2069,33 +2084,45 @@ int MachineObject::command_start_pa_calibration(const X1CCalibInfos &pa_data, in
|
|||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
pa_calib_results.clear();
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_data.calib_datas[0].nozzle_diameter);
|
||||
j["print"]["mode"] = mode;
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_data.calib_datas[0].nozzle_diameter);
|
||||
j["print"]["mode"] = mode;
|
||||
|
||||
for (int i = 0; i < pa_data.calib_datas.size(); ++i) {
|
||||
j["print"]["filaments"][i]["tray_id"] = pa_data.calib_datas[i].tray_id;
|
||||
j["print"]["filaments"][i]["bed_temp"] = pa_data.calib_datas[i].bed_temp;
|
||||
j["print"]["filaments"][i]["filament_id"] = pa_data.calib_datas[i].filament_id;
|
||||
j["print"]["filaments"][i]["setting_id"] = pa_data.calib_datas[i].setting_id;
|
||||
j["print"]["filaments"][i]["nozzle_temp"] = pa_data.calib_datas[i].nozzle_temp;
|
||||
j["print"]["filaments"][i]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed);
|
||||
}
|
||||
std::string filament_ids;
|
||||
for (int i = 0; i < pa_data.calib_datas.size(); ++i) {
|
||||
j["print"]["filaments"][i]["tray_id"] = pa_data.calib_datas[i].tray_id;
|
||||
j["print"]["filaments"][i]["bed_temp"] = pa_data.calib_datas[i].bed_temp;
|
||||
j["print"]["filaments"][i]["filament_id"] = pa_data.calib_datas[i].filament_id;
|
||||
j["print"]["filaments"][i]["setting_id"] = pa_data.calib_datas[i].setting_id;
|
||||
j["print"]["filaments"][i]["nozzle_temp"] = pa_data.calib_datas[i].nozzle_temp;
|
||||
j["print"]["filaments"][i]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
if (i > 0) filament_ids += ",";
|
||||
filament_ids += pa_data.calib_datas[i].filament_id;
|
||||
}
|
||||
return -1;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali: " << j.dump();
|
||||
|
||||
try {
|
||||
json js;
|
||||
js["cali_type"] = "cali_pa_auto";
|
||||
js["nozzle_diameter"] = pa_data.calib_datas[0].nozzle_diameter;
|
||||
js["filament_id"] = filament_ids;
|
||||
js["printer_type"] = this->printer_type;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent) agent->track_event("cali", js.dump());
|
||||
} catch (...) {}
|
||||
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &pa_calib_values, bool is_auto_cali)
|
||||
{
|
||||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1 && pa_calib_values.size() > 0) {
|
||||
if (pa_calib_values.size() > 0) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_set";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
|
@ -2126,73 +2153,61 @@ int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &
|
|||
|
||||
int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_calib)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_del";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["filament_id"] = pa_calib.filament_id;
|
||||
j["print"]["cali_idx"] = pa_calib.cali_idx;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib.nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_del";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["filament_id"] = pa_calib.filament_id;
|
||||
j["print"]["cali_idx"] = pa_calib.cali_idx;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib.nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_del: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_del: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id)
|
||||
{
|
||||
reset_pa_cali_history_result();
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["filament_id"] = filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["filament_id"] = filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_get_pa_calibration_result(float nozzle_diameter)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::commnad_select_pa_calibration(const PACalibIndexInfo& pa_calib_info)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_sel";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["tray_id"] = pa_calib_info.tray_id;
|
||||
j["print"]["cali_idx"] = pa_calib_info.cali_idx;
|
||||
j["print"]["filament_id"] = pa_calib_info.filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_info.nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_sel";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["tray_id"] = pa_calib_info.tray_id;
|
||||
j["print"]["cali_idx"] = pa_calib_info.cali_idx;
|
||||
j["print"]["filament_id"] = pa_calib_info.filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_info.nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_sel: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_sel: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_start_flow_ratio_calibration(const X1CCalibInfos& calib_data)
|
||||
{
|
||||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1 && calib_data.calib_datas.size() > 0) {
|
||||
if (calib_data.calib_datas.size() > 0) {
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
|
@ -2217,16 +2232,13 @@ int MachineObject::command_start_flow_ratio_calibration(const X1CCalibInfos& cal
|
|||
|
||||
int MachineObject::command_get_flow_ratio_calibration_result(float nozzle_diameter)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "flowrate_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "flowrate_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_ipcam_record(bool on_off)
|
||||
|
|
@ -2678,6 +2690,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
std::string access_code = j_pre["system"]["access_code"].get<std::string>();
|
||||
if (!access_code.empty()) {
|
||||
set_access_code(access_code);
|
||||
set_user_access_code(access_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2690,6 +2703,8 @@ int MachineObject::parse_json(std::string payload)
|
|||
uint64_t t_utc = j.value("t_utc", 0ULL);
|
||||
if (t_utc > 0)
|
||||
last_utc_time = std::chrono::system_clock::time_point(t_utc * 1ms);
|
||||
else
|
||||
last_utc_time = last_update_time;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "parse_json: dev_id=" << dev_id << ", playload=" << j.dump(4);
|
||||
|
||||
|
|
@ -3341,14 +3356,21 @@ int MachineObject::parse_json(std::string payload)
|
|||
;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
try {
|
||||
if (jj.contains("nozzle_diameter")) {
|
||||
if (jj["nozzle_diameter"].is_number_float()) {
|
||||
nozzle_diameter = jj["nozzle_diameter"].get<float>();
|
||||
} else if (jj["nozzle_diameter"].is_string()) {
|
||||
nozzle_diameter = string_to_float(jj["nozzle_diameter"].get<std::string>());
|
||||
|
||||
if (nozzle_setting_hold_count > 0) {
|
||||
nozzle_setting_hold_count--;
|
||||
} else {
|
||||
if (jj["nozzle_diameter"].is_number_float()) {
|
||||
nozzle_diameter = jj["nozzle_diameter"].get<float>();
|
||||
}
|
||||
else if (jj["nozzle_diameter"].is_string()) {
|
||||
nozzle_diameter = string_to_float(jj["nozzle_diameter"].get<std::string>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
|
|
@ -3357,8 +3379,14 @@ int MachineObject::parse_json(std::string payload)
|
|||
|
||||
try {
|
||||
if (jj.contains("nozzle_type")) {
|
||||
if (jj["nozzle_type"].is_string()) {
|
||||
nozzle_type = jj["nozzle_type"].get<std::string>();
|
||||
|
||||
if (nozzle_setting_hold_count > 0) {
|
||||
nozzle_setting_hold_count--;
|
||||
}
|
||||
else {
|
||||
if (jj["nozzle_type"].is_string()) {
|
||||
nozzle_type = jj["nozzle_type"].get<std::string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3513,8 +3541,8 @@ int MachineObject::parse_json(std::string payload)
|
|||
camera_resolution_supported.swap(resolution_supported);
|
||||
}
|
||||
if (ipcam.contains("liveview")) {
|
||||
char const *local_protos[] = { "none", "local", "rtsps", "rtsp" };
|
||||
liveview_local = enum_index_of(ipcam["liveview"].value<std::string>("local", "none").c_str(), local_protos, 4, LiveviewLocal::LVL_None);
|
||||
char const *local_protos[] = {"none", "disabled", "local", "rtsps", "rtsp"};
|
||||
liveview_local = enum_index_of(ipcam["liveview"].value<std::string>("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None);
|
||||
liveview_remote = ipcam["liveview"].value<std::string>("remote", "disabled") == "enabled";
|
||||
}
|
||||
if (ipcam.contains("file")) {
|
||||
|
|
@ -3526,7 +3554,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
if (ipcam.contains("rtsp_url")) {
|
||||
local_rtsp_url = ipcam["rtsp_url"].get<std::string>();
|
||||
liveview_local = local_rtsp_url.empty() ? LVL_None : local_rtsp_url == "disable"
|
||||
? LVL_None : boost::algorithm::starts_with(local_rtsp_url, "rtsps") ? LVL_Rtsps : LVL_Rtsp;
|
||||
? LVL_Disable : boost::algorithm::starts_with(local_rtsp_url, "rtsps") ? LVL_Rtsps : LVL_Rtsp;
|
||||
}
|
||||
if (ipcam.contains("tutk_server")) {
|
||||
tutk_state = ipcam["tutk_server"].get<std::string>();
|
||||
|
|
@ -3620,11 +3648,19 @@ int MachineObject::parse_json(std::string payload)
|
|||
if (jj.contains("cali_version")) {
|
||||
cali_version = jj["cali_version"].get<int>();
|
||||
}
|
||||
else {
|
||||
cali_version = -1;
|
||||
}
|
||||
std::string str = jj.dump();
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
|
||||
std::map<std::string, std::vector<Preset const *>> filament_list = preset_bundle->filaments.get_filament_presets();
|
||||
std::ostringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
|
||||
if (jj.contains("ams")) {
|
||||
if (jj["ams"].contains("ams")) {
|
||||
|
|
@ -3701,6 +3737,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
|
||||
json j_ams = jj["ams"]["ams"];
|
||||
std::set<std::string> ams_id_set;
|
||||
|
||||
for (auto it = amsList.begin(); it != amsList.end(); it++) {
|
||||
ams_id_set.insert(it->first);
|
||||
}
|
||||
|
|
@ -3785,6 +3822,17 @@ int MachineObject::parse_json(std::string payload)
|
|||
} else {
|
||||
curr_tray->type = type;
|
||||
}
|
||||
if (filament_list.find(curr_tray->setting_id) == filament_list.end()) {
|
||||
wxColour color = *wxWHITE;
|
||||
char col_buf[10];
|
||||
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
|
||||
try {
|
||||
this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0);
|
||||
continue;
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
curr_tray->setting_id = "";
|
||||
curr_tray->type = "";
|
||||
|
|
@ -3817,14 +3865,37 @@ int MachineObject::parse_json(std::string payload)
|
|||
curr_tray->bed_temp = (*tray_it)["bed_temp"].get<std::string>();
|
||||
else
|
||||
curr_tray->bed_temp = "";
|
||||
if (tray_it->contains("nozzle_temp_max"))
|
||||
if (tray_it->contains("tray_color")) {
|
||||
auto color = (*tray_it)["tray_color"].get<std::string>();
|
||||
curr_tray->update_color_from_str(color);
|
||||
} else {
|
||||
curr_tray->color = "";
|
||||
}
|
||||
if (tray_it->contains("nozzle_temp_max")) {
|
||||
curr_tray->nozzle_temp_max = (*tray_it)["nozzle_temp_max"].get<std::string>();
|
||||
}
|
||||
else
|
||||
curr_tray->nozzle_temp_max = "";
|
||||
if (tray_it->contains("nozzle_temp_min"))
|
||||
curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
curr_tray->nozzle_temp_min = "";
|
||||
if (curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") {
|
||||
try {
|
||||
std::string preset_setting_id;
|
||||
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id,
|
||||
curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id);
|
||||
if (!is_equation) {
|
||||
command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id,
|
||||
curr_tray->color, curr_tray->type,
|
||||
std::stoi(curr_tray->nozzle_temp_min),
|
||||
std::stoi(curr_tray->nozzle_temp_max));
|
||||
}
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<<tray_id;
|
||||
}
|
||||
}
|
||||
if (tray_it->contains("xcam_info"))
|
||||
curr_tray->xcam_info = (*tray_it)["xcam_info"].get<std::string>();
|
||||
else
|
||||
|
|
@ -3833,12 +3904,6 @@ int MachineObject::parse_json(std::string payload)
|
|||
curr_tray->uuid = (*tray_it)["tray_uuid"].get<std::string>();
|
||||
else
|
||||
curr_tray->uuid = "0";
|
||||
if (tray_it->contains("tray_color")) {
|
||||
auto color = (*tray_it)["tray_color"].get<std::string>();
|
||||
curr_tray->update_color_from_str(color);
|
||||
} else {
|
||||
curr_tray->color = "";
|
||||
}
|
||||
|
||||
if (tray_it->contains("ctype"))
|
||||
curr_tray->ctype = (*tray_it)["ctype"].get<int>();
|
||||
|
|
@ -3952,6 +4017,17 @@ int MachineObject::parse_json(std::string payload)
|
|||
else {
|
||||
vt_tray.type = type;
|
||||
}
|
||||
if (filament_list.find(vt_tray.setting_id) == filament_list.end()) {
|
||||
wxColour color = *wxWHITE;
|
||||
char col_buf[10];
|
||||
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
|
||||
try {
|
||||
BOOST_LOG_TRIVIAL(info) << "no filament_id in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id;
|
||||
this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
vt_tray.setting_id = "";
|
||||
|
|
@ -3985,6 +4061,12 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.bed_temp = jj["vt_tray"]["bed_temp"].get<std::string>();
|
||||
else
|
||||
vt_tray.bed_temp = "";
|
||||
if (jj["vt_tray"].contains("tray_color")) {
|
||||
auto color = jj["vt_tray"]["tray_color"].get<std::string>();
|
||||
vt_tray.update_color_from_str(color);
|
||||
} else {
|
||||
vt_tray.color = "";
|
||||
}
|
||||
if (jj["vt_tray"].contains("nozzle_temp_max"))
|
||||
vt_tray.nozzle_temp_max = jj["vt_tray"]["nozzle_temp_max"].get<std::string>();
|
||||
else
|
||||
|
|
@ -3993,6 +4075,22 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
vt_tray.nozzle_temp_min = "";
|
||||
if (vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") {
|
||||
try {
|
||||
std::string preset_setting_id;
|
||||
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid,
|
||||
vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id);
|
||||
if (!is_equation) {
|
||||
command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type,
|
||||
std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max));
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id;
|
||||
}
|
||||
|
||||
}
|
||||
if (jj["vt_tray"].contains("xcam_info"))
|
||||
vt_tray.xcam_info = jj["vt_tray"]["xcam_info"].get<std::string>();
|
||||
else
|
||||
|
|
@ -4001,13 +4099,6 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.uuid = jj["vt_tray"]["tray_uuid"].get<std::string>();
|
||||
else
|
||||
vt_tray.uuid = "0";
|
||||
if (jj["vt_tray"].contains("tray_color")) {
|
||||
auto color = jj["vt_tray"]["tray_color"].get<std::string>();
|
||||
vt_tray.update_color_from_str(color);
|
||||
}
|
||||
else {
|
||||
vt_tray.color = "";
|
||||
}
|
||||
|
||||
if (jj["vt_tray"].contains("cali_idx"))
|
||||
vt_tray.cali_idx = jj["vt_tray"]["cali_idx"].get<int>();
|
||||
|
|
@ -5450,7 +5541,7 @@ std::vector<std::string> DeviceManager::get_resolution_supported(std::string typ
|
|||
std::vector<std::string> resolution_supported;
|
||||
|
||||
std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json";
|
||||
std::ifstream json_file(config_file.c_str());
|
||||
boost::nowide::ifstream json_file(config_file.c_str());
|
||||
try {
|
||||
json jj;
|
||||
if (json_file.is_open()) {
|
||||
|
|
@ -5472,7 +5563,7 @@ std::vector<std::string> DeviceManager::get_compatible_machine(std::string type_
|
|||
{
|
||||
std::vector<std::string> compatible_machine;
|
||||
std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json";
|
||||
std::ifstream json_file(config_file.c_str());
|
||||
boost::nowide::ifstream json_file(config_file.c_str());
|
||||
try {
|
||||
json jj;
|
||||
if (json_file.is_open()) {
|
||||
|
|
@ -5491,10 +5582,12 @@ std::vector<std::string> DeviceManager::get_compatible_machine(std::string type_
|
|||
}
|
||||
|
||||
|
||||
bool DeviceManager::load_filaments_blacklist_config(std::string config_file)
|
||||
bool DeviceManager::load_filaments_blacklist_config()
|
||||
{
|
||||
filaments_blacklist = json::object();
|
||||
std::ifstream json_file(config_file.c_str());
|
||||
|
||||
std::string config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
|
||||
boost::nowide::ifstream json_file(config_file.c_str());
|
||||
|
||||
try {
|
||||
if (json_file.is_open()) {
|
||||
|
|
@ -5593,4 +5686,10 @@ std::string DeviceManager::load_gcode(std::string type_str, std::string gcode_fi
|
|||
return "";
|
||||
}
|
||||
|
||||
void change_the_opacity(wxColour& colour)
|
||||
{
|
||||
if (colour.Alpha() == 255) {
|
||||
colour = wxColour(colour.Red(), colour.Green(), colour.Blue(), 254);
|
||||
}
|
||||
}
|
||||
} // namespace Slic3r
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ enum ManualPaCaliMethod {
|
|||
PA_PATTERN,
|
||||
};
|
||||
|
||||
|
||||
struct RatingInfo {
|
||||
bool request_successful;
|
||||
int http_code;
|
||||
|
|
@ -289,6 +290,7 @@ public:
|
|||
unsigned reserved;
|
||||
HMSMessageLevel msg_level = HMS_UNKNOWN;
|
||||
int msg_code = 0;
|
||||
bool already_read = false;
|
||||
bool parse_hms_info(unsigned attr, unsigned code);
|
||||
std::string get_long_error_code();
|
||||
|
||||
|
|
@ -622,6 +624,7 @@ public:
|
|||
std::vector<CaliPresetInfo> selected_cali_preset;
|
||||
float cache_flow_ratio { 0.0 };
|
||||
bool cali_finished = true;
|
||||
FlowRatioCalibrationType flow_ratio_calibration_type = FlowRatioCalibrationType::COMPLETE_CALIBRATION;
|
||||
|
||||
ManualPaCaliMethod manual_pa_cali_method = ManualPaCaliMethod::PA_LINE;
|
||||
bool has_get_pa_calib_tab{ false };
|
||||
|
|
@ -694,6 +697,7 @@ public:
|
|||
std::string tutk_state;
|
||||
enum LiveviewLocal {
|
||||
LVL_None,
|
||||
LVL_Disable,
|
||||
LVL_Local,
|
||||
LVL_Rtsps,
|
||||
LVL_Rtsp
|
||||
|
|
@ -704,6 +708,8 @@ public:
|
|||
bool file_model_download{false};
|
||||
bool virtual_camera{false};
|
||||
|
||||
int nozzle_setting_hold_count = 0;
|
||||
|
||||
bool xcam_ai_monitoring{ false };
|
||||
int xcam_ai_monitoring_hold_count = 0;
|
||||
std::string xcam_ai_monitoring_sensitivity;
|
||||
|
|
@ -1026,11 +1032,13 @@ public:
|
|||
static bool get_printer_is_enclosed(std::string type_str);
|
||||
static std::vector<std::string> get_resolution_supported(std::string type_str);
|
||||
static std::vector<std::string> get_compatible_machine(std::string type_str);
|
||||
static bool load_filaments_blacklist_config(std::string config_file);
|
||||
static bool load_filaments_blacklist_config();
|
||||
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
|
||||
static std::string load_gcode(std::string type_str, std::string gcode_file);
|
||||
};
|
||||
|
||||
// change the opacity
|
||||
void change_the_opacity(wxColour& colour);
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_DeviceManager_hpp_
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ wxString get_thumbnails_string(const std::vector<Vec2d>& values)
|
|||
return ret_str;
|
||||
}
|
||||
|
||||
|
||||
Field::~Field()
|
||||
{
|
||||
if (m_on_kill_focus)
|
||||
|
|
@ -93,11 +92,6 @@ Field::~Field()
|
|||
m_back_to_initial_value = nullptr;
|
||||
if (m_back_to_sys_value)
|
||||
m_back_to_sys_value = nullptr;
|
||||
if (getWindow()) {
|
||||
wxWindow* win = getWindow();
|
||||
win->Destroy();
|
||||
win = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Field::PostInitialize()
|
||||
|
|
@ -133,6 +127,8 @@ void Field::PostInitialize()
|
|||
if (getWindow()) {
|
||||
if (m_opt.readonly) {
|
||||
this->disable();
|
||||
} else {
|
||||
this->enable();
|
||||
}
|
||||
getWindow()->Bind(wxEVT_KEY_UP, [](wxKeyEvent& evt) {
|
||||
if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) {
|
||||
|
|
@ -161,7 +157,7 @@ void Field::PostInitialize()
|
|||
}
|
||||
|
||||
evt.Skip();
|
||||
});
|
||||
}, getWindow()->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,6 +298,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
m_value.clear();
|
||||
break;
|
||||
}
|
||||
std::string opt_key_without_idx = m_opt_id.substr(0, m_opt_id.find('#'));
|
||||
if (m_opt_id == "filament_flow_ratio") {
|
||||
if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
|
||||
wxString msg_text = format_wxstr(_L("Value %s is out of range, continue?"), str);
|
||||
|
|
@ -318,6 +315,21 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(m_opt_id == "filament_retraction_distances_when_cut" || opt_key_without_idx == "retraction_distances_when_cut"){
|
||||
if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
|
||||
wxString msg_text = format_wxstr(_L("Value %s is out of range. The valid range is from %d to %d."), str, m_opt.min, m_opt.max);
|
||||
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES);
|
||||
if (dialog.ShowModal()) {
|
||||
if (m_value.empty()) {
|
||||
if (m_opt.min > val) val = m_opt.min;
|
||||
if (val > m_opt.max) val = m_opt.max;
|
||||
}
|
||||
else
|
||||
val = boost::any_cast<double>(m_value);
|
||||
set_value(double_to_string(val), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
show_error(m_parent, _L("Value is out of range."));
|
||||
if (m_opt.min > val) val = m_opt.min;
|
||||
|
|
@ -490,6 +502,101 @@ void Field::sys_color_changed()
|
|||
#endif
|
||||
}
|
||||
|
||||
std::vector<std::deque<wxWindow *>**> spools;
|
||||
std::vector<std::deque<wxWindow *>*> spools2;
|
||||
|
||||
void switch_window_pools()
|
||||
{
|
||||
for (auto p : spools) {
|
||||
spools2.push_back(*p);
|
||||
*p = new std::deque<wxWindow*>;
|
||||
}
|
||||
}
|
||||
|
||||
void release_window_pools()
|
||||
{
|
||||
for (auto p : spools2) {
|
||||
delete p;
|
||||
}
|
||||
spools2.clear();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct Builder
|
||||
{
|
||||
Builder()
|
||||
{
|
||||
pool_ = new std::deque<wxWindow*>;
|
||||
spools.push_back(&pool_);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
T *build(wxWindow * p, Args ...args)
|
||||
{
|
||||
if (pool_->empty()) {
|
||||
auto t = new T(p, args...);
|
||||
t->SetClientData(pool_);
|
||||
return t;
|
||||
}
|
||||
auto t = dynamic_cast<T*>(pool_->front());
|
||||
pool_->pop_front();
|
||||
t->Reparent(p);
|
||||
t->Enable();
|
||||
t->Show();
|
||||
return t;
|
||||
}
|
||||
std::deque<wxWindow*>* pool_;
|
||||
};
|
||||
|
||||
struct wxEventFunctorRef
|
||||
{
|
||||
wxEventFunctor * func;
|
||||
};
|
||||
|
||||
wxEventFunctor & wxMakeEventFunctor(const int, wxEventFunctorRef func)
|
||||
{
|
||||
return *func.func;
|
||||
}
|
||||
|
||||
struct myEvtHandler : wxEvtHandler
|
||||
{
|
||||
void UnbindAll()
|
||||
{
|
||||
size_t cookie;
|
||||
for (wxDynamicEventTableEntry *entry = GetFirstDynamicEntry(cookie);
|
||||
entry;
|
||||
entry = GetNextDynamicEntry(cookie)) {
|
||||
// In Field, All Bind has id, but for TextInput, ComboBox, SpinInput, all not
|
||||
if (entry->m_id != wxID_ANY && entry->m_lastId == wxID_ANY)
|
||||
Unbind(entry->m_eventType,
|
||||
wxEventFunctorRef{entry->m_fn},
|
||||
entry->m_id,
|
||||
entry->m_lastId,
|
||||
entry->m_callbackUserData);
|
||||
//DoUnbind(entry->m_id, entry->m_lastId, entry->m_eventType, *entry->m_fn, entry->m_callbackUserData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void unbind_events(wxEvtHandler *h)
|
||||
{
|
||||
static_cast<myEvtHandler *>(h)->UnbindAll();
|
||||
}
|
||||
|
||||
void free_window(wxWindow *win)
|
||||
{
|
||||
unbind_events(win);
|
||||
for (auto c : win->GetChildren())
|
||||
if (dynamic_cast<wxTextCtrl*>(c))
|
||||
unbind_events(c);
|
||||
win->Hide();
|
||||
if (auto sizer = win->GetContainingSizer())
|
||||
sizer->Clear();
|
||||
win->Reparent(wxGetApp().mainframe);
|
||||
if (win->GetClientData())
|
||||
reinterpret_cast<std::deque<wxWindow *>*>(win->GetClientData())->push_back(win);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
|
||||
{
|
||||
|
|
@ -554,10 +661,15 @@ void TextCtrl::BUILD() {
|
|||
|
||||
// BBS: new param ui style
|
||||
// const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
|
||||
static Builder<wxTextCtrl> builder1;
|
||||
static Builder<::TextInput> builder2;
|
||||
auto temp = m_opt.multiline
|
||||
? (wxWindow *) new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, wxTE_MULTILINE)
|
||||
: new ::TextInput(m_parent, text_value, _L(m_opt.sidetext), "", wxDefaultPosition, size, wxTE_PROCESS_ENTER);
|
||||
? (wxWindow*)builder1.build(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE)
|
||||
: builder2.build(m_parent, "", "", "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||
temp->SetLabel(_L(m_opt.sidetext));
|
||||
auto text_ctrl = m_opt.multiline ? (wxTextCtrl *)temp : ((TextInput *) temp)->GetTextCtrl();
|
||||
text_ctrl->SetLabel(text_value);
|
||||
temp->SetSize(size);
|
||||
m_combine_side_text = !m_opt.multiline;
|
||||
if (parent_is_custom_ctrl && m_opt.height < 0)
|
||||
opt_height = (double) text_ctrl->GetSize().GetHeight() / m_em_unit;
|
||||
|
|
@ -620,7 +732,7 @@ void TextCtrl::BUILD() {
|
|||
if (!bEnterPressed)
|
||||
propagate_value();
|
||||
}), temp->GetId());
|
||||
/*
|
||||
/*
|
||||
// select all text using Ctrl+A
|
||||
temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event)
|
||||
{
|
||||
|
|
@ -789,7 +901,8 @@ void CheckBox::BUILD() {
|
|||
m_last_meaningful_value = static_cast<unsigned char>(check_value);
|
||||
|
||||
// BBS: use ::CheckBox
|
||||
auto temp = new ::CheckBox(m_parent);
|
||||
static Builder<::CheckBox> builder;
|
||||
auto temp = builder.build(m_parent);
|
||||
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
//temp->SetBackgroundColour(*wxWHITE);
|
||||
temp->SetValue(check_value);
|
||||
|
|
@ -908,8 +1021,14 @@ void SpinCtrl::BUILD() {
|
|||
? 0 : m_opt.min;
|
||||
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
|
||||
|
||||
auto temp = new SpinInput(m_parent, text_value, _L(m_opt.sidetext), wxDefaultPosition, size,
|
||||
wxSP_ARROW_KEYS, min_val, max_val, default_value);
|
||||
static Builder<SpinInput> builder;
|
||||
auto temp = builder.build(m_parent, "", "", wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS);
|
||||
temp->SetSize(size);
|
||||
temp->SetLabel(_L(m_opt.sidetext));
|
||||
temp->GetTextCtrl()->SetLabel(text_value);
|
||||
temp->SetRange(min_val, max_val);
|
||||
temp->SetValue(default_value);
|
||||
m_combine_side_text = true;
|
||||
#ifdef __WXGTK3__
|
||||
wxSize best_sz = temp->GetBestSize();
|
||||
|
|
@ -932,7 +1051,7 @@ void SpinCtrl::BUILD() {
|
|||
}
|
||||
|
||||
propagate_value();
|
||||
}));
|
||||
}), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId());
|
||||
|
||||
|
|
@ -1084,14 +1203,15 @@ void Choice::BUILD()
|
|||
if (m_opt.nullable)
|
||||
m_last_meaningful_value = dynamic_cast<ConfigOptionEnumsGenericNullable const *>(m_opt.default_value.get())->get_at(0);
|
||||
|
||||
choice_ctrl* temp;
|
||||
choice_ctrl * temp;
|
||||
auto dynamic_list = dynamic_lists.find(m_opt.opt_key);
|
||||
if (dynamic_list != dynamic_lists.end())
|
||||
m_list = dynamic_list->second;
|
||||
if (m_opt.gui_type != ConfigOptionDef::GUIType::undefined && m_opt.gui_type != ConfigOptionDef::GUIType::select_open
|
||||
&& m_list == nullptr) {
|
||||
m_is_editable = true;
|
||||
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER);
|
||||
static Builder<choice_ctrl> builder1;
|
||||
temp = builder1.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxTE_PROCESS_ENTER);
|
||||
}
|
||||
else {
|
||||
#ifdef UNDEIFNED__WXOSX__ // __WXOSX__ // BBS
|
||||
|
|
@ -1103,9 +1223,12 @@ void Choice::BUILD()
|
|||
temp->SetTextCtrlStyle(wxTE_READONLY);
|
||||
temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr);
|
||||
#else
|
||||
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
|
||||
static Builder<choice_ctrl> builder2;
|
||||
temp = builder2.build(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
|
||||
#endif //__WXOSX__
|
||||
}
|
||||
temp->SetSize(size);
|
||||
temp->Clear();
|
||||
temp->GetDropDown().SetUseContentWidth(true);
|
||||
if (parent_is_custom_ctrl && m_opt.height < 0)
|
||||
opt_height = (double) temp->GetTextCtrl()->GetSize().GetHeight() / m_em_unit;
|
||||
|
|
@ -1158,9 +1281,9 @@ void Choice::BUILD()
|
|||
e.StopPropagation();
|
||||
else
|
||||
e.Skip();
|
||||
});
|
||||
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
|
||||
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; });
|
||||
}, temp->GetId());
|
||||
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; }, temp->GetId());
|
||||
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; }, temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent&) { on_change_field(); }, temp->GetId());
|
||||
|
||||
|
|
@ -1169,12 +1292,12 @@ void Choice::BUILD()
|
|||
e.Skip();
|
||||
if (!bEnterPressed)
|
||||
propagate_value();
|
||||
} );
|
||||
}, temp->GetId() );
|
||||
|
||||
temp->Bind(wxEVT_TEXT_ENTER, [this](wxEvent& e) {
|
||||
EnterPressed enter(this);
|
||||
propagate_value();
|
||||
} );
|
||||
}, temp->GetId() );
|
||||
}
|
||||
|
||||
temp->SetToolTip(get_tooltip_text(temp->GetValue()));
|
||||
|
|
|
|||
|
|
@ -4080,16 +4080,19 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
float window_padding = 4.0f * m_scale;
|
||||
const float icon_size = ImGui::GetTextLineHeight() * 0.7;
|
||||
std::vector<float> offsets;
|
||||
std::map<std::string, float> offsets;
|
||||
std::map<int, double> model_volume_of_extruders_all_plates; // map<extruder_idx, volume>
|
||||
std::map<int, double> flushed_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::map<int, double> wipe_tower_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::map<int, double> support_volume_of_extruders_all_plates; // map<extruder_idx, flushed volume>
|
||||
std::vector<double> model_used_filaments_m_all_plates;
|
||||
std::vector<double> model_used_filaments_g_all_plates;
|
||||
std::vector<double> flushed_filaments_m_all_plates;
|
||||
std::vector<double> flushed_filaments_g_all_plates;
|
||||
std::vector<double> wipe_tower_used_filaments_m_all_plates;
|
||||
std::vector<double> wipe_tower_used_filaments_g_all_plates;
|
||||
std::vector<double> support_used_filaments_m_all_plates;
|
||||
std::vector<double> support_used_filaments_g_all_plates;
|
||||
float total_time_all_plates = 0.0f;
|
||||
float total_cost_all_plates = 0.0f;
|
||||
bool show_detailed_statistics_page = false;
|
||||
|
|
@ -4098,6 +4101,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
Model = 1,
|
||||
Flushed = 2,
|
||||
WipeTower = 4,
|
||||
Support = 1 << 3,
|
||||
};
|
||||
};
|
||||
int displayed_columns = 0;
|
||||
|
|
@ -4197,6 +4201,12 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
double wipe_tower_volume = plate_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
wipe_tower_volume_of_extruders_all_plates[extruder_id] += wipe_tower_volume;
|
||||
}
|
||||
if (plate_print_statistics.support_volumes_per_extruder.find(extruder_id) == plate_print_statistics.support_volumes_per_extruder.end())
|
||||
support_volume_of_extruders_all_plates[extruder_id] += 0;
|
||||
else {
|
||||
double support_volume = plate_print_statistics.support_volumes_per_extruder.at(extruder_id);
|
||||
support_volume_of_extruders_all_plates[extruder_id] += support_volume;
|
||||
}
|
||||
}
|
||||
const PrintEstimatedStatistics::Mode& plate_time_mode = plate_print_statistics.modes[static_cast<size_t>(m_time_estimate_mode)];
|
||||
total_time_all_plates += plate_time_mode.time;
|
||||
|
|
@ -4227,6 +4237,13 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
wipe_tower_used_filaments_m_all_plates.push_back(wipe_tower_filament_m);
|
||||
wipe_tower_used_filaments_g_all_plates.push_back(wipe_tower_filament_g);
|
||||
}
|
||||
for (auto it = support_volume_of_extruders_all_plates.begin(); it != support_volume_of_extruders_all_plates.end(); it++) {
|
||||
auto [support_filament_m, support_filament_g] = get_used_filament_from_volume(it->second, it->first);
|
||||
if (support_filament_m != 0.0 || support_filament_g != 0.0)
|
||||
displayed_columns |= ColumnData::Support;
|
||||
support_used_filaments_m_all_plates.push_back(support_filament_m);
|
||||
support_used_filaments_g_all_plates.push_back(support_filament_g);
|
||||
}
|
||||
|
||||
char buff[64];
|
||||
double longest_str = 0.0;
|
||||
|
|
@ -4236,21 +4253,30 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
}
|
||||
::sprintf(buff, "%.2f", longest_str);
|
||||
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[2]} });
|
||||
std::vector<std::pair<std::string, std::vector<::string>>> title_columns;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
title_columns.push_back({ _u8L("Filament"), {""} });
|
||||
title_columns.push_back({ _u8L("Model"), {buff} });
|
||||
}
|
||||
else if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Total"), offsets[3]} });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
title_columns.push_back({ _u8L("Support"), {buff} });
|
||||
}
|
||||
else {
|
||||
if (displayed_columns != (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower))
|
||||
displayed_columns = (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower);
|
||||
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), {buff}}, {_u8L("Flushed"), {buff}}, {_u8L("Tower"), {buff}}, {_u8L("Total"), {buff}} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Tower"), offsets[3]}, {_u8L("Total"), offsets[4]} });
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
title_columns.push_back({ _u8L("Flushed"), {buff} });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
title_columns.push_back({ _u8L("Tower"), {buff} });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
title_columns.push_back({ _u8L("Total"), {buff} });
|
||||
}
|
||||
auto offsets_ = calculate_offsets(title_columns, icon_size);
|
||||
std::vector<std::pair<std::string, float>> title_offsets;
|
||||
for (int i = 0; i < offsets_.size(); i++) {
|
||||
title_offsets.push_back({ title_columns[i].first, offsets_[i] });
|
||||
offsets[title_columns[i].first] = offsets_[i];
|
||||
}
|
||||
append_headers(title_offsets);
|
||||
}
|
||||
|
||||
// item
|
||||
|
|
@ -4259,39 +4285,43 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
for (auto it = model_volume_of_extruders_all_plates.begin(); it != model_volume_of_extruders_all_plates.end(); it++) {
|
||||
if (i < model_used_filaments_m_all_plates.size() && i < model_used_filaments_g_all_plates.size()) {
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ std::to_string(it->first + 1), offsets[0] });
|
||||
columns_offsets.push_back({ std::to_string(it->first + 1), offsets[_u8L("Filament")]});
|
||||
|
||||
char buf[64];
|
||||
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1.0;
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
float column_sum_m = 0.0f;
|
||||
float column_sum_g = 0.0f;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Model")] });
|
||||
column_sum_m += model_used_filaments_m_all_plates[i];
|
||||
column_sum_g += model_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m_all_plates[i], flushed_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m_all_plates[i] + flushed_filaments_m_all_plates[i]),
|
||||
(model_used_filaments_g_all_plates[i] + flushed_filaments_g_all_plates[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", support_used_filaments_m_all_plates[i], support_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Support")] });
|
||||
column_sum_m += support_used_filaments_m_all_plates[i];
|
||||
column_sum_g += support_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m_all_plates[i], model_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m_all_plates[i], flushed_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Flushed")] });
|
||||
column_sum_m += flushed_filaments_m_all_plates[i];
|
||||
column_sum_g += flushed_filaments_g_all_plates[i];
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", wipe_tower_used_filaments_m_all_plates[i], wipe_tower_used_filaments_g_all_plates[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m_all_plates[i] + flushed_filaments_m_all_plates[i] + wipe_tower_used_filaments_m_all_plates[i]),
|
||||
(model_used_filaments_g_all_plates[i] + flushed_filaments_g_all_plates[i] + wipe_tower_used_filaments_g_all_plates[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Tower")] });
|
||||
column_sum_m += wipe_tower_used_filaments_m_all_plates[i];
|
||||
column_sum_g += wipe_tower_used_filaments_g_all_plates[i];
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", column_sum_m, column_sum_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[_u8L("Total")] });
|
||||
}
|
||||
|
||||
append_item(filament_colors[it->first], columns_offsets);
|
||||
|
|
@ -4686,19 +4716,90 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
std::vector<double> wipe_tower_used_filaments_m;
|
||||
std::vector<double> wipe_tower_used_filaments_g;
|
||||
double total_wipe_tower_used_filament_m = 0, total_wipe_tower_used_filament_g = 0;
|
||||
std::vector<double> support_used_filaments_m;
|
||||
std::vector<double> support_used_filaments_g;
|
||||
double total_support_used_filament_m = 0, total_support_used_filament_g = 0;
|
||||
struct ColumnData {
|
||||
enum {
|
||||
Model = 1,
|
||||
Flushed = 2,
|
||||
WipeTower = 4,
|
||||
Support = 1 << 3,
|
||||
};
|
||||
};
|
||||
int displayed_columns = 0;
|
||||
std::map<std::string, float> color_print_offsets;
|
||||
const PrintStatistics& ps = wxGetApp().plater()->get_partplate_list().get_current_fff_print().print_statistics();
|
||||
double koef = imperial_units ? GizmoObjectManipulation::in_to_mm : 1000.0;
|
||||
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
|
||||
|
||||
|
||||
// used filament statistics
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.volumes_per_extruder.find(extruder_id) == m_print_statistics.volumes_per_extruder.end()) {
|
||||
model_used_filaments_m.push_back(0.0);
|
||||
model_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.volumes_per_extruder.at(extruder_id);
|
||||
auto [model_used_filament_m, model_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
model_used_filaments_m.push_back(model_used_filament_m);
|
||||
model_used_filaments_g.push_back(model_used_filament_g);
|
||||
total_model_used_filament_m += model_used_filament_m;
|
||||
total_model_used_filament_g += model_used_filament_g;
|
||||
displayed_columns |= ColumnData::Model;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.wipe_tower_volumes_per_extruder.find(extruder_id) == m_print_statistics.wipe_tower_volumes_per_extruder.end()) {
|
||||
wipe_tower_used_filaments_m.push_back(0.0);
|
||||
wipe_tower_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
auto [wipe_tower_used_filament_m, wipe_tower_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
wipe_tower_used_filaments_m.push_back(wipe_tower_used_filament_m);
|
||||
wipe_tower_used_filaments_g.push_back(wipe_tower_used_filament_g);
|
||||
total_wipe_tower_used_filament_m += wipe_tower_used_filament_m;
|
||||
total_wipe_tower_used_filament_g += wipe_tower_used_filament_g;
|
||||
displayed_columns |= ColumnData::WipeTower;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.flush_per_filament.find(extruder_id) == m_print_statistics.flush_per_filament.end()) {
|
||||
flushed_filaments_m.push_back(0.0);
|
||||
flushed_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.flush_per_filament.at(extruder_id);
|
||||
auto [flushed_filament_m, flushed_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
flushed_filaments_m.push_back(flushed_filament_m);
|
||||
flushed_filaments_g.push_back(flushed_filament_g);
|
||||
total_flushed_filament_m += flushed_filament_m;
|
||||
total_flushed_filament_g += flushed_filament_g;
|
||||
displayed_columns |= ColumnData::Flushed;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.support_volumes_per_extruder.find(extruder_id) == m_print_statistics.support_volumes_per_extruder.end()) {
|
||||
support_used_filaments_m.push_back(0.0);
|
||||
support_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.support_volumes_per_extruder.at(extruder_id);
|
||||
auto [used_filament_m, used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
support_used_filaments_m.push_back(used_filament_m);
|
||||
support_used_filaments_g.push_back(used_filament_g);
|
||||
total_support_used_filament_m += used_filament_m;
|
||||
total_support_used_filament_g += used_filament_g;
|
||||
displayed_columns |= ColumnData::Support;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// extrusion paths section -> title
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
|
|
@ -4776,76 +4877,36 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
case EViewType::ColorPrint:
|
||||
{
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.volumes_per_extruder.find(extruder_id) == m_print_statistics.volumes_per_extruder.end()) {
|
||||
model_used_filaments_m.push_back(0.0);
|
||||
model_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.volumes_per_extruder.at(extruder_id);
|
||||
auto [model_used_filament_m, model_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
model_used_filaments_m.push_back(model_used_filament_m);
|
||||
model_used_filaments_g.push_back(model_used_filament_g);
|
||||
total_model_used_filament_m += model_used_filament_m;
|
||||
total_model_used_filament_g += model_used_filament_g;
|
||||
displayed_columns |= ColumnData::Model;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.wipe_tower_volumes_per_extruder.find(extruder_id) == m_print_statistics.wipe_tower_volumes_per_extruder.end()) {
|
||||
wipe_tower_used_filaments_m.push_back(0.0);
|
||||
wipe_tower_used_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.wipe_tower_volumes_per_extruder.at(extruder_id);
|
||||
auto [wipe_tower_used_filament_m, wipe_tower_used_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
wipe_tower_used_filaments_m.push_back(wipe_tower_used_filament_m);
|
||||
wipe_tower_used_filaments_g.push_back(wipe_tower_used_filament_g);
|
||||
total_wipe_tower_used_filament_m += wipe_tower_used_filament_m;
|
||||
total_wipe_tower_used_filament_g += wipe_tower_used_filament_g;
|
||||
displayed_columns |= ColumnData::WipeTower;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t extruder_id : m_extruder_ids) {
|
||||
if (m_print_statistics.flush_per_filament.find(extruder_id) == m_print_statistics.flush_per_filament.end()) {
|
||||
flushed_filaments_m.push_back(0.0);
|
||||
flushed_filaments_g.push_back(0.0);
|
||||
}
|
||||
else {
|
||||
double volume = m_print_statistics.flush_per_filament.at(extruder_id);
|
||||
auto [flushed_filament_m, flushed_filament_g] = get_used_filament_from_volume(volume, extruder_id);
|
||||
flushed_filaments_m.push_back(flushed_filament_m);
|
||||
flushed_filaments_g.push_back(flushed_filament_g);
|
||||
total_flushed_filament_m += flushed_filament_m;
|
||||
total_flushed_filament_g += flushed_filament_g;
|
||||
displayed_columns |= ColumnData::Flushed;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> total_filaments;
|
||||
char buffer[64];
|
||||
::sprintf(buffer, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", ps.total_used_filament / /*1000*/koef, ps.total_weight / unit_conver);
|
||||
total_filaments.push_back(buffer);
|
||||
|
||||
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[2]}});
|
||||
std::vector<std::pair<std::string, std::vector<::string>>> title_columns;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
title_columns.push_back({ _u8L("Filament"), {""} });
|
||||
title_columns.push_back({ _u8L("Model"), total_filaments });
|
||||
}
|
||||
else if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Total"), offsets[3]} });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
title_columns.push_back({ _u8L("Support"), total_filaments });
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "displayed_columns: " << displayed_columns;
|
||||
if (displayed_columns != (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower))
|
||||
displayed_columns = (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower);
|
||||
|
||||
offsets = calculate_offsets({ {_u8L("Filament"), {""}}, {_u8L("Model"), total_filaments}, {_u8L("Flushed"), total_filaments}, {_u8L("Tower"), total_filaments}, {_u8L("Total"), total_filaments} }, icon_size);
|
||||
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Model"), offsets[1]}, {_u8L("Flushed"), offsets[2]}, {_u8L("Tower"), offsets[3]}, {_u8L("Total"), offsets[4]} });
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
title_columns.push_back({ _u8L("Flushed"), total_filaments });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
title_columns.push_back({ _u8L("Tower"), total_filaments });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
title_columns.push_back({ _u8L("Total"), total_filaments });
|
||||
}
|
||||
auto offsets_ = calculate_offsets(title_columns, icon_size);
|
||||
std::vector<std::pair<std::string, float>> title_offsets;
|
||||
for (int i = 0; i < offsets_.size(); i++) {
|
||||
title_offsets.push_back({ title_columns[i].first, offsets_[i] });
|
||||
color_print_offsets[title_columns[i].first] = offsets_[i];
|
||||
}
|
||||
append_headers(title_offsets);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -4986,40 +5047,42 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
const bool filament_visible = m_tools.m_tool_visibles[extruder_idx];
|
||||
if (i < model_used_filaments_m.size() && i < model_used_filaments_g.size()) {
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ std::to_string(extruder_idx + 1), offsets[0] });
|
||||
columns_offsets.push_back({ std::to_string(extruder_idx + 1), color_print_offsets[_u8L("Filament")]});
|
||||
|
||||
char buf[64];
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
float column_sum_m = 0.0f;
|
||||
float column_sum_g = 0.0f;
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Model")] });
|
||||
column_sum_m += model_used_filaments_m[i];
|
||||
column_sum_g += model_used_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m[i], flushed_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m[i] + flushed_filaments_m[i]),
|
||||
(model_used_filaments_g[i] + flushed_filaments_g[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", support_used_filaments_m[i], support_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Support")] });
|
||||
column_sum_m += support_used_filaments_m[i];
|
||||
column_sum_g += support_used_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", model_used_filaments_m[i], model_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", flushed_filaments_m[i], flushed_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Flushed")]});
|
||||
column_sum_m += flushed_filaments_m[i];
|
||||
column_sum_g += flushed_filaments_g[i];
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", wipe_tower_used_filaments_m[i], wipe_tower_used_filaments_g[i] / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", (model_used_filaments_m[i] + flushed_filaments_m[i] + wipe_tower_used_filaments_m[i]),
|
||||
(model_used_filaments_g[i] + flushed_filaments_g[i] + wipe_tower_used_filaments_g[i]) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Tower")] });
|
||||
column_sum_m += wipe_tower_used_filaments_m[i];
|
||||
column_sum_g += wipe_tower_used_filaments_g[i];
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", column_sum_m, column_sum_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Total")] });
|
||||
}
|
||||
|
||||
|
||||
append_item(EItemType::Rect, m_tools.m_tool_colors[extruder_idx], columns_offsets, false, filament_visible, [this, extruder_idx]() {
|
||||
m_tools.m_tool_visibles[extruder_idx] = !m_tools.m_tool_visibles[extruder_idx];
|
||||
|
|
@ -5035,6 +5098,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
if (need_scrollable)
|
||||
ImGui::EndChild();
|
||||
|
||||
// Sum of all rows
|
||||
char buf[64];
|
||||
if (m_extruder_ids.size() > 1) {
|
||||
// Separator
|
||||
|
|
@ -5045,42 +5109,32 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
window->DrawList->AddLine(separator.Min, ImVec2(separator.Max.x, separator.Min.y), ImGui::GetColorU32(ImGuiCol_Separator));
|
||||
|
||||
std::vector<std::pair<std::string, float>> columns_offsets;
|
||||
columns_offsets.push_back({ _u8L("Total"), offsets[0] });
|
||||
if (displayed_columns == ColumnData::Model) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
columns_offsets.push_back({ _u8L("Total"), color_print_offsets[_u8L("Filament")]});
|
||||
if (displayed_columns & ColumnData::Model) {
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0)
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
else
|
||||
::sprintf(buf, imperial_units ? "%.2f in %.2f oz" : "%.2f m %.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Model")] });
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_flushed_filament_m, total_flushed_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_flushed_filament_m , (total_model_used_filament_g + total_flushed_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
if (displayed_columns & ColumnData::Support) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_support_used_filament_m, total_support_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Support")] });
|
||||
}
|
||||
if (displayed_columns == (ColumnData::Model | ColumnData::Flushed | ColumnData::WipeTower)) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m, total_model_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[1] });
|
||||
|
||||
if (displayed_columns & ColumnData::Flushed) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_flushed_filament_m, total_flushed_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[2] });
|
||||
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Flushed")] });
|
||||
}
|
||||
if (displayed_columns & ColumnData::WipeTower) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_wipe_tower_used_filament_m, total_wipe_tower_used_filament_g / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[3] });
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m, (total_model_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, offsets[4] });
|
||||
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Tower")] });
|
||||
}
|
||||
if ((displayed_columns & ~ColumnData::Model) > 0) {
|
||||
::sprintf(buf, imperial_units ? "%.2f in\n%.2f oz" : "%.2f m\n%.2f g", total_model_used_filament_m + total_support_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m,
|
||||
(total_model_used_filament_g + total_support_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g) / unit_conver);
|
||||
columns_offsets.push_back({ buf, color_print_offsets[_u8L("Total")] });
|
||||
}
|
||||
append_item(EItemType::None, m_tools.m_tool_colors[0], columns_offsets);
|
||||
}
|
||||
|
||||
//BBS display filament change times
|
||||
|
|
@ -5521,7 +5575,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.title(time_title);
|
||||
std::string filament_str = _u8L("Filament");
|
||||
std::string total_filament_str = _u8L("Total Filament");
|
||||
std::string model_filament_str = _u8L("Model Filament");
|
||||
std::string cost_str = _u8L("Cost");
|
||||
std::string prepare_str = _u8L("Prepare time");
|
||||
std::string print_str = _u8L("Model printing time");
|
||||
|
|
@ -5535,7 +5590,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
max_len += std::max(ImGui::CalcTextSize(cost_str.c_str()).x,
|
||||
std::max(ImGui::CalcTextSize(print_str.c_str()).x,
|
||||
std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x),
|
||||
ImGui::CalcTextSize(filament_str.c_str()).x)));
|
||||
std::max(ImGui::CalcTextSize(total_filament_str.c_str()).x, ImGui::CalcTextSize(model_filament_str.c_str()).x))));
|
||||
else
|
||||
max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x,
|
||||
(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x)));
|
||||
|
|
@ -5545,24 +5600,34 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
//BBS display filament cost
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(filament_str + ":");
|
||||
imgui.text(total_filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
|
||||
//BBS: use current plater's print statistics
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
char buf[64];
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / /*1000*/koef);
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / koef);
|
||||
imgui.text(buf);
|
||||
ImGui::SameLine();
|
||||
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", ps.total_weight / unit_conver);
|
||||
imgui.text(buf);
|
||||
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(model_filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
auto exlude_m = total_support_used_filament_m + total_flushed_filament_m + total_wipe_tower_used_filament_m;
|
||||
auto exlude_g = total_support_used_filament_g + total_flushed_filament_g + total_wipe_tower_used_filament_g;
|
||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", ps.total_used_filament / koef - exlude_m);
|
||||
imgui.text(buf);
|
||||
ImGui::SameLine();
|
||||
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", (ps.total_weight - exlude_g) / unit_conver);
|
||||
imgui.text(buf);
|
||||
|
||||
//BBS: display cost of filaments
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(cost_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
|
||||
::sprintf(buf, "%.2f", ps.total_cost);
|
||||
imgui.text(buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -657,7 +657,7 @@ void GLCanvas3D::LayersEditing::generate_layer_height_texture()
|
|||
bool level_of_detail_2nd_level = true;
|
||||
m_layers_texture.cells = Slic3r::generate_layer_height_texture(
|
||||
*m_slicing_parameters,
|
||||
Slic3r::generate_object_layers(*m_slicing_parameters, m_layer_height_profile),
|
||||
Slic3r::generate_object_layers(*m_slicing_parameters, m_layer_height_profile, false),
|
||||
m_layers_texture.data.data(), m_layers_texture.height, m_layers_texture.width, level_of_detail_2nd_level);
|
||||
m_layers_texture.valid = true;
|
||||
}
|
||||
|
|
@ -1024,6 +1024,8 @@ wxDEFINE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent);
|
|||
wxDEFINE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_REDO, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_SWITCH_TO_OBJECT, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_SWITCH_TO_GLOBAL, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_COLLAPSE_SIDEBAR, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
|
||||
wxDEFINE_EVENT(EVT_GLCANVAS_RENDER_TIMER, wxTimerEvent/*RenderTimerEvent*/);
|
||||
|
|
@ -1096,6 +1098,25 @@ void GLCanvas3D::load_arrange_settings()
|
|||
m_arrange_settings_fff_seq_print.is_seq_print = true;
|
||||
}
|
||||
|
||||
GLCanvas3D::ArrangeSettings& GLCanvas3D::get_arrange_settings()
|
||||
{
|
||||
PrinterTechnology ptech = current_printer_technology();
|
||||
|
||||
auto* ptr = &m_arrange_settings_fff;
|
||||
|
||||
if (ptech == ptSLA) {
|
||||
ptr = &m_arrange_settings_sla;
|
||||
}
|
||||
else if (ptech == ptFFF) {
|
||||
if (wxGetApp().global_print_sequence() == PrintSequence::ByObject)
|
||||
ptr = &m_arrange_settings_fff_seq_print;
|
||||
else
|
||||
ptr = &m_arrange_settings_fff;
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
int GLCanvas3D::GetHoverId()
|
||||
{
|
||||
if (m_hover_plate_idxs.size() == 0) {
|
||||
|
|
@ -1152,7 +1173,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D &bed)
|
|||
m_retina_helper.reset(new RetinaHelper(canvas));
|
||||
#endif // ENABLE_RETINA_GL
|
||||
}
|
||||
|
||||
m_timer_set_color.Bind(wxEVT_TIMER, &GLCanvas3D::on_set_color_timer, this);
|
||||
load_arrange_settings();
|
||||
|
||||
m_selection.set_volumes(&m_volumes.volumes);
|
||||
|
|
@ -1347,7 +1368,36 @@ ModelInstanceEPrintVolumeState GLCanvas3D::check_volumes_outside_state() const
|
|||
return state;
|
||||
}
|
||||
|
||||
void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx)
|
||||
void GLCanvas3D::toggle_selected_volume_visibility(bool selected_visible)
|
||||
{
|
||||
m_render_sla_auxiliaries = !selected_visible;
|
||||
if (selected_visible) {
|
||||
const Selection::IndicesList &idxs = m_selection.get_volume_idxs();
|
||||
if (idxs.size() > 0) {
|
||||
for (GLVolume *vol : m_volumes.volumes) {
|
||||
if (vol->composite_id.object_id >= 1000 && vol->composite_id.object_id < 1000 + wxGetApp().plater()->get_partplate_list().get_plate_count())
|
||||
continue; // the wipe tower
|
||||
if (vol->composite_id.volume_id >= 0) {
|
||||
vol->is_active = false;
|
||||
}
|
||||
}
|
||||
for (unsigned int idx : idxs) {
|
||||
GLVolume *v = const_cast<GLVolume *>(m_selection.get_volume(idx));
|
||||
v->is_active = true;
|
||||
}
|
||||
}
|
||||
} else { // show all
|
||||
for (GLVolume *vol : m_volumes.volumes) {
|
||||
if (vol->composite_id.object_id >= 1000 && vol->composite_id.object_id < 1000 + wxGetApp().plater()->get_partplate_list().get_plate_count())
|
||||
continue; // the wipe tower
|
||||
if (vol->composite_id.volume_id >= 0) {
|
||||
vol->is_active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject *mo, int instance_idx)
|
||||
{
|
||||
if (current_printer_technology() != ptSLA)
|
||||
return;
|
||||
|
|
@ -1771,7 +1821,9 @@ void GLCanvas3D::render(bool only_init)
|
|||
|
||||
if (!is_initialized() && !init())
|
||||
return;
|
||||
|
||||
if (m_canvas_type == ECanvasType::CanvasView3D && m_gizmos.get_current_type() == GLGizmosManager::Undefined) {
|
||||
enable_return_toolbar(false);
|
||||
}
|
||||
if (!m_main_toolbar.is_enabled())
|
||||
m_gcode_viewer.init(wxGetApp().get_mode(), wxGetApp().preset_bundle);
|
||||
|
||||
|
|
@ -3170,15 +3222,25 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||
}
|
||||
|
||||
// BBS: use keypad to change extruder
|
||||
case '1':
|
||||
case '1': {
|
||||
if (!m_timer_set_color.IsRunning()) {
|
||||
m_timer_set_color.StartOnce(500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case '0': //Color logic for material 10
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9': {
|
||||
if (m_timer_set_color.IsRunning()) {
|
||||
if (keyCode < '7') keyCode += 10;
|
||||
m_timer_set_color.Stop();
|
||||
}
|
||||
if (m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation)
|
||||
obj_list->set_extruder_for_selected_items(keyCode - '0');
|
||||
break;
|
||||
|
|
@ -3720,6 +3782,14 @@ void GLCanvas3D::on_render_timer(wxTimerEvent& evt)
|
|||
// wxWakeUpIdle();
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_set_color_timer(wxTimerEvent& evt)
|
||||
{
|
||||
auto obj_list = wxGetApp().obj_list();
|
||||
if (m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation)
|
||||
obj_list->set_extruder_for_selected_items(1);
|
||||
m_timer_set_color.Stop();
|
||||
}
|
||||
|
||||
|
||||
void GLCanvas3D::schedule_extra_frame(int miliseconds)
|
||||
{
|
||||
|
|
@ -4026,6 +4096,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.position = Vec2d(-1.0, -1.0);
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.LeftDClick()) {
|
||||
// switch to object panel if double click on object, otherwise switch to global panel if double click on background
|
||||
if (selected_object_idx >= 0)
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_SWITCH_TO_OBJECT));
|
||||
else
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_SWITCH_TO_GLOBAL));
|
||||
}
|
||||
else if (evt.LeftDown() || evt.RightDown() || evt.MiddleDown()) {
|
||||
//BBS: add orient deactivate logic
|
||||
if (!m_gizmos.on_mouse(evt)) {
|
||||
|
|
@ -4988,8 +5065,10 @@ std::vector<Vec2f> GLCanvas3D::get_empty_cells(const Vec2f start_point, const Ve
|
|||
Vec2d vmin(build_volume.min.x(), build_volume.min.y()), vmax(build_volume.max.x(), build_volume.max.y());
|
||||
BoundingBoxf bbox(vmin, vmax);
|
||||
std::vector<Vec2f> cells;
|
||||
for (float x = bbox.min.x()+step(0)/2; x < bbox.max.x()-step(0)/2; x += step(0))
|
||||
for (float y = bbox.min.y()+step(1)/2; y < bbox.max.y()-step(1)/2; y += step(1))
|
||||
auto min_x = start_point.x() - step(0) * int((start_point.x() - bbox.min.x()) / step(0));
|
||||
auto min_y = start_point.y() - step(1) * int((start_point.y() - bbox.min.y()) / step(1));
|
||||
for (float x = min_x; x < bbox.max.x() - step(0) / 2; x += step(0))
|
||||
for (float y = min_y; y < bbox.max.y() - step(1) / 2; y += step(1))
|
||||
{
|
||||
cells.emplace_back(x, y);
|
||||
}
|
||||
|
|
@ -5125,7 +5204,14 @@ void GLCanvas3D::update_sequential_clearance()
|
|||
// the results are then cached for following displacements
|
||||
if (m_sequential_print_clearance_first_displacement) {
|
||||
m_sequential_print_clearance.m_hull_2d_cache.clear();
|
||||
float shrink_factor = static_cast<float>(scale_(0.5 * fff_print()->config().extruder_clearance_radius.value - EPSILON));
|
||||
bool all_objects_are_short = std::all_of(fff_print()->objects().begin(), fff_print()->objects().end(), \
|
||||
[&](PrintObject* obj) { return obj->height() < scale_(fff_print()->config().nozzle_height.value - MARGIN_HEIGHT); });
|
||||
float shrink_factor;
|
||||
if (all_objects_are_short)
|
||||
shrink_factor = scale_(0.5 * MAX_OUTER_NOZZLE_DIAMETER - 0.1);
|
||||
else
|
||||
shrink_factor = static_cast<float>(scale_(0.5 * fff_print()->config().extruder_clearance_radius.value - EPSILON));
|
||||
|
||||
double mitter_limit = scale_(0.1);
|
||||
m_sequential_print_clearance.m_hull_2d_cache.reserve(m_model->objects.size());
|
||||
for (size_t i = 0; i < m_model->objects.size(); ++i) {
|
||||
|
|
@ -5435,7 +5521,7 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
|||
PrinterTechnology ptech = current_printer_technology();
|
||||
|
||||
bool settings_changed = false;
|
||||
float dist_min = 0.1f; // should be larger than 0 so objects won't touch
|
||||
float dist_min = 0.f; // 0 means auto
|
||||
std::string dist_key = "min_object_distance", rot_key = "enable_rotation";
|
||||
std::string bed_shrink_x_key = "bed_shrink_x", bed_shrink_y_key = "bed_shrink_y";
|
||||
std::string multi_material_key = "allow_multi_materials_on_same_plate";
|
||||
|
|
@ -5446,17 +5532,12 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
|||
bool seq_print = false;
|
||||
|
||||
if (ptech == ptSLA) {
|
||||
dist_min = 0.1f;
|
||||
postfix = "_sla";
|
||||
} else if (ptech == ptFFF) {
|
||||
auto co_opt = m_config->option<ConfigOptionEnum<PrintSequence>>("print_sequence");
|
||||
if (co_opt && (co_opt->value == PrintSequence::ByObject)) {
|
||||
dist_min = float(min_object_distance(*m_config));
|
||||
seq_print = &settings == &m_arrange_settings_fff_seq_print;
|
||||
if (seq_print) {
|
||||
postfix = "_fff_seq_print";
|
||||
//BBS:
|
||||
seq_print = true;
|
||||
} else {
|
||||
dist_min = 0.0f;
|
||||
postfix = "_fff";
|
||||
}
|
||||
}
|
||||
|
|
@ -5481,6 +5562,8 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
|
|||
appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance));
|
||||
settings_changed = true;
|
||||
}
|
||||
imgui->text(_L("0 means auto spacing."));
|
||||
|
||||
ImGui::Separator();
|
||||
if (imgui->bbl_checkbox(_L("Auto rotate for arrangement"), settings.enable_rotation)) {
|
||||
settings_out.enable_rotation = settings.enable_rotation;
|
||||
|
|
@ -6346,7 +6429,7 @@ void GLCanvas3D::_update_select_plate_toolbar_stats_item(bool force_selected) {
|
|||
bool GLCanvas3D::_update_imgui_select_plate_toolbar()
|
||||
{
|
||||
bool result = true;
|
||||
if (!m_sel_plate_toolbar.is_enabled()) return false;
|
||||
if (!m_sel_plate_toolbar.is_enabled() || m_sel_plate_toolbar.is_render_finish) return false;
|
||||
|
||||
_update_select_plate_toolbar_stats_item();
|
||||
|
||||
|
|
@ -7926,6 +8009,7 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar()
|
|||
}
|
||||
|
||||
imgui.end();
|
||||
m_sel_plate_toolbar.is_render_finish = true;
|
||||
}
|
||||
|
||||
//BBS: GUI refactor: GLToolbar adjust
|
||||
|
|
|
|||
|
|
@ -187,6 +187,8 @@ wxDECLARE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent);
|
|||
wxDECLARE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_REDO, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_SWITCH_TO_OBJECT, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_SWITCH_TO_GLOBAL, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_COLLAPSE_SIDEBAR, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_RELOAD_FROM_DISK, SimpleEvent);
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_RENDER_TIMER, wxTimerEvent/*RenderTimerEvent*/);
|
||||
|
|
@ -515,6 +517,7 @@ private:
|
|||
unsigned int m_last_w, m_last_h;
|
||||
bool m_in_render;
|
||||
wxTimer m_timer;
|
||||
wxTimer m_timer_set_color;
|
||||
LayersEditing m_layers_editing;
|
||||
Mouse m_mouse;
|
||||
GLGizmosManager m_gizmos;
|
||||
|
|
@ -607,25 +610,6 @@ private:
|
|||
|
||||
PrinterTechnology current_printer_technology() const;
|
||||
|
||||
template<class Self>
|
||||
static auto & get_arrange_settings(Self *self) {
|
||||
PrinterTechnology ptech = self->current_printer_technology();
|
||||
|
||||
auto *ptr = &self->m_arrange_settings_fff;
|
||||
|
||||
if (ptech == ptSLA) {
|
||||
ptr = &self->m_arrange_settings_sla;
|
||||
} else if (ptech == ptFFF) {
|
||||
auto co_opt = self->m_config->template option<ConfigOptionEnum<PrintSequence>>("print_sequence");
|
||||
if (co_opt && (co_opt->value == PrintSequence::ByObject))
|
||||
ptr = &self->m_arrange_settings_fff_seq_print;
|
||||
else
|
||||
ptr = &self->m_arrange_settings_fff;
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//BBS:record key botton frequency
|
||||
|
|
@ -651,7 +635,11 @@ public:
|
|||
}
|
||||
|
||||
void load_arrange_settings();
|
||||
ArrangeSettings& get_arrange_settings() { return get_arrange_settings(this); }
|
||||
ArrangeSettings& get_arrange_settings();// { return get_arrange_settings(this); }
|
||||
ArrangeSettings& get_arrange_settings(PrintSequence print_seq) {
|
||||
return (print_seq == PrintSequence::ByObject) ? m_arrange_settings_fff_seq_print
|
||||
: m_arrange_settings_fff;
|
||||
}
|
||||
|
||||
class SequentialPrintClearance
|
||||
{
|
||||
|
|
@ -774,6 +762,7 @@ public:
|
|||
const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); }
|
||||
void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); }
|
||||
|
||||
void toggle_selected_volume_visibility(bool selected_visible);
|
||||
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||
void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1, const ModelVolume* mv = nullptr);
|
||||
void update_instance_printable_state_for_object(size_t obj_idx);
|
||||
|
|
@ -960,6 +949,7 @@ public:
|
|||
void on_mouse_wheel(wxMouseEvent& evt);
|
||||
void on_timer(wxTimerEvent& evt);
|
||||
void on_render_timer(wxTimerEvent& evt);
|
||||
void on_set_color_timer(wxTimerEvent& evt);
|
||||
void on_mouse(wxMouseEvent& evt);
|
||||
void on_gesture(wxGestureEvent& evt);
|
||||
void on_paint(wxPaintEvent& evt);
|
||||
|
|
@ -1068,6 +1058,17 @@ public:
|
|||
void highlight_toolbar_item(const std::string& item_name);
|
||||
void highlight_gizmo(const std::string& gizmo_name);
|
||||
|
||||
ArrangeSettings get_arrange_settings() const {
|
||||
const ArrangeSettings &settings = get_arrange_settings();
|
||||
ArrangeSettings ret = settings;
|
||||
if (&settings == &m_arrange_settings_fff_seq_print) {
|
||||
ret.distance = std::max(ret.distance,
|
||||
float(min_object_distance(*m_config)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Timestamp for FPS calculation and notification fade-outs.
|
||||
static int64_t timestamp_now() {
|
||||
#ifdef _WIN32
|
||||
|
|
|
|||
|
|
@ -149,6 +149,40 @@ namespace GUI {
|
|||
|
||||
class MainFrame;
|
||||
|
||||
void start_ping_test()
|
||||
{
|
||||
wxArrayString output;
|
||||
wxExecute("ping www.amazon.com", output, wxEXEC_NODISABLE);
|
||||
|
||||
wxString output_i;
|
||||
std::string output_temp;
|
||||
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping amazon:" << output_temp;
|
||||
|
||||
}
|
||||
wxExecute("ping www.apple.com", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping www.apple.com:" << output_temp;
|
||||
}
|
||||
wxExecute("ping www.bambulab.com", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping bambulab:" << output_temp;
|
||||
}
|
||||
//Get GateWay IP
|
||||
wxExecute("ping 192.168.0.1", output, wxEXEC_NODISABLE);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
output_i = output[i].To8BitData();
|
||||
output_temp = output_i.ToStdString(wxConvUTF8);
|
||||
BOOST_LOG_TRIVIAL(info) << "ping 192.168.0.1:" << output_temp;
|
||||
}
|
||||
}
|
||||
|
||||
std::string VersionInfo::convert_full_version(std::string short_version)
|
||||
{
|
||||
|
|
@ -474,9 +508,11 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = {
|
|||
/* FT_3MF */ { "3MF files"sv, { ".3mf"sv } },
|
||||
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv, ".3mf"sv } },
|
||||
#ifdef __APPLE__
|
||||
/* FT_MODEL */ { "Supported files"sv, { ".3mf"sv, ".stl"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv , ".usd"sv, ".usda"sv, ".usdc"sv, ".usdz"sv, ".abc"sv, ".ply"sv} },
|
||||
/* FT_MODEL */
|
||||
{"Supported files"sv, {".3mf"sv, ".stl"sv, ".oltp"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv, ".usd"sv, ".usda"sv, ".usdc"sv, ".usdz"sv, ".abc"sv, ".ply"sv}},
|
||||
#else
|
||||
/* FT_MODEL */ {"Supported files"sv, {".3mf"sv, ".stl"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv }},
|
||||
/* FT_MODEL */
|
||||
{"Supported files"sv, {".3mf"sv, ".stl"sv, ".oltp"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv}},
|
||||
#endif
|
||||
/* FT_PROJECT */ { "Project files"sv, { ".3mf"sv} },
|
||||
/* FT_GALLERY */ { "Known files"sv, { ".stl"sv, ".obj"sv } },
|
||||
|
|
@ -993,8 +1029,7 @@ void GUI_App::post_init()
|
|||
});
|
||||
|
||||
|
||||
std::string filaments_blacklist_config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
|
||||
DeviceManager::load_filaments_blacklist_config(encode_path(filaments_blacklist_config_file.c_str()));
|
||||
DeviceManager::load_filaments_blacklist_config();
|
||||
|
||||
// remove old log files over LOG_FILES_MAX_NUM
|
||||
std::string log_addr = data_dir();
|
||||
|
|
@ -1935,7 +1970,7 @@ std::map<std::string, std::string> GUI_App::get_extra_header()
|
|||
extra_headers.insert(std::make_pair("X-BBL-OS-Version", os_version));
|
||||
if (app_config)
|
||||
extra_headers.insert(std::make_pair("X-BBL-Device-ID", app_config->get("slicer_uuid")));
|
||||
extra_headers.insert(std::make_pair("X-BBL-Language", convert_studio_language_to_api(app_config->get("language"))));
|
||||
extra_headers.insert(std::make_pair("X-BBL-Language", convert_studio_language_to_api(into_u8(current_language_code_safe()))));
|
||||
return extra_headers;
|
||||
}
|
||||
|
||||
|
|
@ -2114,9 +2149,6 @@ bool GUI_App::on_init_inner()
|
|||
d->EndModal(wxID_ABORT);
|
||||
});
|
||||
|
||||
std::map<std::string, std::string> extra_headers = get_extra_header();
|
||||
Slic3r::Http::set_extra_headers(extra_headers);
|
||||
|
||||
// Verify resources path
|
||||
const wxString resources_dir = from_u8(Slic3r::resources_dir());
|
||||
wxCHECK_MSG(wxDirExists(resources_dir), false,
|
||||
|
|
@ -2379,6 +2411,10 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
Bind(EVT_SHOW_IP_DIALOG, &GUI_App::show_ip_address_enter_dialog_handler, this);
|
||||
|
||||
|
||||
std::map<std::string, std::string> extra_headers = get_extra_header();
|
||||
Slic3r::Http::set_extra_headers(extra_headers);
|
||||
|
||||
copy_network_if_available();
|
||||
on_init_network();
|
||||
|
||||
|
|
@ -2555,7 +2591,7 @@ void GUI_App::copy_network_if_available()
|
|||
{
|
||||
if (app_config->get("update_network_plugin") != "true")
|
||||
return;
|
||||
std::string network_library, player_library, network_library_dst, player_library_dst;
|
||||
std::string network_library, player_library, live555_library, network_library_dst, player_library_dst, live555_library_dst;
|
||||
std::string data_dir_str = data_dir();
|
||||
boost::filesystem::path data_dir_path(data_dir_str);
|
||||
auto plugin_folder = data_dir_path / "plugins";
|
||||
|
|
@ -2563,19 +2599,25 @@ void GUI_App::copy_network_if_available()
|
|||
std::string changelog_file = cache_folder.string() + "/network_plugins.json";
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
network_library = cache_folder.string() + "/bambu_networking.dll";
|
||||
player_library = cache_folder.string() + "/BambuSource.dll";
|
||||
player_library = cache_folder.string() + "/BambuSource.dll";
|
||||
live555_library = cache_folder.string() + "/live555.dll";
|
||||
network_library_dst = plugin_folder.string() + "/bambu_networking.dll";
|
||||
player_library_dst = plugin_folder.string() + "/BambuSource.dll";
|
||||
player_library_dst = plugin_folder.string() + "/BambuSource.dll";
|
||||
live555_library_dst = plugin_folder.string() + "/live555.dll";
|
||||
#elif defined(__WXMAC__)
|
||||
network_library = cache_folder.string() + "/libbambu_networking.dylib";
|
||||
player_library = cache_folder.string() + "/libBambuSource.dylib";
|
||||
live555_library = cache_folder.string() + "/liblive555.dylib";
|
||||
network_library_dst = plugin_folder.string() + "/libbambu_networking.dylib";
|
||||
player_library_dst = plugin_folder.string() + "/libBambuSource.dylib";
|
||||
live555_library_dst = plugin_folder.string() + "/liblive555.dylib";
|
||||
#else
|
||||
network_library = cache_folder.string() + "/libbambu_networking.so";
|
||||
player_library = cache_folder.string() + "/libBambuSource.so";
|
||||
player_library = cache_folder.string() + "/libBambuSource.so";
|
||||
live555_library = cache_folder.string() + "/liblive555.so";
|
||||
network_library_dst = plugin_folder.string() + "/libbambu_networking.so";
|
||||
player_library_dst = plugin_folder.string() + "/libBambuSource.so";
|
||||
player_library_dst = plugin_folder.string() + "/libBambuSource.so";
|
||||
live555_library_dst = plugin_folder.string() + "/liblive555.so";
|
||||
#endif
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": checking network_library " << network_library << ", player_library " << player_library;
|
||||
|
|
@ -2609,6 +2651,19 @@ void GUI_App::copy_network_if_available()
|
|||
fs::remove(player_library);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": Copying player library from" << player_library << " to " << player_library_dst<<" successfully.";
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(live555_library)) {
|
||||
CopyFileResult cfr = copy_file(live555_library, live555_library_dst, error_message, false);
|
||||
if (cfr != CopyFileResult::SUCCESS) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": Copying failed(" << cfr << "): " << error_message;
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr const auto perms = fs::owner_read | fs::owner_write | fs::group_read | fs::others_read;
|
||||
fs::permissions(live555_library_dst, perms);
|
||||
fs::remove(live555_library);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": Copying live555 library from" << live555_library << " to " << live555_library_dst<<" successfully.";
|
||||
}
|
||||
if (boost::filesystem::exists(changelog_file))
|
||||
fs::remove(changelog_file);
|
||||
app_config->set("update_network_plugin", "false");
|
||||
|
|
@ -3136,7 +3191,10 @@ void GUI_App::check_printer_presets()
|
|||
#endif
|
||||
}
|
||||
|
||||
void GUI_App::recreate_GUI(const wxString& msg_name)
|
||||
void switch_window_pools();
|
||||
void release_window_pools();
|
||||
|
||||
void GUI_App::recreate_GUI(const wxString &msg_name)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "recreate_GUI enter";
|
||||
m_is_recreating_gui = true;
|
||||
|
|
@ -3144,12 +3202,18 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
|
|||
update_http_extra_header();
|
||||
|
||||
mainframe->shutdown();
|
||||
|
||||
ProgressDialog dlg(msg_name, msg_name, 100, nullptr, wxPD_AUTO_HIDE);
|
||||
dlg.Pulse();
|
||||
dlg.Update(10, _L("Rebuild") + dots);
|
||||
|
||||
MainFrame *old_main_frame = mainframe;
|
||||
struct ClientData : wxClientData
|
||||
{
|
||||
~ClientData() { release_window_pools(); }
|
||||
};
|
||||
old_main_frame->SetClientObject(new ClientData);
|
||||
|
||||
switch_window_pools();
|
||||
mainframe = new MainFrame();
|
||||
if (is_editor())
|
||||
// hide settings tabs after first Layout
|
||||
|
|
@ -3218,6 +3282,7 @@ void GUI_App::ShowUserGuide() {
|
|||
if (res) {
|
||||
load_current_presets();
|
||||
update_publish_status();
|
||||
mainframe->refresh_plugin_tips();
|
||||
// BBS: remove SLA related message
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
|
|
@ -5934,6 +5999,15 @@ int GUI_App::filaments_cnt() const
|
|||
return preset_bundle->filament_presets.size();
|
||||
}
|
||||
|
||||
PrintSequence GUI_App::global_print_sequence() const
|
||||
{
|
||||
PrintSequence global_print_seq = PrintSequence::ByDefault;
|
||||
auto curr_preset_config = preset_bundle->prints.get_edited_preset().config;
|
||||
if (curr_preset_config.has("print_sequence"))
|
||||
global_print_seq = curr_preset_config.option<ConfigOptionEnum<PrintSequence>>("print_sequence")->value;
|
||||
return global_print_seq;
|
||||
}
|
||||
|
||||
wxString GUI_App::current_language_code_safe() const
|
||||
{
|
||||
// Translate the language code to a code, for which Prusa Research maintains translations.
|
||||
|
|
@ -6007,6 +6081,7 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
|
|||
if (res) {
|
||||
load_current_presets();
|
||||
update_publish_status();
|
||||
mainframe->refresh_plugin_tips();
|
||||
// BBS: remove SLA related message
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -587,6 +587,7 @@ private:
|
|||
|
||||
// BBS
|
||||
int filaments_cnt() const;
|
||||
PrintSequence global_print_sequence() const;
|
||||
|
||||
std::vector<Tab *> tabs_list;
|
||||
std::vector<Tab *> model_tabs_list;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ std::map<std::string, std::vector<SimpleSettingData>> SettingsFactory::OBJECT_C
|
|||
{"seam_position", "",2},
|
||||
{"slice_closing_radius", "",3}, {"resolution", "",4},
|
||||
{"xy_hole_compensation", "",5}, {"xy_contour_compensation", "",6}, {"elefant_foot_compensation", "",7},
|
||||
{"make_overhang_printable_angle","", 8},{"make_overhang_printable_hole_size","",9}, {"wall_sequence","",10}
|
||||
{"make_overhang_printable_angle","", 8},{"make_overhang_printable_hole_size","",9}, {"wall_sequence","",10},
|
||||
{"precise_z_height", "",10}
|
||||
|
||||
}},
|
||||
{ L("Support"), {{"brim_type", "",1},{"brim_width", "",2},{"brim_object_gap", "",3},
|
||||
{"enable_support", "",4},{"support_type", "",5},{"support_threshold_angle", "",6},{"support_on_build_plate_only", "",7},
|
||||
|
|
|
|||
|
|
@ -699,6 +699,9 @@ void ObjectList::update_filament_values_for_items(const size_t filaments_count)
|
|||
|
||||
void ObjectList::update_plate_values_for_items()
|
||||
{
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(nullptr);
|
||||
#endif
|
||||
PartPlateList& list = wxGetApp().plater()->get_partplate_list();
|
||||
for (size_t i = 0; i < m_objects->size(); ++i)
|
||||
{
|
||||
|
|
@ -724,6 +727,9 @@ void ObjectList::update_plate_values_for_items()
|
|||
Expand(item);
|
||||
Select(item);
|
||||
}
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(m_objects_model);
|
||||
#endif
|
||||
}
|
||||
|
||||
// BBS
|
||||
|
|
@ -3627,7 +3633,7 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed,
|
|||
//BBS start add obj_idx for debug
|
||||
PartPlateList& list = wxGetApp().plater()->get_partplate_list();
|
||||
if (notify_partplate) {
|
||||
list.notify_instance_update(obj_idx, 0);
|
||||
list.notify_instance_update(obj_idx, 0, true);
|
||||
}
|
||||
//int plate_idx = list.find_instance_belongs(obj_idx, 0);
|
||||
//std::string item_name_str = (boost::format("[P%1%][O%2%]%3%") % plate_idx % std::to_string(obj_idx) % model_object->name).str();
|
||||
|
|
@ -3869,16 +3875,10 @@ void ObjectList::update_lock_icons_for_model()
|
|||
|
||||
void ObjectList::delete_all_objects_from_list()
|
||||
{
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(nullptr);
|
||||
#endif
|
||||
m_prevent_list_events = true;
|
||||
reload_all_plates();
|
||||
m_prevent_list_events = false;
|
||||
part_selection_changed();
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(m_objects_model);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObjectList::increase_object_instances(const size_t obj_idx, const size_t num)
|
||||
|
|
@ -5697,6 +5697,9 @@ void ObjectList::on_plate_deleted(int plate_idx)
|
|||
void ObjectList::reload_all_plates(bool notify_partplate)
|
||||
{
|
||||
m_prevent_canvas_selection_update = true;
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(nullptr);
|
||||
#endif
|
||||
|
||||
// Unselect all objects before deleting them, so that no change of selection is emitted during deletion.
|
||||
|
||||
|
|
@ -5726,6 +5729,9 @@ void ObjectList::reload_all_plates(bool notify_partplate)
|
|||
|
||||
update_selections();
|
||||
|
||||
#ifdef __WXOSX__
|
||||
AssociateModel(m_objects_model);
|
||||
#endif
|
||||
m_prevent_canvas_selection_update = false;
|
||||
|
||||
// update scene
|
||||
|
|
@ -5853,6 +5859,7 @@ void ObjectList::toggle_printable_state()
|
|||
|
||||
// update scene
|
||||
wxGetApp().plater()->update();
|
||||
wxGetApp().plater()->reload_paint_after_background_process_apply();
|
||||
}
|
||||
|
||||
ModelObject* ObjectList::object(const int obj_idx) const
|
||||
|
|
|
|||
|
|
@ -209,36 +209,36 @@ bool ObjectSettings::update_settings_list()
|
|||
ModelObject * parent_object = nullptr;
|
||||
for (auto item : items) {
|
||||
auto type = objects_model->GetItemType(item);
|
||||
if (type == itPlate) {
|
||||
is_plate_settings = true;
|
||||
|
||||
int plate_id = objects_model->GetPlateIdByItem(item);
|
||||
|
||||
static ModelConfig cfg;
|
||||
PartPlateList& ppl = wxGetApp().plater()->get_partplate_list();
|
||||
|
||||
if (plate_id < 0 || plate_id >= ppl.get_plate_count()) {
|
||||
plate_id = ppl.get_curr_plate_index();
|
||||
}
|
||||
assert(plate_id >= 0 && plate_id < ppl.get_plate_count());
|
||||
|
||||
cfg.assign_config(*ppl.get_plate(plate_id)->config());
|
||||
plate_configs.emplace(ppl.get_plate(plate_id), &cfg);
|
||||
}
|
||||
if (type != itObject && type != itVolume && type != itLayerRoot && type != itLayer) {
|
||||
if (type != itPlate && type != itObject && type != itVolume && type != itLayerRoot && type != itLayer) {
|
||||
continue;
|
||||
}
|
||||
int plate_id = objects_model->GetPlateIdByItem(item);
|
||||
PartPlateList& ppl = wxGetApp().plater()->get_partplate_list();
|
||||
if (plate_id < 0 || plate_id >= ppl.get_plate_count()) {
|
||||
plate_id = ppl.get_curr_plate_index();
|
||||
}
|
||||
assert(plate_id >= 0 && plate_id < ppl.get_plate_count());
|
||||
static ModelConfig cfg;
|
||||
cfg.assign_config(*ppl.get_plate(plate_id)->config());
|
||||
if (type == itPlate) {
|
||||
is_plate_settings = true;
|
||||
plate_configs.emplace(ppl.get_plate(plate_id), &cfg);
|
||||
break;
|
||||
}
|
||||
|
||||
const int obj_idx = objects_model->GetObjectIdByItem(item);
|
||||
assert(obj_idx >= 0);
|
||||
auto object = wxGetApp().model().objects[obj_idx];
|
||||
if (type == itObject) {
|
||||
is_object_settings = true;
|
||||
plate_configs.emplace(ppl.get_plate(plate_id), &cfg);
|
||||
object_configs.emplace(object, &object->config);
|
||||
}
|
||||
else if(type == itVolume){
|
||||
is_volume_settings = true;
|
||||
if (parent_object && parent_object != object)
|
||||
return false;
|
||||
plate_configs.emplace(ppl.get_plate(plate_id), &cfg);
|
||||
parent_object = object;
|
||||
const int vol_idx = objects_model->GetVolumeIdByItem(item);
|
||||
assert(vol_idx >= 0);
|
||||
|
|
@ -249,6 +249,7 @@ bool ObjectSettings::update_settings_list()
|
|||
is_layer_range_settings = true;
|
||||
if (parent_object && parent_object != object)
|
||||
return false;
|
||||
plate_configs.emplace(ppl.get_plate(plate_id), &cfg);
|
||||
parent_object = object;
|
||||
|
||||
t_layer_height_range height_range = objects_model->GetLayerRangeByItem(item);
|
||||
|
|
@ -265,38 +266,38 @@ bool ObjectSettings::update_settings_list()
|
|||
auto tab_layer = dynamic_cast<TabPrintModel*>(wxGetApp().get_layer_tab());
|
||||
|
||||
if (is_plate_settings) {
|
||||
tab_plate->set_model_config(plate_configs);
|
||||
tab_object->set_model_config({});
|
||||
tab_volume->set_model_config({});
|
||||
tab_layer->set_model_config({});
|
||||
tab_plate->set_model_config(plate_configs);
|
||||
;// m_tab_active = tab_plate;
|
||||
}
|
||||
else if (is_object_settings) {
|
||||
tab_plate->set_model_config(plate_configs);
|
||||
tab_object->set_model_config(object_configs);
|
||||
tab_volume->set_model_config({});
|
||||
tab_layer->set_model_config({});
|
||||
tab_plate->set_model_config({});
|
||||
//m_tab_active = tab_object;
|
||||
}
|
||||
else if (is_volume_settings) {
|
||||
tab_plate->set_model_config(plate_configs);
|
||||
tab_object->set_model_config({ {parent_object, &parent_object->config} });
|
||||
tab_volume->set_model_config(object_configs);
|
||||
tab_layer->set_model_config({});
|
||||
tab_plate->set_model_config({});
|
||||
//m_tab_active = tab_volume;
|
||||
}
|
||||
else if (is_layer_range_settings) {
|
||||
tab_plate->set_model_config(plate_configs);
|
||||
tab_object->set_model_config({ {parent_object, &parent_object->config} });
|
||||
tab_volume->set_model_config({});
|
||||
tab_layer->set_model_config(object_configs);
|
||||
tab_plate->set_model_config({});
|
||||
//m_tab_active = tab_layer;
|
||||
}
|
||||
else {
|
||||
tab_plate->set_model_config({});
|
||||
tab_object->set_model_config({});
|
||||
tab_volume->set_model_config({});
|
||||
tab_layer->set_model_config({});
|
||||
tab_plate->set_model_config({});
|
||||
//m_tab_active = nullptr;
|
||||
}
|
||||
((ParamsPanel*) tab_object->GetParent())->set_active_tab(nullptr);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue
