diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index fed9a43..5cf62d1 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -136,7 +136,7 @@ class SedimentCalibrationTab(QWidget): self.label_sand_target = QLabel() self.label_sand_target.setText("Sand target") self.gridLayout_groupbox_sample.addWidget(self.label_sand_target, 1, 0, 1, 1) - self.combobox_sand_sample_choice = CheckableComboBox() + self.combobox_sand_sample_choice = QComboBox() self.gridLayout_groupbox_sample.addWidget(self.combobox_sand_sample_choice, 1, 1, 1, 1) self.pushbutton_plot_sample = QPushButton() @@ -203,7 +203,7 @@ class SedimentCalibrationTab(QWidget): self.gridLayout_groupbox_interpolate_info.addWidget(self.label_time_sand, 5, 2, 1, 1) self.label_concentration_sand = QLabel() - self.label_concentration_sand.setText("Cfine (g/L)") + self.label_concentration_sand.setText("Csand (g/L)") self.gridLayout_groupbox_interpolate_info.addWidget(self.label_concentration_sand, 5, 3, 1, 1) # --- Groupbox interpolate plot --- @@ -570,6 +570,7 @@ class SedimentCalibrationTab(QWidget): def function_pushbutton_plot_sample(self): self.sample_choice_for_calibration() self.plot_acoustic_recording() + self.summary_samples_choices() self.plot_profile_of_concentration_fine() self.compute_FCB() @@ -892,7 +893,9 @@ class SedimentCalibrationTab(QWidget): print(f"stg.fine_sample_profile : {stg.fine_sample_profile}") # --- List selected sand samples --- - stg.sand_sample_target = [(s, int(s[1:]) - 1) for s in self.combobox_sand_sample_choice.currentData()] + # stg.sand_sample_target = [(s, int(s[1:]) - 1) for s in self.combobox_sand_sample_choice.currentData()] + stg.sand_sample_target = [(self.combobox_sand_sample_choice.currentText(), + self.combobox_sand_sample_choice.currentIndex())] print(f"stg.sand_sample_target : {stg.sand_sample_target}") # --- Find index in time (along acoustic recording) of sand sample target --- @@ -962,6 +965,54 @@ class SedimentCalibrationTab(QWidget): stg.sand_sample_target_indice = [(d1, t1), (d2, t2)] print("stg.sand_sample_target_indice ", stg.sand_sample_target_indice) + def summary_samples_choices(self): + + for i in reversed(range(self.gridLayout_groupbox_interpolate_info.count())): + self.gridLayout_groupbox_interpolate_info.itemAt(i).widget().setParent(None) + + self.gridLayout_groupbox_interpolate_info.addWidget(self.pushbutton_interpolate_Mfine_profile, 0, 0, 1, 4) + + fine_head = ["Sample", "Depth (m)", "time", "Cfine (g/L)"] + fine_label = [self.label_sample_fine, self.label_depth_fine, self.label_time_fine, + self.label_concentration_fine] + + for j in range(len(fine_head)): + exec("fine_label[" + str(j) + "] = QLabel()") + eval("fine_label[" + str(j) + "].setText(fine_head[" + str(j) + "])") + print((f"self.gridLayout_groupbox_interpolate_info.addWidget(fine_label[{j}], 1, {j}, 1, 1)")) + eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(fine_label[{j}], 1, {j}, 1, 1)") + + fine_data = [] + for k in range(len(stg.fine_sample_profile)): + fine_data.append([stg.fine_sample_profile[k][0], str(stg.depth_fine[k]), str(stg.time_fine[k]), str(stg.Ctot_fine[k])]) + print(fine_data) + + for p in range(len(fine_data)): + for q in range(len(fine_data[0])): + # exec("fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "][0]" + " = QLabel()") + # eval("fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "][0]" + ".setText(" + "fine_data[" + str(p) + "][" + str(q) + "])") + # eval("self.gridLayout_groupbox_interpolate_info.addWidget(" + "fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "], " + str(1+p) + ", " + str(q) + ", 1, 1)") + eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(fine_data[{p}][{q}]), {2 + p}, {q}, 1, 1)") + + sand_head = ["Sample", "Depth (m)", "time", "Csand (g/L)"] + sand_label = [self.label_sample_sand, self.label_depth_sand, self.label_time_sand, + self.label_concentration_sand] + + for s in range(len(sand_head)): + exec("sand_label[" + str(s) + "] = QLabel()") + eval("sand_label[" + str(s) + "].setText(sand_head[" + str(s) + "])") + # print((f"self.gridLayout_groupbox_interpolate_info.addWidget(sand_label[{s}], 0, {s + 1}, 1, 1)")) + eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(sand_label[{s}], {2 + len(fine_data)}, {s}, 1, 1)") + + sand_data = [stg.sand_sample_target[0][0], + str(stg.depth_sand[stg.sand_sample_target[0][1]]), + str(stg.time_sand[stg.sand_sample_target[0][1]]), + str(stg.Ctot_sand[stg.sand_sample_target[0][1]])] + + for t in range(len(sand_data)): + self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(sand_data[t]), 3 + len(fine_data), t, 1, 1) + + def plot_profile_of_concentration_fine(self): # --- Plot profile of the concentration of the fine sediments --- @@ -1191,7 +1242,7 @@ class SedimentCalibrationTab(QWidget): def import_calibration_file(self): filename = QFileDialog.getOpenFileName(self, "Open file", - [stg.path_BS_raw_data[-1] if stg.path_BS_raw_data[-1] != "" else ""][0], + # [stg.path_BS_raw_data[-1] if stg.path_BS_raw_data[-1] != "" else ""][0], "Calibration file (*.xls, *.ods, *csv)") dir_name = path.dirname(filename[0]) name = path.basename(filename[0])