Esempio n. 1
0
    def realRender(self, painter, renderPath):  # TODO/PORT: Still needs work.
        """
        TOWRITE

        :param `painter`: TOWRITE
        :type `painter`: `QPainter`_
        :param `renderPath`: TOWRITE
        :type `renderPath`: `QPainterPath`_
        """
        color1 = self.objectColor()  #QColor  # lighter color
        color2 = color1.darker(150)  #QColor  # darker color

        # If we have a dark color, lighten it
        darkness = color1.lightness() #int
        threshold = 32 #int   #TODO: This number may need adjusted or maybe just add it to settings.
        if darkness < threshold:
            color2 = color1
            if not darkness:
                color1 = QColor(threshold, threshold, threshold)  # lighter() does not affect pure black
            else :
                color1 = color2.lighter(100 + threshold)

        count = renderPath.elementCount()  # int
        for i in range(0, count - 1):  # for(int i = 0; i < count-1; ++i);

            elem = renderPath.elementAt(i)      # QPainterPath::Element
            next = renderPath.elementAt(i + 1)  # QPainterPath::Element

            if next.isMoveTo():
                continue

            elemPath = QPainterPath()
            elemPath.moveTo(elem.x, elem.y)
            elemPath.lineTo(next.x, next.y)

            renderPen = QPen(QColor(0, 0, 0, 0))
            renderPen.setWidthF(0)
            painter.setPen(renderPen)
            stroker = QPainterPathStroker()
            stroker.setWidth(0.35)
            stroker.setCapStyle(Qt.RoundCap)
            stroker.setJoinStyle(Qt.RoundJoin)
            realPath = stroker.createStroke(elemPath)  # QPainterPath
            painter.drawPath(realPath)

            grad = QLinearGradient(elemPath.pointAtPercent(0.5), elemPath.pointAtPercent(0.0))
            grad.setColorAt(0, color1)
            grad.setColorAt(1, color2)
            grad.setSpread(QGradient.ReflectSpread)

            painter.fillPath(realPath, QBrush(grad))
Esempio n. 2
0
 def set_shape(self, width, height):
     ''' Define the symbol shape '''
     circ = min(width, height)
     path = QPainterPath()
     path.addEllipse(0, 0, circ, circ)
     point1 = path.pointAtPercent(0.625)
     point2 = path.pointAtPercent(0.125)
     point3 = path.pointAtPercent(0.875)
     point4 = path.pointAtPercent(0.375)
     path.moveTo(point1)
     path.lineTo(point2)
     path.moveTo(point3)
     path.lineTo(point4)
     self.setPath(path)
     # call Join superclass, otherwise symbol will take Join shape
     super(Join, self).set_shape(circ, circ)
Esempio n. 3
0
 def set_shape(self, width, height):
     ''' Define the symbol shape '''
     circ = min(width, height)
     path = QPainterPath()
     path.addEllipse(0, 0, circ, circ)
     point1 = path.pointAtPercent(0.625)
     point2 = path.pointAtPercent(0.125)
     point3 = path.pointAtPercent(0.875)
     point4 = path.pointAtPercent(0.375)
     path.moveTo(point1)
     path.lineTo(point2)
     path.moveTo(point3)
     path.lineTo(point4)
     self.setPath(path)
     # call Join superclass, otherwise symbol will take Join shape
     super(Join, self).set_shape(circ, circ)
Esempio n. 4
0
 def reshape(self):
     ''' Update the connection or arrow shape '''
     shape = QPainterPath()
     shape.moveTo(self.start_point)
     for point in self.middle_points:
         shape.lineTo(point)
     shape.lineTo(self.end_point)
     # If required draw an arrow head (e.g. in SDL NEXTSTATE and JOIN)
     if self.child.arrow_head:
         self.draw_arrow_head(shape, origin='head',
                              kind=self.child.arrow_head)
     if self.child.arrow_tail:
         shape.moveTo(shape.pointAtPercent(0))
         self.draw_arrow_head(shape, origin='tail',
                              kind=self.child.arrow_head)
     self.setPath(shape)
Esempio n. 5
0
 def reshape(self):
     ''' Update the connection or arrow shape '''
     shape = QPainterPath()
     shape.moveTo(self.start_point)
     for point in self.middle_points:
         shape.lineTo(point)
     shape.lineTo(self.end_point)
     # If required draw an arrow head (e.g. in SDL NEXTSTATE and JOIN)
     if self.child.arrow_head:
         self.draw_arrow_head(shape, origin='head',
                              kind=self.child.arrow_head)
     if self.child.arrow_tail:
         shape.moveTo(shape.pointAtPercent(0))
         self.draw_arrow_head(shape, origin='tail',
                              kind=self.child.arrow_head)
     self.setPath(shape)