def __init__(self, parent=None, scene=None): QGraphicsRectItem.__init__(self, 0, 0, 10, 45, parent) transform = QTransform() transform.translate(0, 5) self.setTransform(transform) self.setBrush(QBrush(QColor('#00FF00'))) if not parent and scene: scene.addItem(self) self._halo = DetectorHalo(5, self, scene)
def __init__(self, parent=None, scene=None): QGraphicsPathItem.__init__(self, parent) self.setPath(self.shape()) transform = QTransform() transform.translate(0, -60) self.setTransform(transform) self.setTransformOriginPoint(QPointF(0, 50)) if not parent and scene: scene.addItem(self) self._halo = TubeHalo(10, self, scene) self.setState(status.OK)
def __init__(self, width, parent=None, scene=None): w = width + 2 if parent and isinstance(parent, QGraphicsRectItem): rect = parent.rect() size = rect.size() size += QSizeF(w, w) rect.setSize(size) else: rect = QRectF() QGraphicsRectItem.__init__(self, rect, parent) transform = QTransform() transform.translate(-w / 2, -w / 2) self.setTransform(transform) self.setBrush(QBrush(statuscolor[status.OK])) self.setPen(QPen(statuscolor[status.OK], width))
def __init__(self, parent=None): scene = QGraphicsScene() QGraphicsView.__init__(self, scene) self.setRenderHints(QPainter.Antialiasing) self._tube = Tube(scene=scene) self._tube.setRotation(1) self._yoke = Yoke(scene=scene) t1 = QTransform() t1.translate(500, 0) self._yoke.setTransform(t1) self._pivotline = QGraphicsLineItem(-200, 0, 700, 0) scene.addItem(self._pivotline) self._pivot = QGraphicsRectItem(0, 0, 6, 10) t2 = QTransform() t2.translate(-3, -10) self._pivot.setTransform(t2) self._pivot.setBrush(QBrush(QColor('#1F1F1F'))) scene.addItem(self._pivot) for i in range(13): txt = '%d' % (i + 1) self.t = QGraphicsTextItem(txt) bw = self.t.boundingRect().size().width() chrwidth = bw / (len(txt) + 1) x = (i - 9) * self.pivotdist - chrwidth / 2 + bw / len(txt) self.t.setX(x) scene.addItem(self.t) self._det = Detector(parent=self._tube, scene=scene) self.values = { 'tubeangle': -1.0, 'pivot': 1, 'detpos': 620, } self.targets = self.values.copy() self.status = { 'tubeangle': status.OK, 'pivot': status.OK, 'detpos': status.OK, }