ElectrodeView.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:ECoG-ClusterFlow 作者: sugeerth 项目源码 文件源码
def paint(self, painter, option, widget):
        """
        This method does the drawing.
        """
        painter.setPen(QtCore.Qt.darkGray)
        painter.setBrush(QtGui.QColor(250, 245, 209))

        adjustedRect = self.boundingRect() # the rectangle around the text

        if self.orientation == 'above':
            # should draw the label balloon above the point
            adjustedRect.adjust(0, 0, 0, -12)
            vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6,
                                       adjustedRect.height() - 1),
                        QtCore.QPointF(adjustedRect.width()/2,
                                       adjustedRect.height() + 12),
                        QtCore.QPointF(adjustedRect.width()/2 + 6,
                                       adjustedRect.height() - 1)]
        else:
            # should draw the label balloon below the point
            adjustedRect.adjust(0, 12, 0, 0)
            vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6, 1),
                        QtCore.QPointF(adjustedRect.width()/2, -12),
                        QtCore.QPointF(adjustedRect.width()/2 + 6, 1)]

        # paint the balloon rectangle
        painter.drawRoundedRect(adjustedRect, 8, 8)

        # paint the balloon arrow triangle fill
        painter.setPen(QtCore.Qt.NoPen)
        painter.drawPolygon(vertices)

        # paint the balloon arrow triangle stroke
        painter.setPen(QtCore.Qt.darkGray)

        painter.drawLine(vertices[0], vertices[1])
        painter.drawLine(vertices[2], vertices[1])

        # Finally call the parent paint method to draw the actual text
        super(GraphicsBalloonTextItem, self).paint(painter, option, widget)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号