Example #1
0
 def overlay(self, other_component, gc, view_bounds=None, mode="normal"):
     with gc:
         gc.set_font(str_to_font(None, None, '8'))
         for x, y, l in self.labels:
             x, y = other_component.map_screen([(x, y)])[0]
             gc.set_text_position(x - 5, y - 5)
             gc.show_text(l)
Example #2
0
 def overlay(self, other_component, gc, view_bounds=None, mode="normal"):
     with gc:
         gc.set_font(str_to_font(None, None, '8'))
         for x, y, l in self.labels:
             x, y = other_component.map_screen([(x, y)])[0]
             gc.set_text_position(x - 5, y - 5)
             gc.show_text(l)
    def _draw_time_text(self, gc, pp_spec):
        if self.manager.movie_create_time_label == False:
            return
        if pp_spec.level == 0:
            (H, M, S) = get_time_label_parts_for_miliseconds(0,
                                hour_label=self.manager.movie_hour_label,
                                minute_label=self.manager.movie_minute_label,
                                second_label=self.manager.movie_second_label)
        else:
            (H, M, S) = get_time_label_parts_for_miliseconds(
                                pp_spec.cum_inactive,
                                hour_label=self.manager.movie_hour_label,
                                minute_label=self.manager.movie_minute_label,
                                second_label=self.manager.movie_second_label)

        if not self._time_label_font:
            self._time_label_font = str_to_font(None, None, self.time_label_font)

        gc.set_font(self._time_label_font)

        shift = 10
        if self.manager.movie_time_label_in_line == True:
            if self.manager.movie_time_label_prefix:
                time_line = '%s %s %s %s' % (self.manager.movie_time_label_prefix, H, M, S)
            else:
                time_line = '%s %s %s' % (H, M, S)
            _, _, tw, th = gc.get_text_extent(time_line)
            x = self._plot.outer_bounds[0] / 2 - tw / 2 - self._plot.padding_left
            y = self._plot.outer_bounds[1] - self._plot.padding_top - th
            gc.set_fill_color((1.0, 1.0, 1.0, 1.0))
            gc.rect(x, y, tw, th + shift)
            gc.draw_path()
            gc.set_fill_color((0.0, 0.0, 0.0, 1.0))
            gc.show_text_at_point(time_line, x, y)
        else:
            for idx, time_e in enumerate([H, M, S]):
                _, _, tw, th = gc.get_text_extent(time_e)
                x = self._plot.outer_bounds[0] - tw - self._plot.padding_right
                y = self._plot.outer_bounds[1] / 2 - idx * (th + shift)
                gc.set_fill_color((1.0, 1.0, 1.0, 1.0))
                #gc.rect(x, y, tw + shift, th)
                gc.rect(x, y, tw, th + shift)
                gc.draw_path()
                gc.set_fill_color((0.0, 0.0, 0.0, 1.0))
                gc.show_text_at_point(time_e, x, y)

        return
Example #4
0
    def render(self, gc):
        names = [ei.name for ei in self.error_components]
        error_components = [ei.value for ei in self.error_components]
        ss = float(sum(error_components))
        pi2 = math.pi * 2
        angles = [si / ss * pi2 for si in error_components]
        percents = [si / ss for si in error_components]

        x, y = self.get_xy()
        gc.translate_ctm(x, y)

        r = self.map_dimension(22, keep_square=True)
        r2 = self.map_dimension(25, keep_square=True)
        s = pi2 / 4.
        gc.set_font(str_to_font(None, None, '12'))
        for i, (ni, a, pp) in enumerate(zip(names, angles, percents)):
            with gc:
                with gc:
                    gc.set_fill_color(self.cmap(min(1, s / pi2)))
                    gc.move_to(0, 0)
                    gc.line_to(0, r)
                    gc.arc(0, 0, r, s, s + a)
                    gc.line_to(0, 0)
                    gc.fill_path()

                if pp > 0.01:
                    txt = '{} {:n}%'.format(ni, int(pp * 100))
                    theta = a / 2.0 + s
                    gc.translate_ctm(-10, 0)
                    x, y = r2 * math.cos(theta), r2 * math.sin(theta)

                    gc.set_fill_color((1, 1, 1))
                    gc.set_stroke_color((1, 1, 1))
                    w, h, _, _ = gc.get_full_text_extent(txt)
                    gc.draw_rect((x - 2, y - 2, w + 2, h + 2))

                    gc.set_fill_color((0, 0, 0))
                    gc.set_text_position(x, y)
                    gc.show_text(txt)
                s += a
Example #5
0
    def render(self, gc):
        names = [ei.name for ei in self.error_components]
        error_components = [ei.value for ei in self.error_components]
        ss = float(sum(error_components))
        pi2 = math.pi * 2
        angles = [si / ss * pi2 for si in error_components]
        percents = [si / ss for si in error_components]

        x, y = self.get_xy()
        gc.translate_ctm(x, y)

        r = self.map_dimension(22, keep_square=True)
        r2 = self.map_dimension(25, keep_square=True)
        s = pi2 / 4.
        gc.set_font(str_to_font(None, None, '12'))
        for i, (ni, a, pp) in enumerate(zip(names, angles, percents)):
            with gc:
                with gc:
                    gc.set_fill_color(self.cmap(min(1, s / pi2)))
                    gc.move_to(0, 0)
                    gc.line_to(0, r)
                    gc.arc(0, 0, r, s, s + a)
                    gc.line_to(0, 0)
                    gc.fill_path()

                if pp > 0.01:
                    txt = '{} {:n}%'.format(ni, int(pp * 100))
                    theta = a / 2.0 + s
                    gc.translate_ctm(-10, 0)
                    x, y = r2 * math.cos(theta), r2 * math.sin(theta)

                    gc.set_fill_color((1, 1, 1))
                    gc.set_stroke_color((1, 1, 1))
                    w, h, _, _ = gc.get_full_text_extent(txt)
                    gc.draw_rect((x - 2, y - 2, w + 2, h + 2))

                    gc.set_fill_color((0, 0, 0))
                    gc.set_text_position(x, y)
                    gc.show_text(txt)
                s += a