kopia lustrzana https://gitlab.com/gerbolyze/gerbonara
autoroute
rodzic
e4dcbe177f
commit
eb20595e00
|
@ -344,18 +344,31 @@ class TextMixin:
|
|||
font = Newstroke.load()
|
||||
text = string.Template(self.text).safe_substitute(variables)
|
||||
aperture = ap.CircleAperture(self.line_width or 0.2, unit=MM)
|
||||
if text == 'H3LIS100DL':
|
||||
print(text, self.rotation, self.at, self.effects)
|
||||
rot = self.rotation
|
||||
h_align = self.h_align
|
||||
mx, my = self.mirrored
|
||||
if rot in (90, 270):
|
||||
rot = (rot+180)%360
|
||||
elif rot == 180:
|
||||
rot = 0
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
|
||||
if my and rot in (0, 180):
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
rot = (rot+180)%360
|
||||
if mx and rot in (90, 270):
|
||||
h_align = {'left': 'right', 'right': 'left'}.get(h_align, h_align)
|
||||
rot = (rot+180)%360
|
||||
|
||||
yield font.render_svg(text,
|
||||
size=self.size or 1.27,
|
||||
h_align=self.h_align,
|
||||
h_align=h_align,
|
||||
v_align=self.effects.justify.v or self.default_v_align,
|
||||
stroke=color,
|
||||
stroke_width=f'{self.line_width:.3f}',
|
||||
scale=(1,1),
|
||||
rotation=self.rotation,
|
||||
mirror=self.mirrored,
|
||||
transform=f'translate({self.at.x:.3f} {self.at.y:.3f})',
|
||||
rotation=0,
|
||||
transform=f'translate({self.at.x:.3f} {self.at.y:.3f}) rotate({rot})',
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -79,8 +79,9 @@ class NoConnect:
|
|||
|
||||
def to_svg(self, colorscheme=Colorscheme.KiCad):
|
||||
r = 0.635
|
||||
yield Tag('path', d=f'M {-r:.3f} {-r:.3f} L {r:.3f} {r:.3f} M {-r:.3f} {r:.3f} L {r:.3f} {-r:.3f}',
|
||||
fill='none', stroke_width='0.1', stroke=colorscheme.no_connect)
|
||||
x, y = self.at.x, self.at.y
|
||||
yield Tag('path', d=f'M {x-r:.3f} {y-r:.3f} L {x+r:.3f} {y+r:.3f} M {x-r:.3f} {y+r:.3f} L {x+r:.3f} {y-r:.3f}',
|
||||
fill='none', stroke_width='0.254', stroke=colorscheme.no_connect)
|
||||
|
||||
|
||||
@sexp_type('bus_entry')
|
||||
|
@ -312,11 +313,14 @@ class DrawnProperty(TextMixin):
|
|||
|
||||
@property
|
||||
def h_align(self):
|
||||
return self.effects.justify.h_str
|
||||
align = self.effects.justify.h_str
|
||||
if self.rotation in (90, 270):
|
||||
align = {'left': 'right', 'right': 'left'}.get(align, align)
|
||||
return align
|
||||
|
||||
@property
|
||||
def rotation(self):
|
||||
rot = -self.at.rotation
|
||||
rot = self.at.rotation
|
||||
rot += getattr(self.parent.at, 'rotation', 0)
|
||||
return rot%360
|
||||
|
||||
|
@ -397,9 +401,6 @@ class SymbolInstance:
|
|||
|
||||
units = [unit for unit in sym.units if unit.unit_global or unit.unit_index == self.unit]
|
||||
|
||||
if self.reference in ('U18',):
|
||||
print(self.reference, self.unit, self.at, self.mirror, units)
|
||||
|
||||
at_xform = xform = f'translate({self.at.x:.3f} {self.at.y:.3f})'
|
||||
if self.mirror.y:
|
||||
xform += f'scale(-1 -1)'
|
||||
|
@ -416,8 +417,8 @@ class SymbolInstance:
|
|||
children = [foo for unit in units for pin in unit.pins for foo in pin.to_svg(colorscheme, self.mirror, rot)]
|
||||
yield Tag('g', children=children, transform=at_xform, fill=colorscheme.fill, stroke=colorscheme.lines)
|
||||
|
||||
#for prop in self.properties:
|
||||
# yield from prop.to_svg()
|
||||
for prop in self.properties:
|
||||
yield from prop.to_svg()
|
||||
|
||||
|
||||
@sexp_type('path')
|
||||
|
|
|
@ -151,13 +151,13 @@ class Pin:
|
|||
ax, ay = self.length+0.2, 0
|
||||
ax, ay = rotate_point(ax, ay, math.radians(-self.at.rotation))
|
||||
|
||||
lx, ly = self.at.x, -self.at.y
|
||||
lx, ly = rotate_point(lx, ly, math.radians(p_rotation))
|
||||
if p_mirror.y:
|
||||
lx, ly = -lx, ly
|
||||
elif p_mirror.x:
|
||||
lx, ly = lx, -ly
|
||||
yield Tag('circle', cx=lx, cy=ly, r='0.5', stroke='blue', stroke_width='0.1', fill='none', z_index='100')
|
||||
#lx, ly = self.at.x, -self.at.y
|
||||
#lx, ly = rotate_point(lx, ly, math.radians(p_rotation))
|
||||
#if p_mirror.y:
|
||||
# lx, ly = -lx, ly
|
||||
#elif p_mirror.x:
|
||||
# lx, ly = lx, -ly
|
||||
#yield Tag('circle', cx=lx, cy=ly, r='0.5', stroke='blue', stroke_width='0.1', fill='none', z_index='100')
|
||||
|
||||
lx, ly = self.at.x + ax, -self.at.y - ay
|
||||
lx, ly = rotate_point(lx, ly, math.radians(p_rotation))
|
||||
|
@ -165,7 +165,7 @@ class Pin:
|
|||
lx, ly = -lx, ly
|
||||
elif p_mirror.x:
|
||||
lx, ly = lx, -ly
|
||||
yield Tag('circle', cx=lx, cy=ly, r='0.5', stroke='red', stroke_width='0.1', fill='none', z_index='100')
|
||||
#yield Tag('circle', cx=lx, cy=ly, r='0.5', stroke='red', stroke_width='0.1', fill='none', z_index='100')
|
||||
|
||||
h_align = 'left'
|
||||
if p_mirror.y:
|
||||
|
|
|
@ -37,8 +37,6 @@ class Newstroke:
|
|||
sx, sy = scale
|
||||
mx, my = mirror
|
||||
x = 0
|
||||
if text in ('VDDA', 'PA9', 'VSS', 'FB3'):
|
||||
print(text, x0, y0, rotation, h_align, v_align, scale)
|
||||
|
||||
if rotation >= 180:
|
||||
rotation -= 180
|
||||
|
|
Ładowanie…
Reference in New Issue