From 1d5f4c819356ce75517a9a7332326fb1b267b6a5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 8 Jul 2024 18:08:07 +0200 Subject: protoboard: Fix bug with empty points in breadboard rendering --- gerbonara/cad/protoboard.py | 42 ++++++++++++++++++++++-------------------- 1 file 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: -- cgit