Fix zip import/export and bounds for empty boards

merge-requests/1/head v0.11.1
jaseg 2022-06-21 14:17:08 +02:00
rodzic 71e996e874
commit 7bdbe66dc7
3 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -267,6 +267,8 @@ class CamFile:
# setup viewport transform flipping y axis
(content_min_x, content_min_y), (content_max_x, content_max_y) = bounds
content_min_x, content_min_y = float(content_min_x), float(content_min_y)
content_max_x, content_max_y = float(content_max_x), float(content_max_y)
content_w, content_h = content_max_x - content_min_x, content_max_y - content_min_y
xform = f'translate({content_min_x:.6} {content_min_y+content_h:.6}) scale(1 -1) translate({-content_min_x:.6} {-content_min_y:.6})'
tags = [tag('g', tags, transform=xform)]

Wyświetl plik

@ -27,6 +27,7 @@ import itertools
from collections import namedtuple
from pathlib import Path
from zipfile import ZipFile, is_zipfile
import tempfile
from .excellon import ExcellonFile, parse_allegro_ncparam, parse_allegro_logfile
from .rs274x import GerberFile
@ -249,13 +250,13 @@ class LayerStack:
@classmethod
def open_zip(kls, file, original_path=None, board_name=None, lazy=False):
tmpdir = tempfile.TemporaryDirectory()
tmp_indir = Path(tmpdir) / 'input'
tmp_indir = Path(tmpdir.name) / 'input'
tmp_indir.mkdir()
with ZipFile(file) as f:
f.extractall(path=tmp_indir)
inst = kls.from_directory(tmp_indir, board_name=board_name, lazy=lazy)
inst = kls.open_dir(tmp_indir, board_name=board_name, lazy=lazy)
inst.tmpdir = tmpdir
inst.original_path = Path(original_path or file)
inst.was_zipped = True
@ -486,7 +487,7 @@ class LayerStack:
if force_bounds:
bounds = svg_unit.convert_bounds_from(arg_unit, force_bounds)
else:
bounds = selfboard_bounds(unit=svg_unit, default=((0, 0), (0, 0)))
bounds = self.board_bounds(unit=svg_unit, default=((0, 0), (0, 0)))
tags = []
inkscape_attrs = lambda label: dict(inkscape__groupmode='layer', inkscape__label=label) if inkscape else {}

Wyświetl plik

@ -269,7 +269,7 @@ def sum_bounds(bounds, *, default=None):
:rtype: tuple
"""
bounds = iter(bounds)
bounds = iter([ b for b in bounds if b is not None ])
for (min_x, min_y), (max_x, max_y) in bounds:
break