summaryrefslogtreecommitdiff
path: root/gerbonara/layers.py
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2022-06-18 23:52:22 +0200
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2022-06-18 23:52:22 +0200
commitdfaf23b71803bdaf331e8353b93e3862838da042 (patch)
tree393a219e9a0be338f1b6e8d8f555d0f67feae8a3 /gerbonara/layers.py
parent4b38d0905e766e19e19103b86af1a6352c8e1bf9 (diff)
downloadgerbonara-dfaf23b71803bdaf331e8353b93e3862838da042.tar.gz
gerbonara-dfaf23b71803bdaf331e8353b93e3862838da042.tar.bz2
gerbonara-dfaf23b71803bdaf331e8353b93e3862838da042.zip
Add selectable inkscape SVG export
Diffstat (limited to 'gerbonara/layers.py')
-rw-r--r--gerbonara/layers.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/gerbonara/layers.py b/gerbonara/layers.py
index 2c48a83..47ade7d 100644
--- a/gerbonara/layers.py
+++ b/gerbonara/layers.py
@@ -480,13 +480,14 @@ class LayerStack:
return setup_svg(tags, bounds, margin=margin, arg_unit=arg_unit, svg_unit=svg_unit, pagecolor=bg, tag=tag)
- def to_pretty_svg(self, side='top', margin=0, arg_unit=MM, svg_unit=MM, force_bounds=None, tag=Tag):
+ def to_pretty_svg(self, side='top', margin=0, arg_unit=MM, svg_unit=MM, force_bounds=None, tag=Tag, inkscape=False):
if force_bounds:
bounds = svg_unit.convert_bounds_from(arg_unit, force_bounds)
else:
- bounds = self.outline.instance.bounding_box(svg_unit, default=((0, 0), (0, 0)))
+ bounds = selfboard_bounds(unit=svg_unit, default=((0, 0), (0, 0)))
tags = []
+ inkscape_attrs = lambda label: dict(inkscape__groupmode='layer', inkscape__label=label) if inkscape else {}
for use, color in {'copper': 'black', 'mask': 'blue', 'silk': 'red'}.items():
if (side, use) not in self:
@@ -495,13 +496,13 @@ class LayerStack:
layer = self[(side, use)]
tags.append(tag('g', list(layer.instance.svg_objects(svg_unit=svg_unit, fg=color, bg="white", tag=Tag)),
- id=f'l-{side}-{use}'))
+ id=f'l-{side}-{use}', **inkscape_attrs(f'{side} {use}')))
for i, layer in enumerate(self.drill_layers):
tags.append(tag('g', list(layer.instance.svg_objects(svg_unit=svg_unit, fg='magenta', bg="white", tag=Tag)),
- id=f'l-drill-{i}'))
+ id=f'l-drill-{i}', **inkscape_attrs(f'drill-{i}')))
- return setup_svg(tags, bounds, margin=margin, arg_unit=arg_unit, svg_unit=svg_unit, pagecolor="white", tag=tag)
+ return setup_svg(tags, bounds, margin=margin, arg_unit=arg_unit, svg_unit=svg_unit, pagecolor="white", tag=tag, inkscape=inkscape)
def bounding_box(self, unit=MM, default=None):
return sum_bounds(( layer.bounding_box(unit, default=default)