meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7010__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.
- meerk40t/__init__.py +1 -1
- meerk40t/balormk/balor_params.py +167 -167
- meerk40t/balormk/clone_loader.py +457 -457
- meerk40t/balormk/controller.py +1566 -1512
- meerk40t/balormk/cylindermod.py +64 -0
- meerk40t/balormk/device.py +966 -1959
- meerk40t/balormk/driver.py +778 -591
- meerk40t/balormk/galvo_commands.py +1195 -0
- meerk40t/balormk/gui/balorconfig.py +237 -111
- meerk40t/balormk/gui/balorcontroller.py +191 -184
- meerk40t/balormk/gui/baloroperationproperties.py +116 -115
- meerk40t/balormk/gui/corscene.py +845 -0
- meerk40t/balormk/gui/gui.py +179 -147
- meerk40t/balormk/livelightjob.py +466 -382
- meerk40t/balormk/mock_connection.py +131 -109
- meerk40t/balormk/plugin.py +133 -135
- meerk40t/balormk/usb_connection.py +306 -301
- meerk40t/camera/__init__.py +1 -1
- meerk40t/camera/camera.py +514 -397
- meerk40t/camera/gui/camerapanel.py +1241 -1095
- meerk40t/camera/gui/gui.py +58 -58
- meerk40t/camera/plugin.py +441 -399
- meerk40t/ch341/__init__.py +27 -27
- meerk40t/ch341/ch341device.py +628 -628
- meerk40t/ch341/libusb.py +595 -589
- meerk40t/ch341/mock.py +171 -171
- meerk40t/ch341/windriver.py +157 -157
- meerk40t/constants.py +13 -0
- meerk40t/core/__init__.py +1 -1
- meerk40t/core/bindalias.py +550 -539
- meerk40t/core/core.py +47 -47
- meerk40t/core/cutcode/cubiccut.py +73 -73
- meerk40t/core/cutcode/cutcode.py +315 -312
- meerk40t/core/cutcode/cutgroup.py +141 -137
- meerk40t/core/cutcode/cutobject.py +192 -185
- meerk40t/core/cutcode/dwellcut.py +37 -37
- meerk40t/core/cutcode/gotocut.py +29 -29
- meerk40t/core/cutcode/homecut.py +29 -29
- meerk40t/core/cutcode/inputcut.py +34 -34
- meerk40t/core/cutcode/linecut.py +33 -33
- meerk40t/core/cutcode/outputcut.py +34 -34
- meerk40t/core/cutcode/plotcut.py +335 -335
- meerk40t/core/cutcode/quadcut.py +61 -61
- meerk40t/core/cutcode/rastercut.py +168 -148
- meerk40t/core/cutcode/waitcut.py +34 -34
- meerk40t/core/cutplan.py +1843 -1316
- meerk40t/core/drivers.py +330 -329
- meerk40t/core/elements/align.py +801 -669
- meerk40t/core/elements/branches.py +1844 -1507
- meerk40t/core/elements/clipboard.py +229 -219
- meerk40t/core/elements/element_treeops.py +4561 -2837
- meerk40t/core/elements/element_types.py +125 -105
- meerk40t/core/elements/elements.py +4329 -3617
- meerk40t/core/elements/files.py +117 -64
- meerk40t/core/elements/geometry.py +473 -224
- meerk40t/core/elements/grid.py +467 -316
- meerk40t/core/elements/materials.py +158 -94
- meerk40t/core/elements/notes.py +50 -38
- meerk40t/core/elements/offset_clpr.py +933 -912
- meerk40t/core/elements/offset_mk.py +963 -955
- meerk40t/core/elements/penbox.py +339 -267
- meerk40t/core/elements/placements.py +300 -83
- meerk40t/core/elements/render.py +785 -687
- meerk40t/core/elements/shapes.py +2618 -2092
- meerk40t/core/elements/trace.py +651 -563
- meerk40t/core/elements/tree_commands.py +415 -409
- meerk40t/core/elements/undo_redo.py +116 -58
- meerk40t/core/elements/wordlist.py +319 -200
- meerk40t/core/exceptions.py +9 -9
- meerk40t/core/laserjob.py +220 -220
- meerk40t/core/logging.py +63 -63
- meerk40t/core/node/blobnode.py +83 -86
- meerk40t/core/node/bootstrap.py +105 -103
- meerk40t/core/node/branch_elems.py +40 -31
- meerk40t/core/node/branch_ops.py +45 -38
- meerk40t/core/node/branch_regmark.py +48 -41
- meerk40t/core/node/cutnode.py +29 -32
- meerk40t/core/node/effect_hatch.py +375 -257
- meerk40t/core/node/effect_warp.py +398 -0
- meerk40t/core/node/effect_wobble.py +441 -309
- meerk40t/core/node/elem_ellipse.py +404 -309
- meerk40t/core/node/elem_image.py +1082 -801
- meerk40t/core/node/elem_line.py +358 -292
- meerk40t/core/node/elem_path.py +259 -201
- meerk40t/core/node/elem_point.py +129 -102
- meerk40t/core/node/elem_polyline.py +310 -246
- meerk40t/core/node/elem_rect.py +376 -286
- meerk40t/core/node/elem_text.py +445 -418
- meerk40t/core/node/filenode.py +59 -40
- meerk40t/core/node/groupnode.py +138 -74
- meerk40t/core/node/image_processed.py +777 -766
- meerk40t/core/node/image_raster.py +156 -113
- meerk40t/core/node/layernode.py +31 -31
- meerk40t/core/node/mixins.py +135 -107
- meerk40t/core/node/node.py +1427 -1304
- meerk40t/core/node/nutils.py +117 -114
- meerk40t/core/node/op_cut.py +462 -335
- meerk40t/core/node/op_dots.py +296 -251
- meerk40t/core/node/op_engrave.py +414 -311
- meerk40t/core/node/op_image.py +755 -369
- meerk40t/core/node/op_raster.py +787 -522
- meerk40t/core/node/place_current.py +37 -40
- meerk40t/core/node/place_point.py +329 -126
- meerk40t/core/node/refnode.py +58 -47
- meerk40t/core/node/rootnode.py +225 -219
- meerk40t/core/node/util_console.py +48 -48
- meerk40t/core/node/util_goto.py +84 -65
- meerk40t/core/node/util_home.py +61 -61
- meerk40t/core/node/util_input.py +102 -102
- meerk40t/core/node/util_output.py +102 -102
- meerk40t/core/node/util_wait.py +65 -65
- meerk40t/core/parameters.py +709 -707
- meerk40t/core/planner.py +875 -785
- meerk40t/core/plotplanner.py +656 -652
- meerk40t/core/space.py +120 -113
- meerk40t/core/spoolers.py +706 -705
- meerk40t/core/svg_io.py +1836 -1549
- meerk40t/core/treeop.py +534 -445
- meerk40t/core/undos.py +278 -124
- meerk40t/core/units.py +784 -680
- meerk40t/core/view.py +393 -322
- meerk40t/core/webhelp.py +62 -62
- meerk40t/core/wordlist.py +513 -504
- meerk40t/cylinder/cylinder.py +247 -0
- meerk40t/cylinder/gui/cylindersettings.py +41 -0
- meerk40t/cylinder/gui/gui.py +24 -0
- meerk40t/device/__init__.py +1 -1
- meerk40t/device/basedevice.py +322 -123
- meerk40t/device/devicechoices.py +50 -0
- meerk40t/device/dummydevice.py +163 -128
- meerk40t/device/gui/defaultactions.py +618 -602
- meerk40t/device/gui/effectspanel.py +114 -0
- meerk40t/device/gui/formatterpanel.py +253 -290
- meerk40t/device/gui/warningpanel.py +337 -260
- meerk40t/device/mixins.py +13 -13
- meerk40t/dxf/__init__.py +1 -1
- meerk40t/dxf/dxf_io.py +766 -554
- meerk40t/dxf/plugin.py +47 -35
- meerk40t/external_plugins.py +79 -79
- meerk40t/external_plugins_build.py +28 -28
- meerk40t/extra/cag.py +112 -116
- meerk40t/extra/coolant.py +403 -0
- meerk40t/extra/encode_detect.py +198 -0
- meerk40t/extra/ezd.py +1165 -1165
- meerk40t/extra/hershey.py +835 -340
- meerk40t/extra/imageactions.py +322 -316
- meerk40t/extra/inkscape.py +630 -622
- meerk40t/extra/lbrn.py +424 -424
- meerk40t/extra/outerworld.py +284 -0
- meerk40t/extra/param_functions.py +1542 -1556
- meerk40t/extra/potrace.py +257 -253
- meerk40t/extra/serial_exchange.py +118 -0
- meerk40t/extra/updater.py +602 -453
- meerk40t/extra/vectrace.py +147 -146
- meerk40t/extra/winsleep.py +83 -83
- meerk40t/extra/xcs_reader.py +597 -0
- meerk40t/fill/fills.py +781 -335
- meerk40t/fill/patternfill.py +1061 -1061
- meerk40t/fill/patterns.py +614 -567
- meerk40t/grbl/control.py +87 -87
- meerk40t/grbl/controller.py +990 -903
- meerk40t/grbl/device.py +1081 -768
- meerk40t/grbl/driver.py +989 -771
- meerk40t/grbl/emulator.py +532 -497
- meerk40t/grbl/gcodejob.py +783 -767
- meerk40t/grbl/gui/grblconfiguration.py +373 -298
- meerk40t/grbl/gui/grblcontroller.py +485 -271
- meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
- meerk40t/grbl/gui/grbloperationconfig.py +105 -0
- meerk40t/grbl/gui/gui.py +147 -116
- meerk40t/grbl/interpreter.py +44 -44
- meerk40t/grbl/loader.py +22 -22
- meerk40t/grbl/mock_connection.py +56 -56
- meerk40t/grbl/plugin.py +294 -264
- meerk40t/grbl/serial_connection.py +93 -88
- meerk40t/grbl/tcp_connection.py +81 -79
- meerk40t/grbl/ws_connection.py +112 -0
- meerk40t/gui/__init__.py +1 -1
- meerk40t/gui/about.py +2042 -296
- meerk40t/gui/alignment.py +1644 -1608
- meerk40t/gui/autoexec.py +199 -0
- meerk40t/gui/basicops.py +791 -670
- meerk40t/gui/bufferview.py +77 -71
- meerk40t/gui/busy.py +170 -133
- meerk40t/gui/choicepropertypanel.py +1673 -1469
- meerk40t/gui/consolepanel.py +706 -542
- meerk40t/gui/devicepanel.py +687 -581
- meerk40t/gui/dialogoptions.py +110 -107
- meerk40t/gui/executejob.py +316 -306
- meerk40t/gui/fonts.py +90 -90
- meerk40t/gui/functionwrapper.py +252 -0
- meerk40t/gui/gui_mixins.py +729 -0
- meerk40t/gui/guicolors.py +205 -182
- meerk40t/gui/help_assets/help_assets.py +218 -201
- meerk40t/gui/helper.py +154 -0
- meerk40t/gui/hersheymanager.py +1430 -846
- meerk40t/gui/icons.py +3422 -2747
- meerk40t/gui/imagesplitter.py +555 -508
- meerk40t/gui/keymap.py +354 -344
- meerk40t/gui/laserpanel.py +892 -806
- meerk40t/gui/laserrender.py +1470 -1232
- meerk40t/gui/lasertoolpanel.py +805 -793
- meerk40t/gui/magnetoptions.py +436 -0
- meerk40t/gui/materialmanager.py +2917 -0
- meerk40t/gui/materialtest.py +1722 -1694
- meerk40t/gui/mkdebug.py +646 -359
- meerk40t/gui/mwindow.py +163 -140
- meerk40t/gui/navigationpanels.py +2605 -2467
- meerk40t/gui/notes.py +143 -142
- meerk40t/gui/opassignment.py +414 -410
- meerk40t/gui/operation_info.py +310 -299
- meerk40t/gui/plugin.py +494 -328
- meerk40t/gui/position.py +714 -669
- meerk40t/gui/preferences.py +901 -650
- meerk40t/gui/propertypanels/attributes.py +1461 -1131
- meerk40t/gui/propertypanels/blobproperty.py +117 -114
- meerk40t/gui/propertypanels/consoleproperty.py +83 -80
- meerk40t/gui/propertypanels/gotoproperty.py +77 -0
- meerk40t/gui/propertypanels/groupproperties.py +223 -217
- meerk40t/gui/propertypanels/hatchproperty.py +489 -469
- meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
- meerk40t/gui/propertypanels/inputproperty.py +59 -58
- meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
- meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
- meerk40t/gui/propertypanels/outputproperty.py +59 -58
- meerk40t/gui/propertypanels/pathproperty.py +389 -380
- meerk40t/gui/propertypanels/placementproperty.py +1214 -383
- meerk40t/gui/propertypanels/pointproperty.py +140 -136
- meerk40t/gui/propertypanels/propertywindow.py +313 -181
- meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
- meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
- meerk40t/gui/propertypanels/textproperty.py +770 -755
- meerk40t/gui/propertypanels/waitproperty.py +56 -55
- meerk40t/gui/propertypanels/warpproperty.py +121 -0
- meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
- meerk40t/gui/ribbon.py +2468 -2210
- meerk40t/gui/scene/scene.py +1100 -1051
- meerk40t/gui/scene/sceneconst.py +22 -22
- meerk40t/gui/scene/scenepanel.py +439 -349
- meerk40t/gui/scene/scenespacewidget.py +365 -365
- meerk40t/gui/scene/widget.py +518 -505
- meerk40t/gui/scenewidgets/affinemover.py +215 -215
- meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
- meerk40t/gui/scenewidgets/bedwidget.py +120 -97
- meerk40t/gui/scenewidgets/elementswidget.py +137 -107
- meerk40t/gui/scenewidgets/gridwidget.py +785 -745
- meerk40t/gui/scenewidgets/guidewidget.py +765 -765
- meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
- meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
- meerk40t/gui/scenewidgets/nodeselector.py +28 -28
- meerk40t/gui/scenewidgets/rectselectwidget.py +589 -346
- meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
- meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
- meerk40t/gui/scenewidgets/selectionwidget.py +2952 -2756
- meerk40t/gui/simpleui.py +357 -333
- meerk40t/gui/simulation.py +2431 -2094
- meerk40t/gui/snapoptions.py +208 -203
- meerk40t/gui/spoolerpanel.py +1227 -1180
- meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
- meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
- meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
- meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
- meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
- meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
- meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
- meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
- meerk40t/gui/themes.py +200 -78
- meerk40t/gui/tips.py +591 -0
- meerk40t/gui/toolwidgets/circlebrush.py +35 -35
- meerk40t/gui/toolwidgets/toolcircle.py +248 -242
- meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
- meerk40t/gui/toolwidgets/tooldraw.py +97 -90
- meerk40t/gui/toolwidgets/toolellipse.py +219 -212
- meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
- meerk40t/gui/toolwidgets/toolline.py +39 -144
- meerk40t/gui/toolwidgets/toollinetext.py +79 -236
- meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
- meerk40t/gui/toolwidgets/toolmeasure.py +160 -216
- meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
- meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
- meerk40t/gui/toolwidgets/toolparameter.py +754 -668
- meerk40t/gui/toolwidgets/toolplacement.py +108 -108
- meerk40t/gui/toolwidgets/toolpoint.py +68 -59
- meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
- meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
- meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
- meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
- meerk40t/gui/toolwidgets/toolrect.py +211 -207
- meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
- meerk40t/gui/toolwidgets/toolribbon.py +598 -113
- meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
- meerk40t/gui/toolwidgets/tooltext.py +98 -89
- meerk40t/gui/toolwidgets/toolvector.py +213 -204
- meerk40t/gui/toolwidgets/toolwidget.py +39 -39
- meerk40t/gui/usbconnect.py +98 -91
- meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
- meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
- meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
- meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
- meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
- meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
- meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
- meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
- meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
- meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
- meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
- meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
- meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
- meerk40t/gui/wordlisteditor.py +985 -931
- meerk40t/gui/wxmeerk40t.py +1444 -1169
- meerk40t/gui/wxmmain.py +5578 -4112
- meerk40t/gui/wxmribbon.py +1591 -1076
- meerk40t/gui/wxmscene.py +1635 -1453
- meerk40t/gui/wxmtree.py +2410 -2089
- meerk40t/gui/wxutils.py +1769 -1099
- meerk40t/gui/zmatrix.py +102 -102
- meerk40t/image/__init__.py +1 -1
- meerk40t/image/dither.py +429 -0
- meerk40t/image/imagetools.py +2778 -2269
- meerk40t/internal_plugins.py +150 -130
- meerk40t/kernel/__init__.py +63 -12
- meerk40t/kernel/channel.py +259 -212
- meerk40t/kernel/context.py +538 -538
- meerk40t/kernel/exceptions.py +41 -41
- meerk40t/kernel/functions.py +463 -414
- meerk40t/kernel/jobs.py +100 -100
- meerk40t/kernel/kernel.py +3809 -3571
- meerk40t/kernel/lifecycles.py +71 -71
- meerk40t/kernel/module.py +49 -49
- meerk40t/kernel/service.py +147 -147
- meerk40t/kernel/settings.py +383 -343
- meerk40t/lihuiyu/controller.py +883 -876
- meerk40t/lihuiyu/device.py +1181 -1069
- meerk40t/lihuiyu/driver.py +1466 -1372
- meerk40t/lihuiyu/gui/gui.py +127 -106
- meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
- meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
- meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
- meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
- meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
- meerk40t/lihuiyu/interpreter.py +53 -53
- meerk40t/lihuiyu/laserspeed.py +450 -450
- meerk40t/lihuiyu/loader.py +90 -90
- meerk40t/lihuiyu/parser.py +404 -404
- meerk40t/lihuiyu/plugin.py +101 -102
- meerk40t/lihuiyu/tcp_connection.py +111 -109
- meerk40t/main.py +231 -165
- meerk40t/moshi/builder.py +788 -781
- meerk40t/moshi/controller.py +505 -499
- meerk40t/moshi/device.py +495 -442
- meerk40t/moshi/driver.py +862 -696
- meerk40t/moshi/gui/gui.py +78 -76
- meerk40t/moshi/gui/moshicontrollergui.py +538 -522
- meerk40t/moshi/gui/moshidrivergui.py +87 -75
- meerk40t/moshi/plugin.py +43 -43
- meerk40t/network/console_server.py +102 -57
- meerk40t/network/kernelserver.py +10 -9
- meerk40t/network/tcp_server.py +142 -140
- meerk40t/network/udp_server.py +103 -77
- meerk40t/network/web_server.py +390 -0
- meerk40t/newly/controller.py +1158 -1144
- meerk40t/newly/device.py +874 -732
- meerk40t/newly/driver.py +540 -412
- meerk40t/newly/gui/gui.py +219 -188
- meerk40t/newly/gui/newlyconfig.py +116 -101
- meerk40t/newly/gui/newlycontroller.py +193 -186
- meerk40t/newly/gui/operationproperties.py +51 -51
- meerk40t/newly/mock_connection.py +82 -82
- meerk40t/newly/newly_params.py +56 -56
- meerk40t/newly/plugin.py +1214 -1246
- meerk40t/newly/usb_connection.py +322 -322
- meerk40t/rotary/gui/gui.py +52 -46
- meerk40t/rotary/gui/rotarysettings.py +240 -232
- meerk40t/rotary/rotary.py +202 -98
- meerk40t/ruida/control.py +291 -91
- meerk40t/ruida/controller.py +138 -1088
- meerk40t/ruida/device.py +672 -231
- meerk40t/ruida/driver.py +534 -472
- meerk40t/ruida/emulator.py +1494 -1491
- meerk40t/ruida/exceptions.py +4 -4
- meerk40t/ruida/gui/gui.py +71 -76
- meerk40t/ruida/gui/ruidaconfig.py +239 -72
- meerk40t/ruida/gui/ruidacontroller.py +187 -184
- meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
- meerk40t/ruida/loader.py +54 -52
- meerk40t/ruida/mock_connection.py +57 -109
- meerk40t/ruida/plugin.py +124 -87
- meerk40t/ruida/rdjob.py +2084 -945
- meerk40t/ruida/serial_connection.py +116 -0
- meerk40t/ruida/tcp_connection.py +146 -0
- meerk40t/ruida/udp_connection.py +73 -0
- meerk40t/svgelements.py +9671 -9669
- meerk40t/tools/driver_to_path.py +584 -579
- meerk40t/tools/geomstr.py +5583 -4680
- meerk40t/tools/jhfparser.py +357 -292
- meerk40t/tools/kerftest.py +904 -890
- meerk40t/tools/livinghinges.py +1168 -1033
- meerk40t/tools/pathtools.py +987 -949
- meerk40t/tools/pmatrix.py +234 -0
- meerk40t/tools/pointfinder.py +942 -942
- meerk40t/tools/polybool.py +940 -940
- meerk40t/tools/rasterplotter.py +1660 -547
- meerk40t/tools/shxparser.py +989 -901
- meerk40t/tools/ttfparser.py +726 -446
- meerk40t/tools/zinglplotter.py +595 -593
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/LICENSE +21 -21
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/METADATA +150 -139
- meerk40t-0.9.7010.dist-info/RECORD +445 -0
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/WHEEL +1 -1
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/top_level.txt +0 -1
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/zip-safe +1 -1
- meerk40t/balormk/elementlightjob.py +0 -159
- meerk40t-0.9.3001.dist-info/RECORD +0 -437
- test/bootstrap.py +0 -63
- test/test_cli.py +0 -12
- test/test_core_cutcode.py +0 -418
- test/test_core_elements.py +0 -144
- test/test_core_plotplanner.py +0 -397
- test/test_core_viewports.py +0 -312
- test/test_drivers_grbl.py +0 -108
- test/test_drivers_lihuiyu.py +0 -443
- test/test_drivers_newly.py +0 -113
- test/test_element_degenerate_points.py +0 -43
- test/test_elements_classify.py +0 -97
- test/test_elements_penbox.py +0 -22
- test/test_file_svg.py +0 -176
- test/test_fill.py +0 -155
- test/test_geomstr.py +0 -1523
- test/test_geomstr_nodes.py +0 -18
- test/test_imagetools_actualize.py +0 -306
- test/test_imagetools_wizard.py +0 -258
- test/test_kernel.py +0 -200
- test/test_laser_speeds.py +0 -3303
- test/test_length.py +0 -57
- test/test_lifecycle.py +0 -66
- test/test_operations.py +0 -251
- test/test_operations_hatch.py +0 -57
- test/test_ruida.py +0 -19
- test/test_spooler.py +0 -22
- test/test_tools_rasterplotter.py +0 -29
- test/test_wobble.py +0 -133
- test/test_zingl.py +0 -124
- {test → meerk40t/cylinder}/__init__.py +0 -0
- /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/entry_points.txt +0 -0
meerk40t/gui/hersheymanager.py
CHANGED
@@ -1,846 +1,1430 @@
|
|
1
|
-
import os
|
2
|
-
import platform
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
import
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
self
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
self.
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
self
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
self.
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
self.
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
)
|
412
|
-
|
413
|
-
self.
|
414
|
-
self.
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
)
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
self.
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
self.
|
481
|
-
self.
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
self.
|
488
|
-
|
489
|
-
|
490
|
-
self.
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
self.
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
if
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
self.
|
521
|
-
|
522
|
-
self.
|
523
|
-
|
524
|
-
|
525
|
-
self.
|
526
|
-
|
527
|
-
self.
|
528
|
-
|
529
|
-
self.
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
self.
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
if
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
if
|
650
|
-
return
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
)
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
)
|
798
|
-
|
799
|
-
self.
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
)
|
1
|
+
import os
|
2
|
+
import platform
|
3
|
+
import wx
|
4
|
+
|
5
|
+
from meerk40t.core.units import Length
|
6
|
+
from meerk40t.gui.choicepropertypanel import ChoicePropertyPanel
|
7
|
+
from meerk40t.gui.icons import (
|
8
|
+
STD_ICON_SIZE,
|
9
|
+
get_default_icon_size,
|
10
|
+
icon_kerning_bigger,
|
11
|
+
icon_kerning_smaller,
|
12
|
+
icon_linegap_bigger,
|
13
|
+
icon_linegap_smaller,
|
14
|
+
icon_textalign_center,
|
15
|
+
icon_textalign_left,
|
16
|
+
icon_textalign_right,
|
17
|
+
icon_textsize_down,
|
18
|
+
icon_textsize_up,
|
19
|
+
icons8_choose_font,
|
20
|
+
)
|
21
|
+
from meerk40t.gui.mwindow import MWindow
|
22
|
+
from meerk40t.gui.wxutils import (
|
23
|
+
StaticBoxSizer,
|
24
|
+
dip_size,
|
25
|
+
wxButton,
|
26
|
+
wxCheckBox,
|
27
|
+
wxComboBox,
|
28
|
+
wxListBox,
|
29
|
+
wxListCtrl,
|
30
|
+
wxStaticBitmap,
|
31
|
+
wxStaticText,
|
32
|
+
wxToggleButton,
|
33
|
+
TextCtrl,
|
34
|
+
)
|
35
|
+
from meerk40t.kernel.kernel import signal_listener
|
36
|
+
from meerk40t.tools.geomstr import TYPE_ARC, TYPE_CUBIC, TYPE_LINE, TYPE_QUAD, Geomstr
|
37
|
+
|
38
|
+
_ = wx.GetTranslation
|
39
|
+
|
40
|
+
|
41
|
+
def remove_fontfile(fontfile):
|
42
|
+
if os.path.exists(fontfile):
|
43
|
+
try:
|
44
|
+
os.remove(fontfile)
|
45
|
+
base, ext = os.path.splitext(fontfile)
|
46
|
+
bmpfile = base + ".png"
|
47
|
+
if os.path.exists(bmpfile):
|
48
|
+
os.remove(bmpfile)
|
49
|
+
except (OSError, RuntimeError, PermissionError, FileNotFoundError):
|
50
|
+
pass
|
51
|
+
|
52
|
+
|
53
|
+
class FontGlyphPicker(wx.Dialog):
|
54
|
+
"""
|
55
|
+
Dialog to pick a glyph from the existing set of characters in a font
|
56
|
+
"""
|
57
|
+
|
58
|
+
def __init__(self, *args, context=None, font=None, **kwds):
|
59
|
+
# begin wxGlade: clsLasertools.__init__
|
60
|
+
kwds["style"] = (
|
61
|
+
kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
|
62
|
+
)
|
63
|
+
wx.Dialog.__init__(self, *args, **kwds)
|
64
|
+
self.context = context
|
65
|
+
self.context.themes.set_window_colors(self)
|
66
|
+
self.font = font
|
67
|
+
self.icon_size = 32
|
68
|
+
mainsizer = wx.BoxSizer(wx.VERTICAL)
|
69
|
+
self.list_glyphs = wxListCtrl(
|
70
|
+
self,
|
71
|
+
wx.ID_ANY,
|
72
|
+
style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES | wx.LC_SINGLE_SEL,
|
73
|
+
context=self.context, list_name="list_glyphpicker"
|
74
|
+
)
|
75
|
+
self.list_glyphs.AppendColumn("UC", format=wx.LIST_FORMAT_LEFT, width=75)
|
76
|
+
self.list_glyphs.AppendColumn("ASCII", format=wx.LIST_FORMAT_LEFT, width=75)
|
77
|
+
self.list_glyphs.AppendColumn("Char", format=wx.LIST_FORMAT_LEFT, width=75)
|
78
|
+
self.list_glyphs.AppendColumn("Debug", format=wx.LIST_FORMAT_LEFT, width=125)
|
79
|
+
self.images = wx.ImageList()
|
80
|
+
self.images.Create(width=self.icon_size, height=self.icon_size)
|
81
|
+
self.list_glyphs.AssignImageList(self.images, wx.IMAGE_LIST_SMALL)
|
82
|
+
self.txt_result = TextCtrl(self, wx.ID_ANY)
|
83
|
+
mainsizer.Add(self.list_glyphs, 1, wx.EXPAND, 0)
|
84
|
+
mainsizer.Add(self.txt_result, 0, wx.EXPAND, 0)
|
85
|
+
|
86
|
+
self.btn_ok = wxButton(self, wx.ID_OK, _("OK"))
|
87
|
+
self.btn_cancel = wxButton(self, wx.ID_CANCEL, _("Cancel"))
|
88
|
+
box_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
89
|
+
box_sizer.Add(self.btn_ok, 0, 0, 0)
|
90
|
+
box_sizer.Add(self.btn_cancel, 0, 0, 0)
|
91
|
+
mainsizer.Add(box_sizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
|
92
|
+
|
93
|
+
self.list_glyphs.Bind(wx.EVT_LEFT_DCLICK, self.on_dbl_click)
|
94
|
+
self.SetSizer(mainsizer)
|
95
|
+
self.list_glyphs.load_column_widths()
|
96
|
+
self.Layout()
|
97
|
+
# end wxGlade
|
98
|
+
self.load_font()
|
99
|
+
|
100
|
+
def load_font(self):
|
101
|
+
def geomstr_to_gcpath(gc, path):
|
102
|
+
"""
|
103
|
+
Takes a Geomstr path and converts it to a GraphicsContext.Graphics path
|
104
|
+
|
105
|
+
This also creates a point list of the relevant nodes and creates a ._cache_edit value to be used by node
|
106
|
+
editing view.
|
107
|
+
"""
|
108
|
+
p = gc.CreatePath()
|
109
|
+
pts = list()
|
110
|
+
for subpath in path.as_subpaths():
|
111
|
+
if len(subpath) == 0:
|
112
|
+
continue
|
113
|
+
end = None
|
114
|
+
for e in subpath.segments:
|
115
|
+
seg_type = int(e[2].real)
|
116
|
+
start = e[0]
|
117
|
+
if end != start:
|
118
|
+
# Start point does not equal previous end point.
|
119
|
+
p.MoveToPoint(start.real, start.imag)
|
120
|
+
c0 = e[1]
|
121
|
+
c1 = e[3]
|
122
|
+
end = e[4]
|
123
|
+
|
124
|
+
if seg_type == TYPE_LINE:
|
125
|
+
p.AddLineToPoint(end.real, end.imag)
|
126
|
+
pts.append(start)
|
127
|
+
pts.append(end)
|
128
|
+
elif seg_type == TYPE_QUAD:
|
129
|
+
p.AddQuadCurveToPoint(c0.real, c0.imag, end.real, end.imag)
|
130
|
+
pts.append(c0)
|
131
|
+
pts.append(start)
|
132
|
+
pts.append(end)
|
133
|
+
elif seg_type == TYPE_ARC:
|
134
|
+
radius = Geomstr.arc_radius(None, line=e)
|
135
|
+
center = Geomstr.arc_center(None, line=e)
|
136
|
+
start_t = Geomstr.angle(None, center, start)
|
137
|
+
end_t = Geomstr.angle(None, center, end)
|
138
|
+
p.AddArc(
|
139
|
+
center.real,
|
140
|
+
center.imag,
|
141
|
+
radius,
|
142
|
+
start_t,
|
143
|
+
end_t,
|
144
|
+
clockwise="ccw"
|
145
|
+
!= Geomstr.orientation(None, start, c0, end),
|
146
|
+
)
|
147
|
+
pts.append(c0)
|
148
|
+
pts.append(start)
|
149
|
+
pts.append(end)
|
150
|
+
elif seg_type == TYPE_CUBIC:
|
151
|
+
p.AddCurveToPoint(
|
152
|
+
c0.real, c0.imag, c1.real, c1.imag, end.real, end.imag
|
153
|
+
)
|
154
|
+
pts.append(c0)
|
155
|
+
pts.append(c1)
|
156
|
+
pts.append(start)
|
157
|
+
pts.append(end)
|
158
|
+
else:
|
159
|
+
print(f"Unknown seg_type: {seg_type}")
|
160
|
+
if subpath.first_point == end:
|
161
|
+
p.CloseSubpath()
|
162
|
+
return p
|
163
|
+
|
164
|
+
def prepare_bitmap(geom, final_icon_width, final_icon_height, as_stroke=False):
|
165
|
+
edge = 1
|
166
|
+
strokewidth = 1
|
167
|
+
wincol = self.context.themes.get("win_bg")
|
168
|
+
strcol = self.context.themes.get("win_fg")
|
169
|
+
|
170
|
+
spen = wx.Pen()
|
171
|
+
sbrush = wx.Brush()
|
172
|
+
spen.SetColour(strcol)
|
173
|
+
sbrush.SetColour(strcol)
|
174
|
+
spen.SetWidth(strokewidth)
|
175
|
+
spen.SetCap(wx.CAP_ROUND)
|
176
|
+
spen.SetJoin(wx.JOIN_ROUND)
|
177
|
+
|
178
|
+
bmp = wx.Bitmap.FromRGBA(
|
179
|
+
final_icon_width,
|
180
|
+
final_icon_height,
|
181
|
+
wincol.red,
|
182
|
+
wincol.blue,
|
183
|
+
wincol.green,
|
184
|
+
0,
|
185
|
+
)
|
186
|
+
dc = wx.MemoryDC()
|
187
|
+
dc.SelectObject(bmp)
|
188
|
+
# dc.SetBackground(self._background)
|
189
|
+
# dc.SetBackground(wx.RED_BRUSH)
|
190
|
+
# dc.Clear()
|
191
|
+
gc = wx.GraphicsContext.Create(dc)
|
192
|
+
gc.dc = dc
|
193
|
+
|
194
|
+
gp = geomstr_to_gcpath(gc, geom)
|
195
|
+
m_x, m_y, p_w, p_h = gp.Box
|
196
|
+
min_x = m_x
|
197
|
+
min_y = m_y
|
198
|
+
max_x = m_x + p_w
|
199
|
+
max_y = m_y + p_h
|
200
|
+
|
201
|
+
path_width = max_x - min_x
|
202
|
+
path_height = max_y - min_y
|
203
|
+
|
204
|
+
path_width += 2 * edge
|
205
|
+
path_height += 2 * edge
|
206
|
+
|
207
|
+
stroke_buffer = strokewidth
|
208
|
+
path_width += 2 * stroke_buffer
|
209
|
+
path_height += 2 * stroke_buffer
|
210
|
+
|
211
|
+
scale_x = final_icon_width / path_width
|
212
|
+
scale_y = final_icon_height / path_height
|
213
|
+
|
214
|
+
scale = min(scale_x, scale_y)
|
215
|
+
width_scaled = int(round(path_width * scale))
|
216
|
+
height_scaled = int(round(path_height * scale))
|
217
|
+
|
218
|
+
# print (f"W: {final_icon_width} vs {width_scaled}, {final_icon_height} vs {height_scaled}")
|
219
|
+
keep_ratio = True
|
220
|
+
|
221
|
+
if keep_ratio:
|
222
|
+
scale_x = min(scale_x, scale_y)
|
223
|
+
scale_y = scale_x
|
224
|
+
|
225
|
+
from meerk40t.gui.zmatrix import ZMatrix
|
226
|
+
from meerk40t.svgelements import Matrix
|
227
|
+
|
228
|
+
matrix = Matrix()
|
229
|
+
matrix.post_translate(
|
230
|
+
-min_x
|
231
|
+
+ edge
|
232
|
+
+ stroke_buffer
|
233
|
+
+ (final_icon_width - width_scaled) / 2 / scale_x,
|
234
|
+
-min_y
|
235
|
+
+ edge
|
236
|
+
+ stroke_buffer
|
237
|
+
+ (final_icon_height - height_scaled) / 2 / scale_x,
|
238
|
+
)
|
239
|
+
matrix.post_scale(scale_x, scale_y)
|
240
|
+
if scale_y < 0:
|
241
|
+
matrix.pre_translate(0, -height_scaled)
|
242
|
+
if scale_x < 0:
|
243
|
+
matrix.pre_translate(-width_scaled, 0)
|
244
|
+
|
245
|
+
gc = wx.GraphicsContext.Create(dc)
|
246
|
+
gc.dc = dc
|
247
|
+
gc.SetInterpolationQuality(wx.INTERPOLATION_BEST)
|
248
|
+
gc.PushState()
|
249
|
+
if not matrix.is_identity():
|
250
|
+
gc.ConcatTransform(wx.GraphicsContext.CreateMatrix(gc, ZMatrix(matrix)))
|
251
|
+
if as_stroke:
|
252
|
+
gc.SetPen(spen)
|
253
|
+
gc.StrokePath(gp)
|
254
|
+
else:
|
255
|
+
gc.SetBrush(sbrush)
|
256
|
+
gc.FillPath(gp, fillStyle=wx.WINDING_RULE)
|
257
|
+
dc.SelectObject(wx.NullBitmap)
|
258
|
+
gc.Destroy()
|
259
|
+
del gc.dc
|
260
|
+
del dc
|
261
|
+
return bmp
|
262
|
+
|
263
|
+
def getbitmap(geom, icon_size, as_stroke=False):
|
264
|
+
final_icon_height = int(icon_size)
|
265
|
+
final_icon_width = int(icon_size)
|
266
|
+
if final_icon_height <= 0:
|
267
|
+
final_icon_height = 1
|
268
|
+
if final_icon_width <= 0:
|
269
|
+
final_icon_width = 1
|
270
|
+
bmp = prepare_bitmap(
|
271
|
+
geom, final_icon_width, final_icon_height, as_stroke=as_stroke
|
272
|
+
)
|
273
|
+
return bmp
|
274
|
+
|
275
|
+
self.list_glyphs.DeleteAllItems()
|
276
|
+
self.images.RemoveAll()
|
277
|
+
from meerk40t.extra.hershey import FontPath
|
278
|
+
|
279
|
+
fontfile = self.context.fonts.full_name(self.font)
|
280
|
+
|
281
|
+
cfont = self.context.fonts.cached_fontclass(fontfile)
|
282
|
+
if cfont is None:
|
283
|
+
return
|
284
|
+
as_stroke = getattr(cfont, "STROKE_BASED", False)
|
285
|
+
for c in cfont.glyphs:
|
286
|
+
if ord(c) == 65535:
|
287
|
+
continue
|
288
|
+
cstr = str(c)
|
289
|
+
hexa = cstr.encode("utf-8")
|
290
|
+
item = self.list_glyphs.InsertItem(self.list_glyphs.ItemCount, hexa)
|
291
|
+
self.list_glyphs.SetItem(item, 1, str(ord(cstr)))
|
292
|
+
self.list_glyphs.SetItem(item, 2, cstr)
|
293
|
+
path = FontPath(False)
|
294
|
+
try:
|
295
|
+
cfont.render(
|
296
|
+
path,
|
297
|
+
c,
|
298
|
+
True,
|
299
|
+
12.0,
|
300
|
+
1.0,
|
301
|
+
1.1,
|
302
|
+
"left",
|
303
|
+
)
|
304
|
+
# path contains now the geometry...
|
305
|
+
okay = True
|
306
|
+
except Exception as e:
|
307
|
+
self.list_glyphs.SetItem(item, 3, str(e))
|
308
|
+
okay = False
|
309
|
+
# path contains now the geometry...
|
310
|
+
if okay:
|
311
|
+
geo = path.geometry
|
312
|
+
# print (f"Length {geo.index} after rendering: {ord(c)} / '{hexa}'")
|
313
|
+
bmp = getbitmap(geo, self.icon_size, as_stroke=as_stroke)
|
314
|
+
if bmp is not None:
|
315
|
+
image_index = self.images.Add(bmp)
|
316
|
+
self.list_glyphs.SetItemImage(item, image_index)
|
317
|
+
else:
|
318
|
+
self.list_glyphs.SetItem(item, 3, "Could not create bitmap")
|
319
|
+
# for idx in range(self.images.GetImageCount()):
|
320
|
+
# bmp = self.images.GetBitmap(idx)
|
321
|
+
# bmp.SaveFile(f"C:\\temp\\bmp_{idx}.png", type=wx.BITMAP_TYPE_PNG)
|
322
|
+
|
323
|
+
def on_dbl_click(self, event):
|
324
|
+
# Get the ascii code
|
325
|
+
x, y = event.GetPosition()
|
326
|
+
row_id, flags = self.list_glyphs.HitTest((x, y))
|
327
|
+
if row_id < 0:
|
328
|
+
return
|
329
|
+
listitem = self.list_glyphs.GetItem(row_id, 1)
|
330
|
+
data = listitem.GetText()
|
331
|
+
try:
|
332
|
+
code = int(data)
|
333
|
+
except ValueError:
|
334
|
+
return
|
335
|
+
content = self.txt_result.GetValue() + chr(code)
|
336
|
+
self.txt_result.ChangeValue(content)
|
337
|
+
|
338
|
+
def result(self):
|
339
|
+
return self.txt_result.GetValue()
|
340
|
+
|
341
|
+
|
342
|
+
class LineTextPropertyPanel(wx.Panel):
|
343
|
+
"""
|
344
|
+
Panel for post-creation text property editing
|
345
|
+
"""
|
346
|
+
|
347
|
+
def __init__(
|
348
|
+
self,
|
349
|
+
*args,
|
350
|
+
context=None,
|
351
|
+
node=None,
|
352
|
+
**kwds,
|
353
|
+
):
|
354
|
+
# begin wxGlade: LayerSettingPanel.__init__
|
355
|
+
kwds["style"] = kwds.get("style", 0)
|
356
|
+
wx.Panel.__init__(self, *args, **kwds)
|
357
|
+
self.context = context
|
358
|
+
self.context.themes.set_window_colors(self)
|
359
|
+
self.context.setting(float, "last_font_size", float(Length("20px")))
|
360
|
+
self.context.setting(str, "last_font", "")
|
361
|
+
|
362
|
+
self.node = node
|
363
|
+
self.fonts = []
|
364
|
+
|
365
|
+
# We neeed this to avoid a crash under Linux when textselection is called too quickly
|
366
|
+
self._islinux = platform.system() == "Linux"
|
367
|
+
|
368
|
+
main_sizer = StaticBoxSizer(self, wx.ID_ANY, _("Vector-Text"), wx.VERTICAL)
|
369
|
+
|
370
|
+
sizer_text = StaticBoxSizer(self, wx.ID_ANY, _("Content"), wx.HORIZONTAL)
|
371
|
+
self.text_text = TextCtrl(
|
372
|
+
self, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_MULTILINE
|
373
|
+
)
|
374
|
+
sizer_text.Add(self.text_text, 1, wx.EXPAND, 0)
|
375
|
+
|
376
|
+
text_options = StaticBoxSizer(self, wx.ID_ANY, "", wx.HORIZONTAL)
|
377
|
+
|
378
|
+
iconsize = dip_size(self, 25, 25)[0]
|
379
|
+
|
380
|
+
align_options = (_("Left"), _("Center"), _("Right"))
|
381
|
+
align_icons = (icon_textalign_left, icon_textalign_center, icon_textalign_right)
|
382
|
+
self.rb_align = []
|
383
|
+
ttip_main = _("Textalignment for multi-lines")
|
384
|
+
for ttip_sub, icon in zip(align_options, align_icons):
|
385
|
+
btn = wxToggleButton(self, wx.ID_ANY)
|
386
|
+
btn.SetToolTip(f"{ttip_main}: {ttip_sub}")
|
387
|
+
btn.SetValue(False)
|
388
|
+
btn.SetBitmap(icon.GetBitmap(resize=iconsize))
|
389
|
+
self.rb_align.append(btn)
|
390
|
+
text_options.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
391
|
+
|
392
|
+
text_options.AddSpacer(25)
|
393
|
+
|
394
|
+
self.btn_bigger = wxButton(self, wx.ID_ANY)
|
395
|
+
self.btn_bigger.SetToolTip(_("Increase the font-size"))
|
396
|
+
self.btn_bigger.SetBitmap(icon_textsize_up.GetBitmap(resize=iconsize))
|
397
|
+
text_options.Add(self.btn_bigger, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
398
|
+
|
399
|
+
self.btn_smaller = wxButton(self, wx.ID_ANY)
|
400
|
+
self.btn_smaller.SetToolTip(_("Decrease the font-size"))
|
401
|
+
self.btn_smaller.SetBitmap(icon_textsize_down.GetBitmap(resize=iconsize))
|
402
|
+
text_options.Add(self.btn_smaller, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
403
|
+
|
404
|
+
text_options.AddSpacer(25)
|
405
|
+
|
406
|
+
msg = (
|
407
|
+
"\n"
|
408
|
+
+ _("- Hold shift/ctrl-Key down for bigger change")
|
409
|
+
+ "\n"
|
410
|
+
+ _("- Right click will reset value to default")
|
411
|
+
)
|
412
|
+
|
413
|
+
self.btn_bigger_spacing = wxButton(self, wx.ID_ANY)
|
414
|
+
self.btn_bigger_spacing.SetToolTip(_("Increase the character-gap") + msg)
|
415
|
+
self.btn_bigger_spacing.SetBitmap(
|
416
|
+
icon_kerning_bigger.GetBitmap(resize=iconsize)
|
417
|
+
)
|
418
|
+
text_options.Add(self.btn_bigger_spacing, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
419
|
+
|
420
|
+
self.btn_smaller_spacing = wxButton(self, wx.ID_ANY)
|
421
|
+
self.btn_smaller_spacing.SetToolTip(_("Decrease the character-gap") + msg)
|
422
|
+
self.btn_smaller_spacing.SetBitmap(
|
423
|
+
icon_kerning_smaller.GetBitmap(resize=iconsize)
|
424
|
+
)
|
425
|
+
text_options.Add(self.btn_smaller_spacing, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
426
|
+
|
427
|
+
text_options.AddSpacer(25)
|
428
|
+
|
429
|
+
self.btn_attrib_lineplus = wxButton(self, id=wx.ID_ANY)
|
430
|
+
self.btn_attrib_lineminus = wxButton(self, id=wx.ID_ANY)
|
431
|
+
text_options.Add(self.btn_attrib_lineplus, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
432
|
+
text_options.Add(self.btn_attrib_lineminus, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
433
|
+
|
434
|
+
self.btn_attrib_lineplus.SetToolTip(_("Increase line distance") + msg)
|
435
|
+
self.btn_attrib_lineminus.SetToolTip(_("Reduce line distance") + msg)
|
436
|
+
self.btn_attrib_lineplus.SetBitmap(
|
437
|
+
icon_linegap_bigger.GetBitmap(resize=iconsize)
|
438
|
+
)
|
439
|
+
self.btn_attrib_lineminus.SetBitmap(
|
440
|
+
icon_linegap_smaller.GetBitmap(resize=iconsize)
|
441
|
+
)
|
442
|
+
self.check_weld = wxCheckBox(self, wx.ID_ANY, "")
|
443
|
+
self.check_weld.SetToolTip(_("Weld overlapping characters together?"))
|
444
|
+
text_options.AddSpacer(25)
|
445
|
+
text_options.Add(self.check_weld, 0, wx.ALIGN_CENTER_VERTICAL, 0)
|
446
|
+
|
447
|
+
for btn in (
|
448
|
+
self.rb_align[0],
|
449
|
+
self.rb_align[1],
|
450
|
+
self.rb_align[2],
|
451
|
+
self.btn_bigger,
|
452
|
+
self.btn_smaller,
|
453
|
+
self.btn_bigger_spacing,
|
454
|
+
self.btn_smaller_spacing,
|
455
|
+
self.btn_attrib_lineminus,
|
456
|
+
self.btn_attrib_lineplus,
|
457
|
+
):
|
458
|
+
btn.SetMinSize(dip_size(self, 35, 35))
|
459
|
+
|
460
|
+
sizer_fonts = StaticBoxSizer(
|
461
|
+
self, wx.ID_ANY, _("Fonts (double-click to use)"), wx.VERTICAL
|
462
|
+
)
|
463
|
+
|
464
|
+
self.list_fonts = wxListBox(self, wx.ID_ANY)
|
465
|
+
self.list_fonts.SetMinSize(dip_size(self, -1, 140))
|
466
|
+
self.list_fonts.SetToolTip(
|
467
|
+
_("Select to preview the font, double-click to apply it")
|
468
|
+
)
|
469
|
+
sizer_fonts.Add(self.list_fonts, 0, wx.EXPAND, 0)
|
470
|
+
|
471
|
+
self.bmp_preview = wxStaticBitmap(self, wx.ID_ANY)
|
472
|
+
self.bmp_preview.SetMinSize(dip_size(self, -1, 50))
|
473
|
+
sizer_fonts.Add(self.bmp_preview, 0, wx.EXPAND, 0)
|
474
|
+
|
475
|
+
main_sizer.Add(sizer_text, 0, wx.EXPAND, 0)
|
476
|
+
main_sizer.Add(text_options, 0, wx.EXPAND, 0)
|
477
|
+
main_sizer.Add(sizer_fonts, 0, wx.EXPAND, 0)
|
478
|
+
self.SetSizer(main_sizer)
|
479
|
+
self.Layout()
|
480
|
+
self.btn_bigger.Bind(wx.EVT_BUTTON, self.on_button_bigger)
|
481
|
+
self.btn_smaller.Bind(wx.EVT_BUTTON, self.on_button_smaller)
|
482
|
+
|
483
|
+
self.btn_bigger_spacing.Bind(wx.EVT_BUTTON, self.on_button_bigger_spacing)
|
484
|
+
self.btn_smaller_spacing.Bind(wx.EVT_BUTTON, self.on_button_smaller_spacing)
|
485
|
+
self.btn_bigger_spacing.Bind(wx.EVT_RIGHT_DOWN, self.on_button_reset_spacing)
|
486
|
+
self.btn_smaller_spacing.Bind(wx.EVT_RIGHT_DOWN, self.on_button_reset_spacing)
|
487
|
+
self.Bind(wx.EVT_BUTTON, self.on_linegap_bigger, self.btn_attrib_lineplus)
|
488
|
+
self.Bind(wx.EVT_BUTTON, self.on_linegap_smaller, self.btn_attrib_lineminus)
|
489
|
+
self.btn_attrib_lineplus.Bind(wx.EVT_RIGHT_DOWN, self.on_linegap_reset)
|
490
|
+
self.btn_attrib_lineminus.Bind(wx.EVT_RIGHT_DOWN, self.on_linegap_reset)
|
491
|
+
self.check_weld.Bind(wx.EVT_CHECKBOX, self.on_weld)
|
492
|
+
for btn in self.rb_align:
|
493
|
+
btn.Bind(wx.EVT_TOGGLEBUTTON, self.on_radio_box)
|
494
|
+
self.text_text.Bind(wx.EVT_TEXT, self.on_text_change)
|
495
|
+
self.text_text.Bind(wx.EVT_RIGHT_DOWN, self.on_context_menu)
|
496
|
+
self.list_fonts.Bind(wx.EVT_LISTBOX, self.on_list_font)
|
497
|
+
self.list_fonts.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list_font_dclick)
|
498
|
+
|
499
|
+
self.set_widgets(self.node)
|
500
|
+
|
501
|
+
def pane_hide(self):
|
502
|
+
pass
|
503
|
+
|
504
|
+
def pane_show(self):
|
505
|
+
pass
|
506
|
+
|
507
|
+
def accepts(self, node):
|
508
|
+
if (
|
509
|
+
hasattr(node, "mkfont")
|
510
|
+
and hasattr(node, "mkfontsize")
|
511
|
+
and hasattr(node, "mktext")
|
512
|
+
):
|
513
|
+
# Let's take the opportunity to check for incorrect types and fix them...
|
514
|
+
self.context.fonts.validate_node(node)
|
515
|
+
return True
|
516
|
+
else:
|
517
|
+
return False
|
518
|
+
|
519
|
+
def set_widgets(self, node):
|
520
|
+
self.node = node
|
521
|
+
# print(f"set_widget for {self.attribute} to {str(node)}")
|
522
|
+
if self.node is None or not self.accepts(node):
|
523
|
+
self.Hide()
|
524
|
+
return
|
525
|
+
if not hasattr(self.node, "mkfontspacing") or self.node.mkfontspacing is None:
|
526
|
+
self.node.mkfontspacing = 1.0
|
527
|
+
if not hasattr(self.node, "mklinegap") or self.node.mklinegap is None:
|
528
|
+
self.node.mklinegap = 1.1
|
529
|
+
if not hasattr(self.node, "mkfontweld") or self.node.mkfontweld is None:
|
530
|
+
self.node.mkfontweld = False
|
531
|
+
self.check_weld.SetValue(self.node.mkfontweld)
|
532
|
+
if not hasattr(self.node, "mkalign") or self.node.mkalign is None:
|
533
|
+
self.node.mkalign = "start"
|
534
|
+
vals = ("start", "middle", "end")
|
535
|
+
try:
|
536
|
+
idx = vals.index(self.node.mkalign)
|
537
|
+
except IndexError:
|
538
|
+
idx = 0
|
539
|
+
for b_idx, btn in enumerate(self.rb_align):
|
540
|
+
btn.SetValue(bool(idx == b_idx))
|
541
|
+
|
542
|
+
self.load_directory()
|
543
|
+
self.text_text.ChangeValue(str(node.mktext))
|
544
|
+
self.Show()
|
545
|
+
|
546
|
+
def load_directory(self):
|
547
|
+
self.list_fonts.Clear()
|
548
|
+
self.fonts = self.context.fonts.available_fonts()
|
549
|
+
font_desc = [e[1] for e in self.fonts]
|
550
|
+
self.list_fonts.SetItems(font_desc)
|
551
|
+
# index = -1
|
552
|
+
# lookfor = getattr(self.context, "sxh_preferred", "")
|
553
|
+
|
554
|
+
def update_node(self):
|
555
|
+
vtext = self.text_text.GetValue()
|
556
|
+
self.context.fonts.update_linetext(self.node, vtext)
|
557
|
+
self.context.signal("element_property_reload", self.node)
|
558
|
+
self.context.signal("refresh_scene", "Scene")
|
559
|
+
self.context.last_font = self.node.mkfont
|
560
|
+
self.context.last_font_size = self.node.mkfontsize
|
561
|
+
|
562
|
+
def on_linegap_reset(self, event):
|
563
|
+
if self.node is None:
|
564
|
+
return
|
565
|
+
self.node.mklinegap = 1.1
|
566
|
+
self.update_node()
|
567
|
+
|
568
|
+
def on_linegap_bigger(self, event):
|
569
|
+
if self.node is None:
|
570
|
+
return
|
571
|
+
gap = 0.01
|
572
|
+
if wx.GetKeyState(wx.WXK_SHIFT):
|
573
|
+
gap = 0.1
|
574
|
+
if wx.GetKeyState(wx.WXK_CONTROL):
|
575
|
+
gap = 0.25
|
576
|
+
if self.node.mklinegap is None:
|
577
|
+
self.node.mklinegap = 1.1
|
578
|
+
else:
|
579
|
+
self.node.mklinegap += gap
|
580
|
+
self.update_node()
|
581
|
+
|
582
|
+
def on_linegap_smaller(self, event):
|
583
|
+
if self.node is None:
|
584
|
+
return
|
585
|
+
gap = 0.01
|
586
|
+
if wx.GetKeyState(wx.WXK_SHIFT):
|
587
|
+
gap = 0.1
|
588
|
+
if wx.GetKeyState(wx.WXK_CONTROL):
|
589
|
+
gap = 0.25
|
590
|
+
if self.node.mklinegap is None:
|
591
|
+
self.node.mklinegap = 1.1
|
592
|
+
else:
|
593
|
+
self.node.mklinegap -= gap
|
594
|
+
if self.node.mklinegap < 0:
|
595
|
+
self.node.mklinegap = 0
|
596
|
+
self.update_node()
|
597
|
+
|
598
|
+
def on_radio_box(self, event):
|
599
|
+
evt_btn = event.GetEventObject()
|
600
|
+
for idx, btn in enumerate(self.rb_align):
|
601
|
+
if btn is evt_btn:
|
602
|
+
new_anchor = idx
|
603
|
+
btn.SetValue(True)
|
604
|
+
else:
|
605
|
+
btn.SetValue(False)
|
606
|
+
if new_anchor == 0:
|
607
|
+
self.node.mkalign = "start"
|
608
|
+
elif new_anchor == 1:
|
609
|
+
self.node.mkalign = "middle"
|
610
|
+
elif new_anchor == 2:
|
611
|
+
self.node.mkalign = "end"
|
612
|
+
self.update_node()
|
613
|
+
|
614
|
+
def on_weld(self, event):
|
615
|
+
if self.node is None:
|
616
|
+
return
|
617
|
+
self.node.mkfontweld = self.check_weld.GetValue()
|
618
|
+
self.update_node()
|
619
|
+
|
620
|
+
def on_button_bigger(self, event):
|
621
|
+
if self.node is None:
|
622
|
+
return
|
623
|
+
self.node.mkfontsize *= 1.2
|
624
|
+
self.update_node()
|
625
|
+
|
626
|
+
def on_button_smaller(self, event):
|
627
|
+
if self.node is None:
|
628
|
+
return
|
629
|
+
self.node.mkfontsize /= 1.2
|
630
|
+
self.update_node()
|
631
|
+
|
632
|
+
def on_button_reset_spacing(self, event):
|
633
|
+
# print ("Reset")
|
634
|
+
self.node.mkfontspacing = 1.0
|
635
|
+
self.update_node()
|
636
|
+
|
637
|
+
def on_button_bigger_spacing(self, event):
|
638
|
+
if self.node is None:
|
639
|
+
return
|
640
|
+
gap = 0.01
|
641
|
+
if wx.GetKeyState(wx.WXK_SHIFT):
|
642
|
+
gap = 0.1
|
643
|
+
if wx.GetKeyState(wx.WXK_CONTROL):
|
644
|
+
gap = 0.25
|
645
|
+
self.node.mkfontspacing += gap
|
646
|
+
self.update_node()
|
647
|
+
|
648
|
+
def on_button_smaller_spacing(self, event):
|
649
|
+
if self.node is None:
|
650
|
+
return
|
651
|
+
gap = 0.01
|
652
|
+
if wx.GetKeyState(wx.WXK_SHIFT):
|
653
|
+
gap = 0.1
|
654
|
+
if wx.GetKeyState(wx.WXK_CONTROL):
|
655
|
+
gap = 0.25
|
656
|
+
self.node.mkfontspacing -= gap
|
657
|
+
self.update_node()
|
658
|
+
|
659
|
+
def on_text_change(self, event):
|
660
|
+
self.update_node()
|
661
|
+
|
662
|
+
def on_list_font_dclick(self, event):
|
663
|
+
if self.node is None:
|
664
|
+
return
|
665
|
+
index = self.list_fonts.GetSelection()
|
666
|
+
if index >= 0:
|
667
|
+
fontinfo = self.fonts[index]
|
668
|
+
fontname = os.path.basename(fontinfo[0])
|
669
|
+
self.node.mkfont = fontname
|
670
|
+
self.update_node()
|
671
|
+
|
672
|
+
def on_list_font(self, event):
|
673
|
+
if self.list_fonts.GetSelection() >= 0:
|
674
|
+
font_info = self.fonts[self.list_fonts.GetSelection()]
|
675
|
+
full_font_file = font_info[0]
|
676
|
+
bmp = self.context.fonts.preview_file(full_font_file)
|
677
|
+
# if bmp is not None:
|
678
|
+
# bmap_bundle = wx.BitmapBundle().FromBitmap(bmp)
|
679
|
+
# else:
|
680
|
+
# bmap_bundle = wx.BitmapBundle()
|
681
|
+
# self.bmp_preview.SetBitmap(bmap_bundle)
|
682
|
+
if bmp is None:
|
683
|
+
bmp = wx.NullBitmap
|
684
|
+
self.bmp_preview.SetBitmap(bmp)
|
685
|
+
|
686
|
+
def on_context_menu(self, event):
|
687
|
+
def on_paste(event):
|
688
|
+
self.text_text.Paste()
|
689
|
+
|
690
|
+
def on_glyph(event):
|
691
|
+
mydlg = FontGlyphPicker(
|
692
|
+
None, id=wx.ID_ANY, context=self.context, font=self.node.mkfont
|
693
|
+
)
|
694
|
+
glyphs = None
|
695
|
+
if mydlg.ShowModal() == wx.ID_OK:
|
696
|
+
# This returns a string of characters that need to be inserted
|
697
|
+
glyphs = mydlg.result()
|
698
|
+
mydlg.Destroy()
|
699
|
+
if glyphs is None or glyphs == "":
|
700
|
+
return
|
701
|
+
text = self.text_text.GetValue()
|
702
|
+
pos = self.text_text.GetInsertionPoint()
|
703
|
+
if pos == self.text_text.GetLastPosition():
|
704
|
+
before = text
|
705
|
+
after = ""
|
706
|
+
else:
|
707
|
+
before = self.text_text.GetValue()[:pos]
|
708
|
+
after = self.text_text.GetValue()[pos:]
|
709
|
+
self.text_text.SetValue(before + glyphs + after)
|
710
|
+
|
711
|
+
menu = wx.Menu()
|
712
|
+
item = menu.Append(wx.ID_ANY, _("Paste"), "", wx.ITEM_NORMAL)
|
713
|
+
self.Bind(wx.EVT_MENU, on_paste, item)
|
714
|
+
item = menu.Append(wx.ID_ANY, _("Insert symbol"), "", wx.ITEM_NORMAL)
|
715
|
+
self.Bind(wx.EVT_MENU, on_glyph, item)
|
716
|
+
self.PopupMenu(menu)
|
717
|
+
menu.Destroy()
|
718
|
+
|
719
|
+
|
720
|
+
def signal(self, signalstr, myargs):
|
721
|
+
if signalstr == "textselect" and self.IsShown():
|
722
|
+
# This can crash for completely unknown reasons under Linux!
|
723
|
+
# Hypothesis: you can't focus / SelectStuff if the control is not yet shown.
|
724
|
+
if self._islinux:
|
725
|
+
return
|
726
|
+
self.text_text.SelectAll()
|
727
|
+
self.text_text.SetFocus()
|
728
|
+
|
729
|
+
|
730
|
+
class PanelFontSelect(wx.Panel):
|
731
|
+
"""
|
732
|
+
Panel to select font during line text creation
|
733
|
+
"""
|
734
|
+
|
735
|
+
def __init__(self, *args, context=None, **kwds):
|
736
|
+
# begin wxGlade: clsLasertools.__init__
|
737
|
+
kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
|
738
|
+
wx.Panel.__init__(self, *args, **kwds)
|
739
|
+
self.context = context
|
740
|
+
self.context.themes.set_window_colors(self)
|
741
|
+
|
742
|
+
mainsizer = wx.BoxSizer(wx.VERTICAL)
|
743
|
+
|
744
|
+
self.all_fonts = []
|
745
|
+
self.fonts = []
|
746
|
+
self.font_checks = {}
|
747
|
+
|
748
|
+
fontinfo = self.context.fonts.fonts_registered
|
749
|
+
sizer_checker = wx.BoxSizer(wx.HORIZONTAL)
|
750
|
+
for extension in fontinfo:
|
751
|
+
info = fontinfo[extension]
|
752
|
+
checker = wxCheckBox(self, wx.ID_ANY, info[0])
|
753
|
+
checker.SetValue(True)
|
754
|
+
checker.Bind(wx.EVT_CHECKBOX, self.on_checker(extension))
|
755
|
+
checker.SetToolTip(
|
756
|
+
_("Show/Hide all fonts of type {info[0]}").format(info=info)
|
757
|
+
)
|
758
|
+
self.font_checks[extension] = [checker, True]
|
759
|
+
sizer_checker.Add(checker, 0, 0, wx.ALIGN_CENTER_VERTICAL)
|
760
|
+
|
761
|
+
sizer_fonts = StaticBoxSizer(
|
762
|
+
self, wx.ID_ANY, _("Fonts (double-click to use)"), wx.VERTICAL
|
763
|
+
)
|
764
|
+
mainsizer.Add(sizer_fonts, 1, wx.EXPAND, 0)
|
765
|
+
|
766
|
+
self.list_fonts = wxListBox(self, wx.ID_ANY)
|
767
|
+
self.list_fonts.SetToolTip(
|
768
|
+
_("Select to preview the font, double-click to apply it")
|
769
|
+
)
|
770
|
+
sizer_fonts.Add(self.list_fonts, 1, wx.EXPAND, 0)
|
771
|
+
sizer_fonts.Add(sizer_checker, 0, wx.EXPAND, 0)
|
772
|
+
|
773
|
+
self.bmp_preview = wxStaticBitmap(self, wx.ID_ANY)
|
774
|
+
self.bmp_preview.SetMinSize(dip_size(self, -1, 70))
|
775
|
+
sizer_fonts.Add(self.bmp_preview, 0, wx.EXPAND, 0)
|
776
|
+
|
777
|
+
sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
|
778
|
+
sizer_fonts.Add(sizer_buttons, 0, wx.EXPAND, 0)
|
779
|
+
|
780
|
+
picsize = dip_size(self, 32, 32)
|
781
|
+
icon_size = picsize[0]
|
782
|
+
bsize = icon_size * self.context.root.bitmap_correction_scale
|
783
|
+
|
784
|
+
self.btn_bigger = wxButton(self, wx.ID_ANY)
|
785
|
+
self.btn_bigger.SetBitmap(icon_textsize_up.GetBitmap(resize=bsize))
|
786
|
+
self.btn_bigger.SetToolTip(_("Increase the font-size"))
|
787
|
+
sizer_buttons.Add(self.btn_bigger, 0, wx.EXPAND, 0)
|
788
|
+
|
789
|
+
self.btn_smaller = wxButton(self, wx.ID_ANY)
|
790
|
+
self.btn_smaller.SetBitmap(icon_textsize_down.GetBitmap(resize=bsize))
|
791
|
+
self.btn_smaller.SetToolTip(_("Decrease the font-size"))
|
792
|
+
sizer_buttons.Add(self.btn_smaller, 0, wx.EXPAND, 0)
|
793
|
+
|
794
|
+
sizer_buttons.AddSpacer(25)
|
795
|
+
|
796
|
+
self.btn_align_left = wxButton(self, wx.ID_ANY)
|
797
|
+
self.btn_align_left.SetBitmap(icon_textalign_left.GetBitmap(resize=bsize))
|
798
|
+
self.btn_align_left.SetToolTip(_("Align text on the left side"))
|
799
|
+
sizer_buttons.Add(self.btn_align_left, 0, wx.EXPAND, 0)
|
800
|
+
|
801
|
+
self.btn_align_center = wxButton(self, wx.ID_ANY)
|
802
|
+
self.btn_align_center.SetBitmap(
|
803
|
+
icon_textalign_center.GetBitmap(resize=bsize)
|
804
|
+
)
|
805
|
+
self.btn_align_center.SetToolTip(_("Align text around the center"))
|
806
|
+
sizer_buttons.Add(self.btn_align_center, 0, wx.EXPAND, 0)
|
807
|
+
|
808
|
+
self.btn_align_right = wxButton(self, wx.ID_ANY)
|
809
|
+
self.btn_align_right.SetBitmap(icon_textalign_right.GetBitmap(resize=bsize))
|
810
|
+
self.btn_align_right.SetToolTip(_("Align text on the right side"))
|
811
|
+
sizer_buttons.Add(self.btn_align_right, 0, wx.EXPAND, 0)
|
812
|
+
|
813
|
+
for btn in (
|
814
|
+
self.btn_align_center,
|
815
|
+
self.btn_align_left,
|
816
|
+
self.btn_align_right,
|
817
|
+
self.btn_bigger,
|
818
|
+
self.btn_smaller,
|
819
|
+
):
|
820
|
+
btn.SetMaxSize(dip_size(self, icon_size + 4, -1))
|
821
|
+
|
822
|
+
lbl_spacer = wxStaticText(self, wx.ID_ANY, "")
|
823
|
+
sizer_buttons.Add(lbl_spacer, 1, 0, 0)
|
824
|
+
|
825
|
+
self.SetSizer(mainsizer)
|
826
|
+
|
827
|
+
self.Layout()
|
828
|
+
|
829
|
+
self.Bind(wx.EVT_LISTBOX, self.on_list_font, self.list_fonts)
|
830
|
+
self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list_font_dclick, self.list_fonts)
|
831
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_bigger, self.btn_bigger)
|
832
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_smaller, self.btn_smaller)
|
833
|
+
|
834
|
+
self.Bind(wx.EVT_BUTTON, self.on_align("start"), self.btn_align_left)
|
835
|
+
self.Bind(wx.EVT_BUTTON, self.on_align("middle"), self.btn_align_center)
|
836
|
+
self.Bind(wx.EVT_BUTTON, self.on_align("end"), self.btn_align_right)
|
837
|
+
|
838
|
+
# end wxGlade
|
839
|
+
self.load_directory()
|
840
|
+
|
841
|
+
def load_directory(self):
|
842
|
+
self.all_fonts = self.context.fonts.available_fonts()
|
843
|
+
self.list_fonts.Clear()
|
844
|
+
self.populate_list_box()
|
845
|
+
|
846
|
+
def populate_list_box(self):
|
847
|
+
self.fonts.clear()
|
848
|
+
font_desc = []
|
849
|
+
for entry in self.all_fonts:
|
850
|
+
# 0 basename, 1 full_path, 2 facename
|
851
|
+
parts = os.path.splitext(entry[0])
|
852
|
+
if len(parts) > 1:
|
853
|
+
extension = parts[1][1:].lower()
|
854
|
+
if extension in self.font_checks:
|
855
|
+
if not self.font_checks[extension][1]:
|
856
|
+
entry = None
|
857
|
+
if entry is not None:
|
858
|
+
self.fonts.append(entry[0])
|
859
|
+
font_desc.append(entry[1])
|
860
|
+
|
861
|
+
self.list_fonts.SetItems(font_desc)
|
862
|
+
|
863
|
+
def on_checker(self, extension):
|
864
|
+
def handler(event):
|
865
|
+
self.font_checks[extension][1] = not self.font_checks[extension][1]
|
866
|
+
# Reload List
|
867
|
+
self.populate_list_box()
|
868
|
+
|
869
|
+
return handler
|
870
|
+
|
871
|
+
def on_btn_bigger(self, event):
|
872
|
+
self.context.signal("linetext", "bigger")
|
873
|
+
|
874
|
+
def on_btn_smaller(self, event):
|
875
|
+
self.context.signal("linetext", "smaller")
|
876
|
+
|
877
|
+
def on_align(self, alignment):
|
878
|
+
def handler(event):
|
879
|
+
self.context.signal("linetext", "align", local_alignment)
|
880
|
+
|
881
|
+
local_alignment = alignment
|
882
|
+
return handler
|
883
|
+
|
884
|
+
def on_list_font_dclick(self, event):
|
885
|
+
index = self.list_fonts.GetSelection()
|
886
|
+
if index >= 0:
|
887
|
+
fontname = self.fonts[index]
|
888
|
+
self.context.signal("linetext", "font", fontname)
|
889
|
+
|
890
|
+
def on_list_font(self, event):
|
891
|
+
if self.list_fonts.GetSelection() >= 0:
|
892
|
+
full_font_file = self.fonts[self.list_fonts.GetSelection()]
|
893
|
+
bmp = self.context.fonts.preview_file(full_font_file)
|
894
|
+
# if bmp is not None:
|
895
|
+
# bmap_bundle = wx.BitmapBundle().FromBitmap(bmp)
|
896
|
+
# else:
|
897
|
+
# bmap_bundle = wx.BitmapBundle()
|
898
|
+
# self.bmp_preview.SetBitmap(bmap_bundle)
|
899
|
+
if bmp is None:
|
900
|
+
bmp = wx.NullBitmap
|
901
|
+
self.bmp_preview.SetBitmap(bmp)
|
902
|
+
|
903
|
+
|
904
|
+
class HersheyFontSelector(MWindow):
|
905
|
+
"""
|
906
|
+
Wrapper Window Class for font selection panel
|
907
|
+
"""
|
908
|
+
|
909
|
+
def __init__(self, *args, **kwds):
|
910
|
+
super().__init__(450, 550, submenu="", *args, **kwds)
|
911
|
+
self.panel = PanelFontSelect(self, wx.ID_ANY, context=self.context)
|
912
|
+
self.sizer.Add(self.panel, 1, wx.EXPAND, 0)
|
913
|
+
_icon = wx.NullIcon
|
914
|
+
_icon.CopyFromBitmap(
|
915
|
+
icons8_choose_font.GetBitmap(resize=0.5 * get_default_icon_size(self.context))
|
916
|
+
)
|
917
|
+
# _icon.CopyFromBitmap(icons8_computer_support.GetBitmap())
|
918
|
+
self.SetIcon(_icon)
|
919
|
+
self.SetTitle(_("Font-Selection"))
|
920
|
+
self.restore_aspect()
|
921
|
+
|
922
|
+
def window_open(self):
|
923
|
+
pass
|
924
|
+
|
925
|
+
def window_close(self):
|
926
|
+
# We don't need an automatic opening
|
927
|
+
self.window_context.open_on_start = False
|
928
|
+
|
929
|
+
def delegates(self):
|
930
|
+
yield self.panel
|
931
|
+
|
932
|
+
@staticmethod
|
933
|
+
def submenu():
|
934
|
+
# Suppress = True
|
935
|
+
return "", "Font-Selector", True
|
936
|
+
|
937
|
+
@staticmethod
|
938
|
+
def helptext():
|
939
|
+
return _("Pick a font to use for vector text")
|
940
|
+
|
941
|
+
@signal_listener("tool_changed")
|
942
|
+
def on_tool_changed(self, origin, newtool=None, *args):
|
943
|
+
# Signal provides a tuple with (togglegroup, id)
|
944
|
+
needs_close = True
|
945
|
+
if newtool is not None:
|
946
|
+
if isinstance(newtool, (list, tuple)):
|
947
|
+
group = newtool[0].lower() if newtool[0] is not None else ""
|
948
|
+
identifier = newtool[1].lower() if newtool[1] is not None else ""
|
949
|
+
else:
|
950
|
+
group = newtool
|
951
|
+
identifier = ""
|
952
|
+
needs_close = identifier != "linetext"
|
953
|
+
if needs_close:
|
954
|
+
self.Close()
|
955
|
+
|
956
|
+
|
957
|
+
class PanelFontManager(wx.Panel):
|
958
|
+
"""
|
959
|
+
Vector Font Manager
|
960
|
+
"""
|
961
|
+
|
962
|
+
def __init__(self, *args, context=None, **kwds):
|
963
|
+
# begin wxGlade: clsLasertools.__init__
|
964
|
+
kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
|
965
|
+
wx.Panel.__init__(self, *args, **kwds)
|
966
|
+
self.context = context
|
967
|
+
self.context.themes.set_window_colors(self)
|
968
|
+
self.SetHelpText("vectortext")
|
969
|
+
|
970
|
+
mainsizer = wx.BoxSizer(wx.VERTICAL)
|
971
|
+
|
972
|
+
self.font_infos = []
|
973
|
+
|
974
|
+
self.text_info = TextCtrl(
|
975
|
+
self,
|
976
|
+
wx.ID_ANY,
|
977
|
+
_(
|
978
|
+
"MeerK40t can use True-Type-Fonts, Hershey-Fonts or Autocad-86 shape fonts designed to be rendered purely with vectors.\n"
|
979
|
+
+ "They can be scaled, burned like any other vector shape and are therefore very versatile.\n"
|
980
|
+
+ "See more: https://en.wikipedia.org/wiki/Hershey_fonts "
|
981
|
+
),
|
982
|
+
style=wx.BORDER_NONE | wx.TE_MULTILINE | wx.TE_READONLY,
|
983
|
+
)
|
984
|
+
|
985
|
+
self.text_info.SetMinSize(dip_size(self, -1, 90))
|
986
|
+
self.text_info.SetBackgroundColour(self.GetBackgroundColour())
|
987
|
+
sizer_info = StaticBoxSizer(self, wx.ID_ANY, _("Information"), wx.HORIZONTAL)
|
988
|
+
mainsizer.Add(sizer_info, 0, wx.EXPAND, 0)
|
989
|
+
sizer_info.Add(self.text_info, 1, wx.EXPAND, 0)
|
990
|
+
|
991
|
+
sizer_directory = StaticBoxSizer(
|
992
|
+
self, wx.ID_ANY, _("Font-Work-Directory"), wx.HORIZONTAL
|
993
|
+
)
|
994
|
+
mainsizer.Add(sizer_directory, 0, wx.EXPAND, 0)
|
995
|
+
|
996
|
+
self.text_fontdir = TextCtrl(self, wx.ID_ANY, "")
|
997
|
+
sizer_directory.Add(self.text_fontdir, 1, wx.EXPAND, 0)
|
998
|
+
self.text_fontdir.SetToolTip(
|
999
|
+
_(
|
1000
|
+
"Additional directory for userdefined fonts (also used to store some cache files)"
|
1001
|
+
)
|
1002
|
+
)
|
1003
|
+
|
1004
|
+
self.btn_dirselect = wxButton(self, wx.ID_ANY, "...")
|
1005
|
+
sizer_directory.Add(self.btn_dirselect, 0, wx.EXPAND, 0)
|
1006
|
+
|
1007
|
+
choices = []
|
1008
|
+
prechoices = context.lookup("choices/preferences")
|
1009
|
+
for info in prechoices:
|
1010
|
+
if info["attr"] == "system_font_directories":
|
1011
|
+
cinfo = dict(info)
|
1012
|
+
cinfo["page"] = ""
|
1013
|
+
choices.append(cinfo)
|
1014
|
+
break
|
1015
|
+
|
1016
|
+
self.sysdirs = ChoicePropertyPanel(
|
1017
|
+
self, wx.ID_ANY, context=self.context, choices=choices, scrolling=False
|
1018
|
+
)
|
1019
|
+
mainsizer.Add(self.sysdirs, 0, wx.EXPAND, 0)
|
1020
|
+
sizer_fonts = StaticBoxSizer(self, wx.ID_ANY, _("Fonts"), wx.VERTICAL)
|
1021
|
+
mainsizer.Add(sizer_fonts, 1, wx.EXPAND, 0)
|
1022
|
+
|
1023
|
+
self.list_fonts = wxListBox(self, wx.ID_ANY)
|
1024
|
+
sizer_fonts.Add(self.list_fonts, 1, wx.EXPAND, 0)
|
1025
|
+
|
1026
|
+
self.bmp_preview = wxStaticBitmap(self, wx.ID_ANY)
|
1027
|
+
self.bmp_preview.SetMinSize(dip_size(self, -1, 70))
|
1028
|
+
sizer_fonts.Add(self.bmp_preview, 0, wx.EXPAND, 0)
|
1029
|
+
|
1030
|
+
sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
|
1031
|
+
sizer_fonts.Add(sizer_buttons, 0, wx.EXPAND, 0)
|
1032
|
+
|
1033
|
+
self.btn_add = wxButton(self, wx.ID_ANY, _("Import"))
|
1034
|
+
sizer_buttons.Add(self.btn_add, 0, wx.EXPAND, 0)
|
1035
|
+
|
1036
|
+
self.btn_delete = wxButton(self, wx.ID_ANY, _("Delete"))
|
1037
|
+
sizer_buttons.Add(self.btn_delete, 0, wx.EXPAND, 0)
|
1038
|
+
|
1039
|
+
lbl_spacer = wxStaticText(self, wx.ID_ANY, "")
|
1040
|
+
sizer_buttons.Add(lbl_spacer, 1, 0, 0)
|
1041
|
+
|
1042
|
+
self.btn_refresh = wxButton(self, wx.ID_ANY, _("Refresh"))
|
1043
|
+
sizer_buttons.Add(self.btn_refresh, 0, wx.EXPAND, 0)
|
1044
|
+
|
1045
|
+
self.webresources = [
|
1046
|
+
"https://github.com/kamalmostafa/hershey-fonts/tree/master/hershey-fonts",
|
1047
|
+
"http://iki.fi/sol/hershey/index.html",
|
1048
|
+
"https://www.mepwork.com/2017/11/autocad-shx-fonts.html",
|
1049
|
+
]
|
1050
|
+
choices = [
|
1051
|
+
_("Goto a font-source..."),
|
1052
|
+
_("Hershey Fonts - #1"),
|
1053
|
+
_("Hershey Fonts - #2"),
|
1054
|
+
_("Autocad-SHX-Fonts"),
|
1055
|
+
]
|
1056
|
+
self.combo_webget = wxComboBox(
|
1057
|
+
self,
|
1058
|
+
wx.ID_ANY,
|
1059
|
+
choices=choices,
|
1060
|
+
style=wx.CB_DROPDOWN | wx.CB_READONLY,
|
1061
|
+
)
|
1062
|
+
self.combo_webget.SetSelection(0)
|
1063
|
+
sizer_buttons.Add(self.combo_webget, 0, wx.EXPAND, 0)
|
1064
|
+
|
1065
|
+
self.SetSizer(mainsizer)
|
1066
|
+
self.Layout()
|
1067
|
+
mainsizer.Fit(self)
|
1068
|
+
|
1069
|
+
self.Bind(wx.EVT_TEXT, self.on_text_directory, self.text_fontdir)
|
1070
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_directory, self.btn_dirselect)
|
1071
|
+
self.Bind(wx.EVT_LISTBOX, self.on_list_font, self.list_fonts)
|
1072
|
+
self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list_font_dclick, self.list_fonts)
|
1073
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_import, self.btn_add)
|
1074
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_delete, self.btn_delete)
|
1075
|
+
self.Bind(wx.EVT_BUTTON, self.on_btn_refresh, self.btn_refresh)
|
1076
|
+
self.Bind(wx.EVT_COMBOBOX, self.on_combo_webget, self.combo_webget)
|
1077
|
+
self.list_fonts.Bind(wx.EVT_MOTION, self.on_list_hover)
|
1078
|
+
# end wxGlade
|
1079
|
+
fontdir = self.context.fonts.font_directory
|
1080
|
+
self.text_fontdir.SetValue(fontdir)
|
1081
|
+
|
1082
|
+
def on_text_directory(self, event):
|
1083
|
+
fontdir = self.text_fontdir.GetValue()
|
1084
|
+
self.font_infos.clear()
|
1085
|
+
font_desc = []
|
1086
|
+
self.list_fonts.Clear()
|
1087
|
+
if os.path.exists(fontdir):
|
1088
|
+
self.context.fonts.font_directory = fontdir
|
1089
|
+
self.text_fontdir.SetBackgroundColour(
|
1090
|
+
wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)
|
1091
|
+
)
|
1092
|
+
self.text_fontdir.SetToolTip(
|
1093
|
+
_(
|
1094
|
+
"Additional directory for userdefined fonts (also used to store some cache files)"
|
1095
|
+
)
|
1096
|
+
)
|
1097
|
+
else:
|
1098
|
+
self.text_fontdir.SetBackgroundColour(
|
1099
|
+
wx.SystemSettings().GetColour(wx.SYS_COLOUR_HIGHLIGHT)
|
1100
|
+
)
|
1101
|
+
self.text_fontdir.SetToolTip(
|
1102
|
+
_("Invalid directory! Will not be used, please provide a valid path.")
|
1103
|
+
)
|
1104
|
+
return
|
1105
|
+
# resp = wx.MessageBox(_("This is an invalid directory, do you want to use the default directory?"),_("Invalid directory"), style=wx.YES_NO|wx.ICON_WARNING)
|
1106
|
+
# if resp==wx.YES:
|
1107
|
+
# fontdir = self.context.fonts.font_directory
|
1108
|
+
# self.text_fontdir.SetValue(fontdir)
|
1109
|
+
# else:
|
1110
|
+
# return
|
1111
|
+
self.font_infos = self.context.fonts.available_fonts()
|
1112
|
+
|
1113
|
+
for info in self.font_infos:
|
1114
|
+
font_desc.append(info[1])
|
1115
|
+
self.list_fonts.SetItems(font_desc)
|
1116
|
+
# Let the world know we have fonts
|
1117
|
+
self.context.signal("icons")
|
1118
|
+
|
1119
|
+
def on_btn_directory(self, event):
|
1120
|
+
fontdir = self.text_fontdir.GetValue()
|
1121
|
+
dlg = wx.DirDialog(
|
1122
|
+
None,
|
1123
|
+
_("Choose font directory"),
|
1124
|
+
fontdir,
|
1125
|
+
style=wx.DD_DEFAULT_STYLE
|
1126
|
+
# | wx.DD_DIR_MUST_EXIST
|
1127
|
+
)
|
1128
|
+
if dlg.ShowModal() == wx.ID_OK:
|
1129
|
+
self.text_fontdir.SetValue(dlg.GetPath())
|
1130
|
+
# Only destroy a dialog after you're done with it.
|
1131
|
+
dlg.Destroy()
|
1132
|
+
|
1133
|
+
def on_list_font_dclick(self, event):
|
1134
|
+
if self.list_fonts.GetSelection() >= 0:
|
1135
|
+
font_file = self.font_infos[self.list_fonts.GetSelection()][0]
|
1136
|
+
self.context.setting(str, "last_font", None)
|
1137
|
+
self.context.last_font = font_file
|
1138
|
+
|
1139
|
+
def on_list_font(self, event):
|
1140
|
+
if self.list_fonts.GetSelection() >= 0:
|
1141
|
+
info = self.font_infos[self.list_fonts.GetSelection()]
|
1142
|
+
full_font_file = info[0]
|
1143
|
+
is_system = info[4]
|
1144
|
+
self.btn_delete.Enable(not is_system)
|
1145
|
+
bmp = self.context.fonts.preview_file(full_font_file)
|
1146
|
+
# if bmp is not None:
|
1147
|
+
# bmap_bundle = wx.BitmapBundle().FromBitmap(bmp)
|
1148
|
+
# else:
|
1149
|
+
# bmap_bundle = wx.BitmapBundle()
|
1150
|
+
# self.bmp_preview.SetBitmap(bmap_bundle)
|
1151
|
+
if bmp is None:
|
1152
|
+
bmp = wx.NullBitmap
|
1153
|
+
self.bmp_preview.SetBitmap(bmp)
|
1154
|
+
|
1155
|
+
def on_list_hover(self, event):
|
1156
|
+
event.Skip()
|
1157
|
+
pt = event.GetPosition()
|
1158
|
+
item = self.list_fonts.HitTest(pt)
|
1159
|
+
ttip = _("List of available fonts")
|
1160
|
+
if item >= 0:
|
1161
|
+
try:
|
1162
|
+
info = self.font_infos[item]
|
1163
|
+
ttip = f"{info[1]}\nFamily: {info[2]}\nSubfamily: {info[3]}\n{info[0]}"
|
1164
|
+
except IndexError:
|
1165
|
+
pass
|
1166
|
+
self.list_fonts.SetToolTip(ttip)
|
1167
|
+
|
1168
|
+
def on_btn_import(self, event, defaultdirectory=None, defaultextension=None):
|
1169
|
+
fontinfo = self.context.fonts.fonts_registered
|
1170
|
+
wildcard = "Vector-Fonts"
|
1171
|
+
idx = 0
|
1172
|
+
filterindex = 0
|
1173
|
+
# 1st put all into one wildcard-pattern
|
1174
|
+
for extension in fontinfo:
|
1175
|
+
ext = "*." + extension
|
1176
|
+
if idx == 0:
|
1177
|
+
wildcard += "|"
|
1178
|
+
else:
|
1179
|
+
wildcard += ";"
|
1180
|
+
wildcard += ext.lower() + ";" + ext.upper()
|
1181
|
+
idx += 1
|
1182
|
+
# 2nd add all individual wildcard-patterns
|
1183
|
+
for idx, extension in enumerate(fontinfo):
|
1184
|
+
if (
|
1185
|
+
defaultextension is not None
|
1186
|
+
and defaultextension.lower() == extension.lower()
|
1187
|
+
):
|
1188
|
+
filterindex = idx + 1
|
1189
|
+
ext = "*." + extension
|
1190
|
+
info = fontinfo[extension]
|
1191
|
+
wildcard += f"|{info[0]}-Fonts|{ext.lower()};{ext.upper()}"
|
1192
|
+
wildcard += "|" + _("All files") + "|*.*"
|
1193
|
+
if defaultdirectory is None:
|
1194
|
+
defdir = ""
|
1195
|
+
else:
|
1196
|
+
defdir = defaultdirectory
|
1197
|
+
# print (os.listdir(os.path.join(os.environ['WINDIR'],'fonts')))
|
1198
|
+
dlg = wx.FileDialog(
|
1199
|
+
self,
|
1200
|
+
message=_(
|
1201
|
+
"Select a font-file to be imported into the the font-directory {fontdir}"
|
1202
|
+
).format(fontdir=self.context.fonts.font_directory),
|
1203
|
+
defaultDir=defdir,
|
1204
|
+
defaultFile="",
|
1205
|
+
wildcard=wildcard,
|
1206
|
+
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE | wx.FD_PREVIEW
|
1207
|
+
# | wx.FD_SHOW_HIDDEN,
|
1208
|
+
)
|
1209
|
+
try:
|
1210
|
+
# Might not be present in early wxpython versions
|
1211
|
+
dlg.SetFilterIndex(filterindex)
|
1212
|
+
except AttributeError:
|
1213
|
+
pass
|
1214
|
+
font_files = None
|
1215
|
+
if dlg.ShowModal() == wx.ID_OK:
|
1216
|
+
font_files = dlg.GetPaths()
|
1217
|
+
# Only destroy a dialog after you're done with it.
|
1218
|
+
dlg.Destroy()
|
1219
|
+
stats = [0, 0] # Successful, errors
|
1220
|
+
if font_files is None:
|
1221
|
+
return
|
1222
|
+
|
1223
|
+
maxidx = len(font_files)
|
1224
|
+
progress_string = _("Fonts imported: {count}")
|
1225
|
+
progress = wx.ProgressDialog(
|
1226
|
+
_("Importing fonts..."),
|
1227
|
+
progress_string.format(count=0),
|
1228
|
+
maximum=maxidx,
|
1229
|
+
parent=None,
|
1230
|
+
style=wx.PD_APP_MODAL | wx.PD_CAN_ABORT,
|
1231
|
+
)
|
1232
|
+
for idx, sourcefile in enumerate(font_files):
|
1233
|
+
basename = os.path.basename(sourcefile)
|
1234
|
+
destfile = os.path.join(self.context.fonts.font_directory, basename)
|
1235
|
+
# print (f"Source File: {sourcefile}\nTarget: {destfile}")
|
1236
|
+
try:
|
1237
|
+
with open(sourcefile, "rb") as f, open(destfile, "wb") as g:
|
1238
|
+
while True:
|
1239
|
+
block = f.read(1 * 1024 * 1024) # work by blocks of 1 MB
|
1240
|
+
if not block: # end of file
|
1241
|
+
break
|
1242
|
+
g.write(block)
|
1243
|
+
bmp = self.context.fonts.preview_file(destfile)
|
1244
|
+
if bmp is not None:
|
1245
|
+
stats[0] += 1
|
1246
|
+
else:
|
1247
|
+
# We delete this file again...
|
1248
|
+
remove_fontfile(destfile)
|
1249
|
+
stats[1] += 1
|
1250
|
+
|
1251
|
+
progress.Update(idx + 1, progress_string.format(count=idx + 1))
|
1252
|
+
if progress.WasCancelled():
|
1253
|
+
break
|
1254
|
+
except (OSError, RuntimeError, PermissionError, FileNotFoundError):
|
1255
|
+
stats[1] += 1
|
1256
|
+
progress.Destroy()
|
1257
|
+
wx.MessageBox(
|
1258
|
+
_(
|
1259
|
+
"Font-Import completed.\nImported: {ok}\nFailed: {fail}\nTotal: {total}"
|
1260
|
+
).format(ok=stats[0], fail=stats[1], total=stats[0] + stats[1]),
|
1261
|
+
_("Import completed"),
|
1262
|
+
wx.OK | wx.ICON_INFORMATION,
|
1263
|
+
)
|
1264
|
+
# Reload....
|
1265
|
+
self.on_text_directory(None)
|
1266
|
+
|
1267
|
+
def on_btn_refresh(self, event):
|
1268
|
+
self.context.fonts.reset_cache()
|
1269
|
+
self.on_text_directory(None)
|
1270
|
+
|
1271
|
+
def on_btn_delete(self, event):
|
1272
|
+
if self.list_fonts.GetSelection() >= 0:
|
1273
|
+
info = self.font_infos[self.list_fonts.GetSelection()]
|
1274
|
+
full_font_file = info[0]
|
1275
|
+
font_file = os.path.basename(full_font_file)
|
1276
|
+
if self.context.fonts.is_system_font(full_font_file):
|
1277
|
+
return
|
1278
|
+
if (
|
1279
|
+
wx.MessageBox(
|
1280
|
+
_("Do you really want to delete this font: {font}").format(
|
1281
|
+
font=font_file
|
1282
|
+
),
|
1283
|
+
_("Confirm"),
|
1284
|
+
wx.YES_NO | wx.CANCEL | wx.ICON_WARNING,
|
1285
|
+
)
|
1286
|
+
== wx.YES
|
1287
|
+
):
|
1288
|
+
remove_fontfile(full_font_file)
|
1289
|
+
# Reload dir...
|
1290
|
+
self.on_text_directory(None)
|
1291
|
+
|
1292
|
+
def on_combo_webget(self, event):
|
1293
|
+
idx = self.combo_webget.GetSelection() - 1
|
1294
|
+
if idx >= 0:
|
1295
|
+
url = self.webresources[idx]
|
1296
|
+
if url.startswith("http"):
|
1297
|
+
if (
|
1298
|
+
wx.MessageBox(
|
1299
|
+
_(
|
1300
|
+
"You will be led now to a source in the web, where you can download free fonts.\n"
|
1301
|
+
+ "Please respect individual property rights!\nDestination: {url}\n"
|
1302
|
+
).format(url=url)
|
1303
|
+
+ _(
|
1304
|
+
"Unpack the downloaded archive after the download and select the extracted files with help of the 'Import'-Button."
|
1305
|
+
),
|
1306
|
+
_("Confirm"),
|
1307
|
+
wx.YES_NO | wx.CANCEL | wx.ICON_INFORMATION,
|
1308
|
+
)
|
1309
|
+
== wx.YES
|
1310
|
+
):
|
1311
|
+
import webbrowser
|
1312
|
+
|
1313
|
+
webbrowser.open(url, new=0, autoraise=True)
|
1314
|
+
else:
|
1315
|
+
# This is a local directory with existing font-files,
|
1316
|
+
# e.g. the Windows-Font-Directory
|
1317
|
+
self.import_files(url, "ttf")
|
1318
|
+
|
1319
|
+
def import_files(self, import_directory, extension):
|
1320
|
+
source_files = os.listdir(import_directory)
|
1321
|
+
font_files = []
|
1322
|
+
for entry in source_files:
|
1323
|
+
if entry.lower().endswith(extension):
|
1324
|
+
font_files.append(os.path.join(import_directory, entry))
|
1325
|
+
stats = [0, 0] # Successful, errors
|
1326
|
+
if len(font_files) == 0:
|
1327
|
+
return
|
1328
|
+
|
1329
|
+
maxidx = len(font_files)
|
1330
|
+
progress_string = _("Fonts imported: {count}")
|
1331
|
+
progress = wx.ProgressDialog(
|
1332
|
+
_("Importing fonts..."),
|
1333
|
+
progress_string.format(count=0),
|
1334
|
+
maximum=maxidx,
|
1335
|
+
parent=None,
|
1336
|
+
style=wx.PD_APP_MODAL | wx.PD_CAN_ABORT,
|
1337
|
+
)
|
1338
|
+
for idx, sourcefile in enumerate(font_files):
|
1339
|
+
basename = os.path.basename(sourcefile)
|
1340
|
+
destfile = os.path.join(self.context.fonts.font_directory, basename)
|
1341
|
+
if os.path.exists(destfile):
|
1342
|
+
continue
|
1343
|
+
# print (f"Source File: {sourcefile}\nTarget: {destfile}")
|
1344
|
+
try:
|
1345
|
+
with open(sourcefile, "rb") as f, open(destfile, "wb") as g:
|
1346
|
+
while True:
|
1347
|
+
block = f.read(1 * 1024 * 1024) # work by blocks of 1 MB
|
1348
|
+
if not block: # end of file
|
1349
|
+
break
|
1350
|
+
g.write(block)
|
1351
|
+
bmp = self.context.fonts.preview_file(destfile)
|
1352
|
+
if bmp is not None:
|
1353
|
+
stats[0] += 1
|
1354
|
+
else:
|
1355
|
+
# We delete this file again...
|
1356
|
+
remove_fontfile(destfile)
|
1357
|
+
stats[1] += 1
|
1358
|
+
|
1359
|
+
progress.Update(idx + 1, progress_string.format(count=idx + 1))
|
1360
|
+
if progress.WasCancelled():
|
1361
|
+
break
|
1362
|
+
except (OSError, RuntimeError, PermissionError, FileNotFoundError):
|
1363
|
+
stats[1] += 1
|
1364
|
+
progress.Destroy()
|
1365
|
+
wx.MessageBox(
|
1366
|
+
_(
|
1367
|
+
"Font-Import completed.\nImported: {ok}\nFailed: {fail}\nTotal: {total}"
|
1368
|
+
).format(ok=stats[0], fail=stats[1], total=stats[0] + stats[1]),
|
1369
|
+
_("Import completed"),
|
1370
|
+
wx.OK | wx.ICON_INFORMATION,
|
1371
|
+
)
|
1372
|
+
# Reload....
|
1373
|
+
self.on_text_directory(None)
|
1374
|
+
|
1375
|
+
def pane_hide(self):
|
1376
|
+
self.sysdirs.pane_hide()
|
1377
|
+
|
1378
|
+
# end of class FontManager
|
1379
|
+
|
1380
|
+
|
1381
|
+
class HersheyFontManager(MWindow):
|
1382
|
+
"""
|
1383
|
+
Wrapper Window Class for Vector Font Manager
|
1384
|
+
"""
|
1385
|
+
|
1386
|
+
def __init__(self, *args, **kwds):
|
1387
|
+
super().__init__(551, 234, submenu="", *args, **kwds)
|
1388
|
+
self.panel = PanelFontManager(self, wx.ID_ANY, context=self.context)
|
1389
|
+
self.sizer.Add(self.panel, 1, wx.EXPAND, 0)
|
1390
|
+
_icon = wx.NullIcon
|
1391
|
+
_icon.CopyFromBitmap(icons8_choose_font.GetBitmap())
|
1392
|
+
# _icon.CopyFromBitmap(icons8_computer_support.GetBitmap())
|
1393
|
+
self.SetIcon(_icon)
|
1394
|
+
self.SetTitle(_("Font-Manager"))
|
1395
|
+
self.Layout()
|
1396
|
+
self.restore_aspect()
|
1397
|
+
|
1398
|
+
def window_open(self):
|
1399
|
+
pass
|
1400
|
+
|
1401
|
+
def window_close(self):
|
1402
|
+
pass
|
1403
|
+
|
1404
|
+
def delegates(self):
|
1405
|
+
yield self.panel
|
1406
|
+
|
1407
|
+
@staticmethod
|
1408
|
+
def submenu():
|
1409
|
+
# suppress in tool-menu
|
1410
|
+
return "", "Font-Manager", True
|
1411
|
+
|
1412
|
+
@staticmethod
|
1413
|
+
def helptext():
|
1414
|
+
return _("Manage the fonts available to MeerK40t")
|
1415
|
+
|
1416
|
+
|
1417
|
+
def register_hershey_stuff(kernel):
|
1418
|
+
kernel.root.register("path_attributes/linetext", LineTextPropertyPanel)
|
1419
|
+
buttonsize = int(STD_ICON_SIZE)
|
1420
|
+
kernel.register(
|
1421
|
+
"button/config/HersheyFontManager",
|
1422
|
+
{
|
1423
|
+
"label": _("Font-Manager"),
|
1424
|
+
"icon": icons8_choose_font,
|
1425
|
+
"tip": _("Open the vector-font management window."),
|
1426
|
+
"help": "vectortext",
|
1427
|
+
"action": lambda v: kernel.console("window toggle HersheyFontManager\n"),
|
1428
|
+
"size": buttonsize,
|
1429
|
+
},
|
1430
|
+
)
|