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 <m@bues.ch>
parent f82b78c7
...@@ -178,6 +178,17 @@ class FupGrid(object): ...@@ -178,6 +178,17 @@ class FupGrid(object):
for i, wire in enumerate(self.wires): for i, wire in enumerate(self.wires):
wire.idNum = i 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.
"""
#TODO
painter.drawLine(x0, y0, x1, y1)
return True
@property @property
def cellPixWidth(self): def cellPixWidth(self):
if self.__drawWidget: if self.__drawWidget:
......
...@@ -130,6 +130,7 @@ class FupWire(FupBaseClass): ...@@ -130,6 +130,7 @@ class FupWire(FupBaseClass):
def draw(self, painter): def draw(self, painter):
if self.outConn is None: if self.outConn is None:
return # Only inputs. Do not draw. return # Only inputs. Do not draw.
grid = self.grid
# Branch circles diameter # Branch circles diameter
r, d = self.BRANCH_DIA // 2, self.BRANCH_DIA r, d = self.BRANCH_DIA // 2, self.BRANCH_DIA
...@@ -147,9 +148,9 @@ class FupWire(FupBaseClass): ...@@ -147,9 +148,9 @@ class FupWire(FupBaseClass):
xAbs1, yAbs1 = inConn.pixCoords xAbs1, yAbs1 = inConn.pixCoords
painter.setPen(self.__wirePen) painter.setPen(self.__wirePen)
x = (xAbs0 // cellPixWidth) * cellPixWidth + cellPixWidth x = (xAbs0 // cellPixWidth) * cellPixWidth + cellPixWidth
painter.drawLine(x, yAbs0, x, yAbs0) grid.drawWireLine(painter, xAbs0, yAbs0, x, yAbs0, force=True)
painter.drawLine(x, yAbs0, x, yAbs1) grid.drawWireLine(painter, x, yAbs0, x, yAbs1)
painter.drawLine(x, yAbs1, xAbs1, yAbs1) grid.drawWireLine(painter, x, yAbs1, xAbs1, yAbs1, force=True)
# Draw the branch circles # Draw the branch circles
painter.setPen(self.__wireBranchPen) 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