meerk40t 0.9.7930__py2.py3-none-any.whl → 0.9.7940__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.
@@ -267,7 +267,7 @@ DEFAULT_ALIAS = {
267
267
  "+left": (".timerleft 0 0.1 left 1mm",),
268
268
  "+up": (".timerup 0 0.1 up 1mm",),
269
269
  "+down": (".timerdown 0 0.1 down 1mm",),
270
- "burn": ("planz clear copy preprocess validate blob preopt optimize spool", ),
270
+ "burn": ("planz clear copy preprocess validate blob preopt optimize spool",),
271
271
  "-scale_up": (".timerscale_up off",),
272
272
  "-scale_down": (".timerscale_down off",),
273
273
  "-rotate_cw": (".timerrotate_cw off",),
@@ -318,7 +318,11 @@ class Bind(Service):
318
318
  key,
319
319
  )
320
320
 
321
- channel(_(" Key Command"))
321
+ channel(
322
+ " {key} {command}".format(
323
+ key=_("Key").ljust(22), command=_("Command")
324
+ )
325
+ )
322
326
  for i, key in enumerate(sorted(self.keymap.keys(), key=keymap_index)):
323
327
  value = self.keymap[key]
324
328
  channel(f"{i:2d}: {key.ljust(22)} {value}")
@@ -445,8 +449,12 @@ class Alias(Service):
445
449
  _ = self._
446
450
  if alias is None:
447
451
  reverse_keymap = {v: k for k, v in self.bind.keymap.items()}
448
- channel(_("Aliases (keybind)`:"))
449
- channel(_(" Alias Command(s)"))
452
+ channel(_("Aliases (keybind):"))
453
+ channel(
454
+ " {key} {value}".format(
455
+ key=_("Alias").ljust(22), value=_("Command(s)")
456
+ )
457
+ )
450
458
  last = None
451
459
  i = -1
452
460
  for key in sorted(
@@ -95,7 +95,7 @@ def init_commands(kernel):
95
95
  except OSError as e:
96
96
  channel(str(e))
97
97
 
98
- @self.console_command("save_types", help=_("save_types"))
98
+ @self.console_command("save_types", help=_("save_types - display save types"))
99
99
  def file_save_types(command, channel, _, **kwargs):
100
100
  for saver, save_name, sname in kernel.find("save"):
101
101
  for description, extension, mimetype, version in saver.save_types():
@@ -2984,7 +2984,7 @@ def init_commands(kernel):
2984
2984
  with self.undoscope("Create cross"):
2985
2985
  node = self.elem_branch.add(
2986
2986
  label=_("Cross at ({xp}, {yp})").format(
2987
- xp=xpos.length_mm, yp=ypos.length_mm
2987
+ xp=Length(xpos).length_mm, yp=Length(ypos).length_mm
2988
2988
  ),
2989
2989
  geometry=geom,
2990
2990
  stroke=self.default_stroke,
@@ -2,8 +2,8 @@ import itertools
2
2
  from copy import copy
3
3
  from math import sqrt
4
4
 
5
- from meerk40t.core.node.node import Node
6
5
  from meerk40t.core.node.mixins import Suppressable
6
+ from meerk40t.core.node.node import Node
7
7
  from meerk40t.core.units import Angle, Length
8
8
  from meerk40t.svgelements import Color, Point
9
9
  from meerk40t.tools.geomstr import Geomstr # , Scanbeam
@@ -179,8 +179,8 @@ class HatchEffectNode(Node, Suppressable):
179
179
  factor = sqrt(abs(matrix.determinant))
180
180
  self._distance *= factor
181
181
  # Let's establish the angle
182
- p1:Point = matrix.point_in_matrix_space((0, 0))
183
- p2:Point = matrix.point_in_matrix_space((1, 0))
182
+ p1: Point = matrix.point_in_matrix_space((0, 0))
183
+ p2: Point = matrix.point_in_matrix_space((1, 0))
184
184
  angle = p1.angle_to(p2)
185
185
  self._angle -= angle
186
186
  # from math import tau
@@ -240,6 +240,8 @@ class HatchEffectNode(Node, Suppressable):
240
240
  subs = right_types(e)
241
241
  res.extend(subs)
242
242
  elif e.type.startswith("elem"):
243
+ if hasattr(e, "hidden") and e.hidden:
244
+ continue
243
245
  res.append(e)
244
246
  return res
245
247
 
@@ -301,7 +303,6 @@ class HatchEffectNode(Node, Suppressable):
301
303
  angle=self._angle + p * self._angle_delta,
302
304
  )
303
305
 
304
-
305
306
  def set_interim(self):
306
307
  self.empty_cache()
307
308
  self._interim = True
@@ -315,9 +316,9 @@ class HatchEffectNode(Node, Suppressable):
315
316
 
316
317
  def can_drop(self, drag_node):
317
318
  if (
318
- hasattr(drag_node, "as_geometry") or
319
- drag_node.type in ("effect", "file", "group", "reference") or
320
- (drag_node.type.startswith("op ") and drag_node.type != "op dots")
319
+ hasattr(drag_node, "as_geometry")
320
+ or drag_node.type in ("effect", "file", "group", "reference")
321
+ or (drag_node.type.startswith("op ") and drag_node.type != "op dots")
321
322
  ):
322
323
  return True
323
324
  return False
@@ -210,7 +210,6 @@ class WarpEffectNode(Node, FunctionalParameter):
210
210
  self.d3 = complex(nn3.x - pp3.x, nn3.y - pp3.y)
211
211
  self.d4 = complex(nn4.x - pp4.x, nn4.y - pp4.y)
212
212
 
213
-
214
213
  def default_map(self, default_map=None):
215
214
  default_map = super().default_map(default_map=default_map)
216
215
  default_map["element_type"] = "Warp"
@@ -229,6 +228,8 @@ class WarpEffectNode(Node, FunctionalParameter):
229
228
  subs = right_types(e)
230
229
  res.extend(subs)
231
230
  elif e.type.startswith("elem"):
231
+ if hasattr(e, "hidden") and e.hidden:
232
+ continue
232
233
  res.append(e)
233
234
  return res
234
235
 
@@ -297,7 +298,11 @@ class WarpEffectNode(Node, FunctionalParameter):
297
298
  self.altered()
298
299
 
299
300
  def can_drop(self, drag_node):
300
- if hasattr(drag_node, "as_geometry") or drag_node.type in ("effect", "file", "group", "reference") or (drag_node.type.startswith("op ") and drag_node.type != "op dots"):
301
+ if (
302
+ hasattr(drag_node, "as_geometry")
303
+ or drag_node.type in ("effect", "file", "group", "reference")
304
+ or (drag_node.type.startswith("op ") and drag_node.type != "op dots")
305
+ ):
301
306
  return True
302
307
  return False
303
308
 
@@ -2,8 +2,8 @@ import math
2
2
  from copy import copy
3
3
  from math import sqrt
4
4
 
5
- from meerk40t.core.node.node import Node
6
5
  from meerk40t.core.node.mixins import Suppressable
6
+ from meerk40t.core.node.node import Node
7
7
  from meerk40t.core.units import Length
8
8
  from meerk40t.svgelements import Color
9
9
  from meerk40t.tools.geomstr import Geomstr # , Scanbeam
@@ -225,6 +225,8 @@ class WobbleEffectNode(Node, Suppressable):
225
225
  subs = right_types(e)
226
226
  res.extend(subs)
227
227
  elif e.type.startswith("elem"):
228
+ if hasattr(e, "hidden") and e.hidden:
229
+ continue
228
230
  res.append(e)
229
231
  return res
230
232
 
@@ -384,7 +386,11 @@ class WobbleEffectNode(Node, Suppressable):
384
386
  self.altered()
385
387
 
386
388
  def can_drop(self, drag_node):
387
- if hasattr(drag_node, "as_geometry") or drag_node.type in ("effect", "file", "group", "reference") or (drag_node.type.startswith("op ") and drag_node.type != "op dots"):
389
+ if (
390
+ hasattr(drag_node, "as_geometry")
391
+ or drag_node.type in ("effect", "file", "group", "reference")
392
+ or (drag_node.type.startswith("op ") and drag_node.type != "op dots")
393
+ ):
388
394
  return True
389
395
  return False
390
396
 
@@ -21,16 +21,17 @@ Methods:
21
21
  """
22
22
  from copy import copy
23
23
  from math import isnan
24
+
24
25
  from meerk40t.constants import (
25
- RASTER_T2B,
26
26
  RASTER_B2T,
27
- RASTER_R2L,
28
- RASTER_L2R,
29
- RASTER_HATCH,
27
+ RASTER_CROSSOVER,
30
28
  RASTER_GREEDY_H,
31
29
  RASTER_GREEDY_V,
32
- RASTER_CROSSOVER,
30
+ RASTER_HATCH,
31
+ RASTER_L2R,
32
+ RASTER_R2L,
33
33
  RASTER_SPIRAL,
34
+ RASTER_T2B,
34
35
  )
35
36
  from meerk40t.core.cutcode.rastercut import RasterCut
36
37
  from meerk40t.core.elements.element_types import *
@@ -67,7 +68,13 @@ class ImageOpNode(Node, Parameters):
67
68
  super().__init__(type="op image", **kwargs)
68
69
  self._formatter = "{enabled}{pass}{element_type}{direction}{speed}mm/s @{power}"
69
70
  # They might come from a svg read, but shouldnt be in settings
70
- for attrib in ("lock", "dangerous", "use_grayscale", "consider_laserspot", "overrule_dpi"):
71
+ for attrib in (
72
+ "lock",
73
+ "dangerous",
74
+ "use_grayscale",
75
+ "consider_laserspot",
76
+ "overrule_dpi",
77
+ ):
71
78
  if attrib in self.settings:
72
79
  del self.settings[attrib]
73
80
 
@@ -146,7 +153,9 @@ class ImageOpNode(Node, Parameters):
146
153
  # Move operation to a different position.
147
154
  return True
148
155
  elif drag_node.type in ("file", "group"):
149
- return not any(e.has_ancestor("branch reg") for e in drag_node.flat(elem_nodes))
156
+ return not any(
157
+ e.has_ancestor("branch reg") for e in drag_node.flat(elem_nodes)
158
+ )
150
159
  return False
151
160
 
152
161
  def drop(self, drag_node, modify=True, flag=False):
@@ -255,8 +264,12 @@ class ImageOpNode(Node, Parameters):
255
264
  height_in_inches = (max_y - min_y) / UNITS_PER_INCH
256
265
  speed_in_per_s = self.speed / MM_PER_INCH
257
266
  if self.raster_direction in (
258
- RASTER_T2B, RASTER_B2T, RASTER_HATCH,
259
- RASTER_GREEDY_H, RASTER_CROSSOVER, RASTER_SPIRAL,
267
+ RASTER_T2B,
268
+ RASTER_B2T,
269
+ RASTER_HATCH,
270
+ RASTER_GREEDY_H,
271
+ RASTER_CROSSOVER,
272
+ RASTER_SPIRAL,
260
273
  ):
261
274
  scanlines = height_in_inches * dpi
262
275
  if not self.bidirectional:
@@ -268,7 +281,12 @@ class ImageOpNode(Node, Parameters):
268
281
  this_len = scanlines * width_in_inches + height_in_inches
269
282
  estimate += this_len / speed_in_per_s
270
283
  # print (f"Horizontal scanlines: {scanlines}, Length: {this_len:.1f}")
271
- if self.raster_direction in (RASTER_L2R, RASTER_R2L, RASTER_HATCH, RASTER_GREEDY_V):
284
+ if self.raster_direction in (
285
+ RASTER_L2R,
286
+ RASTER_R2L,
287
+ RASTER_HATCH,
288
+ RASTER_GREEDY_V,
289
+ ):
272
290
  scanlines = width_in_inches * dpi
273
291
  if not self.bidirectional:
274
292
  scanlines *= 2
@@ -304,7 +322,14 @@ class ImageOpNode(Node, Parameters):
304
322
  if self.consider_laserspot:
305
323
  try:
306
324
  laserspot = getattr(context.device, "laserspot", "0.3mm")
307
- spot = 2 * float(Length(laserspot)) / ( context.device.view.native_scale_x + context.device.view.native_scale_y)
325
+ spot = (
326
+ 2
327
+ * float(Length(laserspot))
328
+ / (
329
+ context.device.view.native_scale_x
330
+ + context.device.view.native_scale_y
331
+ )
332
+ )
308
333
  # print (f"Laserpot in device units: {spot:.2f} [{laserspot.length_mm}], scale: {context.device.view.native_scale_x + context.device.view.native_scale_y:.2f}")
309
334
  except (ValueError, AttributeError):
310
335
  spot = 0
@@ -388,9 +413,12 @@ class ImageOpNode(Node, Parameters):
388
413
  def call_me(method):
389
414
  def handler():
390
415
  method(self)
416
+
391
417
  return handler
392
418
 
393
- for key, description, method in context.kernel.lookup_all("raster_preprocessor/.*"):
419
+ for key, description, method in context.kernel.lookup_all(
420
+ "raster_preprocessor/.*"
421
+ ):
394
422
  if key == self.raster_direction:
395
423
  plan.commands.append(call_me(method))
396
424
  # print (f"Found {description}")
@@ -433,7 +461,13 @@ class ImageOpNode(Node, Parameters):
433
461
  start_on_top = self.raster_preference_top
434
462
  if direction in (RASTER_GREEDY_V, RASTER_L2R, RASTER_R2L):
435
463
  horizontal = False
436
- if direction in (RASTER_B2T, RASTER_T2B, RASTER_HATCH, RASTER_CROSSOVER, RASTER_GREEDY_H):
464
+ if direction in (
465
+ RASTER_B2T,
466
+ RASTER_T2B,
467
+ RASTER_HATCH,
468
+ RASTER_CROSSOVER,
469
+ RASTER_GREEDY_H,
470
+ ):
437
471
  horizontal = True
438
472
  if direction in (RASTER_T2B, RASTER_CROSSOVER):
439
473
  start_on_top = True
@@ -494,7 +528,7 @@ class ImageOpNode(Node, Parameters):
494
528
  gres = 0
495
529
  if gres > 255:
496
530
  gres = 255
497
- stepsize = 255 / gres
531
+ stepsize = 255 / gres
498
532
 
499
533
  # no need for the filter as we have already moved every
500
534
  # pixel during preprocessing to either 255 or 0
@@ -607,27 +641,42 @@ class ImageOpNode(Node, Parameters):
607
641
  else:
608
642
  # Create Cut Object for regular image
609
643
  image_filter = None
610
- do_optimize = self.raster_direction in (RASTER_GREEDY_H, RASTER_GREEDY_V)
644
+ do_optimize = self.raster_direction in (
645
+ RASTER_GREEDY_H,
646
+ RASTER_GREEDY_V,
647
+ )
611
648
  if do_optimize:
612
649
  # get some image statistics
613
650
  white_pixels = 0
614
651
  used_colors = pil_image.getcolors()
615
652
  for col_count, col in used_colors:
616
- if col==255:
653
+ if col == 255:
617
654
  white_pixels = col_count
618
655
  break
619
- white_pixel_ratio = white_pixels / (pil_image.width * pil_image.height)
656
+ white_pixel_ratio = white_pixels / (
657
+ pil_image.width * pil_image.height
658
+ )
620
659
  # print (f"white pixels: {white_pixels}, ratio = {white_pixel_ratio:.3f}")
621
660
  if white_pixel_ratio < 0.3:
622
- self.raster_direction = RASTER_T2B if self.raster_direction == RASTER_GREEDY_H else RASTER_L2R
661
+ self.raster_direction = (
662
+ RASTER_T2B
663
+ if self.raster_direction == RASTER_GREEDY_H
664
+ else RASTER_L2R
665
+ )
623
666
 
624
- if self.raster_direction in (RASTER_CROSSOVER, RASTER_SPIRAL): # Crossover - need both
667
+ if self.raster_direction in (
668
+ RASTER_CROSSOVER,
669
+ RASTER_SPIRAL,
670
+ ): # Crossover - need both
625
671
  settings["raster_step_x"] = step_x
626
672
  settings["raster_step_y"] = step_y
627
- if self.raster_direction == RASTER_CROSSOVER and "split_crossover" in self._instructions:
673
+ if (
674
+ self.raster_direction == RASTER_CROSSOVER
675
+ and "split_crossover" in self._instructions
676
+ ):
628
677
  self._instructions["mode_filter"] = "ROW"
629
- horizontal=True
630
- bidirectional=True
678
+ horizontal = True
679
+ bidirectional = True
631
680
  start_on_top = True
632
681
  start_on_left = True
633
682
  if horizontal:
@@ -666,7 +715,7 @@ class ImageOpNode(Node, Parameters):
666
715
  cutcodes.append(cut)
667
716
 
668
717
  # Now set it for the next pass
669
- horizontal=False
718
+ horizontal = False
670
719
  if horizontal:
671
720
  # Raster step is only along y for horizontal raster
672
721
  settings["raster_step_x"] = 0
@@ -701,7 +750,7 @@ class ImageOpNode(Node, Parameters):
701
750
  )
702
751
  cut.path = path
703
752
  cut.original_op = self.type
704
- cutcodes.append(cut)
753
+ cutcodes.append(cut)
705
754
  if self.raster_direction == RASTER_HATCH:
706
755
  # Create optional crosshatch cut
707
756
  direction = RASTER_L2R if start_on_left else RASTER_R2L
@@ -750,6 +799,11 @@ class ImageOpNode(Node, Parameters):
750
799
  self._bounds = None
751
800
  if self.output:
752
801
  if self._children:
753
- self._bounds = Node.union_bounds(self._children, bounds=self._bounds, ignore_locked=False, ignore_hidden=True)
802
+ self._bounds = Node.union_bounds(
803
+ self._children,
804
+ bounds=self._bounds,
805
+ ignore_locked=False,
806
+ ignore_hidden=True,
807
+ )
754
808
  self._bounds_dirty = False
755
809
  return self._bounds