def __setupPath(self): """Sets the comment path""" settings = self.canvas.settings # Bottom adjustment yShift = self.height - self.minHeight baseY = self.baseY + yShift self._leftEdge = \ self.baseX + settings.mainLine + settings.hCellPadding boxWidth = self.textRect.width() + \ 2 * (settings.hCellPadding + settings.hTextPadding) boxWidth = max(boxWidth, settings.minWidth) path = getCommentBoxPath(settings, self._leftEdge, baseY, boxWidth, self.minHeight) self.setPath(path) self.commentConnector = Connector(self.canvas, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(self._leftEdge + settings.hCellPadding, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge - settings.hCellPadding, baseY + self.minHeight + settings.vCellPadding) self.commentConnector.setPath(connectorPath) self.commentConnector.penColor = settings.commentBorderColor self.commentConnector.penWidth = settings.boxLineWidth
def __setupConnector(self): """Prepares the connector""" settings = self.canvas.settings cellToTheLeft = self.canvas.cells[self.addr[1]][self.addr[0] - 1] if cellToTheLeft.kind != CellElement.CONNECTOR: leftEdge = self.baseX else: leftEdge = \ cellToTheLeft.baseX + settings.mainLine + settings.hCellPadding shift = self.hShift * 2 * settings.openGroupHSpacer leftEdge += shift self.connector = Connector(self.canvas, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(leftEdge + settings.hCellPadding, self.baseY + self.minHeight / 2) connectorPath.lineTo(leftEdge, self.baseY + self.minHeight / 2) connectorPath.lineTo( leftEdge - settings.hCellPadding, self.baseY + self.minHeight + settings.vCellPadding) self.connector.setPath(connectorPath) self.connector.penColor = settings.hiddenCommentBorderColor self.connector.penWidth = settings.boxLineWidth
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)
def _setupConnector(self): """Sets the path for painting""" settings = self.canvas.settings # Bottom adjustment yShift = self.height - self.minHeight baseY = self.baseY + yShift cellToTheLeft = self.canvas.cells[self.addr[1]][self.addr[0] - 1] if cellToTheLeft.kind != CellElement.CONNECTOR: # not implemented yet self._leftEdge = self.baseX else: self._leftEdge = \ cellToTheLeft.baseX + \ settings.mainLine + settings.hCellPadding shift = self.hShift * 2 * settings.openGroupHSpacer self._leftEdge += shift self.connector = Connector(settings, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(self._leftEdge + settings.hCellPadding, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge - settings.hCellPadding, baseY + self.minHeight + settings.vCellPadding) self.connector.setPath(connectorPath) self.connector.penColor = settings.docLinkLineColor self.connector.penWidth = settings.docLinkLineWidth
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)
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
def __setupConnector(self): """Prepares the connector""" settings = self.canvas.settings leftEdge = \ self.baseX + settings.mainLine + settings.hCellPadding self.connector = Connector(self.canvas, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(leftEdge + settings.hCellPadding, self.baseY + self.minHeight / 2) connectorPath.lineTo(leftEdge, self.baseY + self.minHeight / 2) connectorPath.lineTo( leftEdge - settings.hCellPadding, self.baseY + self.minHeight + settings.vCellPadding) self.connector.setPath(connectorPath) self.connector.penColor = settings.commentBorderColor self.connector.penWidth = settings.boxLineWidth
def draw(self, scene, baseX, baseY): """Draws the cell""" self.baseX = baseX self.baseY = baseY path = QPainterPath() for connection in self.connections: startX, startY = self.__getXY(connection[0]) endX, endY = self.__getXY(connection[1]) if self.__angled(connection[0], connection[1]): centerX, centerY = self.__getXY(self.CENTER) path.moveTo(startX, startY) path.lineTo(centerX, centerY) path.lineTo(endX, endY) else: path.moveTo(startX, startY) path.lineTo(endX, endY) # It does not look nice so commented out #if len(self.connections) == 1: # if self.connections[0][0] == self.NORTH: # if self.connections[0][1] == self.CENTER: # # That's a half connector used when terminal items are # # suppressed. # radius = self.canvas.settings.vCellPadding / 2.0 # path.addEllipse(endX - radius / 2.0, # endY - radius / 2.0, radius, radius) self.setPath(path) scene.addItem(self)
def __setupPath(self): """Sets the comment path""" settings = self.canvas.settings # Bottom adjustment yShift = self.height - self.minHeight baseY = self.baseY + yShift cellToTheLeft = self.canvas.cells[self.addr[1]][self.addr[0] - 1] if cellToTheLeft.kind != CellElement.CONNECTOR: # not implemented yet self._leftEdge = self.baseX else: self._leftEdge = \ cellToTheLeft.baseX + \ settings.mainLine + settings.hCellPadding boxWidth = self._textRect.width() + \ 2 * (settings.hCellPadding + self._hTextPadding) if not settings.hidecomments: boxWidth = max(boxWidth, settings.minWidth) shift = self.hShift * 2 * settings.openGroupHSpacer self._leftEdge += shift path = getCommentBoxPath(settings, self._leftEdge, baseY, boxWidth, self.minHeight) self.setPath(path) self.connector = Connector(settings, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(self._leftEdge + settings.hCellPadding, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge - settings.hCellPadding, baseY + self.minHeight + settings.vCellPadding) self.connector.setPath(connectorPath) self.connector.penColor = settings.commentLineColor self.connector.penWidth = settings.commentLineWidth self._leftEdge -= shift
def _setupConnector(self): """Sets the path for painting""" settings = self.canvas.settings # Bottom adjustment yShift = self.height - self.minHeight baseY = self.baseY + yShift # Dirty hack: see the overriden draw() member: the baseX has already # been adjusted with mainLine and hCellPadding self._leftEdge = self.baseX self.connector = Connector(self.canvas, 0, 0, 0, 0) connectorPath = QPainterPath() connectorPath.moveTo(self._leftEdge + settings.hCellPadding, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge, baseY + self.minHeight / 2) connectorPath.lineTo(self._leftEdge - settings.hCellPadding, baseY + self.minHeight + settings.vCellPadding) self.connector.setPath(connectorPath) self.connector.penColor = self.borderColor self.connector.penWidth = settings.boxLineWidth
def getNoCellCommentBoxPath(x, y, width, height, corner): """Provides the path for exactly specified rectangle""" path = QPainterPath() path.moveTo(x, y) path.lineTo(x + width - corner, y) path.lineTo(x + width, y + corner) path.lineTo(x + width, y + height) path.lineTo(x, y + height) path.lineTo(x, y) # -1 is to avoid sharp corners of the lines path.moveTo(x + width - corner, y + 1) path.lineTo(x + width - corner, y + corner) path.lineTo(x + width - 1, y + corner) return path