コード例 #1
0
ファイル: plot_canvas.py プロジェクト: petebachant/python-qwt
def qwtCombinePathList(rect, pathList):
    if not pathList:
        return QPainterPath()

    ordered = [None] * 8
    for subPath in pathList:
        index = -1
        br = subPath.controlPointRect()
        if br.center().x() < rect.center().x():
            if br.center().y() < rect.center().y():
                if abs(br.top() - rect.top()) < abs(br.left() - rect.left()):
                    index = 1
                else:
                    index = 0
            else:
                if abs(br.bottom() - rect.bottom) < abs(br.left() -
                                                        rect.left()):
                    index = 6
                else:
                    index = 7
            if subPath.currentPosition().y() > br.center().y():
                qwtRevertPath(subPath)
        else:
            if br.center().y() < rect.center().y():
                if abs(br.top() - rect.top()) < abs(br.right() - rect.right()):
                    index = 2
                else:
                    index = 3
            else:
                if abs(br.bottom() - rect.bottom()) < abs(br.right() -
                                                          rect.right()):
                    index = 5
                else:
                    index = 4
            if subPath.currentPosition().y() < br.center().y():
                qwtRevertPath(subPath)
        ordered[index] = subPath
    for i in range(4):
        if ordered[2 * i].isEmpty() != ordered[2 * i + 1].isEmpty():
            return QPainterPath()
    corners = QPolygonF(rect)
    path = QPainterPath()
    for i in range(4):
        if ordered[2 * i].isEmpty():
            path.lineTo(corners[i])
        else:
            path.connectPath(ordered[2 * i])
            path.connectPath(ordered[2 * i + 1])
    path.closeSubpath()
    return path
コード例 #2
0
ファイル: plot_canvas.py プロジェクト: petebachant/python-qwt
def qwtCombinePathList(rect, pathList):
    if not pathList:
        return QPainterPath()
    
    ordered = [None] * 8
    for subPath in pathList:
        index = -1
        br = subPath.controlPointRect()
        if br.center().x() < rect.center().x():
            if br.center().y() < rect.center().y():
                if abs(br.top()-rect.top()) < abs(br.left()-rect.left()):
                    index = 1
                else:
                    index = 0
            else:
                if abs(br.bottom()-rect.bottom) < abs(br.left()-rect.left()):
                    index = 6
                else:
                    index = 7
            if subPath.currentPosition().y() > br.center().y():
                qwtRevertPath(subPath)
        else:
            if br.center().y() < rect.center().y():
                if abs(br.top()-rect.top()) < abs(br.right()-rect.right()):
                    index = 2
                else:
                    index = 3
            else:
                if abs(br.bottom()-rect.bottom()) < abs(br.right()-rect.right()):
                    index = 5
                else:
                    index = 4
            if subPath.currentPosition().y() < br.center().y():
                qwtRevertPath(subPath)
        ordered[index] = subPath
    for i in range(4):
        if ordered[2*i].isEmpty() != ordered[2*i+1].isEmpty():
            return QPainterPath()
    corners = QPolygonF(rect)
    path = QPainterPath()
    for i in range(4):
        if ordered[2*i].isEmpty():
            path.lineTo(corners[i])
        else:
            path.connectPath(ordered[2*i])
            path.connectPath(ordered[2*i+1])
    path.closeSubpath()
    return path
コード例 #3
0
 def drawPolygon(self, *args):
     if len(args) == 3:
         points, pointCount, mode = args
     elif len(args) == 2:
         points, mode = args
         pointCount = len(points)
     else:
         raise TypeError("Unexpected arguments")
     device = self.nullDevice()
     if device is None:
         return
     if device.mode() == QwtNullPaintDevice.PathMode:
         path = QPainterPath()
         if pointCount > 0:
             path.moveTo(points[0])
             for i in range(1, pointCount):
                 path.lineTo(points[i])
             if mode != QPaintEngine.PolylineMode:
                 path.closeSubpath()
         device.drawPath(path)
         return
     device.drawPolygon(points, pointCount, mode)
コード例 #4
0
 def drawPolygon(self, *args):
     if len(args) == 3:
         points, pointCount, mode = args
     elif len(args) == 2:
         points, mode = args
         pointCount = len(points)
     else:
         raise TypeError("Unexpected arguments")
     device = self.nullDevice()
     if device is None:
         return
     if device.mode() == QwtNullPaintDevice.PathMode:
         path = QPainterPath()
         if pointCount > 0:
             path.moveTo(points[0])
             for i in range(1, pointCount):
                 path.lineTo(points[i])
             if mode != QPaintEngine.PolylineMode:
                 path.closeSubpath()
         device.drawPath(path)
         return
     device.drawPolygon(points, pointCount, mode)