Exemple #1
0
    def port_scene_position(self,
                            port_type: PortType,
                            index: int,
                            t: QTransform = None) -> QPointF:
        """
        Port scene position

        Parameters
        ----------
        port_type : PortType
        index : int
        t : QTransform

        Returns
        -------
        value : QPointF
        """
        if t is None:
            t = QTransform()

        step = self._entry_height + self._spacing
        total_height = float(self.caption_height) + step * index
        # TODO_UPSTREAM: why?
        total_height += step / 2.0

        if port_type == PortType.output:
            x = self._width + self._style.connection_point_diameter
            result = QPointF(x, total_height)
        elif port_type == PortType.input:
            x = -float(self._style.connection_point_diameter)
            result = QPointF(x, total_height)
        else:
            raise ValueError(port_type)

        return t.map(result)
Exemple #2
0
    def draw_icon(self, painter):
        path = QPainterPath(QPointF(0, 0.3))
        path.lineTo(0, 0.9)
        path.lineTo(1, 0.3)
        path.lineTo(1, 0.9)
        path.closeSubpath()
        painter.drawPath(path)
        painter.drawLine(QPointF(0.5, 0.6), QPointF(0.5, 0.15))

        # Draw the arrow end-caps
        painter.setBrush(QBrush(QColor(0, 0, 0)))

        top_arrow_point = QPointF(0.65, 0.36)
        arrow = QPolygonF([
            QPointF(-0.09, 0.0),
            QPointF(-0.005, 0.0),
            QPointF(-0.005, 0.8),
            QPointF(0.005, 0.8),
            QPointF(0.005, 0.0),
            QPointF(0.09, 0.0),
            QPointF(0.00, -0.25)
        ])

        t = QTransform()
        t.rotate(35)
        top_arrow_r = t.map(arrow)
        arrow_l = top_arrow_r.translated(top_arrow_point)
        painter.drawPolygon(arrow_l)

        painter.setBrush(self._interlock_brush)
        painter.drawRect(QRectF(0.3, 0, 0.4, 0.15))
Exemple #3
0
 def draw_icon(self, painter):
     painter.drawEllipse(QPointF(0.5, 0.5), 0.5, 0.5)
     painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 45 * 16, -120 * 16)
     painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 135 * 16, 120 * 16)
     bottom_arrow_point = QPointF(0.5, 0.8)
     painter.drawLine(bottom_arrow_point, QPointF(0.5, 0.7))
     curve_start = QPointF(0.5, 0.7)
     bend_angle = 25
     curve_end_l = QPointF(
         0.4 * math.cos(math.radians(90 + bend_angle)) + 0.5,
         -0.4 * math.sin(math.radians(90 + bend_angle)) + 0.5)
     c1 = QPointF(0.5, 0.4)
     path = QPainterPath(curve_start)
     path.quadTo(c1, curve_end_l)
     painter.drawPath(path)
     curve_end_r = QPointF(
         0.4 * math.cos(math.radians(90 - bend_angle)) + 0.5,
         -0.4 * math.sin(math.radians(90 - bend_angle)) + 0.5)
     path = QPainterPath(curve_start)
     path.quadTo(c1, curve_end_r)
     painter.drawPath(path)
     # Draw the arrow end-caps
     painter.setBrush(QBrush(QColor(0, 0, 0)))
     arrow = QPolygonF(
         [QPointF(-0.025, 0.0),
          QPointF(0.025, 0.0),
          QPointF(0.0, 0.025)])
     painter.drawPolygon(arrow.translated(bottom_arrow_point))
     t = QTransform()
     t.rotate(180.0 - 25.0)
     arrow_l = t.map(arrow)
     arrow_l = arrow_l.translated(curve_end_l)
     painter.drawPolygon(arrow_l)
     t = QTransform()
     t.rotate(180.0 + 25.0)
     arrow_r = t.map(arrow)
     arrow_r = arrow_r.translated(curve_end_r)
     painter.drawPolygon(arrow_r)
Exemple #4
0
    def draw_icon(self, painter):
        painter.drawEllipse(QPointF(0.5, 0.5), 0.5, 0.5)
        painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 90 * 16, -100 * 16)
        painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 135 * 16, 100 * 16)

        # Draw the arrow end-caps
        painter.setBrush(QBrush(QColor(0, 0, 0)))

        top_arrow_point = QPointF(0.35, 0.15)
        arrow = QPolygonF([
            QPointF(-0.08, 0.0),
            QPointF(-0.005, 0.0),
            QPointF(-0.005, 0.15),
            QPointF(0.005, 0.15),
            QPointF(0.005, 0.0),
            QPointF(0.08, 0.0),
            QPointF(0.00, -0.08)
        ])

        t = QTransform()
        t.rotate(-25)
        top_arrow_r = t.map(arrow)
        arrow_l = top_arrow_r.translated(top_arrow_point)
        painter.drawPolygon(arrow_l)

        bottom_left_arrow_point = QPointF(0.35, 0.89)
        t = QTransform()
        t.rotate(180.0 + 25.0)
        arrow_r = t.map(arrow)
        arrow_r = arrow_r.translated(bottom_left_arrow_point)
        painter.drawPolygon(arrow_r)

        bottom_right_arrow_point = QPointF(0.85, 0.65)
        t = QTransform()
        t.rotate(180.0 - 65.0)
        arrow_r = t.map(arrow)
        arrow_r = arrow_r.translated(bottom_right_arrow_point)
        painter.drawPolygon(arrow_r)
Exemple #5
0
def qwtDrawPixmapSymbols(painter, points, numPoints, symbol):
    size = symbol.size()
    if size.isEmpty():
        size = symbol.pixmap().size()
    transform = QTransform(painter.transform())
    if transform.isScaling():
        r = QRect(0, 0, size.width(), size.height())
        size = transform.mapRect(r).size()
    pm = QPixmap(symbol.pixmap())
    if pm.size() != size:
        pm = pm.scaled(size)
    pinPoint = QPointF(0.5 * size.width(), 0.5 * size.height())
    if symbol.isPinPointEnabled():
        pinPoint = symbol.pinPoint()
    painter.resetTransform()
    for pos in points:
        pos = QPointF(transform.map(pos)) - pinPoint
        QwtPainter.drawPixmap(painter, QRect(pos.toPoint(), pm.size()), pm)
Exemple #6
0
app = QApplication([])

# --- Construct custom symbol ---

path = QPainterPath()
path.moveTo(0, 8)
path.lineTo(0, 5)
path.lineTo(-3, 5)
path.lineTo(0, 0)
path.lineTo(3, 5)
path.lineTo(0, 5)

transform = QTransform()
transform.rotate(-30.0)
path = transform.map(path)

pen = QPen(Qt.black, 2)
pen.setJoinStyle(Qt.MiterJoin)

symbol = QwtSymbol()
symbol.setPen(pen)
symbol.setBrush(Qt.red)
symbol.setPath(path)
symbol.setPinPoint(QPointF(0.0, 0.0))
symbol.setSize(10, 14)

# --- Test it within a simple plot ---

curve = QwtPlotCurve()
curve_pen = QPen(Qt.blue)