コード例 #1
0
    def _add_timeline(self):
        """Draw the timeline."""

        # height is either the necessary space to display all items or the
        # maximal available display size, so it's looks nicely in larger
        # windows and enables scrolling in smaller ones.
        height = self.TIMEPOINT_DIAMETER * len(self._time_points)
        height += self.TIMEPOINT_SPACING * len(self._time_points)
        height = max(height, self.viewport().height())

        # draw the timeline left aligned with enough space to draw the items
        # and the selection ring.
        x = self.MARGIN_HORIZONTAL + (self.SELECTION_DIAMETER / 2)

        # position the line on the left side of the item
        item = QGraphicsLineItem(0, 0, 0, height)

        # The used color for the timeline is the lightest one of the FRM II
        # colors
        item.setPen(QPen(QBrush(QColor(0xa3, 0xc1, 0xe7)),
                         self.TIMELINE_WIDTH))

        self.scene().addItem(item)

        # move the whole item to the desired timeline position
        item.setPos(x, 0)
        return item
コード例 #2
0
ファイル: beam.py プロジェクト: umithardal/nicos
class Beam(QGraphicsLineItem):
    """Class representing the neutron beam."""
    def __init__(self, fromObj, toObj, parent=None, scene=None):
        self._start = fromObj
        self._end = toObj
        QGraphicsLineItem.__init__(self, parent)
        self.setPen(QPen(QColor('white'), 4))
        self._beam = QGraphicsLineItem(parent)
        self._beam.setPen(QPen(QColor('blue'), 1))
        if not parent and scene:
            scene.addItem(self)
            scene.addItem(self._beam)
        self.update()
        self.setZValue(50)
        self._beam.setZValue(51)

    def paint(self, painter, options, widget):
        self.setLine(QLineF(self._start.scenePos(), self._end.scenePos()))
        QGraphicsLineItem.paint(self, painter, options, widget)

    def setLine(self, line):
        self._beam.setLine(line)
        QGraphicsLineItem.setLine(self, line)

    def boundingRect(self):
        # This refreshes the bounding rect
        self.setLine(QLineF(self._start.scenePos(), self._end.scenePos()))
        return QGraphicsLineItem.boundingRect(self)
コード例 #3
0
class Crystal(TableBase):
    """Display a crystal on a table."""

    _pencolor = None

    def __init__(self, x, y, size=10, parent=None, scene=None):
        TableBase.__init__(self, x, y, size, parent, scene)
        sz = size / 2
        self._crystal = QGraphicsLineItem(-sz, 0, sz, 0, self)
        if not self._pencolor:
            self._pencolor = QColor('black')
        self._crystal.setPen(QPen(self._pencolor, 3))
        self._crystal.setZValue(100)
コード例 #4
0
ファイル: sample.py プロジェクト: ess-dmsc/nicos
class Sample(TableBase):
    """Display a sample on a table."""

    _pencolor = None

    def __init__(self, x, y, size=20, parent=None, scene=None):
        if parent:
            self._color = parent._color
        TableBase.__init__(self, x, y, size, parent, scene)
        if not self._pencolor:
            self._pencolor = QColor('#666666')
        self._pen = QPen(self._pencolor, 1)
        self._pen.setBrush(QBrush(self._pencolor))
        sz = size / 3
        self._polygon = QGraphicsRectItem(
            QRectF(-QPointF(sz, sz), QPointF(sz, sz)), self)
        self._polygon.setBrush(QBrush(self._pencolor))
        self._l1 = QGraphicsLineItem(-size, 0, size, 0, self)
        self._l1.setPen(self._pen)
        self._l2 = QGraphicsLineItem(0, -size, 0, size, self)
        self._l2.setPen(self._pen)