Exemple #1
0
 def draw_text(self, p):
     x = 0
     y = -20
     w = self.laize * self.ech
     h = self.CLICHE_HEIGHT * self.ech
     font_size = 14 * self.ech
     text = self.cliche.code
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=text)
     pose = self.bobine_selected.pose
     text = "({} pose)".format(pose) if pose == 1 else "({} poses)".format(
         pose)
     y = 10
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=text)
Exemple #2
0
 def draw_percent(self, p):
     """
     Dessine le label indiquant le pourcentage
     Si le % est inférieur à 22 on le dessine à droite la de la bar % sinon à gauche
     :param p: Paramètre de dessin
     """
     height = self.height()
     scale = self.get_scale()
     width = 150
     margin_text = 5
     if self.percent > 22:
         color_text = color_blanc
         pos_text_x = self.percent*scale-width - margin_text
         align = "D"
     else:
         color_text = color_bleu_gris
         pos_text_x = self.percent*scale + margin_text
         align = "G"
     draw_text(p,
               x=pos_text_x,
               y=0,
               width=width,
               height=height,
               color=color_text,
               align=align,
               font_size=12,
               text='{result}%'.format(result=round(self.percent, 1)))
Exemple #3
0
 def draw_repere_maximum(self, p):
     draw_rectangle(p,
                    x=self.chart_margin_left,
                    y=self.get_chart_height() + self.chart_margin_top -
                    self.get_chart_height() * 0.9,
                    width=self.get_chart_width(),
                    height=width_grille * 2,
                    color=color_noir)
     draw_text(p,
               x=self.chart_margin_left - 10 - 60,
               y=self.get_chart_height() + self.chart_margin_top -
               self.get_chart_height() * 0.9 - 10,
               width=60,
               height=20,
               color=color_blanc,
               align="D",
               font_size=10,
               text='180m/min')
     draw_text(p,
               x=self.chart_margin_right - 10 + 20 + self.get_chart_width(),
               y=self.get_chart_height() + self.chart_margin_top -
               self.get_chart_height() * 0.9 - 10,
               width=60,
               height=20,
               color=color_blanc,
               align="G",
               font_size=10,
               text='180m/min')
 def draw_label_laize(self, p):
     x = 0
     y = 10 * self.ech
     w = self.laize * self.ech
     h = self.BOBINE_HEIGHT * self.ech
     font_size = 22 * self.ech
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=str(int(self.laize)))
 def draw_code(self, p):
     x = 0
     y = -30 * self.ech
     w = self.laize * self.ech
     h = self.BOBINE_HEIGHT * self.ech
     font_size = 10 * self.ech
     text = self.bobine.code
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=text)
 def draw_label_number(self, p):
     x = 0
     y = -30 * self.ech
     w = self.laize * self.ech
     h = self.BOBINE_HEIGHT * self.ech
     font_size = 14 * self.ech
     text = "Laize {}".format(self.number)
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=text)
Exemple #7
0
 def draw_principale_x_axis(self, p, i, t):
     draw_rectangle(p,
                    x=i + self.chart_margin_left,
                    y=self.chart_margin_top,
                    width=width_grille,
                    height=self.height() - self.chart_margin_bottom -
                    self.chart_margin_top + 10,
                    color=color_gris_moyen)
     color = color_blanc
     draw_text(p,
               x=i + self.chart_margin_left - 20,
               y=self.get_chart_height() + self.chart_margin_top + 10,
               height=40,
               width=40,
               color=color,
               align="C",
               font_size=10,
               text=hour_in_timestamp(t))
    def draw_speed(self, p):
        def get_speed():
            speeds = data_store_manager.get_current_store().data
            i = 0
            current_sum = 0
            new_data = []
            for speed in speeds:
                if i < 90:
                    value = speed[1]
                    current_sum += value
                else:
                    i = 0
                    new_data.append(round(current_sum / 90))
                    current_sum = 0
                i += 1
            new_data.append(round(current_sum / 90))
            return new_data

        speeds = get_speed()
        i = 0
        for speed in speeds:
            speed = speed if speed < 190 else 190
            color = color_vert if speed > VITESSE_LIMITE_ASSIMILATION_ARRET else color_rouge
            draw_rectangle(p, self.X_CHART + i,
                           self.H_CHART - speed + self.Y_CHART, 1, speed + 1,
                           color)
            i += 1
        current_store = data_store_manager.get_current_store()
        vendredi = timestamp_to_day(timestamp_at_day_ago(
            current_store.day_ago)) == "vendredi"
        if vendredi:
            draw_rectangle(p, self.X_CHART + (40 * 14), self.Y_CHART, 40 * 2,
                           self.H_CHART, color_gris_moyen)
            draw_text(p,
                      self.X_CHART + (40 * 14),
                      self.Y_CHART,
                      40 * 2,
                      self.H_CHART,
                      color_gris_fonce,
                      align="C",
                      font_size=10,
                      text="Vendredi")
 def draw_h_grid(self, p):
     i = 0
     speed = 0
     while i <= 4:
         speed = 180 if i == 4 else speed
         color = color_gris_clair if i < 4 else color_gris_moyen
         draw_rectangle(p, self.X_CHART - 3,
                        self.H_CHART - speed + self.Y_CHART,
                        self.W_CHART + 3, 1, color)
         draw_text(p,
                   x=self.X_CHART - 35,
                   y=self.H_CHART - speed + self.Y_CHART - 10,
                   width=30,
                   height=20,
                   color=color_noir,
                   align="D",
                   font_size=8,
                   text=str(speed))
         speed += 50
         i += 1
 def draw_v_grid(self, p):
     i = 0
     hour = 6
     while i <= 32:
         dec_hour = 3 if i % 2 == 0 else 0
         color = color_gris_moyen if i % 2 == 0 else color_gris_clair
         draw_rectangle(p, self.X_CHART + (20 * i), self.Y_CHART, 1,
                        self.H_CHART + 5 + dec_hour, color)
         if i % 2 == 0:
             draw_text(p,
                       x=self.X_CHART + (20 * i) - 25,
                       y=self.Y_CHART + self.H_CHART + 5,
                       width=50,
                       height=20,
                       color=color_noir,
                       align="C",
                       font_size=8,
                       text="{}:00".format(hour))
             hour += 1
         i += 1
Exemple #11
0
 def draw_bague(self, p, pic_height, arrow_length):
     x = 0
     y = pic_height + arrow_length
     w = self.width() - 1
     h = self.height() - 2 * (pic_height + arrow_length)
     draw_rectangle(p,
                    x,
                    y,
                    w,
                    h,
                    color=color_beige,
                    border_color=color_noir)
     font_size = 16 * self.ech
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=str(self.width_value))
Exemple #12
0
 def draw_entretoise(self, p, width, height):
     x = 0
     y = 0
     w = width - 1
     h = height - 1
     draw_rectangle(p,
                    x,
                    y,
                    w,
                    h,
                    color=color_gris,
                    border_color=color_noir)
     font_size = 14 * self.ech
     draw_text(p,
               x,
               y,
               w,
               h,
               color=color_noir,
               align="C",
               font_size=font_size,
               text=str(self.width_value))
Exemple #13
0
 def draw_horizontal_label(self, p):
     for i in range(4):
         draw_text(p,
                   x=self.chart_margin_left - 10 - 60,
                   y=self.get_chart_height() + self.chart_margin_top -
                   i * self.get_chart_height() / 4 - 10,
                   width=60,
                   height=20,
                   color=color_blanc,
                   align="D",
                   font_size=10,
                   text='{speed}m/min'.format(speed=50 * i))
         draw_text(p,
                   x=self.chart_margin_right - 10 + 20 +
                   self.get_chart_width(),
                   y=self.get_chart_height() + self.chart_margin_top -
                   i * self.get_chart_height() / 4 - 10,
                   width=60,
                   height=20,
                   color=color_blanc,
                   align="G",
                   font_size=10,
                   text='{speed}m/min'.format(speed=50 * i))
Exemple #14
0
 def draw_max_info(self, p):
     """
     Dessine l'information maximum théorique
     :param p: Paramètre de dessin
     """
     scale = self.get_scale()
     width = (100 - PERCENT_PROD_THEROIQUE_MAXI) * scale
     y = 0
     height = self.height()
     align = "C"
     text = "82% \n (Max.)"
     font_size = 8
     x = PERCENT_PROD_THEROIQUE_MAXI*scale
     draw_rectangle(p, PERCENT_PROD_THEROIQUE_MAXI * scale, 0 + 2, 1, self.height() - 4, color_bleu)
     draw_text(p,
               x=x,
               y=y,
               width=width,
               height=height,
               color=color_bleu,
               align=align,
               font_size=font_size,
               text=text,
               bold=True)
 def draw_label(self, p):
     """
     Dessine la valeur de la bar
     :param p: Paramètre de dessin
     """
     # Si la largeur est suffisante on trace la valeur horizontalement
     if self.width() > 80:
         draw_text(p,
                   0,
                   self.height() - self.height_bar - 20 -
                   self.PADDING_LABEL_H,
                   self.width(),
                   20,
                   color=color_bleu_gris,
                   align="C",
                   font_size=12,
                   text=self.text_value)
     else:
         if self.width() > 30:
             font_size = 12
         else:
             font_size = 10
         # Sinon on trace la valeur verticalement
         p.rotate(90)
         # Si la hauteur est suffisante on trace la valeur à l'intérieur de la bar
         if self.height_bar > 70:
             draw_text(p,
                       self.height() - self.height_bar +
                       self.PADDING_LABEL_V,
                       -self.width() / 2 - 10.5,
                       200,
                       20,
                       color=color_blanc,
                       align="G",
                       font_size=font_size,
                       text=self.text_value)
         # Sinon la valeur à l'extérieur de la bar
         else:
             draw_text(p,
                       self.height() - self.height_bar - 200 -
                       self.PADDING_LABEL_V,
                       -self.width() / 2 - 10.5,
                       200,
                       20,
                       color=color_noir,
                       align="D",
                       font_size=font_size,
                       text=self.text_value)