def paint(self, painter, option, widget): """Draws a filled rectangle and then adds a title""" # Draw the rectangle QGraphicsRectItem.paint(self, painter, option, widget) # Draw text over the rectangle font = QFont("Arial", 10) font.setBold(True) painter.setFont(font) painter.setPen(QPen(QColor(90, 90, 88))) 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 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 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])