Commits

Martin Vejnár committed 5a4f3a5

Support for dot/clk pins in svg.

  • Participants
  • Parent commits d88964c

Comments (0)

Files changed (2)

     PIN_VISIBLE_FLAG_PAD = 1
     PIN_VISIBLE_FLAG_PIN = 2
 
-    PIN_FUNCTION_FLAG_DOT = 2
-    PIN_FUNCTION_FLAG_CLK = 1
+    PIN_FUNCTION_FLAG_DOT = 1
+    PIN_FUNCTION_FLAG_CLK = 2
 
 class Gate(EagleObject):
     pass
 import sys
 import math
 
+def _rotate_one(angle, x, y):
+    if angle == 0:
+        return x, y
+    elif angle == 1:
+        return -y, x
+    elif angle == 2:
+        return -x, -y
+    elif angle == 3:
+        return y, -x
+
+def _rotate(angle, points):
+    return [_rotate_one(angle, x, y) for x, y in points]
+
 class _EaglePrinter:
     def __init__(self, root):
         self.out = [
                 self.color_map[layer.color], wire.width*2))
 
     def print_pin(self, pin):
-        if pin.length == 0:
-            return
-
-        wire = Wire()
-        wire.arc = False
-        wire.layer = 94
-        wire.width = 1524/2
-
-        wire.x1 = pin.x
-        wire.y1 = pin.y
-
         len = pin.length * 2540 * 10
 
         def _get_target(x, y, len, angle):
-            if angle == 0:
-                return x + len, y
-            elif angle == 1:
-                return x, y + len
-            elif angle == 2:
-                return x - len, y
-            elif angle == 3:
-                return x, y - len
+            rx, ry = _rotate_one(angle, len, 0)
+            return x + rx, y + ry
 
         if (pin.function & pin.PIN_FUNCTION_FLAG_CLK) != 0 and pin.length >= 1:
+            p1, p2, p3 = _rotate(pin.angle, [(len, 9906), (len + 19810, 0), (len, -9906)])
+
+            wire = Wire()
+            wire.arc = False
+            wire.layer = 94
+            wire.width = 1524/2
+
+            wire.x1, wire.y1, wire.x2, wire.y2 = p1[0] + pin.x, p1[1] + pin.y, p2[0] + pin.x, p2[1] + pin.y
+            self.print_wire(wire)
+
+            wire.x1, wire.y1, wire.x2, wire.y2 = p2[0] + pin.x, p2[1] + pin.y, p3[0] + pin.x, p3[1] + pin.y
+            self.print_wire(wire)
+
+        if (pin.function & pin.PIN_FUNCTION_FLAG_DOT) != 0 and pin.length >= 1:
             circle = Circle()
             circle.x, circle.y = _get_target(pin.x, pin.y, len-9906, pin.angle)
             circle.layer = 94
             self.print_circle(circle)
             len -= 9906*2
 
-        wire.x2, wire.y2 = _get_target(pin.x, pin.y, len, pin.angle)
+        if pin.length >= 1:
+            wire = Wire()
+            wire.arc = False
+            wire.layer = 94
+            wire.width = 1524/2
 
-        self.update_bb(wire.x1 - wire.width, wire.y1 - wire.width)
-        self.update_bb(wire.x2 + wire.width, wire.y2 + wire.width)
+            wire.x1 = pin.x
+            wire.y1 = pin.y
 
-        self.print_wire(wire)
+            wire.x2, wire.y2 = _get_target(pin.x, pin.y, len, pin.angle)
+
+            self.update_bb(wire.x1 - wire.width, wire.y1 - wire.width)
+            self.update_bb(wire.x2 + wire.width, wire.y2 + wire.width)
+
+            self.print_wire(wire)
 
         if pin.visible & pin.PIN_VISIBLE_FLAG_PIN:
             factor = 0.7