meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7020__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. meerk40t/__init__.py +1 -1
  2. meerk40t/balormk/balor_params.py +167 -167
  3. meerk40t/balormk/clone_loader.py +457 -457
  4. meerk40t/balormk/controller.py +1566 -1512
  5. meerk40t/balormk/cylindermod.py +64 -0
  6. meerk40t/balormk/device.py +966 -1959
  7. meerk40t/balormk/driver.py +778 -591
  8. meerk40t/balormk/galvo_commands.py +1194 -0
  9. meerk40t/balormk/gui/balorconfig.py +237 -111
  10. meerk40t/balormk/gui/balorcontroller.py +191 -184
  11. meerk40t/balormk/gui/baloroperationproperties.py +116 -115
  12. meerk40t/balormk/gui/corscene.py +845 -0
  13. meerk40t/balormk/gui/gui.py +179 -147
  14. meerk40t/balormk/livelightjob.py +466 -382
  15. meerk40t/balormk/mock_connection.py +131 -109
  16. meerk40t/balormk/plugin.py +133 -135
  17. meerk40t/balormk/usb_connection.py +306 -301
  18. meerk40t/camera/__init__.py +1 -1
  19. meerk40t/camera/camera.py +514 -397
  20. meerk40t/camera/gui/camerapanel.py +1241 -1095
  21. meerk40t/camera/gui/gui.py +58 -58
  22. meerk40t/camera/plugin.py +441 -399
  23. meerk40t/ch341/__init__.py +27 -27
  24. meerk40t/ch341/ch341device.py +628 -628
  25. meerk40t/ch341/libusb.py +595 -589
  26. meerk40t/ch341/mock.py +171 -171
  27. meerk40t/ch341/windriver.py +157 -157
  28. meerk40t/constants.py +13 -0
  29. meerk40t/core/__init__.py +1 -1
  30. meerk40t/core/bindalias.py +550 -539
  31. meerk40t/core/core.py +47 -47
  32. meerk40t/core/cutcode/cubiccut.py +73 -73
  33. meerk40t/core/cutcode/cutcode.py +315 -312
  34. meerk40t/core/cutcode/cutgroup.py +141 -137
  35. meerk40t/core/cutcode/cutobject.py +192 -185
  36. meerk40t/core/cutcode/dwellcut.py +37 -37
  37. meerk40t/core/cutcode/gotocut.py +29 -29
  38. meerk40t/core/cutcode/homecut.py +29 -29
  39. meerk40t/core/cutcode/inputcut.py +34 -34
  40. meerk40t/core/cutcode/linecut.py +33 -33
  41. meerk40t/core/cutcode/outputcut.py +34 -34
  42. meerk40t/core/cutcode/plotcut.py +335 -335
  43. meerk40t/core/cutcode/quadcut.py +61 -61
  44. meerk40t/core/cutcode/rastercut.py +168 -148
  45. meerk40t/core/cutcode/waitcut.py +34 -34
  46. meerk40t/core/cutplan.py +1843 -1316
  47. meerk40t/core/drivers.py +330 -329
  48. meerk40t/core/elements/align.py +801 -669
  49. meerk40t/core/elements/branches.py +1858 -1507
  50. meerk40t/core/elements/clipboard.py +229 -219
  51. meerk40t/core/elements/element_treeops.py +4595 -2837
  52. meerk40t/core/elements/element_types.py +125 -105
  53. meerk40t/core/elements/elements.py +4315 -3617
  54. meerk40t/core/elements/files.py +117 -64
  55. meerk40t/core/elements/geometry.py +473 -224
  56. meerk40t/core/elements/grid.py +467 -316
  57. meerk40t/core/elements/materials.py +158 -94
  58. meerk40t/core/elements/notes.py +50 -38
  59. meerk40t/core/elements/offset_clpr.py +934 -912
  60. meerk40t/core/elements/offset_mk.py +963 -955
  61. meerk40t/core/elements/penbox.py +339 -267
  62. meerk40t/core/elements/placements.py +300 -83
  63. meerk40t/core/elements/render.py +785 -687
  64. meerk40t/core/elements/shapes.py +2618 -2092
  65. meerk40t/core/elements/testcases.py +105 -0
  66. meerk40t/core/elements/trace.py +651 -563
  67. meerk40t/core/elements/tree_commands.py +415 -409
  68. meerk40t/core/elements/undo_redo.py +116 -58
  69. meerk40t/core/elements/wordlist.py +319 -200
  70. meerk40t/core/exceptions.py +9 -9
  71. meerk40t/core/laserjob.py +220 -220
  72. meerk40t/core/logging.py +63 -63
  73. meerk40t/core/node/blobnode.py +83 -86
  74. meerk40t/core/node/bootstrap.py +105 -103
  75. meerk40t/core/node/branch_elems.py +40 -31
  76. meerk40t/core/node/branch_ops.py +45 -38
  77. meerk40t/core/node/branch_regmark.py +48 -41
  78. meerk40t/core/node/cutnode.py +29 -32
  79. meerk40t/core/node/effect_hatch.py +375 -257
  80. meerk40t/core/node/effect_warp.py +398 -0
  81. meerk40t/core/node/effect_wobble.py +441 -309
  82. meerk40t/core/node/elem_ellipse.py +404 -309
  83. meerk40t/core/node/elem_image.py +1082 -801
  84. meerk40t/core/node/elem_line.py +358 -292
  85. meerk40t/core/node/elem_path.py +259 -201
  86. meerk40t/core/node/elem_point.py +129 -102
  87. meerk40t/core/node/elem_polyline.py +310 -246
  88. meerk40t/core/node/elem_rect.py +376 -286
  89. meerk40t/core/node/elem_text.py +445 -418
  90. meerk40t/core/node/filenode.py +59 -40
  91. meerk40t/core/node/groupnode.py +138 -74
  92. meerk40t/core/node/image_processed.py +777 -766
  93. meerk40t/core/node/image_raster.py +156 -113
  94. meerk40t/core/node/layernode.py +31 -31
  95. meerk40t/core/node/mixins.py +135 -107
  96. meerk40t/core/node/node.py +1427 -1304
  97. meerk40t/core/node/nutils.py +117 -114
  98. meerk40t/core/node/op_cut.py +463 -335
  99. meerk40t/core/node/op_dots.py +296 -251
  100. meerk40t/core/node/op_engrave.py +414 -311
  101. meerk40t/core/node/op_image.py +755 -369
  102. meerk40t/core/node/op_raster.py +787 -522
  103. meerk40t/core/node/place_current.py +37 -40
  104. meerk40t/core/node/place_point.py +329 -126
  105. meerk40t/core/node/refnode.py +58 -47
  106. meerk40t/core/node/rootnode.py +225 -219
  107. meerk40t/core/node/util_console.py +48 -48
  108. meerk40t/core/node/util_goto.py +84 -65
  109. meerk40t/core/node/util_home.py +61 -61
  110. meerk40t/core/node/util_input.py +102 -102
  111. meerk40t/core/node/util_output.py +102 -102
  112. meerk40t/core/node/util_wait.py +65 -65
  113. meerk40t/core/parameters.py +709 -707
  114. meerk40t/core/planner.py +875 -785
  115. meerk40t/core/plotplanner.py +656 -652
  116. meerk40t/core/space.py +120 -113
  117. meerk40t/core/spoolers.py +706 -705
  118. meerk40t/core/svg_io.py +1836 -1549
  119. meerk40t/core/treeop.py +534 -445
  120. meerk40t/core/undos.py +278 -124
  121. meerk40t/core/units.py +784 -680
  122. meerk40t/core/view.py +393 -322
  123. meerk40t/core/webhelp.py +62 -62
  124. meerk40t/core/wordlist.py +513 -504
  125. meerk40t/cylinder/cylinder.py +247 -0
  126. meerk40t/cylinder/gui/cylindersettings.py +41 -0
  127. meerk40t/cylinder/gui/gui.py +24 -0
  128. meerk40t/device/__init__.py +1 -1
  129. meerk40t/device/basedevice.py +322 -123
  130. meerk40t/device/devicechoices.py +50 -0
  131. meerk40t/device/dummydevice.py +163 -128
  132. meerk40t/device/gui/defaultactions.py +618 -602
  133. meerk40t/device/gui/effectspanel.py +114 -0
  134. meerk40t/device/gui/formatterpanel.py +253 -290
  135. meerk40t/device/gui/warningpanel.py +337 -260
  136. meerk40t/device/mixins.py +13 -13
  137. meerk40t/dxf/__init__.py +1 -1
  138. meerk40t/dxf/dxf_io.py +766 -554
  139. meerk40t/dxf/plugin.py +47 -35
  140. meerk40t/external_plugins.py +79 -79
  141. meerk40t/external_plugins_build.py +28 -28
  142. meerk40t/extra/cag.py +112 -116
  143. meerk40t/extra/coolant.py +403 -0
  144. meerk40t/extra/encode_detect.py +204 -0
  145. meerk40t/extra/ezd.py +1165 -1165
  146. meerk40t/extra/hershey.py +834 -340
  147. meerk40t/extra/imageactions.py +322 -316
  148. meerk40t/extra/inkscape.py +628 -622
  149. meerk40t/extra/lbrn.py +424 -424
  150. meerk40t/extra/outerworld.py +283 -0
  151. meerk40t/extra/param_functions.py +1542 -1556
  152. meerk40t/extra/potrace.py +257 -253
  153. meerk40t/extra/serial_exchange.py +118 -0
  154. meerk40t/extra/updater.py +602 -453
  155. meerk40t/extra/vectrace.py +147 -146
  156. meerk40t/extra/winsleep.py +83 -83
  157. meerk40t/extra/xcs_reader.py +597 -0
  158. meerk40t/fill/fills.py +781 -335
  159. meerk40t/fill/patternfill.py +1061 -1061
  160. meerk40t/fill/patterns.py +614 -567
  161. meerk40t/grbl/control.py +87 -87
  162. meerk40t/grbl/controller.py +990 -903
  163. meerk40t/grbl/device.py +1084 -768
  164. meerk40t/grbl/driver.py +989 -771
  165. meerk40t/grbl/emulator.py +532 -497
  166. meerk40t/grbl/gcodejob.py +783 -767
  167. meerk40t/grbl/gui/grblconfiguration.py +373 -298
  168. meerk40t/grbl/gui/grblcontroller.py +485 -271
  169. meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
  170. meerk40t/grbl/gui/grbloperationconfig.py +105 -0
  171. meerk40t/grbl/gui/gui.py +147 -116
  172. meerk40t/grbl/interpreter.py +44 -44
  173. meerk40t/grbl/loader.py +22 -22
  174. meerk40t/grbl/mock_connection.py +56 -56
  175. meerk40t/grbl/plugin.py +294 -264
  176. meerk40t/grbl/serial_connection.py +93 -88
  177. meerk40t/grbl/tcp_connection.py +81 -79
  178. meerk40t/grbl/ws_connection.py +112 -0
  179. meerk40t/gui/__init__.py +1 -1
  180. meerk40t/gui/about.py +2042 -296
  181. meerk40t/gui/alignment.py +1644 -1608
  182. meerk40t/gui/autoexec.py +199 -0
  183. meerk40t/gui/basicops.py +791 -670
  184. meerk40t/gui/bufferview.py +77 -71
  185. meerk40t/gui/busy.py +232 -133
  186. meerk40t/gui/choicepropertypanel.py +1662 -1469
  187. meerk40t/gui/consolepanel.py +706 -542
  188. meerk40t/gui/devicepanel.py +687 -581
  189. meerk40t/gui/dialogoptions.py +110 -107
  190. meerk40t/gui/executejob.py +316 -306
  191. meerk40t/gui/fonts.py +90 -90
  192. meerk40t/gui/functionwrapper.py +252 -0
  193. meerk40t/gui/gui_mixins.py +729 -0
  194. meerk40t/gui/guicolors.py +205 -182
  195. meerk40t/gui/help_assets/help_assets.py +218 -201
  196. meerk40t/gui/helper.py +154 -0
  197. meerk40t/gui/hersheymanager.py +1440 -846
  198. meerk40t/gui/icons.py +3422 -2747
  199. meerk40t/gui/imagesplitter.py +555 -508
  200. meerk40t/gui/keymap.py +354 -344
  201. meerk40t/gui/laserpanel.py +897 -806
  202. meerk40t/gui/laserrender.py +1470 -1232
  203. meerk40t/gui/lasertoolpanel.py +805 -793
  204. meerk40t/gui/magnetoptions.py +436 -0
  205. meerk40t/gui/materialmanager.py +2944 -0
  206. meerk40t/gui/materialtest.py +1722 -1694
  207. meerk40t/gui/mkdebug.py +646 -359
  208. meerk40t/gui/mwindow.py +163 -140
  209. meerk40t/gui/navigationpanels.py +2605 -2467
  210. meerk40t/gui/notes.py +143 -142
  211. meerk40t/gui/opassignment.py +414 -410
  212. meerk40t/gui/operation_info.py +310 -299
  213. meerk40t/gui/plugin.py +500 -328
  214. meerk40t/gui/position.py +714 -669
  215. meerk40t/gui/preferences.py +901 -650
  216. meerk40t/gui/propertypanels/attributes.py +1461 -1131
  217. meerk40t/gui/propertypanels/blobproperty.py +117 -114
  218. meerk40t/gui/propertypanels/consoleproperty.py +83 -80
  219. meerk40t/gui/propertypanels/gotoproperty.py +77 -0
  220. meerk40t/gui/propertypanels/groupproperties.py +223 -217
  221. meerk40t/gui/propertypanels/hatchproperty.py +489 -469
  222. meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
  223. meerk40t/gui/propertypanels/inputproperty.py +59 -58
  224. meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
  225. meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
  226. meerk40t/gui/propertypanels/outputproperty.py +59 -58
  227. meerk40t/gui/propertypanels/pathproperty.py +389 -380
  228. meerk40t/gui/propertypanels/placementproperty.py +1214 -383
  229. meerk40t/gui/propertypanels/pointproperty.py +140 -136
  230. meerk40t/gui/propertypanels/propertywindow.py +313 -181
  231. meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
  232. meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
  233. meerk40t/gui/propertypanels/textproperty.py +770 -755
  234. meerk40t/gui/propertypanels/waitproperty.py +56 -55
  235. meerk40t/gui/propertypanels/warpproperty.py +121 -0
  236. meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
  237. meerk40t/gui/ribbon.py +2471 -2210
  238. meerk40t/gui/scene/scene.py +1100 -1051
  239. meerk40t/gui/scene/sceneconst.py +22 -22
  240. meerk40t/gui/scene/scenepanel.py +439 -349
  241. meerk40t/gui/scene/scenespacewidget.py +365 -365
  242. meerk40t/gui/scene/widget.py +518 -505
  243. meerk40t/gui/scenewidgets/affinemover.py +215 -215
  244. meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
  245. meerk40t/gui/scenewidgets/bedwidget.py +120 -97
  246. meerk40t/gui/scenewidgets/elementswidget.py +137 -107
  247. meerk40t/gui/scenewidgets/gridwidget.py +785 -745
  248. meerk40t/gui/scenewidgets/guidewidget.py +765 -765
  249. meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
  250. meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
  251. meerk40t/gui/scenewidgets/nodeselector.py +28 -28
  252. meerk40t/gui/scenewidgets/rectselectwidget.py +592 -346
  253. meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
  254. meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
  255. meerk40t/gui/scenewidgets/selectionwidget.py +2958 -2756
  256. meerk40t/gui/simpleui.py +362 -333
  257. meerk40t/gui/simulation.py +2451 -2094
  258. meerk40t/gui/snapoptions.py +208 -203
  259. meerk40t/gui/spoolerpanel.py +1227 -1180
  260. meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
  261. meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
  262. meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
  263. meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
  264. meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
  265. meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
  266. meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
  267. meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
  268. meerk40t/gui/themes.py +200 -78
  269. meerk40t/gui/tips.py +590 -0
  270. meerk40t/gui/toolwidgets/circlebrush.py +35 -35
  271. meerk40t/gui/toolwidgets/toolcircle.py +248 -242
  272. meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
  273. meerk40t/gui/toolwidgets/tooldraw.py +97 -90
  274. meerk40t/gui/toolwidgets/toolellipse.py +219 -212
  275. meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
  276. meerk40t/gui/toolwidgets/toolline.py +39 -144
  277. meerk40t/gui/toolwidgets/toollinetext.py +79 -236
  278. meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
  279. meerk40t/gui/toolwidgets/toolmeasure.py +163 -216
  280. meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
  281. meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
  282. meerk40t/gui/toolwidgets/toolparameter.py +754 -668
  283. meerk40t/gui/toolwidgets/toolplacement.py +108 -108
  284. meerk40t/gui/toolwidgets/toolpoint.py +68 -59
  285. meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
  286. meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
  287. meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
  288. meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
  289. meerk40t/gui/toolwidgets/toolrect.py +211 -207
  290. meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
  291. meerk40t/gui/toolwidgets/toolribbon.py +598 -113
  292. meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
  293. meerk40t/gui/toolwidgets/tooltext.py +98 -89
  294. meerk40t/gui/toolwidgets/toolvector.py +213 -204
  295. meerk40t/gui/toolwidgets/toolwidget.py +39 -39
  296. meerk40t/gui/usbconnect.py +98 -91
  297. meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
  298. meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
  299. meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
  300. meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
  301. meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
  302. meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
  303. meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
  304. meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
  305. meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
  306. meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
  307. meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
  308. meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
  309. meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
  310. meerk40t/gui/wordlisteditor.py +985 -931
  311. meerk40t/gui/wxmeerk40t.py +1447 -1169
  312. meerk40t/gui/wxmmain.py +5644 -4112
  313. meerk40t/gui/wxmribbon.py +1591 -1076
  314. meerk40t/gui/wxmscene.py +1631 -1453
  315. meerk40t/gui/wxmtree.py +2416 -2089
  316. meerk40t/gui/wxutils.py +1769 -1099
  317. meerk40t/gui/zmatrix.py +102 -102
  318. meerk40t/image/__init__.py +1 -1
  319. meerk40t/image/dither.py +429 -0
  320. meerk40t/image/imagetools.py +2793 -2269
  321. meerk40t/internal_plugins.py +150 -130
  322. meerk40t/kernel/__init__.py +63 -12
  323. meerk40t/kernel/channel.py +259 -212
  324. meerk40t/kernel/context.py +538 -538
  325. meerk40t/kernel/exceptions.py +41 -41
  326. meerk40t/kernel/functions.py +463 -414
  327. meerk40t/kernel/jobs.py +100 -100
  328. meerk40t/kernel/kernel.py +3828 -3571
  329. meerk40t/kernel/lifecycles.py +71 -71
  330. meerk40t/kernel/module.py +49 -49
  331. meerk40t/kernel/service.py +147 -147
  332. meerk40t/kernel/settings.py +383 -343
  333. meerk40t/lihuiyu/controller.py +883 -876
  334. meerk40t/lihuiyu/device.py +1181 -1069
  335. meerk40t/lihuiyu/driver.py +1466 -1372
  336. meerk40t/lihuiyu/gui/gui.py +127 -106
  337. meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
  338. meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
  339. meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
  340. meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
  341. meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
  342. meerk40t/lihuiyu/interpreter.py +53 -53
  343. meerk40t/lihuiyu/laserspeed.py +450 -450
  344. meerk40t/lihuiyu/loader.py +90 -90
  345. meerk40t/lihuiyu/parser.py +404 -404
  346. meerk40t/lihuiyu/plugin.py +101 -102
  347. meerk40t/lihuiyu/tcp_connection.py +111 -109
  348. meerk40t/main.py +231 -165
  349. meerk40t/moshi/builder.py +788 -781
  350. meerk40t/moshi/controller.py +505 -499
  351. meerk40t/moshi/device.py +495 -442
  352. meerk40t/moshi/driver.py +862 -696
  353. meerk40t/moshi/gui/gui.py +78 -76
  354. meerk40t/moshi/gui/moshicontrollergui.py +538 -522
  355. meerk40t/moshi/gui/moshidrivergui.py +87 -75
  356. meerk40t/moshi/plugin.py +43 -43
  357. meerk40t/network/console_server.py +140 -57
  358. meerk40t/network/kernelserver.py +10 -9
  359. meerk40t/network/tcp_server.py +142 -140
  360. meerk40t/network/udp_server.py +103 -77
  361. meerk40t/network/web_server.py +404 -0
  362. meerk40t/newly/controller.py +1158 -1144
  363. meerk40t/newly/device.py +874 -732
  364. meerk40t/newly/driver.py +540 -412
  365. meerk40t/newly/gui/gui.py +219 -188
  366. meerk40t/newly/gui/newlyconfig.py +116 -101
  367. meerk40t/newly/gui/newlycontroller.py +193 -186
  368. meerk40t/newly/gui/operationproperties.py +51 -51
  369. meerk40t/newly/mock_connection.py +82 -82
  370. meerk40t/newly/newly_params.py +56 -56
  371. meerk40t/newly/plugin.py +1214 -1246
  372. meerk40t/newly/usb_connection.py +322 -322
  373. meerk40t/rotary/gui/gui.py +52 -46
  374. meerk40t/rotary/gui/rotarysettings.py +240 -232
  375. meerk40t/rotary/rotary.py +202 -98
  376. meerk40t/ruida/control.py +291 -91
  377. meerk40t/ruida/controller.py +138 -1088
  378. meerk40t/ruida/device.py +676 -231
  379. meerk40t/ruida/driver.py +534 -472
  380. meerk40t/ruida/emulator.py +1494 -1491
  381. meerk40t/ruida/exceptions.py +4 -4
  382. meerk40t/ruida/gui/gui.py +71 -76
  383. meerk40t/ruida/gui/ruidaconfig.py +239 -72
  384. meerk40t/ruida/gui/ruidacontroller.py +187 -184
  385. meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
  386. meerk40t/ruida/loader.py +54 -52
  387. meerk40t/ruida/mock_connection.py +57 -109
  388. meerk40t/ruida/plugin.py +124 -87
  389. meerk40t/ruida/rdjob.py +2084 -945
  390. meerk40t/ruida/serial_connection.py +116 -0
  391. meerk40t/ruida/tcp_connection.py +146 -0
  392. meerk40t/ruida/udp_connection.py +73 -0
  393. meerk40t/svgelements.py +9671 -9669
  394. meerk40t/tools/driver_to_path.py +584 -579
  395. meerk40t/tools/geomstr.py +5583 -4680
  396. meerk40t/tools/jhfparser.py +357 -292
  397. meerk40t/tools/kerftest.py +904 -890
  398. meerk40t/tools/livinghinges.py +1168 -1033
  399. meerk40t/tools/pathtools.py +987 -949
  400. meerk40t/tools/pmatrix.py +234 -0
  401. meerk40t/tools/pointfinder.py +942 -942
  402. meerk40t/tools/polybool.py +941 -940
  403. meerk40t/tools/rasterplotter.py +1660 -547
  404. meerk40t/tools/shxparser.py +1047 -901
  405. meerk40t/tools/ttfparser.py +726 -446
  406. meerk40t/tools/zinglplotter.py +595 -593
  407. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/LICENSE +21 -21
  408. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/METADATA +150 -139
  409. meerk40t-0.9.7020.dist-info/RECORD +446 -0
  410. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/WHEEL +1 -1
  411. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/top_level.txt +0 -1
  412. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/zip-safe +1 -1
  413. meerk40t/balormk/elementlightjob.py +0 -159
  414. meerk40t-0.9.3001.dist-info/RECORD +0 -437
  415. test/bootstrap.py +0 -63
  416. test/test_cli.py +0 -12
  417. test/test_core_cutcode.py +0 -418
  418. test/test_core_elements.py +0 -144
  419. test/test_core_plotplanner.py +0 -397
  420. test/test_core_viewports.py +0 -312
  421. test/test_drivers_grbl.py +0 -108
  422. test/test_drivers_lihuiyu.py +0 -443
  423. test/test_drivers_newly.py +0 -113
  424. test/test_element_degenerate_points.py +0 -43
  425. test/test_elements_classify.py +0 -97
  426. test/test_elements_penbox.py +0 -22
  427. test/test_file_svg.py +0 -176
  428. test/test_fill.py +0 -155
  429. test/test_geomstr.py +0 -1523
  430. test/test_geomstr_nodes.py +0 -18
  431. test/test_imagetools_actualize.py +0 -306
  432. test/test_imagetools_wizard.py +0 -258
  433. test/test_kernel.py +0 -200
  434. test/test_laser_speeds.py +0 -3303
  435. test/test_length.py +0 -57
  436. test/test_lifecycle.py +0 -66
  437. test/test_operations.py +0 -251
  438. test/test_operations_hatch.py +0 -57
  439. test/test_ruida.py +0 -19
  440. test/test_spooler.py +0 -22
  441. test/test_tools_rasterplotter.py +0 -29
  442. test/test_wobble.py +0 -133
  443. test/test_zingl.py +0 -124
  444. {test → meerk40t/cylinder}/__init__.py +0 -0
  445. /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
  446. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/entry_points.txt +0 -0
@@ -1,622 +1,628 @@
1
- import gzip
2
- import os.path
3
- import platform
4
- from subprocess import PIPE, TimeoutExpired, run
5
- from time import time
6
-
7
- from meerk40t.core.exceptions import BadFileError
8
- from meerk40t.kernel.kernel import get_safe_path
9
-
10
-
11
- def get_inkscape(context, manual_candidate=None):
12
- root_context = context
13
- root_context.setting(str, "inkscape_path", "inkscape.exe")
14
- inkscape = ""
15
- try:
16
- inkscape = root_context.inkscape_path
17
- except AttributeError:
18
- inkscape = ""
19
- system = platform.system()
20
- if system == "Darwin":
21
- candidates = [
22
- "/Applications/Inkscape.app/Contents/MacOS/Inkscape",
23
- "/Applications/Inkscape.app/Contents/Resources/bin/inkscape",
24
- ]
25
- elif system == "Windows":
26
- candidates = [
27
- "C:/Program Files (x86)/Inkscape/inkscape.exe",
28
- "C:/Program Files (x86)/Inkscape/bin/inkscape.exe",
29
- "C:/Program Files/Inkscape/inkscape.exe",
30
- "C:/Program Files/Inkscape/bin/inkscape.exe",
31
- "C:/inkscape/bin/inkscape.exe",
32
- ]
33
- elif system == "Linux":
34
- candidates = [
35
- "/usr/local/bin/inkscape",
36
- "/usr/bin/inkscape",
37
- ]
38
- else:
39
- candidates = []
40
- if inkscape and inkscape not in candidates:
41
- candidates.insert(0, inkscape)
42
- if manual_candidate and manual_candidate not in candidates:
43
- candidates.insert(0, manual_candidate)
44
- match = None
45
- for ink in candidates:
46
- if os.path.exists(ink):
47
- match = ink
48
- root_context.inkscape_path = match
49
- break
50
- if match is None:
51
- inkscape = ""
52
- return inkscape
53
-
54
-
55
- def run_command_and_log(command_array, logfile):
56
- f = None
57
- timeout_value = None
58
- try:
59
- f = open(logfile, "w")
60
- except:
61
- # Any error...
62
- f = None
63
- if f:
64
- for idx, param in enumerate(command_array):
65
- if idx == 0:
66
- f.write(f"Executing: {param}\n")
67
- f.write("Parameters:\n")
68
- else:
69
- f.write(f"{param}\n")
70
- result = False
71
- c = None
72
- try:
73
- start_time = time()
74
- c = run(command_array, timeout=timeout_value, stdout=PIPE)
75
- end_time = time()
76
- if f:
77
- f.write(
78
- f"Executed successfully, result: {c.returncode} (execution time: {end_time-start_time:.1f} sec)\n"
79
- )
80
- f.write("Output:\n")
81
- try:
82
- f.write(c.stdout.decode("utf-8", errors="surrogateescape"))
83
- except UnicodeDecodeError:
84
- pass
85
- result = True
86
- except (FileNotFoundError, TimeoutExpired, UnicodeDecodeError, OSError) as e:
87
- if f:
88
- f.write(f"Execution failed: {str(e)}\n")
89
- if f:
90
- f.close()
91
- return result, c
92
-
93
-
94
- class MultiLoader:
95
- """
96
- This module makes use of inkscape to convert a multitude of format into svg :
97
- """
98
-
99
- @staticmethod
100
- def load_types():
101
- yield "Inkscape supported files", (
102
- "pdf",
103
- "pdxf",
104
- "eps",
105
- "cdr",
106
- "cmx",
107
- "ccx",
108
- "cdt",
109
- "wmf",
110
- "vsd",
111
- "ai",
112
- ), "image/svg+xml"
113
- # yield "Portable Document Format files", ("pdf", "pdxf", "eps"), "image/svg+xml"
114
- # yield "Corel Draw files", ("cdr", "cmx", "ccx", "cdt"), "image/svg+xml"
115
- # yield "Windows Metafile files", ("wmf",), "image/svg+xml"
116
- # yield "Visio files", ("vsd",), "image/svg+xml"
117
- # yield "Adobe Illustrator files", ("ai",), "image/svg+xml"
118
-
119
- @staticmethod
120
- def load(kernel_service, elements_service, pathname, **kwargs):
121
- """
122
- Load content by means of inkscapes ability to convert
123
- multiple vector formats into svg.
124
- Requires the installation of inkscape on your system.
125
- """
126
- # Elemental calls this routine claiming it would be the kernel...
127
- if hasattr(kernel_service, "kernel"):
128
- kernel = kernel_service.kernel
129
- else:
130
- kernel = kernel_service
131
- _ = kernel.translation
132
- safe_dir = os.path.realpath(get_safe_path(kernel.name))
133
-
134
- # Establish the standard svg-handler first
135
- handler = None
136
- for loader, loader_name, sname in kernel.find("load"):
137
- for description, extensions, mimetype in loader.load_types():
138
- if "svg" in extensions:
139
- handler = loader
140
- break
141
-
142
- context_root = kernel.root
143
- safe_dir = os.path.realpath(get_safe_path(kernel.name))
144
- logfile = os.path.join(safe_dir, "inkscape.log")
145
- timeout_value = None
146
-
147
- inkscape = get_inkscape(context_root)
148
- if not inkscape:
149
- raise BadFileError("Inkscape not found")
150
-
151
- result, c = run_command_and_log([inkscape, "-V"], logfile)
152
- if not result:
153
- return pathname
154
- try:
155
- version = c.stdout.decode("utf-8", errors="surrogateescape")
156
- except UnicodeDecodeError:
157
- version = "inkscape 1.x"
158
-
159
- svg_temp_file = os.path.join(safe_dir, "inkscape.svg")
160
- logfile = os.path.join(safe_dir, "inkscape.log")
161
-
162
- # Check Version of Inkscape
163
- if "inkscape 1." in version.lower():
164
- cmd = [
165
- inkscape,
166
- "--export-plain-svg",
167
- f"--export-filename={svg_temp_file}",
168
- pathname,
169
- ]
170
- else:
171
- cmd = [
172
- inkscape,
173
- "--export-plain-svg",
174
- svg_temp_file,
175
- pathname,
176
- ]
177
- was_shown = kernel.busyinfo.shown
178
- if was_shown:
179
- kernel.busyinfo.change(msg=_("Calling inkscape..."))
180
- kernel.busyinfo.show()
181
-
182
- result, c = run_command_and_log(cmd, logfile)
183
- if not result or c.returncode == 1:
184
- return False
185
-
186
- def unescaped(filename):
187
- OS_NAME = platform.system()
188
- if OS_NAME == "Windows":
189
- newstring = filename.replace("&", "&&")
190
- else:
191
- newstring = filename.replace("&", "&&")
192
- return newstring
193
-
194
- if was_shown:
195
- kernel.busyinfo.change(
196
- msg=_("Loading File...") + "\n" + unescaped(svg_temp_file)
197
- )
198
- kernel.busyinfo.show()
199
- filename_to_process = svg_temp_file
200
- preproc = elements_service.lookup("preprocessor/.svg")
201
- if preproc is not None:
202
- filename_to_process = preproc(filename_to_process)
203
- results = handler.load(elements_service, elements_service, filename_to_process)
204
- return results
205
-
206
-
207
- def plugin(kernel, lifecycle):
208
- if lifecycle == "register":
209
- _ = kernel.translation
210
-
211
- @kernel.console_command(
212
- "load",
213
- help=_("inkscape ... load - load the previous conversion"),
214
- input_type="inkscape",
215
- output_type="inkscape",
216
- )
217
- def inscape_load(channel, _, data=None, **kwargs):
218
- inkscape_path, filename = data
219
- channel(_("inkscape load - loading the previous conversion..."))
220
- try:
221
- kernel.elements.load(filename)
222
- except BadFileError as e:
223
- channel(_("File is Malformed."))
224
- channel(str(e))
225
- else:
226
- kernel.elements.classify(list(kernel.elements.elems()))
227
- return "inkscape", data
228
-
229
- @kernel.console_command(
230
- "simplify",
231
- help=_("inkscape simplify - convert to plain svg"),
232
- input_type="inkscape",
233
- output_type="inkscape",
234
- )
235
- def inkscape_simplify(channel, _, data=None, **kwargs):
236
- inkscape_path, filename = data
237
- if not os.path.exists(inkscape_path):
238
- channel(_("Inkscape not found. Try 'inkscape locate'"))
239
- return
240
- channel(_("inkscape simplify - converting to plain svg"))
241
- c = run(
242
- [
243
- inkscape_path,
244
- "--export-plain-svg",
245
- "--export-filename=temp.svg",
246
- filename,
247
- ],
248
- stdout=PIPE,
249
- )
250
- channel(c.stdout)
251
- return "inkscape", (inkscape_path, "temp.svg")
252
-
253
- @kernel.console_command(
254
- "text2path",
255
- help=_("inkscape text2path - convert text objects to paths"),
256
- input_type="inkscape",
257
- output_type="inkscape",
258
- )
259
- def inkscape_text2path(channel, _, data=None, **kwargs):
260
- inkscape_path, filename = data
261
- if not os.path.exists(inkscape_path):
262
- channel(_("Inkscape not found. Try 'inkscape locate'"))
263
- return
264
- channel(_("inkscape text2path - converting text objects to paths"))
265
- c = run(
266
- [
267
- inkscape_path,
268
- "--export-area-drawing",
269
- "--export-text-to-path",
270
- "--export-plain-svg",
271
- "--export-filename=temp.svg",
272
- filename,
273
- ],
274
- stdout=PIPE,
275
- )
276
- channel(c.stdout)
277
- return "inkscape", (inkscape_path, "temp.svg")
278
-
279
- @kernel.console_option("dpi", "d", type=int, help=_("dpi to use"), default=1000)
280
- @kernel.console_option("step", "s", type=int, help=_("step to use"))
281
- @kernel.console_command(
282
- "makepng",
283
- help=_("inkscape makepng - make a png of all elements"),
284
- input_type="inkscape",
285
- output_type="inkscape",
286
- )
287
- def inkscape_png(channel, _, dpi=1000, step=None, data=None, **kwargs):
288
- if step is not None and step > 0:
289
- dpi = 1000 / step
290
- inkscape_path, filename = data
291
- if not os.path.exists(inkscape_path):
292
- channel(_("Inkscape not found. Try 'inkscape locate'"))
293
- return
294
- channel(_("inkscape makepng - making a png of all elements"))
295
- c = run(
296
- [
297
- inkscape_path,
298
- "--export-background",
299
- "white",
300
- "--export-background-opacity",
301
- "255",
302
- "--export-area-drawing",
303
- "--export-type=png",
304
- "--export-filename=temp.png",
305
- f"--export-dpi={dpi}",
306
- filename,
307
- ],
308
- stdout=PIPE,
309
- )
310
- channel(c.stdout)
311
- return "inkscape", (inkscape_path, "temp.png")
312
-
313
- @kernel.console_argument(
314
- "filename", type=str, help=_("filename of svg to be simplified")
315
- )
316
- @kernel.console_command(
317
- "input",
318
- help=_("input filename fn ... - provide the filename to process"),
319
- input_type="inkscape",
320
- output_type="inkscape",
321
- )
322
- def inkscape_input_filename(channel, _, filename, data, **kwargs):
323
- inkscape_path, fn = data
324
- if filename is None:
325
- channel(_("inkscape filename fn - filename not specified"))
326
- if not os.path.exists(filename):
327
- channel(
328
- _("inkscape filename {filename} - file not found").format(
329
- filename=filename
330
- )
331
- )
332
- return
333
- return "inkscape", (inkscape_path, filename)
334
-
335
- @kernel.console_command(
336
- "version",
337
- help=_("inkscape version - get the inkscape version"),
338
- input_type="inkscape",
339
- output_type="inkscape",
340
- )
341
- def inkscape_version(channel, _, data, **kwargs):
342
- inkscape_path, filename = data
343
- if not os.path.exists(inkscape_path):
344
- channel(_("Inkscape not found. Try 'inkscape locate'"))
345
- return
346
- c = run([inkscape_path, "-V"], stdout=PIPE)
347
- try:
348
- version = c.stdout.decode("utf-8", errors="surrogateescape")
349
- except UnicodeDecodeError:
350
- version = "unknown"
351
-
352
- channel(
353
- _('Inkscape executable at "{path}" is: {version}').format(
354
- path=inkscape_path, version=version
355
- )
356
- )
357
- return "inkscape", data
358
-
359
- @kernel.console_argument(
360
- "inkpath", type=str, help=_("Optional: location of inkscape executable")
361
- )
362
- @kernel.console_command(
363
- "locate",
364
- help=_("inkscape locate - set the path to inkscape on your computer"),
365
- input_type="inkscape",
366
- output_type="inkscape",
367
- )
368
- def inkscape_locate(channel, _, data, inkpath=None, **kwargs):
369
- inkscape_path, filename = data
370
- match = get_inkscape(kernel.root, inkpath)
371
- root_context = kernel.root
372
- root_context.setting(str, "inkscape_path", "inkscape.exe")
373
- if match:
374
- channel(_("Inkscape location: {match}").format(match=match))
375
- else:
376
- root_context.inkscape_path = "inkscape.exe"
377
- channel(
378
- _(
379
- "Inkscape location: Inkscape not found in default installation directories"
380
- )
381
- )
382
-
383
- return "inkscape", (match, filename)
384
-
385
- @kernel.console_command(
386
- "inkscape",
387
- help=_("invoke inkscape to convert elements"),
388
- output_type="inkscape",
389
- )
390
- def inkscape_base(**kwargs):
391
- root_context = kernel.root
392
- root_context.setting(str, "inkscape_path", "inkscape.exe")
393
- return "inkscape", (root_context.inkscape_path, None)
394
-
395
- def check_for_features(pathname, **kwargs):
396
- # We try to establish if a file contains certain features...
397
-
398
- source = pathname
399
- if not os.path.exists(source):
400
- return pathname
401
- if pathname.lower().endswith("svgz"):
402
- source = gzip.open(pathname, "rb")
403
- METHOD_CONVERT_TO_OBJECT = 1
404
- METHOD_CONVERT_TO_PNG = 2
405
- features = {
406
- "text": [False, ("<text",), METHOD_CONVERT_TO_OBJECT],
407
- "clipping": [False, ("<clippath",), METHOD_CONVERT_TO_PNG],
408
- "mask": [False, ("<mask",), METHOD_CONVERT_TO_PNG],
409
- "gradient": [
410
- False,
411
- ("<lineargradient", "<radialgradient"),
412
- METHOD_CONVERT_TO_PNG,
413
- ],
414
- "pattern": [False, ("<pattern",), METHOD_CONVERT_TO_PNG],
415
- }
416
- safe_dir = os.path.realpath(get_safe_path(kernel.name))
417
- svg_temp_file = os.path.join(safe_dir, "temp.svg")
418
- png_temp_file = os.path.join(safe_dir, "temp.png")
419
- needs_conversion = 0
420
- with open(source, mode="r", encoding="utf8", errors="surrogateescape") as f:
421
- while True:
422
- line = f.readline().lower()
423
- if not line:
424
- break
425
- for feat, entry in features.items():
426
- for candidate in entry[1]:
427
- if candidate in line:
428
- entry[0] = True
429
- if entry[2] > needs_conversion:
430
- needs_conversion = entry[2]
431
- context = kernel.root
432
- inkscape = get_inkscape(context)
433
- timeout_value = None
434
- if needs_conversion == 0:
435
- return pathname
436
- if len(inkscape) == 0:
437
- # Inkscape not found.
438
- return pathname
439
- # What is our preference? Load, convert, ask?
440
- conversion_preference = int(kernel.root.svg_not_supported)
441
- wasbusy = kernel.busyinfo.shown
442
-
443
- if conversion_preference == 1:
444
- # Ask
445
- msg = _(
446
- "This file contains certain features that might not be fully supported by MeerK40t"
447
- )
448
- for feat, entry in features.items():
449
- if entry[0]:
450
- msg += "\n" + f" - {feat}"
451
- if needs_conversion == METHOD_CONVERT_TO_PNG:
452
- msg += "\n" + _(
453
- "The complete design would be rendered into a single graphic."
454
- )
455
- elif needs_conversion == METHOD_CONVERT_TO_OBJECT:
456
- msg += "\n" + _(
457
- "Text elements would be converted into path objects."
458
- )
459
-
460
- msg += "\n" + _(
461
- "Do you want to convert the file via inkscape or do you want load the unmodified file?"
462
- )
463
- if wasbusy:
464
- kernel.busyinfo.hide()
465
- response = kernel.yesno(
466
- msg,
467
- option_yes=_("Convert"),
468
- option_no=_("Load original"),
469
- caption=_("SVG-Conversion"),
470
- )
471
- if response:
472
- # convert
473
- conversion_preference = 2
474
- else:
475
- # Load
476
- conversion_preference = 0
477
- # translate = ["load", "ask", "convert"]
478
- # print (f"Conversion preference: {translate[conversion_preference]} - {conversion_preference}")
479
- if wasbusy:
480
- kernel.busyinfo.show()
481
-
482
- if conversion_preference == 0:
483
- # Load
484
- return pathname
485
-
486
- if wasbusy:
487
- kernel.busyinfo.change(msg=_("Calling inkscape..."))
488
- kernel.busyinfo.show()
489
- log_file = os.path.join(safe_dir, "inkscape.log")
490
- result, c = run_command_and_log([inkscape, "-V"], log_file)
491
- if not result:
492
- return pathname
493
- version = None
494
- try:
495
- version = c.stdout.decode(encoding="utf-8", errors="surrogateescape")
496
- except UnicodeDecodeError:
497
- version = "inkscape 1.x"
498
-
499
- if needs_conversion == METHOD_CONVERT_TO_OBJECT:
500
- # Ask inkscape to convert all text elements to paths
501
- # slightly different invocation for different values
502
- # Check Version of Inkscape
503
- if "inkscape 1." in version.lower():
504
- cmd = [
505
- inkscape,
506
- "--export-text-to-path",
507
- "--export-plain-svg",
508
- f"--export-filename={svg_temp_file}",
509
- pathname,
510
- ]
511
- else:
512
- cmd = [
513
- inkscape,
514
- "--export-text-to-path",
515
- "--export-plain-svg",
516
- svg_temp_file,
517
- pathname,
518
- ]
519
- result, c = run_command_and_log(cmd, log_file)
520
- if result and c.returncode == 0:
521
- return svg_temp_file
522
-
523
- return pathname
524
-
525
- if needs_conversion == METHOD_CONVERT_TO_PNG:
526
- dpi = 500
527
- if "inkscape 1." in version.lower():
528
- cmd = [
529
- inkscape,
530
- "--export-background",
531
- "white",
532
- "--export-background-opacity",
533
- "255",
534
- "--export-area-drawing",
535
- "--export-type=png",
536
- f"--export-filename={png_temp_file}",
537
- f"--export-dpi={dpi}",
538
- pathname,
539
- ]
540
- else:
541
- cmd = [
542
- inkscape,
543
- "--export-area-drawing",
544
- "--export-dpi",
545
- str(dpi),
546
- "--export-background",
547
- "rgb(255, 255, 255)",
548
- "--export-background-opacity",
549
- "255",
550
- "--export-png",
551
- png_temp_file,
552
- pathname,
553
- ]
554
- result, c = run_command_and_log(cmd, log_file)
555
- if result and c.returncode == 0:
556
- return png_temp_file
557
-
558
- return pathname
559
-
560
- kernel.register("preprocessor/.svg", check_for_features)
561
- # Let's establish some settings too
562
- stip = (
563
- _("Meerk40t does not support all svg-features, so you might want")
564
- + "\n"
565
- + _("to preprocess the file to get a proper representation of the design.")
566
- + "\n"
567
- + _(
568
- " - Certain subvariants of Fonts - single element will be converted to a path"
569
- )
570
- + "\n"
571
- + _(
572
- " - Gradient fills / patterns - the whole design will be rendered into a graphic"
573
- )
574
- + "\n"
575
- + _(" - Clipping/Mask - the whole design will be rendered into a graphic")
576
- )
577
- system = platform.system()
578
- if system == "Darwin":
579
- wildcard = "Inkscape|(Inkscape;inkscape)|All files|*.*"
580
- elif system == "Windows":
581
- wildcard = "Inkscape|inkscape.exe|All files|*.*"
582
- elif system == "Linux":
583
- wildcard = "Inkscape|inkscape|All files|*.*"
584
- else:
585
- wildcard = "Inkscape|(Inkscape;inkscape)|All files|*.*"
586
-
587
- kernel.root.setting(str, "inkscape_path", "")
588
- choices = [
589
- {
590
- "attr": "inkscape_path",
591
- "object": kernel.root,
592
- "default": "",
593
- "type": str,
594
- "style": "file",
595
- "wildcard": wildcard,
596
- "label": _("Inkscape"),
597
- "tip": _(
598
- "Path to inkscape-executable. Leave empty to let Meerk40t establish standard locations"
599
- ),
600
- "page": "Input/Output",
601
- "section": "SVG-Features",
602
- },
603
- {
604
- "attr": "svg_not_supported",
605
- "object": kernel.root,
606
- "default": 0,
607
- "type": int,
608
- "style": "option",
609
- "label": _("Unsupported elements"),
610
- "choices": (0, 2, 1),
611
- "display": (
612
- _("Always load into meerk40t"),
613
- _("Convert with inkscape"),
614
- _("Ask at load time"),
615
- ),
616
- "tip": stip,
617
- "page": "Input/Output",
618
- "section": "SVG-Features",
619
- },
620
- ]
621
- kernel.register_choices("preferences", choices)
622
- kernel.register("load/MultiLoader", MultiLoader)
1
+ import gzip
2
+ import os.path
3
+ import platform
4
+ from subprocess import PIPE, TimeoutExpired, run
5
+ from time import time
6
+
7
+ from meerk40t.core.exceptions import BadFileError
8
+
9
+ def get_inkscape(context, manual_candidate=None):
10
+ root_context = context
11
+ root_context.setting(str, "inkscape_path", "inkscape.exe")
12
+ try:
13
+ inkscape = root_context.inkscape_path
14
+ except AttributeError:
15
+ inkscape = ""
16
+ system = platform.system()
17
+ if system == "Darwin":
18
+ candidates = [
19
+ "/Applications/Inkscape.app/Contents/MacOS/Inkscape",
20
+ "/Applications/Inkscape.app/Contents/Resources/bin/inkscape",
21
+ ]
22
+ elif system == "Windows":
23
+ candidates = [
24
+ "C:/Program Files (x86)/Inkscape/inkscape.exe",
25
+ "C:/Program Files (x86)/Inkscape/bin/inkscape.exe",
26
+ "C:/Program Files/Inkscape/inkscape.exe",
27
+ "C:/Program Files/Inkscape/bin/inkscape.exe",
28
+ "C:/inkscape/bin/inkscape.exe",
29
+ ]
30
+ elif system == "Linux":
31
+ candidates = [
32
+ "/usr/local/bin/inkscape",
33
+ "/usr/bin/inkscape",
34
+ ]
35
+ else:
36
+ candidates = []
37
+ if inkscape and inkscape not in candidates:
38
+ candidates.insert(0, inkscape)
39
+ if manual_candidate and manual_candidate not in candidates:
40
+ candidates.insert(0, manual_candidate)
41
+ match = None
42
+ for ink in candidates:
43
+ if os.path.exists(ink):
44
+ match = ink
45
+ root_context.inkscape_path = match
46
+ break
47
+ if match is None:
48
+ inkscape = ""
49
+ return inkscape
50
+
51
+
52
+ def run_command_and_log(command_array, logfile):
53
+ timeout_value = None
54
+ try:
55
+ f = open(logfile, "w")
56
+ except:
57
+ # Any error...
58
+ f = None
59
+ if f:
60
+ for idx, param in enumerate(command_array):
61
+ if idx == 0:
62
+ f.write(f"Executing: {param}\n")
63
+ f.write("Parameters:\n")
64
+ else:
65
+ f.write(f"{param}\n")
66
+ result = False
67
+ c = None
68
+ try:
69
+ start_time = time()
70
+ c = run(command_array, timeout=timeout_value, stdout=PIPE)
71
+ end_time = time()
72
+ if f:
73
+ f.write(
74
+ f"Executed successfully, result: {c.returncode} (execution time: {end_time-start_time:.1f} sec)\n"
75
+ )
76
+ f.write("Output:\n")
77
+ try:
78
+ f.write(c.stdout.decode("utf-8", errors="surrogateescape"))
79
+ except (UnicodeEncodeError, UnicodeDecodeError):
80
+ pass
81
+ result = True
82
+ except (
83
+ FileNotFoundError,
84
+ TimeoutExpired,
85
+ UnicodeDecodeError,
86
+ UnicodeEncodeError,
87
+ OSError,
88
+ ) as e:
89
+ if f:
90
+ f.write(f"Execution failed: {str(e)}\n")
91
+ if f:
92
+ f.close()
93
+ return result, c
94
+
95
+
96
+ class MultiLoader:
97
+ """
98
+ This module makes use of inkscape to convert a multitude of format into svg :
99
+ """
100
+
101
+ @staticmethod
102
+ def load_types():
103
+ yield "Inkscape supported files", (
104
+ "pdf",
105
+ "pdxf",
106
+ "eps",
107
+ "cdr",
108
+ "cmx",
109
+ "ccx",
110
+ "cdt",
111
+ "wmf",
112
+ "vsd",
113
+ "ai",
114
+ ), "image/svg+xml"
115
+ # yield "Portable Document Format files", ("pdf", "pdxf", "eps"), "image/svg+xml"
116
+ # yield "Corel Draw files", ("cdr", "cmx", "ccx", "cdt"), "image/svg+xml"
117
+ # yield "Windows Metafile files", ("wmf",), "image/svg+xml"
118
+ # yield "Visio files", ("vsd",), "image/svg+xml"
119
+ # yield "Adobe Illustrator files", ("ai",), "image/svg+xml"
120
+
121
+ @staticmethod
122
+ def load(kernel_service, elements_service, pathname, **kwargs):
123
+ """
124
+ Load content by means of inkscapes ability to convert
125
+ multiple vector formats into svg.
126
+ Requires the installation of inkscape on your system.
127
+ """
128
+ # Elemental calls this routine claiming it would be the kernel...
129
+ if hasattr(kernel_service, "kernel"):
130
+ kernel = kernel_service.kernel
131
+ else:
132
+ kernel = kernel_service
133
+ _ = kernel.translation
134
+
135
+ # Establish the standard svg-handler first
136
+ handler = None
137
+ for loader, loader_name, sname in kernel.find("load"):
138
+ for description, extensions, mimetype in loader.load_types():
139
+ if "svg" in extensions:
140
+ handler = loader
141
+ break
142
+
143
+ context_root = kernel.root
144
+ safe_dir = kernel.os_information["WORKDIR"]
145
+ logfile = os.path.join(safe_dir, "inkscape.log")
146
+
147
+ inkscape = get_inkscape(context_root)
148
+ if not inkscape:
149
+ raise BadFileError("Inkscape not found")
150
+
151
+ result, c = run_command_and_log([inkscape, "-V"], logfile)
152
+ if not result:
153
+ return pathname
154
+ try:
155
+ version = c.stdout.decode("utf-8", errors="surrogateescape")
156
+ except UnicodeDecodeError:
157
+ version = "inkscape 1.x"
158
+
159
+ svg_temp_file = os.path.join(safe_dir, "inkscape.svg")
160
+ if os.path.exists(svg_temp_file):
161
+ try:
162
+ os.remove(svg_temp_file)
163
+ except (OSError, FileNotFoundError):
164
+ raise BadFileError("Couldn't delete temporary inkscape file")
165
+ logfile = os.path.join(safe_dir, "inkscape.log")
166
+
167
+ # Check Version of Inkscape
168
+ if "inkscape 1." in version.lower():
169
+ cmd = [
170
+ inkscape,
171
+ "--export-plain-svg",
172
+ f"--export-filename={svg_temp_file}",
173
+ pathname,
174
+ ]
175
+ else:
176
+ cmd = [
177
+ inkscape,
178
+ "--export-plain-svg",
179
+ svg_temp_file,
180
+ pathname,
181
+ ]
182
+ was_shown = kernel.busyinfo.shown
183
+ if was_shown:
184
+ kernel.busyinfo.change(msg=_("Calling inkscape..."))
185
+ kernel.busyinfo.show()
186
+
187
+ result, c = run_command_and_log(cmd, logfile)
188
+ if not result or c.returncode == 1:
189
+ return False
190
+ # Has an output file been created?
191
+ if not os.path.exists(svg_temp_file):
192
+ return False
193
+
194
+ def unescaped(filename):
195
+ OS_NAME = platform.system()
196
+ if OS_NAME == "Windows":
197
+ newstring = filename.replace("&", "&&")
198
+ else:
199
+ newstring = filename.replace("&", "&&")
200
+ return newstring
201
+
202
+ if was_shown:
203
+ kernel.busyinfo.change(
204
+ msg=_("Loading File...") + "\n" + unescaped(svg_temp_file)
205
+ )
206
+ kernel.busyinfo.show()
207
+ filename_to_process = svg_temp_file
208
+ preproc = elements_service.lookup("preprocessor/.svg")
209
+ if preproc is not None:
210
+ filename_to_process = preproc(filename_to_process)
211
+ results = handler.load(elements_service, elements_service, filename_to_process)
212
+ return results
213
+
214
+
215
+ def plugin(kernel, lifecycle):
216
+ if lifecycle == "register":
217
+ _ = kernel.translation
218
+
219
+ @kernel.console_command(
220
+ "load",
221
+ help=_("inkscape ... load - load the previous conversion"),
222
+ input_type="inkscape",
223
+ output_type="inkscape",
224
+ )
225
+ def inscape_load(channel, _, data=None, **kwargs):
226
+ inkscape_path, filename = data
227
+ channel(_("inkscape load - loading the previous conversion..."))
228
+ try:
229
+ kernel.elements.load(filename, svg_ppi=kernel.elements.svg_ppi)
230
+ except BadFileError as e:
231
+ channel(_("File is Malformed."))
232
+ channel(str(e))
233
+ else:
234
+ kernel.elements.classify(list(kernel.elements.elems()))
235
+ return "inkscape", data
236
+
237
+ @kernel.console_command(
238
+ "simplify",
239
+ help=_("inkscape simplify - convert to plain svg"),
240
+ input_type="inkscape",
241
+ output_type="inkscape",
242
+ )
243
+ def inkscape_simplify(channel, _, data=None, **kwargs):
244
+ inkscape_path, filename = data
245
+ if not os.path.exists(inkscape_path):
246
+ channel(_("Inkscape not found. Try 'inkscape locate'"))
247
+ return
248
+ channel(_("inkscape simplify - converting to plain svg"))
249
+ c = run(
250
+ [
251
+ inkscape_path,
252
+ "--export-plain-svg",
253
+ "--export-filename=temp.svg",
254
+ filename,
255
+ ],
256
+ stdout=PIPE,
257
+ )
258
+ channel(c.stdout)
259
+ return "inkscape", (inkscape_path, "temp.svg")
260
+
261
+ @kernel.console_command(
262
+ "text2path",
263
+ help=_("inkscape text2path - convert text objects to paths"),
264
+ input_type="inkscape",
265
+ output_type="inkscape",
266
+ )
267
+ def inkscape_text2path(channel, _, data=None, **kwargs):
268
+ inkscape_path, filename = data
269
+ if not os.path.exists(inkscape_path):
270
+ channel(_("Inkscape not found. Try 'inkscape locate'"))
271
+ return
272
+ channel(_("inkscape text2path - converting text objects to paths"))
273
+ c = run(
274
+ [
275
+ inkscape_path,
276
+ "--export-area-drawing",
277
+ "--export-text-to-path",
278
+ "--export-plain-svg",
279
+ "--export-filename=temp.svg",
280
+ filename,
281
+ ],
282
+ stdout=PIPE,
283
+ )
284
+ channel(c.stdout)
285
+ return "inkscape", (inkscape_path, "temp.svg")
286
+
287
+ @kernel.console_option("dpi", "d", type=int, help=_("dpi to use"), default=1000)
288
+ @kernel.console_option("step", "s", type=int, help=_("step to use"))
289
+ @kernel.console_command(
290
+ "makepng",
291
+ help=_("inkscape makepng - make a png of all elements"),
292
+ input_type="inkscape",
293
+ output_type="inkscape",
294
+ )
295
+ def inkscape_png(channel, _, dpi=1000, step=None, data=None, **kwargs):
296
+ if step is not None and step > 0:
297
+ dpi = 1000 / step
298
+ inkscape_path, filename = data
299
+ if not os.path.exists(inkscape_path):
300
+ channel(_("Inkscape not found. Try 'inkscape locate'"))
301
+ return
302
+ channel(_("inkscape makepng - making a png of all elements"))
303
+ c = run(
304
+ [
305
+ inkscape_path,
306
+ "--export-background",
307
+ "white",
308
+ "--export-background-opacity",
309
+ "255",
310
+ "--export-area-drawing",
311
+ "--export-type=png",
312
+ "--export-filename=temp.png",
313
+ f"--export-dpi={dpi}",
314
+ filename,
315
+ ],
316
+ stdout=PIPE,
317
+ )
318
+ channel(c.stdout)
319
+ return "inkscape", (inkscape_path, "temp.png")
320
+
321
+ @kernel.console_argument(
322
+ "filename", type=str, help=_("filename of svg to be simplified")
323
+ )
324
+ @kernel.console_command(
325
+ "input",
326
+ help=_("input filename fn ... - provide the filename to process"),
327
+ input_type="inkscape",
328
+ output_type="inkscape",
329
+ )
330
+ def inkscape_input_filename(channel, _, filename, data, **kwargs):
331
+ inkscape_path, fn = data
332
+ if filename is None:
333
+ channel(_("inkscape filename fn - filename not specified"))
334
+ if not os.path.exists(filename):
335
+ channel(
336
+ _("inkscape filename {filename} - file not found").format(
337
+ filename=filename
338
+ )
339
+ )
340
+ return
341
+ return "inkscape", (inkscape_path, filename)
342
+
343
+ @kernel.console_command(
344
+ "version",
345
+ help=_("inkscape version - get the inkscape version"),
346
+ input_type="inkscape",
347
+ output_type="inkscape",
348
+ )
349
+ def inkscape_version(channel, _, data, **kwargs):
350
+ inkscape_path, filename = data
351
+ if not os.path.exists(inkscape_path):
352
+ channel(_("Inkscape not found. Try 'inkscape locate'"))
353
+ return
354
+ c = run([inkscape_path, "-V"], stdout=PIPE)
355
+ try:
356
+ version = c.stdout.decode("utf-8", errors="surrogateescape")
357
+ except UnicodeDecodeError:
358
+ version = "unknown"
359
+
360
+ channel(
361
+ _('Inkscape executable at "{path}" is: {version}').format(
362
+ path=inkscape_path, version=version
363
+ )
364
+ )
365
+ return "inkscape", data
366
+
367
+ @kernel.console_argument(
368
+ "inkpath", type=str, help=_("Optional: location of inkscape executable")
369
+ )
370
+ @kernel.console_command(
371
+ "locate",
372
+ help=_("inkscape locate - set the path to inkscape on your computer"),
373
+ input_type="inkscape",
374
+ output_type="inkscape",
375
+ )
376
+ def inkscape_locate(channel, _, data, inkpath=None, **kwargs):
377
+ inkscape_path, filename = data
378
+ match = get_inkscape(kernel.root, inkpath)
379
+ root_context = kernel.root
380
+ root_context.setting(str, "inkscape_path", "inkscape.exe")
381
+ if match:
382
+ channel(_("Inkscape location: {match}").format(match=match))
383
+ else:
384
+ root_context.inkscape_path = "inkscape.exe"
385
+ channel(
386
+ _(
387
+ "Inkscape location: Inkscape not found in default installation directories"
388
+ )
389
+ )
390
+
391
+ return "inkscape", (match, filename)
392
+
393
+ @kernel.console_command(
394
+ "inkscape",
395
+ help=_("invoke inkscape to convert elements"),
396
+ output_type="inkscape",
397
+ )
398
+ def inkscape_base(**kwargs):
399
+ root_context = kernel.root
400
+ root_context.setting(str, "inkscape_path", "inkscape.exe")
401
+ return "inkscape", (root_context.inkscape_path, None)
402
+
403
+ def check_for_features(pathname, **kwargs):
404
+ # We try to establish if a file contains certain features...
405
+
406
+ source = pathname
407
+ if not os.path.exists(source):
408
+ return pathname
409
+ if pathname.lower().endswith("svgz"):
410
+ source = gzip.open(pathname, "rb")
411
+ METHOD_CONVERT_TO_OBJECT = 1
412
+ METHOD_CONVERT_TO_PNG = 2
413
+ features = {
414
+ "text": [False, ("<text",), METHOD_CONVERT_TO_OBJECT],
415
+ "clipping": [False, ("<clippath",), METHOD_CONVERT_TO_PNG],
416
+ "mask": [False, ("<mask",), METHOD_CONVERT_TO_PNG],
417
+ "gradient": [
418
+ False,
419
+ ("<lineargradient", "<radialgradient"),
420
+ METHOD_CONVERT_TO_PNG,
421
+ ],
422
+ "pattern": [False, ("<pattern",), METHOD_CONVERT_TO_PNG],
423
+ }
424
+ safe_dir = kernel.os_information["WORKDIR"]
425
+ svg_temp_file = os.path.join(safe_dir, "temp.svg")
426
+ png_temp_file = os.path.join(safe_dir, "temp.png")
427
+ needs_conversion = 0
428
+ with open(source, mode="r", encoding="utf8", errors="surrogateescape") as f:
429
+ while True:
430
+ line = f.readline().lower()
431
+ if not line:
432
+ break
433
+ for feat, entry in features.items():
434
+ for candidate in entry[1]:
435
+ if candidate in line:
436
+ entry[0] = True
437
+ if entry[2] > needs_conversion:
438
+ needs_conversion = entry[2]
439
+ context = kernel.root
440
+ inkscape = get_inkscape(context)
441
+ if needs_conversion == 0:
442
+ return pathname
443
+ if len(inkscape) == 0:
444
+ # Inkscape not found.
445
+ return pathname
446
+ # What is our preference? Load, convert, ask?
447
+ conversion_preference = int(kernel.root.svg_not_supported)
448
+ wasbusy = kernel.busyinfo.shown
449
+
450
+ if conversion_preference == 1:
451
+ # Ask
452
+ msg = _(
453
+ "This file contains certain features that might not be fully supported by MeerK40t"
454
+ )
455
+ for feat, entry in features.items():
456
+ if entry[0]:
457
+ msg += "\n" + f" - {feat}"
458
+ if needs_conversion == METHOD_CONVERT_TO_PNG:
459
+ msg += "\n" + _(
460
+ "The complete design would be rendered into a single graphic."
461
+ )
462
+ elif needs_conversion == METHOD_CONVERT_TO_OBJECT:
463
+ msg += "\n" + _(
464
+ "Text elements would be converted into path objects."
465
+ )
466
+
467
+ msg += "\n" + _(
468
+ "Do you want to convert the file via inkscape or do you want load the unmodified file?"
469
+ )
470
+ if wasbusy:
471
+ kernel.busyinfo.hide()
472
+ response = kernel.yesno(
473
+ msg,
474
+ option_yes=_("Convert"),
475
+ option_no=_("Load original"),
476
+ caption=_("SVG-Conversion"),
477
+ )
478
+ if response:
479
+ # convert
480
+ conversion_preference = 2
481
+ else:
482
+ # Load
483
+ conversion_preference = 0
484
+ # translate = ["load", "ask", "convert"]
485
+ # print (f"Conversion preference: {translate[conversion_preference]} - {conversion_preference}")
486
+ if wasbusy:
487
+ kernel.busyinfo.show()
488
+
489
+ if conversion_preference == 0:
490
+ # Load
491
+ return pathname
492
+
493
+ if wasbusy:
494
+ kernel.busyinfo.change(msg=_("Calling inkscape..."))
495
+ kernel.busyinfo.show()
496
+ log_file = os.path.join(safe_dir, "inkscape.log")
497
+ result, c = run_command_and_log([inkscape, "-V"], log_file)
498
+ if not result:
499
+ return pathname
500
+ try:
501
+ version = c.stdout.decode(encoding="utf-8", errors="surrogateescape")
502
+ except UnicodeDecodeError:
503
+ version = "inkscape 1.x"
504
+
505
+ if needs_conversion == METHOD_CONVERT_TO_OBJECT:
506
+ # Ask inkscape to convert all text elements to paths
507
+ # slightly different invocation for different values
508
+ # Check Version of Inkscape
509
+ if "inkscape 1." in version.lower():
510
+ cmd = [
511
+ inkscape,
512
+ "--export-text-to-path",
513
+ "--export-plain-svg",
514
+ f"--export-filename={svg_temp_file}",
515
+ pathname,
516
+ ]
517
+ else:
518
+ cmd = [
519
+ inkscape,
520
+ "--export-text-to-path",
521
+ "--export-plain-svg",
522
+ svg_temp_file,
523
+ pathname,
524
+ ]
525
+ result, c = run_command_and_log(cmd, log_file)
526
+ if result and c.returncode == 0:
527
+ return svg_temp_file
528
+
529
+ return pathname
530
+
531
+ if needs_conversion == METHOD_CONVERT_TO_PNG:
532
+ dpi = 500
533
+ if "inkscape 1." in version.lower():
534
+ cmd = [
535
+ inkscape,
536
+ "--export-background",
537
+ "white",
538
+ "--export-background-opacity",
539
+ "255",
540
+ "--export-area-drawing",
541
+ "--export-type=png",
542
+ f"--export-filename={png_temp_file}",
543
+ f"--export-dpi={dpi}",
544
+ pathname,
545
+ ]
546
+ else:
547
+ cmd = [
548
+ inkscape,
549
+ "--export-area-drawing",
550
+ "--export-dpi",
551
+ str(dpi),
552
+ "--export-background",
553
+ "rgb(255, 255, 255)",
554
+ "--export-background-opacity",
555
+ "255",
556
+ "--export-png",
557
+ png_temp_file,
558
+ pathname,
559
+ ]
560
+ result, c = run_command_and_log(cmd, log_file)
561
+ if result and c.returncode == 0:
562
+ return png_temp_file
563
+
564
+ return pathname
565
+
566
+ kernel.register("preprocessor/.svg", check_for_features)
567
+ # Let's establish some settings too
568
+ stip = (
569
+ _("Meerk40t does not support all svg-features, so you might want")
570
+ + "\n"
571
+ + _("to preprocess the file to get a proper representation of the design.")
572
+ + "\n"
573
+ + _(
574
+ " - Certain subvariants of Fonts - single element will be converted to a path"
575
+ )
576
+ + "\n"
577
+ + _(
578
+ " - Gradient fills / patterns - the whole design will be rendered into a graphic"
579
+ )
580
+ + "\n"
581
+ + _(" - Clipping/Mask - the whole design will be rendered into a graphic")
582
+ )
583
+ system = platform.system()
584
+ if system == "Darwin":
585
+ wildcard = "Inkscape|(Inkscape;inkscape)|All files|*.*"
586
+ elif system == "Windows":
587
+ wildcard = "Inkscape|inkscape.exe|All files|*.*"
588
+ elif system == "Linux":
589
+ wildcard = "Inkscape|inkscape|All files|*.*"
590
+ else:
591
+ wildcard = "Inkscape|(Inkscape;inkscape)|All files|*.*"
592
+
593
+ kernel.root.setting(str, "inkscape_path", "")
594
+ choices = [
595
+ {
596
+ "attr": "inkscape_path",
597
+ "object": kernel.root,
598
+ "default": "",
599
+ "type": str,
600
+ "style": "file",
601
+ "wildcard": wildcard,
602
+ "label": _("Inkscape"),
603
+ "tip": _(
604
+ "Path to inkscape-executable. Leave empty to let Meerk40t establish standard locations"
605
+ ),
606
+ "page": "Input/Output",
607
+ "section": "SVG-Features",
608
+ },
609
+ {
610
+ "attr": "svg_not_supported",
611
+ "object": kernel.root,
612
+ "default": 0,
613
+ "type": int,
614
+ "style": "option",
615
+ "label": _("Unsupported elements"),
616
+ "choices": (0, 2, 1),
617
+ "display": (
618
+ _("Always load into meerk40t"),
619
+ _("Convert with inkscape"),
620
+ _("Ask at load time"),
621
+ ),
622
+ "tip": stip,
623
+ "page": "Input/Output",
624
+ "section": "SVG-Features",
625
+ },
626
+ ]
627
+ kernel.register_choices("preferences", choices)
628
+ kernel.register("load/MultiLoader", MultiLoader)