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_cliche(self, p): x = 0 y = 0 w = self.laize * self.ech - 1 h = (self.CLICHE_HEIGHT - 1) * self.ech color = get_color_cliche(self.color) draw_rectangle(p, x, y, w, h, color=color, border_color=color_noir)
def draw_fond(self, p): """ Dessine un rectangle de la taille du bloc :param p: parametre de dessin """ color = color_vert_fonce if self.hover else color_blanc draw_rectangle(p, 0, 0, self.width(), self.height(), color)
def draw_bar_fond(self, p): """ Draw le fond de la bar :param p: Paramètre de dessin """ height = self.height() draw_rectangle(p, 1, 1, self.width()-2, height-2, color_blanc, border_color=color_bleu_gris)
def draw_container_horizontal_background(self, p): color = color_bleu_gris # Bande horizontale haut draw_rectangle(p, 0, 0, self.width(), self.chart_margin_top, color) # Bande horizontale haut draw_rectangle(p, 0, self.height() - self.chart_margin_bottom, self.width(), self.chart_margin_bottom, color)
def draw_bar(self, p): """ Dessine la bar :param p: Parmaètre de dessin """ draw_rectangle(p, 0, self.height() - self.height_bar, self.width(), self.height_bar, self.color_bar)
def draw_secondaire_x_axis(self, p, i): 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 + 5, color=color_gris_clair)
def draw_fond(self, p): """ Dessine un rectangle de la taille du bloc :param p: parametre de dessin """ draw_rectangle(p, self.PADDING, self.PADDING, self.width() - self.PADDING * 2, self.height() - self.PADDING * 2, color_bleu_gris)
def draw_horizontal_grille(self, p): for i in range(4): draw_rectangle(p, x=self.chart_margin_left, y=self.get_chart_height() + self.chart_margin_top - i * self.get_chart_height() / 4, width=self.get_chart_width(), height=width_grille, color=color_gris_clair)
def draw_bobine(self, p): x = 0 y = 0 w = self.laize * self.ech - 1 h = (self.BOBINE_HEIGHT - 1) * self.ech if self.bobine: color = get_color_bobine(self.bobine.color) else: color = color_gris draw_rectangle(p, x, y, w, h, color=color, border_color=color_noir)
def _draw_fond(self, p): """ Dessine un rectangle de la taille du bloc :param p: parametre de dessin """ if self.background_color: draw_rectangle(p, 0 + self.padding, 0 + self.padding, self.width() - self.padding * 2, self.height() - self.padding * 2, self.background_color) pass
def draw_container_vertical_background(self, p): color = color_bleu_gris # Le 10px de plus est pour cacher les barres de l'axis horizontal. height = self.height( ) - self.chart_margin_top - self.chart_margin_bottom + 10 # Bande verticale gauche draw_rectangle(p, 0, self.chart_margin_top, self.chart_margin_left, height, color) # Bande verticale droite (le +1 pour la coordonnée "x" est pour ne pas cacher la dernière # barre de la grille verticale. draw_rectangle(p, self.width() - self.chart_margin_right + 1, self.chart_margin_top, self.chart_margin_right, height, color)
def draw_border(self, p): draw_rectangle(p, self.X_CHART, self.Y_CHART, 1, self.H_CHART, color_bleu_gris) draw_rectangle(p, self.X_CHART, self.Y_CHART, self.W_CHART, 1, color_bleu_gris) draw_rectangle(p, self.X_CHART + self.W_CHART, self.Y_CHART, 1, self.H_CHART + 1, color_bleu_gris) draw_rectangle(p, self.X_CHART, self.Y_CHART + self.H_CHART, self.W_CHART, 1, color_bleu_gris)
def draw_arrow(self, p, arrow_length, arrow_size): x = self.width() / 2 y = self.height() - arrow_length w = self.BORDER_SIZE h = arrow_length draw_rectangle(p, x, y, w, h, color=color_rouge) x = x - arrow_size / 2 y = self.height() - arrow_size w = arrow_size + 2 h = arrow_size draw_triangle(p, x, y, w, h, background_color=color_rouge, border_size=self.BORDER_SIZE, reverse=True)
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_bar(self, p): """ Dessine la bar :param p: Paramètre de dessin """ height = self.height() scale = self.get_scale() if self.percent != 0: if self.parametric_color: if self.percent < 25: color = color_rouge elif self.percent < 50: color = color_orange else: color = color_vert else: color = color_bleu draw_rectangle(p, 2, 2, self.percent*scale-4, height-4, color)
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
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))
def draw_speed(self, p, i, speed): if speed < 0: color = color_gris_fonce draw_rectangle(p, x=i * 1 + self.chart_margin_left, y=self.chart_margin_top + self.get_chart_height() - 10, width=1, height=10, color=color) else: if speed < 30: color = color_rouge else: color = color_vert draw_rectangle(p, x=i * 1 + self.chart_margin_left, y=self.chart_margin_top + self.get_chart_height() - speed * (self.get_chart_height() / 200) + 1, width=1, height=speed * (self.get_chart_height() / 200), color=color)
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))
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_border(self, p): """ Dessine une bordure de la taille du bloc :param p: parametre de dessin """ if self.border_color: from commun.constants.colors import color_blanc draw_rectangle(p, 0 + self.padding, 0 + self.padding, self.width() - self.padding * 2, self.height() - self.padding * 2, self.border_color) background_color = self.background_color if self.background_color else color_blanc border_left = self.border_size if self.border_manager["left"] else 0 border_top = self.border_size if self.border_manager["top"] else 0 border_right = self.border_size if self.border_manager[ "right"] else 0 border_bottom = self.border_size if self.border_manager[ "bottom"] else 0 draw_rectangle( p, 0 + self.padding + border_left, 0 + self.padding + border_top, self.width() - self.padding - border_right * 2 - 1, self.height() - self.padding - border_bottom * 2 - 1, background_color) pass
def draw_background(self, p): draw_rectangle(p, self.chart_margin_left, self.chart_margin_top, self.get_chart_width(), self.get_chart_height(), color_blanc)