123456789101112131415161718192021222324252627282930313233 |
- """
- A QGraphicsLineItem, augmented with the two points it is defined by.
- Required since, when in a group, the QGraphicsScene does not update the internal
- points of the underlying QLine object, so we update them manually whenever the group is moved.
- """
- from PyQt5.QtWidgets import QGraphicsLineItem
- from PyQt5.Qt import QPointF
- class SketchedLineItem(QGraphicsLineItem):
- def __init__(self, p1_x, p1_y, p2_x, p2_y):
- QGraphicsLineItem.__init__(self, p1_x, p1_y, p2_x, p2_y)
- # store away scene coordinates of points
- self._p1 = QPointF(p1_x, p1_y)
- self._p2 = QPointF(p2_x, p2_y)
- def set_p1(self, point):
- # type: (QPointF) -> None
- self._p1 = point
- def set_p2(self, point):
- # type: (QPointF) -> None
- self._p2 = point
- def get_p1(self):
- # type: () -> QPointF
- return self._p1
- def get_p2(self):
- # type: () -> QPointF
- return self._p2
|