Skip to content
Snippets Groups Projects
Commit 4e445b33 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

PumpCalib. Correct color/order bug. Correct legend bug.

parent d9017533
No related branches found
No related tags found
No related merge requests found
import pandas as pd import pandas as pd
import numpy as np
import datetime
import os import os
import re import re
import utils
from config import Config from config import Config
...@@ -21,6 +18,7 @@ class PumpCalibProvider: ...@@ -21,6 +18,7 @@ class PumpCalibProvider:
# Keep only runs-related files (like: 20191010-064649_COLPUMP_calib_runs.csv) # Keep only runs-related files (like: 20191010-064649_COLPUMP_calib_runs.csv)
regex = re.compile(r'^[0-9]{8}-[0-9]{6}_' + self.pump_id + '_calib_runs.csv$') regex = re.compile(r'^[0-9]{8}-[0-9]{6}_' + self.pump_id + '_calib_runs.csv$')
runs_files = list(filter(regex.search, self.all_files)) runs_files = list(filter(regex.search, self.all_files))
runs_files.sort()
runs_df = pd.DataFrame() runs_df = pd.DataFrame()
calib_id_int = 0 calib_id_int = 0
......
...@@ -32,8 +32,6 @@ class PumpCalibUim: ...@@ -32,8 +32,6 @@ class PumpCalibUim:
self.runs_df = pd.DataFrame() self.runs_df = pd.DataFrame()
self.coef_df = pd.DataFrame() self.coef_df = pd.DataFrame()
self.__initialize_runs_plot__()
def set_current_pump_prvd(self, pump_text: str = None) -> PumpCalibProvider: def set_current_pump_prvd(self, pump_text: str = None) -> PumpCalibProvider:
if pump_text is None: if pump_text is None:
pump_text = self.main_ui.pump_combobox_pump.currentText() pump_text = self.main_ui.pump_combobox_pump.currentText()
...@@ -58,29 +56,14 @@ class PumpCalibUim: ...@@ -58,29 +56,14 @@ class PumpCalibUim:
#################################################################### ####################################################################
# Plot # Plot
def __initialize_runs_plot__(self) -> None:
self.plot_item = pg.PlotItem()
self.main_ui.pump_graphicsview_runs.setCentralItem(self.plot_item)
# Create legend
self.legend = pg.LegendItem(offset=(40, 10))
self.legend.setParentItem(self.plot_item.graphicsItem())
self.runs_points_list = []
def __update_runs_plot__(self, runs_df: pd.DataFrame, coef_df: pd.DataFrame) -> None: def __update_runs_plot__(self, runs_df: pd.DataFrame, coef_df: pd.DataFrame) -> None:
self.plot_item.clear() # Create plot item
# for item in self.runs_points_list: plot_item = pg.PlotItem()
# self.legend.removeItem(item) self.main_ui.pump_graphicsview_runs.setCentralItem(plot_item)
self.legend = utils.clear_legend_items(self.legend)
# while self.legend.layout.count() > 0:
# self.legend.layout.removeAt(0)
# grphic_item = self.plot_item.graphicsItem()
# grphic_item.removeItem(self.legend)
# self.legend = pg.LegendItem(offset=(40, 10))
# self.legend.setParentItem(self.plot_item)
# Create legend
legend = pg.LegendItem(offset=(40, 10))
legend.setParentItem(plot_item.graphicsItem())
# Create the color scale # Create the color scale
color_map = pg.ColorMap(pos=[runs_df["calib_id_int"].min(), color_map = pg.ColorMap(pos=[runs_df["calib_id_int"].min(),
...@@ -93,7 +76,7 @@ class PumpCalibUim: ...@@ -93,7 +76,7 @@ class PumpCalibUim:
angle=degrees(atan(row["slope"])), angle=degrees(atan(row["slope"])),
pen=pg.mkPen(color=color_map.mapToQColor(row["calib_id_int"])), pen=pg.mkPen(color=color_map.mapToQColor(row["calib_id_int"])),
name=row["calib_id_str"]) name=row["calib_id_str"])
self.plot_item.addItem(reg_line) plot_item.addItem(reg_line)
# Add runs points # Add runs points
for calib_id in runs_df["calib_id_int"].unique(): for calib_id in runs_df["calib_id_int"].unique():
...@@ -103,6 +86,5 @@ class PumpCalibUim: ...@@ -103,6 +86,5 @@ class PumpCalibUim:
size=6, size=6,
brush=color_map.mapToQColor(calib_id), brush=color_map.mapToQColor(calib_id),
name=run_df["calib_id_str"].unique()[0]) name=run_df["calib_id_str"].unique()[0])
self.legend.addItem(run_points, run_df["calib_id_str"].unique()[0]) legend.addItem(run_points, run_df["calib_id_str"].unique()[0])
self.plot_item.addItem(run_points) plot_item.addItem(run_points)
self.runs_points_list.append(run_points)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment