Example #1
0
    def __init__(self, edge):
        QGraphicsPathItem.__init__(self)
        self.__edge = edge

        startPoint = QPointF(edge.points[0][0], edge.points[0][1])
        painterPath = QPainterPath(startPoint)

        index = 1
        while index + 3 <= len(edge.points):
            painterPath.cubicTo(edge.points[index][0], edge.points[index][1],
                                edge.points[index + 1][0],
                                edge.points[index + 1][1],
                                edge.points[index + 2][0],
                                edge.points[index + 2][1])
            index = index + 3
        if index + 2 <= len(edge.points):
            painterPath.quadTo(edge.points[index + 1][0],
                               edge.points[index + 1][1],
                               edge.points[index + 2][0],
                               edge.points[index + 2][1])
            index = index + 2

        if index + 1 <= len(edge.points):
            painterPath.lineTo(edge.points[index + 1][0],
                               edge.points[index + 1][1])

        if edge.head != edge.tail:
            lastIndex = len(edge.points) - 1
            self.addArrow(painterPath, edge.points[lastIndex - 1][0],
                          edge.points[lastIndex - 1][1],
                          edge.points[lastIndex][0], edge.points[lastIndex][1])
        self.setPath(painterPath)
Example #2
0
    def paint(self, painter, option, widget):
        """Draws the independent comment"""
        settings = self.canvas.settings

        brush = QBrush(settings.commentBGColor)
        self.setBrush(brush)

        if self.isSelected():
            selectPen = QPen(settings.selectColor)
            selectPen.setWidth(settings.selectPenWidth)
            selectPen.setJoinStyle(Qt.RoundJoin)
            self.setPen(selectPen)
        else:
            pen = QPen(settings.commentLineColor)
            pen.setWidth(settings.commentLineWidth)
            pen.setJoinStyle(Qt.RoundJoin)
            self.setPen(pen)

        # Hide the dotted outline
        itemOption = QStyleOptionGraphicsItem(option)
        if itemOption.state & QStyle.State_Selected != 0:
            itemOption.state = itemOption.state & ~QStyle.State_Selected
        QGraphicsPathItem.paint(self, painter, itemOption, widget)

        # Draw the text in the rectangle
        pen = QPen(settings.commentFGColor)
        painter.setFont(settings.monoFont)
        painter.setPen(pen)
        painter.drawText(
            self.__leftEdge + settings.hCellPadding + self.__hTextPadding,
            self.baseY + settings.vCellPadding + self.__vTextPadding,
            self.__textRect.width(), self.__textRect.height(),
            Qt.AlignLeft, self.__getText())
Example #3
0
    def __init__(self, ref, canvas, x, y):
        CommentCellBase.__init__(self, ref, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.SIDE_COMMENT

        # To make double click delivered
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Example #4
0
    def paint(self, painter, option, widget):
        """Draws the leading comment"""
        settings = self.canvas.settings
        self.setPen(
            self.getPainterPen(self.isSelected(), settings.commentBorderColor))
        self.setBrush(QBrush(settings.commentBGColor))

        # Bottom adjustment
        yShift = self.height - self.minHeight
        baseY = self.baseY + yShift

        # Hide the dotted outline
        itemOption = QStyleOptionGraphicsItem(option)
        if itemOption.state & QStyle.State_Selected != 0:
            itemOption.state = itemOption.state & ~QStyle.State_Selected
        QGraphicsPathItem.paint(self, painter, itemOption, widget)

        # Draw the text in the rectangle
        pen = QPen(settings.commentFGColor)
        painter.setFont(settings.monoFont)
        painter.setPen(pen)
        painter.drawText(
            self._leftEdge + settings.hCellPadding + settings.hTextPadding,
            baseY + settings.vCellPadding + settings.vTextPadding,
            self.textRect.width(), self.textRect.height(), Qt.AlignLeft,
            self.text)
    def __init__(self, edge, modObj):
        QGraphicsPathItem.__init__(self)
        self.__edge = edge
        self.__modObj = modObj

        startPoint = QPointF(edge.points[0][0], edge.points[0][1])
        painterPath = QPainterPath(startPoint)

        index = 1
        while index + 3 <= len(edge.points):
            painterPath.cubicTo(edge.points[index][0], edge.points[index][1],
                                edge.points[index + 1][0],
                                edge.points[index + 1][1],
                                edge.points[index + 2][0],
                                edge.points[index + 2][1])
            index = index + 3
        if index + 2 <= len(edge.points):
            painterPath.quadTo(edge.points[index + 1][0],
                               edge.points[index + 1][1],
                               edge.points[index + 2][0],
                               edge.points[index + 2][1])
            index = index + 2

        if index + 1 <= len(edge.points):
            painterPath.lineTo(edge.points[index + 1][0],
                               edge.points[index + 1][1])

        self.setPath(painterPath)
Example #6
0
    def paint(self, painter, option, widget):
        """Draws a curve and then adds an arrow"""
        pen = QPen(QColor(0, 0, 0))
        pen.setWidth(2)
        self.setPen(pen)

        painter.setRenderHint(QPainter.Antialiasing, True)
        QGraphicsPathItem.paint(self, painter, option, widget)
    def paint(self, painter, option, widget):
        """Draws a curve and then adds an arrow"""
        pen = QPen(QColor(0, 0, 0))
        pen.setWidth(2)
        pen.setStyle(Qt.DotLine)
        self.setPen(pen)

        QGraphicsPathItem.paint(self, painter, option, widget)
Example #8
0
    def __init__(self, ref, canvas, x, y):
        CommentCellBase.__init__(self, ref, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.INDEPENDENT_COMMENT
        self.leadingForElse = False
        self.sideForElse = False

        # To make double click delivered
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Example #9
0
    def __init__(self, ref, canvas, x, y):
        CommentCellBase.__init__(self, ref, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.ABOVE_COMMENT
        self.needConnector = False
        self.commentConnector = None

        # To make double click delivered
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Example #10
0
    def __init__(self, connections, canvas, x, y):
        """Connections are supposed to be a list of tuples.

        Eample: [ (NORTH, SOUTH), (EAST, CENTER) ]
        """
        CellElement.__init__(self, None, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.CONNECTOR
        self.subKind = self.GENERIC
        self.connections = connections
Example #11
0
    def paint(self, painter, option, widget):
        """Draws the code block"""
        settings = self.canvas.settings

        pen = QPen(settings.cfLineColor)
        pen.setWidth(settings.cfLineWidth)
        pen.setJoinStyle(Qt.RoundJoin)
        self.setPen(pen)
        painter.setPen(pen)
        QGraphicsPathItem.paint(self, painter, option, widget)
Example #12
0
    def __init__(self, settings, x1, y1, x2, y2):
        QGraphicsPathItem.__init__(self)
        self.__settings = settings

        path = QPainterPath()
        path.moveTo(x1, y1)
        path.lineTo(x2, y2)
        self.setPath(path)

        self.penStyle = None
        self.penColor = None
        self.penWidth = None
Example #13
0
    def __init__(self, canvas, x1, y1, x2, y2):
        CellElement.__init__(self, None, canvas, x=None, y=None)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.DEPENDENT_CONNECTOR

        path = QPainterPath()
        path.moveTo(x1, y1)
        path.lineTo(x2, y2)
        self.setPath(path)

        self.penStyle = None
        self.penColor = None
        self.penWidth = None
Example #14
0
    def __init__(self, ref, canvas, x, y):
        CommentCellBase.__init__(self, ref, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.ABOVE_COMMENT
        self.needConnector = False
        self.commentConnector = None

        # Decorators have a small badge so the connector needs to touch it
        # more to the left than the usual main line
        self.smallBadge = False
        self.hanging = False
        self.commentMainLine = None

        # To make double click delivered
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Example #15
0
    def __init__(self, ref, canvas, x, y):
        CellElement.__init__(self, ref, canvas, x, y)
        QGraphicsPathItem.__init__(self)
        self.kind = CellElement.LEADING_COMMENT
        self.__text = None
        self.__textRect = None
        self.__leftEdge = None
        self.connector = None

        self.__vTextPadding = canvas.settings.vTextPadding
        self.__hTextPadding = canvas.settings.hTextPadding
        if canvas.settings.hidecomments:
            self.__vTextPadding = canvas.settings.vHiddenTextPadding
            self.__hTextPadding = canvas.settings.hHiddenTextPadding

        # To make double click delivered
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Example #16
0
    def paint(self, painter, option, widget):
        """Paints the connector"""
        color = self.__settings.lineColor
        if self.penColor:
            color = self.penColor
        width = self.__settings.lineWidth
        if self.penWidth:
            width = self.penWidth

        pen = QPen(color)
        pen.setWidth(width)
        pen.setCapStyle(Qt.FlatCap)
        pen.setJoinStyle(Qt.RoundJoin)
        if self.penStyle:
            pen.setStyle(self.penStyle)
        self.setPen(pen)
        QGraphicsPathItem.paint(self, painter, option, widget)
Example #17
0
    def paint(self, painter, option, widget):
        """Draws the leading comment"""
        settings = self.canvas.settings

        # Bottom adjustment
        yShift = self.height - self.minHeight
        baseY = self.baseY + yShift

        # Left adjustments
        shift = self.hShift * 2 * settings.openGroupHSpacer
        self._leftEdge += shift

        brush = QBrush(settings.commentBGColor)
        self.setBrush(brush)

        if self.isSelected():
            selectPen = QPen(settings.selectColor)
            selectPen.setWidth(settings.selectPenWidth)
            selectPen.setJoinStyle(Qt.RoundJoin)
            self.setPen(selectPen)
        else:
            pen = QPen(settings.commentLineColor)
            pen.setWidth(settings.commentLineWidth)
            pen.setJoinStyle(Qt.RoundJoin)
            self.setPen(pen)

        # Hide the dotted outline
        itemOption = QStyleOptionGraphicsItem(option)
        if itemOption.state & QStyle.State_Selected != 0:
            itemOption.state = itemOption.state & ~QStyle.State_Selected
        QGraphicsPathItem.paint(self, painter, itemOption, widget)

        # Draw the text in the rectangle
        pen = QPen(settings.commentFGColor)
        painter.setFont(settings.monoFont)
        painter.setPen(pen)
        painter.drawText(
            self._leftEdge + settings.hCellPadding + self._hTextPadding,
            baseY + settings.vCellPadding + self._vTextPadding,
            self._textRect.width(), self._textRect.height(), Qt.AlignLeft,
            self.__getText())

        self._leftEdge -= shift