49 self._end = QPointF() if end is None else QPointF(end) |
49 self._end = QPointF() if end is None else QPointF(end) |
50 self._filled = filled |
50 self._filled = filled |
51 self._type = arrowType |
51 self._type = arrowType |
52 |
52 |
53 if colors is None: |
53 if colors is None: |
54 self._colors = (QColor(Qt.black), QColor(Qt.white)) |
54 self._colors = (QColor(Qt.GlobalColor.black), |
|
55 QColor(Qt.GlobalColor.white)) |
55 else: |
56 else: |
56 self._colors = colors |
57 self._colors = colors |
57 |
58 |
58 self._halfLength = 13.0 |
59 self._halfLength = 13.0 |
59 |
60 |
60 self.setFlag(QGraphicsItem.ItemIsMovable, True) |
61 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsMovable, True) |
61 self.setFlag(QGraphicsItem.ItemIsSelectable, True) |
62 self.setFlag(QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, True) |
62 |
63 |
63 def setPoints(self, xa, ya, xb, yb): |
64 def setPoints(self, xa, ya, xb, yb): |
64 """ |
65 """ |
65 Public method to set the start and end points of the line. |
66 Public method to set the start and end points of the line. |
66 |
67 |
114 @param painter reference to the painter object (QPainter) |
115 @param painter reference to the painter object (QPainter) |
115 @param option style options (QStyleOptionGraphicsItem) |
116 @param option style options (QStyleOptionGraphicsItem) |
116 @param widget optional reference to the widget painted on (QWidget) |
117 @param widget optional reference to the widget painted on (QWidget) |
117 """ |
118 """ |
118 if ( |
119 if ( |
119 (option.state & QStyle.State_Selected) == |
120 (option.state & QStyle.StateFlag.State_Selected) == |
120 QStyle.State(QStyle.State_Selected) |
121 QStyle.State(QStyle.StateFlag.State_Selected) |
121 ): |
122 ): |
122 width = 2 |
123 width = 2 |
123 else: |
124 else: |
124 width = 1 |
125 width = 1 |
125 |
126 |
126 # draw the line first |
127 # draw the line first |
127 line = QLineF(self._origin, self._end) |
128 line = QLineF(self._origin, self._end) |
128 painter.setPen( |
129 painter.setPen( |
129 QPen(self._colors[0], width, Qt.SolidLine, Qt.FlatCap, |
130 QPen(self._colors[0], width, Qt.PenStyle.SolidLine, |
130 Qt.MiterJoin)) |
131 Qt.PenCapStyle.FlatCap, Qt.PenJoinStyle.MiterJoin)) |
131 painter.drawLine(line) |
132 painter.drawLine(line) |
132 |
133 |
133 # draw the arrow head |
134 # draw the arrow head |
134 arrowAngle = self._type * ArrowheadAngleFactor |
135 arrowAngle = self._type * ArrowheadAngleFactor |
135 slope = math.atan2(line.dy(), line.dx()) |
136 slope = math.atan2(line.dy(), line.dx()) |