Exemple #1
0
    def _add_time_point(self, center_x, center_y, time_point):
        """Add a single time point item."""
        x = center_x - (self.TIMEPOINT_DIAMETER / 2)
        y = center_y - (self.TIMEPOINT_DIAMETER / 2)

        # Create the acutal time point item
        time_point_item = QGraphicsEllipseItem(0, 0, self.TIMEPOINT_DIAMETER,
                                               self.TIMEPOINT_DIAMETER)

        # The used color is the strongest one of the FRM II colors.
        time_point_item.setBrush(QBrush(QColor(0x00, 0x71, 0xbb)))
        time_point_item.setPen(QPen(0))

        self.scene().addItem(time_point_item)
        time_point_item.setPos(x, y)

        # place the time point item above the timeline and the selection item
        time_point_item.setZValue(2)

        # Create the label of the time point showing the time in the
        # defined strftime format on the right side of the time point item.
        label = QGraphicsTextItem(time_point.strftime(self.STRFTIME_FMT))
        label.setFont(QFont('Monospace'))
        label_height = label.boundingRect().height()

        # minor height adjustment
        label_y = y - label_height / 6

        self.scene().addItem(label)
        label.setPos(x + self.SELECTION_DIAMETER + self.LABEL_SPACING, label_y)

        # store references to the item and the timepoint in the same dict
        # to be able to use it for forward and reverse lookup
        self._time_point_items[time_point] = time_point_item
        self._time_point_items[time_point_item] = time_point
Exemple #2
0
class DetTable(TableBase):
    """Class to display the detector including shielding and detector tube."""

    _color = QColor('#ff66ff')

    def __init__(self, x, y, size=20, parent=None, scene=None):
        TableBase.__init__(self, x, y, size, parent, scene)
        self._halowidth = max(size / 4, 10)
        self._halo = Halo(x, y, size, self._halowidth, self, scene)
        self._tuberadius = size / 5
        p = QPointF(self._tuberadius, self._tuberadius)
        s = QSizeF(2 * self._tuberadius, 2 * self._tuberadius)
        self._tube = QGraphicsEllipseItem(QRectF(-p, s), self)
        self._tube.setPen(QPen(QColor('black'), 3))
        self._tube.setBrush(QBrush(QColor('white')))
        self._tube.setZValue(20)