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

fup: Draw wires on grid borders

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 1fe7939a
......@@ -335,11 +335,11 @@ class FupElem(FupBaseClass):
cellPixHeight = self.grid.cellPixHeight
cellPixWidth = self.grid.cellPixWidth
if conn.IN:
xPix = (x * cellPixWidth) + FupConn.CONN_OFFS
xPix = (x * cellPixWidth) + conn.CONN_OFFS
yPix = (y * cellPixHeight) + (cellPixHeight // 2)
return xPix, yPix
elif conn.OUT:
xPix = (x * cellPixWidth) + cellPixWidth - FupConn.CONN_OFFS
xPix = (x * cellPixWidth) + cellPixWidth - conn.CONN_OFFS
yPix = (y * cellPixHeight) + (cellPixHeight // 2)
return xPix, yPix
raise IndexError
......
......@@ -120,18 +120,23 @@ class FupElem_BOOLEAN(FupElem):
# Draw inputs
for i, conn in enumerate(self.inputs):
x = conn.CONN_OFFS if conn.isConnected else 0
y = (i * cellHeight) + (cellHeight // 2)
painter.setPen(self._connPen if conn.wire
painter.setPen(self._connPen if conn.isConnected
else self._connOpenPen)
painter.drawLine(0, y, xpad, y)
painter.drawLine(x, y, xpad, y)
# Draw output
y = elemHeight - (cellHeight // 2)
painter.setPen(self._connPen
if len(self.outputs) and self.outputs[0].wire
else self._connOpenPen)
painter.drawLine(cellWidth - xpad, y,
cellWidth, y)
if self.outputs:
assert(len(self.outputs) == 1)
conn = self.outputs[0]
x = (cellWidth - conn.CONN_OFFS) if conn.isConnected\
else cellWidth
y = elemHeight - (cellHeight // 2)
painter.setPen(self._connPen if conn.isConnected
else self._connOpenPen)
painter.drawLine(cellWidth - xpad, y,
cellWidth, y)
# Draw body
painter.setPen(self._outlineSelPen if self.selected
......
......@@ -137,6 +137,7 @@ class FupWire(FupBaseClass):
# Draw wire from output to all inputs
xAbs0, yAbs0 = self.outConn.pixCoords
cellPixWidth = self.grid.cellPixWidth
for inConn in self.connections:
if inConn is self.outConn:
continue
......@@ -145,8 +146,10 @@ class FupWire(FupBaseClass):
# Draw the wire from out to in
xAbs1, yAbs1 = inConn.pixCoords
painter.setPen(self.__wirePen)
painter.drawLine(xAbs0, yAbs0, xAbs0, yAbs1)
painter.drawLine(xAbs0, yAbs1, xAbs1, yAbs1)
x = (xAbs0 // cellPixWidth) * cellPixWidth + cellPixWidth
painter.drawLine(x, yAbs0, x, yAbs0)
painter.drawLine(x, yAbs0, x, yAbs1)
painter.drawLine(x, yAbs1, xAbs1, yAbs1)
# Draw the branch circles
painter.setPen(self.__wireBranchPen)
......
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