summaryrefslogtreecommitdiff
path: root/gerbonara/cam.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-05-21 15:29:18 +0200
committerjaseg <git@jaseg.de>2022-05-21 15:29:18 +0200
commite422243a6e76d0b798ae8f175a717c193be4d22a (patch)
tree40f2de58c06baa42d45f1d47bf9ca7d111bcb6be /gerbonara/cam.py
parentc127c89fa3a6dd957b2eb66660905dc84751c2b2 (diff)
downloadgerbonara-e422243a6e76d0b798ae8f175a717c193be4d22a.tar.gz
gerbonara-e422243a6e76d0b798ae8f175a717c193be4d22a.tar.bz2
gerbonara-e422243a6e76d0b798ae8f175a717c193be4d22a.zip
Fix layer stack SVG export
Diffstat (limited to 'gerbonara/cam.py')
-rw-r--r--gerbonara/cam.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/gerbonara/cam.py b/gerbonara/cam.py
index 27b49ce..3e00fb6 100644
--- a/gerbonara/cam.py
+++ b/gerbonara/cam.py
@@ -22,6 +22,9 @@ from dataclasses import dataclass
from copy import deepcopy
from enum import Enum
import string
+import shutil
+from pathlib import Path
+from functools import cached_property
from .utils import LengthUnit, MM, Inch, Tag, sum_bounds, setup_svg
from . import graphic_primitives as gp
@@ -246,6 +249,14 @@ class CamFile:
self.layer_name = layer_name
self.import_settings = import_settings
+ @property
+ def is_lazy(self):
+ return False
+
+ @property
+ def instance(self):
+ return self
+
def to_svg(self, margin=0, arg_unit=MM, svg_unit=MM, force_bounds=None, fg='black', bg='white', tag=Tag):
if force_bounds:
bounds = svg_unit.convert_bounds_from(arg_unit, force_bounds)
@@ -386,3 +397,22 @@ class CamFile:
""" Test if this file contains any objects """
return not self.is_empty
+class LazyCamFile:
+ def __init__(self, klass, path, *args, **kwargs):
+ self._class = klass
+ self.original_path = Path(path)
+ self._args = args
+ self._kwargs = kwargs
+
+ @cached_property
+ def instance(self):
+ return self._class.open(self.original_path, *self._args, **self._kwargs)
+
+ @property
+ def is_lazy(self):
+ return True
+
+ def save(self, filename, *args, **kwargs):
+ """ Copy this Gerber file to the new path. """
+ shutil.copy(self.original_path, filename)
+