Commit e44a2961 authored by Michael Büsch's avatar Michael Büsch

fup: Add grid method to draw wires

Signed-off-by: Michael Büsch's avatarMichael Buesch <>
parent f82b78c7
......@@ -178,6 +178,17 @@ class FupGrid(object):
for i, wire in enumerate(self.wires):
wire.idNum = i
def drawWireLine(self, painter, x0, y0, x1, y1, force=False):
"""Draw a wire line on 'painter'.
x0, y0 => Start pixel coordinates.
x1, y1 => End pixel coordinates.
force => Draw, even if there are collisions.
Returns True, if there were no collisions.
painter.drawLine(x0, y0, x1, y1)
return True
def cellPixWidth(self):
if self.__drawWidget:
......@@ -130,6 +130,7 @@ class FupWire(FupBaseClass):
def draw(self, painter):
if self.outConn is None:
return # Only inputs. Do not draw.
grid = self.grid
# Branch circles diameter
r, d = self.BRANCH_DIA // 2, self.BRANCH_DIA
......@@ -147,9 +148,9 @@ class FupWire(FupBaseClass):
xAbs1, yAbs1 = inConn.pixCoords
x = (xAbs0 // cellPixWidth) * cellPixWidth + cellPixWidth
painter.drawLine(x, yAbs0, x, yAbs0)
painter.drawLine(x, yAbs0, x, yAbs1)
painter.drawLine(x, yAbs1, xAbs1, yAbs1)
grid.drawWireLine(painter, xAbs0, yAbs0, x, yAbs0, force=True)
grid.drawWireLine(painter, x, yAbs0, x, yAbs1)
grid.drawWireLine(painter, x, yAbs1, xAbs1, yAbs1, force=True)
# Draw the branch circles
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment