Example #1
0
def qwtDrawBox(p, rect, pal, lw):
    if lw > 0.:
        if rect.width() == 0.:
            p.setPen(pal.dark().color())
            p.drawLine(rect.topLeft(), rect.bottomLeft())
            return
        if rect.height() == 0.:
            p.setPen(pal.dark().color())
            p.drawLine(rect.topLeft(), rect.topRight())
            return
        lw = min([lw, rect.height() / 2. - 1.])
        lw = min([lw, rect.width() / 2. - 1.])
        outerRect = rect.adjusted(0, 0, 1, 1)
        polygon = QPolygonF(outerRect)
        if outerRect.width() > 2 * lw and outerRect.height() > 2 * lw:
            innerRect = outerRect.adjusted(lw, lw, -lw, -lw)
            polygon = polygon.subtracted(innerRect)
        p.setPen(Qt.NoPen)
        p.setBrush(pal.dark())
        p.drawPolygon(polygon)
    windowRect = rect.adjusted(lw, lw, -lw + 1, -lw + 1)
    if windowRect.isValid():
        p.fillRect(windowRect, pal.window())
Example #2
0
def qwtDrawBox(p, rect, pal, lw):
    if lw > 0.:
        if rect.width() == 0.:
            p.setPen(pal.dark().color())
            p.drawLine(rect.topLeft(), rect.bottomLeft())
            return
        if rect.height() == 0.:
            p.setPen(pal.dark().color())
            p.drawLine(rect.topLeft(), rect.topRight())
            return
        lw = min([lw, rect.height()/2.-1.])
        lw = min([lw, rect.width()/2.-1.])
        outerRect = rect.adjusted(0, 0, 1, 1)
        polygon = QPolygonF(outerRect)
        if outerRect.width() > 2*lw and outerRect.height() > 2*lw:
            innerRect = outerRect.adjusted(lw, lw, -lw, -lw)
            polygon = polygon.subtracted(innerRect)
        p.setPen(Qt.NoPen)
        p.setBrush(pal.dark())
        p.drawPolygon(polygon)
    windowRect = rect.adjusted(lw, lw, -lw+1, -lw+1)
    if windowRect.isValid():
        p.fillRect(windowRect, pal.window())