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,505 +1,518 @@
1
- from math import isinf, isnan
2
-
3
- import wx
4
-
5
- from meerk40t.gui.scene.sceneconst import (
6
- BUFFER,
7
- HITCHAIN_DELEGATE,
8
- ORIENTATION_ABSOLUTE,
9
- ORIENTATION_CENTERED,
10
- ORIENTATION_DIM_MASK,
11
- ORIENTATION_GRID,
12
- ORIENTATION_HORIZONTAL,
13
- ORIENTATION_MODE_MASK,
14
- ORIENTATION_NO_BUFFER,
15
- ORIENTATION_RELATIVE,
16
- ORIENTATION_VERTICAL,
17
- RESPONSE_CHAIN,
18
- )
19
- from meerk40t.gui.zmatrix import ZMatrix
20
- from meerk40t.svgelements import Matrix
21
-
22
-
23
- class Widget(list):
24
- """
25
- Widgets are drawable, interaction objects within the scene. They have their own space, matrix, orientation, and
26
- processing of events.
27
- """
28
-
29
- def __init__(
30
- self,
31
- scene,
32
- left: float = None,
33
- top: float = None,
34
- right: float = None,
35
- bottom: float = None,
36
- all: bool = False,
37
- visible: bool = True,
38
- ):
39
- """
40
- All produces a widget of infinite space rather than finite space.
41
- """
42
- assert scene.__class__.__name__ == "Scene"
43
- list.__init__(self)
44
- self.matrix = Matrix()
45
- self.scene = scene
46
- self.parent = None
47
- self.properties = ORIENTATION_RELATIVE
48
- self.visible = True
49
- # If this property is set, then it won't be counted as topmost in the hitchain...
50
- self.transparent = False
51
- if all:
52
- # contains all points
53
- self.left = -float("inf")
54
- self.top = -float("inf")
55
- self.right = float("inf")
56
- self.bottom = float("inf")
57
- else:
58
- # contains no points
59
- self.left = float("inf")
60
- self.top = float("inf")
61
- self.right = -float("inf")
62
- self.bottom = -float("inf")
63
- if left is not None:
64
- self.left = left
65
- if right is not None:
66
- self.right = right
67
- if top is not None:
68
- self.top = top
69
- if bottom is not None:
70
- self.bottom = bottom
71
- if visible is not None:
72
- self.visible = visible
73
-
74
- def __str__(self):
75
- return f"{type(self).__name__}({self.left}, {self.top}, {self.right}, {self.bottom})"
76
-
77
- def __repr__(self):
78
- return f"{type(self).__name__}({self.left}, {self.top}, {self.right}, {self.bottom})"
79
-
80
- def hit(self):
81
- """
82
- Default hit state delegates to child-widgets within the current object.
83
- """
84
- return HITCHAIN_DELEGATE
85
-
86
- def draw(self, gc):
87
- """
88
- Widget.draw() routine which concat's the widgets matrix and call the process_draw() function.
89
- """
90
- # Concat if this is a thing.
91
- if not self.visible:
92
- return
93
- matrix = self.matrix
94
- gc.PushState()
95
- if matrix is not None and not matrix.is_identity():
96
- gc.ConcatTransform(wx.GraphicsContext.CreateMatrix(gc, ZMatrix(matrix)))
97
- self.process_draw(gc)
98
- for i in range(len(self) - 1, -1, -1):
99
- widget = self[i]
100
- if widget is not None:
101
- widget.draw(gc)
102
- gc.PopState()
103
-
104
- def process_draw(self, gc):
105
- """
106
- Overloaded function by derived widgets to process the drawing of this widget.
107
- """
108
- pass
109
-
110
- def contains(self, x, y=None):
111
- """
112
- Query whether the current point is contained within the current widget.
113
- """
114
- if y is None:
115
- y = x.y
116
- x = x.x
117
- return (
118
- self.visible
119
- and self.left <= x <= self.right
120
- and self.top <= y <= self.bottom
121
- )
122
-
123
- def event(
124
- self,
125
- window_pos=None,
126
- space_pos=None,
127
- event_type=None,
128
- nearest_snap=None,
129
- **kwargs,
130
- ):
131
- """
132
- Default event which simply chains the event to the next hittable object.
133
- """
134
- return RESPONSE_CHAIN
135
-
136
- def notify_added_to_parent(self, parent):
137
- """
138
- Widget notify that calls scene notify.
139
- """
140
- self.scene.notify_added_to_parent(parent)
141
-
142
- def notify_added_child(self, child):
143
- """
144
- Widget notify that calls scene notify.
145
- """
146
- self.scene.notify_added_child(child)
147
-
148
- def notify_removed_from_parent(self, parent):
149
- """
150
- Widget notify that calls scene notify.
151
- """
152
- self.scene.notify_removed_from_parent(parent)
153
-
154
- def notify_removed_child(self, child):
155
- """
156
- Widget notify that calls scene notify.
157
- """
158
- self.scene.notify_removed_child(child)
159
-
160
- def notify_moved_child(self, child):
161
- """
162
- Widget notify that calls scene notify.
163
- """
164
- self.scene.notify_moved_child(child)
165
-
166
- def translate(self, dx, dy):
167
- """
168
- Move the current widget and all child widgets.
169
- """
170
- if dx == 0 and dy == 0:
171
- return
172
- if isnan(dx) or isnan(dy) or isinf(dx) or isinf(dy):
173
- return
174
- self.translate_loop(dx, dy)
175
-
176
- def translate_loop(self, dx, dy):
177
- """
178
- Loop the translation call to all child objects.
179
- """
180
- if self.properties & ORIENTATION_ABSOLUTE != 0:
181
- return # Do not translate absolute oriented widgets.
182
- self.translate_self(dx, dy)
183
- for w in self:
184
- w.translate_loop(dx, dy)
185
-
186
- def translate_self(self, dx, dy):
187
- """
188
- Perform the local translation of the current widget
189
- """
190
- self.left += dx
191
- self.right += dx
192
- self.top += dy
193
- self.bottom += dy
194
- if self.parent is not None:
195
- self.notify_moved_child(self)
196
-
197
- def union_children_bounds(self, bounds=None):
198
- """
199
- Find the bounds of the current widget and all child widgets.
200
- """
201
- if bounds is None:
202
- bounds = [self.left, self.top, self.right, self.bottom]
203
- else:
204
- if bounds[0] > self.left:
205
- bounds[0] = self.left
206
- if bounds[1] > self.top:
207
- bounds[1] = self.top
208
- if bounds[2] < self.right:
209
- bounds[2] = self.left
210
- if bounds[3] < self.bottom:
211
- bounds[3] = self.bottom
212
- for w in self:
213
- w.union_children_bounds(bounds)
214
- return bounds
215
-
216
- @property
217
- def height(self):
218
- """
219
- Height of the current widget.
220
- """
221
- return self.bottom - self.top
222
-
223
- @property
224
- def width(self):
225
- """
226
- Width of the current widget.
227
- """
228
- return self.right - self.left
229
-
230
- def layout_by_orientation(self, widget, last, properties):
231
- """
232
- Perform specific layout based on the properties given.
233
- ORIENTATION_ABSOLUTE places the widget exactly in the scene.
234
- ORIENTATION_NO_BUFFER nullifies any buffer between objects being laid out.
235
- ORIENTATION_RELATIVE lays out the added widget relative to the parent.
236
- ORIENTATION_GRID lays out the added widget in a DIM_MASK grid.
237
- ORIENTATION_VERTICAL lays the added widget below the reference widget.
238
- ORIENTATION_HORIZONTAL lays the added widget to the right of the reference widget.
239
- ORIENTATION_CENTERED lays out the added widget and within the parent and all child centered.
240
- """
241
- if properties & ORIENTATION_ABSOLUTE != 0:
242
- return
243
- if properties & ORIENTATION_NO_BUFFER != 0:
244
- buffer = 0
245
- else:
246
- buffer = BUFFER
247
- if (properties & ORIENTATION_MODE_MASK) == ORIENTATION_RELATIVE:
248
- widget.translate(self.left, self.top)
249
- return
250
- elif last is None: # orientation = origin
251
- widget.translate(self.left - widget.left, self.top - widget.top)
252
- elif (properties & ORIENTATION_GRID) != 0:
253
- dim = properties & ORIENTATION_DIM_MASK
254
- if (properties & ORIENTATION_VERTICAL) != 0:
255
- if dim == 0: # Vertical
256
- if self.height >= last.bottom - self.top + widget.height:
257
- # add to line
258
- widget.translate(
259
- last.left - widget.left, last.bottom - widget.top
260
- )
261
- else:
262
- # line return
263
- widget.translate(
264
- last.right - widget.left + buffer, self.top - widget.top
265
- )
266
- else:
267
- if dim == 0: # Horizontal
268
- if self.width >= last.right - self.left + widget.width:
269
- # add to line
270
- widget.translate(
271
- last.right - widget.left + buffer, last.top - widget.top
272
- )
273
- else:
274
- # line return
275
- widget.translate(
276
- self.left - widget.left, last.bottom - widget.top + buffer
277
- )
278
- elif (properties & ORIENTATION_HORIZONTAL) != 0:
279
- widget.translate(last.right - widget.left + buffer, last.top - widget.top)
280
- elif (properties & ORIENTATION_VERTICAL) != 0:
281
- widget.translate(last.left - widget.left, last.bottom - widget.top + buffer)
282
- if properties & ORIENTATION_CENTERED:
283
- self.center_children()
284
-
285
- def center_children(self):
286
- """
287
- Centers the children of the current widget within the current widget.
288
- """
289
- child_bounds = self.union_children_bounds()
290
- dx = self.left - (child_bounds[0] + child_bounds[2]) / 2.0
291
- dy = self.top - (child_bounds[1] + child_bounds[3]) / 2.0
292
- if dx != 0 and dy != 0:
293
- for w in self:
294
- w.translate_loop(dx, dy)
295
-
296
- def center_widget(self, x, y=None):
297
- """
298
- Moves the current widget to center within the bounds of the children.
299
- """
300
- if y is None:
301
- y = x.y
302
- x = x.x
303
- child_bounds = self.union_children_bounds()
304
- cx = (child_bounds[0] + child_bounds[2]) / 2.0
305
- cy = (child_bounds[1] + child_bounds[3]) / 2.0
306
- self.translate(x - cx, y - cy)
307
-
308
- def set_position(self, x, y=None):
309
- """
310
- Sets the absolute position of this widget by moving it from its current position
311
- to given position.
312
- """
313
- if y is None:
314
- y = x.y
315
- x = x.x
316
- dx = x - self.left
317
- dy = y - self.top
318
- self.translate(dx, dy)
319
-
320
- def add_widget(self, index=-1, widget=None, properties=None):
321
- """
322
- Add a widget to the current widget.
323
-
324
- Adds at the particular index according to the properties.
325
-
326
- The properties can be used to trigger particular layouts or properties for the added widget.
327
- """
328
- with self.scene.scene_lock:
329
- if properties is None:
330
- properties = self.properties
331
- if len(self) == 0:
332
- last = self
333
- else:
334
- last = self[-1]
335
-
336
- if 0 <= index < len(self):
337
- self.insert(index, widget)
338
- else:
339
- self.append(widget)
340
- widget.parent = self
341
- self.layout_by_orientation(widget, last, properties)
342
- self.notify_added_to_parent(self)
343
- self.notify_added_child(widget)
344
-
345
- def remove_all_widgets(self):
346
- """
347
- Remove all widgets from the current widget.
348
- """
349
- with self.scene.scene_lock:
350
- for w in self:
351
- if w is None:
352
- continue
353
- w.parent = None
354
- w.notify_removed_from_parent(self)
355
- self.notify_removed_child(w)
356
- self.clear()
357
- try:
358
- self.scene.notify_tree_changed()
359
- except AttributeError:
360
- pass
361
-
362
- def remove_widget(self, widget=None):
363
- """
364
- Remove the given widget from being a child of the current widget.
365
- """
366
- if widget is None:
367
- return
368
- with self.scene.scene_lock:
369
- if isinstance(widget, Widget):
370
- for i, w in enumerate(self):
371
- if w is widget:
372
- del self[i]
373
- elif isinstance(widget, int):
374
- index = widget
375
- widget = self[index]
376
- del self[index]
377
- widget.parent = None
378
- widget.notify_removed_from_parent(self)
379
- self.notify_removed_child(widget)
380
- try:
381
- self.scene.notify_tree_changed()
382
- except AttributeError:
383
- pass
384
-
385
- def set_widget(self, index, widget):
386
- """
387
- Sets the given widget at the index to replace the child currently at the position of that widget.
388
- """
389
- with self.scene.scene_lock:
390
- w = self[index]
391
- self[index] = widget
392
- widget.parent = self
393
- widget.notify_added_to_parent(self)
394
- self.notify_removed_child(w)
395
- try:
396
- self.scene.notify_tree_changed()
397
- except AttributeError:
398
- pass
399
-
400
- def on_matrix_change(self):
401
- """
402
- Notification of a changed matrix.
403
- """
404
- pass
405
-
406
- def scene_matrix_reset(self):
407
- """
408
- Resets the scene matrix.
409
- """
410
- self.matrix.reset()
411
- self.on_matrix_change()
412
-
413
- def scene_post_scale(self, sx, sy=None, ax=0, ay=0):
414
- """
415
- Adds a post_scale to the matrix.
416
- """
417
- self.matrix.post_scale(sx, sy, ax, ay)
418
- self.on_matrix_change()
419
-
420
- def scene_post_pan(self, px, py):
421
- """
422
- Adds a post_pan to the matrix.
423
- """
424
- self.matrix.post_translate(px, py)
425
- self.on_matrix_change()
426
-
427
- def scene_post_rotate(self, angle, rx=0, ry=0):
428
- """
429
- Adds a post_rotate to the matrix.
430
- """
431
- self.matrix.post_rotate(angle, rx, ry)
432
- self.on_matrix_change()
433
-
434
- def scene_pre_scale(self, sx, sy=None, ax=0, ay=0):
435
- """
436
- Adds a pre_scale to the matrix()
437
- """
438
- self.matrix.pre_scale(sx, sy, ax, ay)
439
- self.on_matrix_change()
440
-
441
- def scene_pre_pan(self, px, py):
442
- """
443
- Adds a pre_pan to the matrix()
444
- """
445
- self.matrix.pre_translate(px, py)
446
- self.on_matrix_change()
447
-
448
- def scene_pre_rotate(self, angle, rx=0, ry=0):
449
- """
450
- Adds a pre_rotate to the matrix()
451
- """
452
- self.matrix.pre_rotate(angle, rx, ry)
453
- self.on_matrix_change()
454
-
455
- def get_scale_x(self):
456
- """
457
- Gets the scale_x of the current matrix
458
- """
459
- return self.matrix.value_scale_x()
460
-
461
- def get_scale_y(self):
462
- """
463
- Gets the scale_y of the current matrix
464
- """
465
- return self.matrix.value_scale_y()
466
-
467
- def get_skew_x(self):
468
- """
469
- Gets the skew_x of the current matrix()
470
- """
471
- return self.matrix.value_skew_x()
472
-
473
- def get_skew_y(self):
474
- """
475
- Gets the skew_y of the current matrix()
476
- """
477
- return self.matrix.value_skew_y()
478
-
479
- def get_translate_x(self):
480
- """
481
- Gets the translate_x of the current matrix()
482
- """
483
- return self.matrix.value_trans_x()
484
-
485
- def get_translate_y(self):
486
- """
487
- Gets the translate_y of the current matrix()
488
- """
489
- return self.matrix.value_trans_y()
490
-
491
- def show(self, flag=None):
492
- """
493
- This does not automatically display the widget (yet)
494
- """
495
- if flag is None:
496
- flag = True
497
- self.visible = flag
498
-
499
- def hide(self, flag=None):
500
- """
501
- This does not automatically display the widget (yet)
502
- """
503
- if flag is None:
504
- flag = True
505
- self.visible = not flag
1
+ from math import isinf, isnan
2
+
3
+ import wx
4
+
5
+ from meerk40t.gui.scene.sceneconst import (
6
+ BUFFER,
7
+ HITCHAIN_DELEGATE,
8
+ ORIENTATION_ABSOLUTE,
9
+ ORIENTATION_CENTERED,
10
+ ORIENTATION_DIM_MASK,
11
+ ORIENTATION_GRID,
12
+ ORIENTATION_HORIZONTAL,
13
+ ORIENTATION_MODE_MASK,
14
+ ORIENTATION_NO_BUFFER,
15
+ ORIENTATION_RELATIVE,
16
+ ORIENTATION_VERTICAL,
17
+ RESPONSE_CHAIN,
18
+ )
19
+ from meerk40t.gui.zmatrix import ZMatrix
20
+ from meerk40t.svgelements import Matrix
21
+
22
+
23
+ class Widget(list):
24
+ """
25
+ Widgets are drawable, interaction objects within the scene. They have their own space, matrix, orientation, and
26
+ processing of events.
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ scene,
32
+ left: float = None,
33
+ top: float = None,
34
+ right: float = None,
35
+ bottom: float = None,
36
+ all: bool = False,
37
+ visible: bool = True,
38
+ ):
39
+ """
40
+ All produces a widget of infinite space rather than finite space.
41
+ """
42
+ assert scene.__class__.__name__ == "Scene"
43
+ list.__init__(self)
44
+ self.matrix = Matrix()
45
+ self.scene = scene
46
+ self.parent = None
47
+ self.properties = ORIENTATION_RELATIVE
48
+ self.visible = True
49
+ # If this property is set, then it won't be counted as topmost in the hitchain...
50
+ self.transparent = False
51
+ if all:
52
+ # contains all points
53
+ self.left = -float("inf")
54
+ self.top = -float("inf")
55
+ self.right = float("inf")
56
+ self.bottom = float("inf")
57
+ else:
58
+ # contains no points
59
+ self.left = float("inf")
60
+ self.top = float("inf")
61
+ self.right = -float("inf")
62
+ self.bottom = -float("inf")
63
+ if left is not None:
64
+ self.left = left
65
+ if right is not None:
66
+ self.right = right
67
+ if top is not None:
68
+ self.top = top
69
+ if bottom is not None:
70
+ self.bottom = bottom
71
+ if visible is not None:
72
+ self.visible = visible
73
+
74
+ def __str__(self):
75
+ return f"{type(self).__name__}({self.left}, {self.top}, {self.right}, {self.bottom})"
76
+
77
+ def __repr__(self):
78
+ return f"{type(self).__name__}({self.left}, {self.top}, {self.right}, {self.bottom})"
79
+
80
+ def hit(self):
81
+ """
82
+ Default hit state delegates to child-widgets within the current object.
83
+ """
84
+ return HITCHAIN_DELEGATE
85
+
86
+ def draw(self, gc):
87
+ """
88
+ Widget.draw() routine which concat's the widgets matrix and call the process_draw() function.
89
+ """
90
+ ## Adding some debug messages to understand the Darwin crashes
91
+ # Concat if this is a thing.
92
+ if not self.visible:
93
+ return
94
+ matrix = self.matrix
95
+ gc.PushState()
96
+ try:
97
+ if matrix is not None and not matrix.is_identity():
98
+ gc.ConcatTransform(wx.GraphicsContext.CreateMatrix(gc, ZMatrix(matrix)))
99
+ except Exception as e:
100
+ print (f"Could not concat gc transformation [{e}]")
101
+ gc.PopState()
102
+ return
103
+
104
+ try:
105
+ self.process_draw(gc)
106
+ except OSError as e:
107
+ print (f"Could not process draw [{e}]")
108
+ for i in range(len(self) - 1, -1, -1):
109
+ widget = self[i]
110
+ if widget is not None:
111
+ try:
112
+ widget.draw(gc)
113
+ except Exception as e:
114
+ print (f"Could not draw widget #{i} {type(widget).__name__} [{e}]")
115
+ gc.PopState()
116
+
117
+ def process_draw(self, gc):
118
+ """
119
+ Overloaded function by derived widgets to process the drawing of this widget.
120
+ """
121
+ pass
122
+
123
+ def contains(self, x, y=None):
124
+ """
125
+ Query whether the current point is contained within the current widget.
126
+ """
127
+ if y is None:
128
+ y = x.y
129
+ x = x.x
130
+ return (
131
+ self.visible
132
+ and self.left <= x <= self.right
133
+ and self.top <= y <= self.bottom
134
+ )
135
+
136
+ def event(
137
+ self,
138
+ window_pos=None,
139
+ space_pos=None,
140
+ event_type=None,
141
+ nearest_snap=None,
142
+ **kwargs,
143
+ ):
144
+ """
145
+ Default event which simply chains the event to the next hittable object.
146
+ """
147
+ return RESPONSE_CHAIN
148
+
149
+ def notify_added_to_parent(self, parent):
150
+ """
151
+ Widget notify that calls scene notify.
152
+ """
153
+ self.scene.notify_added_to_parent(parent)
154
+
155
+ def notify_added_child(self, child):
156
+ """
157
+ Widget notify that calls scene notify.
158
+ """
159
+ self.scene.notify_added_child(child)
160
+
161
+ def notify_removed_from_parent(self, parent):
162
+ """
163
+ Widget notify that calls scene notify.
164
+ """
165
+ self.scene.notify_removed_from_parent(parent)
166
+
167
+ def notify_removed_child(self, child):
168
+ """
169
+ Widget notify that calls scene notify.
170
+ """
171
+ self.scene.notify_removed_child(child)
172
+
173
+ def notify_moved_child(self, child):
174
+ """
175
+ Widget notify that calls scene notify.
176
+ """
177
+ self.scene.notify_moved_child(child)
178
+
179
+ def translate(self, dx, dy):
180
+ """
181
+ Move the current widget and all child widgets.
182
+ """
183
+ if dx == 0 and dy == 0:
184
+ return
185
+ if isnan(dx) or isnan(dy) or isinf(dx) or isinf(dy):
186
+ return
187
+ self.translate_loop(dx, dy)
188
+
189
+ def translate_loop(self, dx, dy):
190
+ """
191
+ Loop the translation call to all child objects.
192
+ """
193
+ if self.properties & ORIENTATION_ABSOLUTE != 0:
194
+ return # Do not translate absolute oriented widgets.
195
+ self.translate_self(dx, dy)
196
+ for w in self:
197
+ w.translate_loop(dx, dy)
198
+
199
+ def translate_self(self, dx, dy):
200
+ """
201
+ Perform the local translation of the current widget
202
+ """
203
+ self.left += dx
204
+ self.right += dx
205
+ self.top += dy
206
+ self.bottom += dy
207
+ if self.parent is not None:
208
+ self.notify_moved_child(self)
209
+
210
+ def union_children_bounds(self, bounds=None):
211
+ """
212
+ Find the bounds of the current widget and all child widgets.
213
+ """
214
+ if bounds is None:
215
+ bounds = [self.left, self.top, self.right, self.bottom]
216
+ else:
217
+ if bounds[0] > self.left:
218
+ bounds[0] = self.left
219
+ if bounds[1] > self.top:
220
+ bounds[1] = self.top
221
+ if bounds[2] < self.right:
222
+ bounds[2] = self.left
223
+ if bounds[3] < self.bottom:
224
+ bounds[3] = self.bottom
225
+ for w in self:
226
+ w.union_children_bounds(bounds)
227
+ return bounds
228
+
229
+ @property
230
+ def height(self):
231
+ """
232
+ Height of the current widget.
233
+ """
234
+ return self.bottom - self.top
235
+
236
+ @property
237
+ def width(self):
238
+ """
239
+ Width of the current widget.
240
+ """
241
+ return self.right - self.left
242
+
243
+ def layout_by_orientation(self, widget, last, properties):
244
+ """
245
+ Perform specific layout based on the properties given.
246
+ ORIENTATION_ABSOLUTE places the widget exactly in the scene.
247
+ ORIENTATION_NO_BUFFER nullifies any buffer between objects being laid out.
248
+ ORIENTATION_RELATIVE lays out the added widget relative to the parent.
249
+ ORIENTATION_GRID lays out the added widget in a DIM_MASK grid.
250
+ ORIENTATION_VERTICAL lays the added widget below the reference widget.
251
+ ORIENTATION_HORIZONTAL lays the added widget to the right of the reference widget.
252
+ ORIENTATION_CENTERED lays out the added widget and within the parent and all child centered.
253
+ """
254
+ if properties & ORIENTATION_ABSOLUTE != 0:
255
+ return
256
+ if properties & ORIENTATION_NO_BUFFER != 0:
257
+ buffer = 0
258
+ else:
259
+ buffer = BUFFER
260
+ if (properties & ORIENTATION_MODE_MASK) == ORIENTATION_RELATIVE:
261
+ widget.translate(self.left, self.top)
262
+ return
263
+ elif last is None: # orientation = origin
264
+ widget.translate(self.left - widget.left, self.top - widget.top)
265
+ elif (properties & ORIENTATION_GRID) != 0:
266
+ dim = properties & ORIENTATION_DIM_MASK
267
+ if (properties & ORIENTATION_VERTICAL) != 0:
268
+ if dim == 0: # Vertical
269
+ if self.height >= last.bottom - self.top + widget.height:
270
+ # add to line
271
+ widget.translate(
272
+ last.left - widget.left, last.bottom - widget.top
273
+ )
274
+ else:
275
+ # line return
276
+ widget.translate(
277
+ last.right - widget.left + buffer, self.top - widget.top
278
+ )
279
+ else:
280
+ if dim == 0: # Horizontal
281
+ if self.width >= last.right - self.left + widget.width:
282
+ # add to line
283
+ widget.translate(
284
+ last.right - widget.left + buffer, last.top - widget.top
285
+ )
286
+ else:
287
+ # line return
288
+ widget.translate(
289
+ self.left - widget.left, last.bottom - widget.top + buffer
290
+ )
291
+ elif (properties & ORIENTATION_HORIZONTAL) != 0:
292
+ widget.translate(last.right - widget.left + buffer, last.top - widget.top)
293
+ elif (properties & ORIENTATION_VERTICAL) != 0:
294
+ widget.translate(last.left - widget.left, last.bottom - widget.top + buffer)
295
+ if properties & ORIENTATION_CENTERED:
296
+ self.center_children()
297
+
298
+ def center_children(self):
299
+ """
300
+ Centers the children of the current widget within the current widget.
301
+ """
302
+ child_bounds = self.union_children_bounds()
303
+ dx = self.left - (child_bounds[0] + child_bounds[2]) / 2.0
304
+ dy = self.top - (child_bounds[1] + child_bounds[3]) / 2.0
305
+ if dx != 0 and dy != 0:
306
+ for w in self:
307
+ w.translate_loop(dx, dy)
308
+
309
+ def center_widget(self, x, y=None):
310
+ """
311
+ Moves the current widget to center within the bounds of the children.
312
+ """
313
+ if y is None:
314
+ y = x.y
315
+ x = x.x
316
+ child_bounds = self.union_children_bounds()
317
+ cx = (child_bounds[0] + child_bounds[2]) / 2.0
318
+ cy = (child_bounds[1] + child_bounds[3]) / 2.0
319
+ self.translate(x - cx, y - cy)
320
+
321
+ def set_position(self, x, y=None):
322
+ """
323
+ Sets the absolute position of this widget by moving it from its current position
324
+ to given position.
325
+ """
326
+ if y is None:
327
+ y = x.y
328
+ x = x.x
329
+ dx = x - self.left
330
+ dy = y - self.top
331
+ self.translate(dx, dy)
332
+
333
+ def add_widget(self, index=-1, widget=None, properties=None):
334
+ """
335
+ Add a widget to the current widget.
336
+
337
+ Adds at the particular index according to the properties.
338
+
339
+ The properties can be used to trigger particular layouts or properties for the added widget.
340
+ """
341
+ with self.scene.scene_lock:
342
+ if properties is None:
343
+ properties = self.properties
344
+ if len(self) == 0:
345
+ last = self
346
+ else:
347
+ last = self[-1]
348
+
349
+ if 0 <= index < len(self):
350
+ self.insert(index, widget)
351
+ else:
352
+ self.append(widget)
353
+ widget.parent = self
354
+ self.layout_by_orientation(widget, last, properties)
355
+ self.notify_added_to_parent(self)
356
+ self.notify_added_child(widget)
357
+
358
+ def remove_all_widgets(self):
359
+ """
360
+ Remove all widgets from the current widget.
361
+ """
362
+ with self.scene.scene_lock:
363
+ for w in self:
364
+ if w is None:
365
+ continue
366
+ w.parent = None
367
+ w.notify_removed_from_parent(self)
368
+ self.notify_removed_child(w)
369
+ self.clear()
370
+ try:
371
+ self.scene.notify_tree_changed()
372
+ except AttributeError:
373
+ pass
374
+
375
+ def remove_widget(self, widget=None):
376
+ """
377
+ Remove the given widget from being a child of the current widget.
378
+ """
379
+ if widget is None:
380
+ return
381
+ with self.scene.scene_lock:
382
+ if isinstance(widget, Widget):
383
+ for i, w in enumerate(self):
384
+ if w is widget:
385
+ del self[i]
386
+ elif isinstance(widget, int):
387
+ index = widget
388
+ widget = self[index]
389
+ del self[index]
390
+ widget.parent = None
391
+ widget.notify_removed_from_parent(self)
392
+ self.notify_removed_child(widget)
393
+ try:
394
+ self.scene.notify_tree_changed()
395
+ except AttributeError:
396
+ pass
397
+
398
+ def set_widget(self, index, widget):
399
+ """
400
+ Sets the given widget at the index to replace the child currently at the position of that widget.
401
+ """
402
+ with self.scene.scene_lock:
403
+ w = self[index]
404
+ self[index] = widget
405
+ widget.parent = self
406
+ widget.notify_added_to_parent(self)
407
+ self.notify_removed_child(w)
408
+ try:
409
+ self.scene.notify_tree_changed()
410
+ except AttributeError:
411
+ pass
412
+
413
+ def on_matrix_change(self):
414
+ """
415
+ Notification of a changed matrix.
416
+ """
417
+ pass
418
+
419
+ def scene_matrix_reset(self):
420
+ """
421
+ Resets the scene matrix.
422
+ """
423
+ self.matrix.reset()
424
+ self.on_matrix_change()
425
+
426
+ def scene_post_scale(self, sx, sy=None, ax=0, ay=0):
427
+ """
428
+ Adds a post_scale to the matrix.
429
+ """
430
+ self.matrix.post_scale(sx, sy, ax, ay)
431
+ self.on_matrix_change()
432
+
433
+ def scene_post_pan(self, px, py):
434
+ """
435
+ Adds a post_pan to the matrix.
436
+ """
437
+ self.matrix.post_translate(px, py)
438
+ self.on_matrix_change()
439
+
440
+ def scene_post_rotate(self, angle, rx=0, ry=0):
441
+ """
442
+ Adds a post_rotate to the matrix.
443
+ """
444
+ self.matrix.post_rotate(angle, rx, ry)
445
+ self.on_matrix_change()
446
+
447
+ def scene_pre_scale(self, sx, sy=None, ax=0, ay=0):
448
+ """
449
+ Adds a pre_scale to the matrix()
450
+ """
451
+ self.matrix.pre_scale(sx, sy, ax, ay)
452
+ self.on_matrix_change()
453
+
454
+ def scene_pre_pan(self, px, py):
455
+ """
456
+ Adds a pre_pan to the matrix()
457
+ """
458
+ self.matrix.pre_translate(px, py)
459
+ self.on_matrix_change()
460
+
461
+ def scene_pre_rotate(self, angle, rx=0, ry=0):
462
+ """
463
+ Adds a pre_rotate to the matrix()
464
+ """
465
+ self.matrix.pre_rotate(angle, rx, ry)
466
+ self.on_matrix_change()
467
+
468
+ def get_scale_x(self):
469
+ """
470
+ Gets the scale_x of the current matrix
471
+ """
472
+ return self.matrix.value_scale_x()
473
+
474
+ def get_scale_y(self):
475
+ """
476
+ Gets the scale_y of the current matrix
477
+ """
478
+ return self.matrix.value_scale_y()
479
+
480
+ def get_skew_x(self):
481
+ """
482
+ Gets the skew_x of the current matrix()
483
+ """
484
+ return self.matrix.value_skew_x()
485
+
486
+ def get_skew_y(self):
487
+ """
488
+ Gets the skew_y of the current matrix()
489
+ """
490
+ return self.matrix.value_skew_y()
491
+
492
+ def get_translate_x(self):
493
+ """
494
+ Gets the translate_x of the current matrix()
495
+ """
496
+ return self.matrix.value_trans_x()
497
+
498
+ def get_translate_y(self):
499
+ """
500
+ Gets the translate_y of the current matrix()
501
+ """
502
+ return self.matrix.value_trans_y()
503
+
504
+ def show(self, flag=None):
505
+ """
506
+ This does not automatically display the widget (yet)
507
+ """
508
+ if flag is None:
509
+ flag = True
510
+ self.visible = flag
511
+
512
+ def hide(self, flag=None):
513
+ """
514
+ This does not automatically display the widget (yet)
515
+ """
516
+ if flag is None:
517
+ flag = True
518
+ self.visible = not flag