diff options
author | jaseg <git@jaseg.de> | 2024-07-08 18:08:07 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2024-07-08 18:10:57 +0200 |
commit | 1d5f4c819356ce75517a9a7332326fb1b267b6a5 (patch) | |
tree | adbfaea3a29e067fe05596d6077e82f326dfad95 /gerbonara | |
parent | 30878adfb1bdc892b69751e2cc12b286c9716bd0 (diff) | |
download | gerbonara-1d5f4c819356ce75517a9a7332326fb1b267b6a5.tar.gz gerbonara-1d5f4c819356ce75517a9a7332326fb1b267b6a5.tar.bz2 gerbonara-1d5f4c819356ce75517a9a7332326fb1b267b6a5.zip |
protoboard: Fix bug with empty points in breadboard rendering
Diffstat (limited to 'gerbonara')
-rw-r--r-- | gerbonara/cad/protoboard.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/gerbonara/cad/protoboard.py b/gerbonara/cad/protoboard.py index a02d20a..da96fb8 100644 --- a/gerbonara/cad/protoboard.py +++ b/gerbonara/cad/protoboard.py @@ -425,28 +425,30 @@ class BreadboardArea: label = f'{j+1}' if last_e == 'R': - tx, ty = points[0] - - if self.horizontal: - ty -= self.pitch_x/2 - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit) - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit, flip=True) - else: - tx -= self.pitch_x/2 - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit) - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit, flip=True) + if points: + tx, ty = points[0] + + if self.horizontal: + ty -= self.pitch_x/2 + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit) + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'top', unit=self.unit, flip=True) + else: + tx -= self.pitch_x/2 + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit) + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'right', 'middle', unit=self.unit, flip=True) else: - tx, ty = points[-1] - - if self.horizontal: - ty += self.pitch_x/2 - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit) - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit, flip=True) - else: - tx += self.pitch_x/2 - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit) - yield Text(tx, ty, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit, flip=True) + if points: + tx, ty = points[-1] + + if self.horizontal: + ty += self.pitch_x/2 + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit) + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'center', 'bottom', unit=self.unit, flip=True) + else: + tx += self.pitch_x/2 + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit) + yield Text(tx, ty, label, self.font_size, self.font_stroke, 'left', 'middle', unit=self.unit, flip=True) last_e = e if self.num_power_rails == 2 and best_layout.count('P') >= 2: |