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 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())
def paint(self, painter, option, widget): """Draws a filled rectangle and then adds a title""" # Hide the dotted outline itemOption = QStyleOptionGraphicsItem(option) if itemOption.state & QStyle.State_Selected != 0: itemOption.state = itemOption.state & ~QStyle.State_Selected # Draw the rectangle pen = painter.pen() pen.setJoinStyle(Qt.RoundJoin) painter.setPen(pen) QGraphicsRectItem.paint(self, painter, itemOption, widget) # Draw text over the rectangle painter.setFont(self.__font) painter.setPen(QPen(QColor(255, 255, 255))) painter.drawText(self.__node.posX - self.__node.width / 2.0, self.__node.posY - self.__node.height / 2.0, self.__node.width, self.__node.height, Qt.AlignCenter, self.__node.label.replace('\\n', '\n')) if self.__outside: pixmap = getPixmap("nonprojectentrydgm.png") pixmapPosX = self.__node.posX - self.__node.width / 2.0 + 2 pixmapPosY = self.__node.posY + self.__node.height / 2.0 - \ pixmap.height() - 2 painter.setRenderHint(QPainter.SmoothPixmapTransform) painter.drawPixmap(pixmapPosX, pixmapPosY, pixmap)
def paint(self, painter, option, widget): """Draws the edge text""" # Hide the dotted outline itemOption = QStyleOptionGraphicsItem(option) if itemOption.state & QStyle.State_Selected != 0: itemOption.state = itemOption.state & ~QStyle.State_Selected QGraphicsTextItem.paint(self, painter, itemOption, widget)
def paint(self, painter, option, widget): """Draws a filled rectangle and then adds a title""" # Hide the dotted outline for clickable system modules itemOption = QStyleOptionGraphicsItem(option) if itemOption.state & QStyle.State_Selected != 0: itemOption.state = itemOption.state & ~QStyle.State_Selected # Draw the rectangle QGraphicsRectItem.paint(self, painter, itemOption, widget) # Draw text over the rectangle font = QFont("Arial", 10) font.setBold(True) painter.setFont(font) painter.drawText(self.__node.posX - self.__node.width / 2.0, self.__node.posY - self.__node.height / 2.0, self.__node.width, self.__node.height, Qt.AlignCenter, self.__node.label)
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
def paint(self, painter, option, widget): """Draws a rectangle, adds title, classes/funcs/globs sections""" # Hide the dotted outline itemOption = QStyleOptionGraphicsItem(option) if itemOption.state & QStyle.State_Selected != 0: itemOption.state = itemOption.state & ~QStyle.State_Selected # Draw the rectangle QGraphicsRectItem.paint(self, painter, itemOption, widget) # Start from the bottom to automatically take potential spare # pixels for the title font = QFont("Arial", 10) painter.setFont(font) posX = self.__node.posX - self.__node.width / 2.0 posY = self.__node.posY + self.__node.height / 2.0 - 1.5 * self.__pixelsPerLine occupiedPixels = 0 for index in range(len(self.__lines) - 1, 0, -1): if self.__lines[index] is None: # Draw a separation line painter.drawLine(posX + 1, posY + self.__pixelsPerLine / 2.0, posX + self.__node.width, posY + self.__pixelsPerLine / 2.0) elif self.__lines[index] != "": # Draw a text line # Sometimes the bottom part of 'g' is not drawn so I add 2 # spare pixels. painter.drawText(int(posX), int(posY), int(self.__node.width), self.__pixelsPerLine + 2, Qt.AlignCenter, self.__lines[index]) occupiedPixels += self.__pixelsPerLine posY -= self.__pixelsPerLine # Draw the title in bold font.setBold(True) painter.setFont(font) available = self.__node.height - occupiedPixels posY = self.__node.posY - self.__node.height / 2.0 painter.drawText(int(posX), int(posY), int(self.__node.width), int(available), Qt.AlignCenter, self.__lines[0])
def paint(self, painter, option, widget): """Draws a filled rectangle and then adds a title""" # Hide the dotted outline itemOption = QStyleOptionGraphicsItem(option) if itemOption.state & QStyle.State_Selected != 0: itemOption.state = itemOption.state & ~QStyle.State_Selected # Draw the rectangle QGraphicsRectItem.paint(self, painter, itemOption, widget) # Draw text over the rectangle font = QFont("Arial", 10) painter.setFont(font) hSpacer = 10 ySpacer = 5 painter.drawText(self.__node.posX - self.__node.width / 2.0 + hSpacer, self.__node.posY - self.__node.height / 2.0 + ySpacer, self.__node.width - hSpacer, self.__node.height - ySpacer, Qt.AlignLeft, self.__srcobj.text)