예제 #1
0
    def drawCell(self, p, x0, x1, y0, y1, subx, suby):
        w, h = x1 - x0, y1 - y0
        rect = QtCore.QRectF(x0, y0, w, h)
        # rect:
        pp1 = QtGui.QPainterPath()
        pp1.addRect(rect)
        # busbars:
        # TODO: make width variable ... currently fixed to 1e-3
        ps = QtGui.QPainterPath()
        for yi in subx:
            yi = y0 + yi * (y1 - y0)
            ps.addRect(QtCore.QRectF(x0, yi, w, 1e-3))

        for xi in suby:
            xi = x0 + xi * (x1 - x0)
            ps.addRect(QtCore.QRectF(xi, y0, 1e-3, h))

        if not self.circleOffs.isNull():
            # intersect rect with ellipse to create pseudo rect shape:
            # scale rect:
            c = rect.center()
            esize = rect.size() * 2**0.5 - self.circleOffs
            esize.setWidth(max(rect.width(), esize.width()))
            esize.setHeight(max(rect.height(), esize.height()))

            rect.setSize(esize)
            rect.moveCenter(c)

            pp2 = QtGui.QPainterPath()
            pp2.addEllipse(rect)
            pp1 = pp2.intersected(pp1)
            ps = pp2.intersected(ps)
        p.addPath(ps)
        p.addPath(pp1)
예제 #2
0
 def painterPath(self):
     p = QPainterPath()
     roundness = int(99 * float(self._alen) / 16 / 90)
     r = QtCore.QRectF(self._rect)
     r.moveTo(self.state['pos'])
     p.addRoundRect(r, roundness)
     return p
예제 #3
0
 def _prepare(self):
     r = self.boundingRect()
     r = QtCore.QRectF(r.x() / r.width(), r.y() / r.height(), 1, 1)
     #get draw params:
     self._edges, self._angles, self._alen = self._intersectionPointsAndAngles(
         r, self._ratioEllispeRectangle)
     #scale rect:
     bl = r.bottomLeft()
     tr = r.topRight()
     size = tr - bl
     newSize = size * self._ratioEllispeRectangle
     ds = 0.5 * (newSize - size)
     r.setBottomLeft(bl - ds)
     r.setTopRight(tr + ds)
     self._rect = r
예제 #4
0
 def painterPath(self):
     p = self.state['pos']
     s = self.state['size']
     path = QPainterPath()
     path.addEllipse(QtCore.QRectF(p[0], p[1], s[0], s[1]))
     return path