예제 #1
0
    def _draw_major_divisions(self, painter, stamps, start_stamp, division):
        """
        Draw black hashed vertical grid-lines showing major time divisions.
        :param painter: allows access to paint functions,''QPainter''
        """
        label_y = self._history_top - self._playhead_pointer_size[1] - 5
        for stamp in stamps:
            x = self.map_stamp_to_x(stamp, False)

            label = self._get_label(division, stamp - start_stamp)
            label_x = x + self._major_divisions_label_indent
            if label_x + QFontMetrics(
                    self._topic_font).width(label) < self.scene().width():
                painter.setPen(self._default_pen)
                painter.setBrush(QBrush(Qt.black))
                path = QPainterPath()
                path.addText(label_x, label_y, self._time_font, label)
                painter.drawPath(path)

            painter.setPen(self._major_division_pen)
            painter.drawLine(
                x, label_y - self._time_tick_height - self._time_font_size, x,
                self._history_bottom)

        painter.setBrush(self._default_brush)
        painter.setPen(self._default_pen)
예제 #2
0
    def _draw_topic_names(self, painter):
        """
        Calculate positions of existing topic names and draw them on the left, one for each row
        :param painter: ,''QPainter''
        """
        topics = self._history_bounds.keys()
        coords = [(self._margin_left,
                   y + (h / 2) + (self._topic_font_height / 2))
                  for (_, y, _, h) in self._history_bounds.values()]

        for text, coords in zip([t.lstrip('/') for t in topics], coords):
            path = QPainterPath()
            path.addText(coords[0], coords[1], self._topic_font, text)
            painter.setBrush(self._default_brush)
            painter.setPen(self._default_pen)
            painter.drawPath(path)