diff --git a/Model/granulo_loader.py b/Model/granulo_loader.py index b7ea7e0..828cb90 100644 --- a/Model/granulo_loader.py +++ b/Model/granulo_loader.py @@ -38,9 +38,9 @@ class GranuloLoader: self._Ctot_sand_per_cent = 100 * self._Ctot_sand / (self._Ctot_fine + self._Ctot_sand) -if __name__ == "__main__": - GranuloLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" - "fine_sample_file.ods", - "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" - "sand_sample_file.ods") +# if __name__ == "__main__": +# GranuloLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" +# "fine_sample_file.ods", +# "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" +# "sand_sample_file.ods") diff --git a/View/sample_data_tab.py b/View/sample_data_tab.py index 3bab249..1bb1f44 100644 --- a/View/sample_data_tab.py +++ b/View/sample_data_tab.py @@ -26,7 +26,7 @@ _translate = QCoreApplication.translate class SampleDataTab(QWidget): - # clicked_signal = pyqtSignal(str) + clickedState = pyqtSignal(bool) def __init__(self, widget_tab): super().__init__() @@ -56,6 +56,12 @@ class SampleDataTab(QWidget): self.verticalLayout_sampleposition_displayoption = QVBoxLayout() self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_sampleposition_displayoption, 3) + self.groupbox_plot_sample_position = QGroupBox() + self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_plot_sample_position, 5) + + self.groupbox_display_option = QGroupBox() + self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_display_option, 5) + path_icon = "./icons/" icon_folder = QIcon(path_icon + "folder.png") @@ -160,7 +166,6 @@ class SampleDataTab(QWidget): # +++ --- GroupBox plot sample position --- +++ # +++++++++++++++++++++++++++++++++++++++++++++ - self.groupbox_plot_sample_position = QGroupBox() self.verticalLayout_groupbox_plot_sample_position = QVBoxLayout(self.groupbox_plot_sample_position) self.canvas_transect_sample_position = None @@ -173,13 +178,10 @@ class SampleDataTab(QWidget): # self.empty_field_for_transect_plot() # self.verticalLayout_groupbox_plot_sample_position.addWidget(self.canvas_sample_position) - self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_plot_sample_position, 5) - # +++++++++++++++++++++++++++++++++++++++ # +++ --- GroupBox display option --- +++ # +++++++++++++++++++++++++++++++++++++++ - self.groupbox_display_option = QGroupBox() self.verticalLayout_groupbox_display_option = QVBoxLayout(self.groupbox_display_option) # self.pushbutton_plot_transect = QPushButton() @@ -215,16 +217,24 @@ class SampleDataTab(QWidget): # self.combobox_y_axis.currentTextChanged.connect(self.empty_field_for_total_concentration_plot) self.combobox_y_axis.currentTextChanged.connect(self.update_plot_total_concentration) + # --- Group box PSD plot --- self.groupbox_option_PSD_plot = QGroupBox() self.groupbox_option_PSD_plot.setTitle("Particle Size Distribution plot") self.horizontalLayout_Ctot_PSD_plot.addWidget(self.groupbox_option_PSD_plot) - self.horizontalLayout_groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) - self.pushbutton_class_PSD = QPushButton() - self.pushbutton_class_PSD.setText("Class PSD") - self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_class_PSD) + self.verticalLayout__groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) + self.combobox_PSD_plot = QComboBox() + self.combobox_PSD_plot.addItems(["Class PSD", "Cumulative PSD"]) + self.verticalLayout__groupbox_option_PSD_plot.addWidget(self.combobox_PSD_plot) - self.pushbutton_class_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_class) + self.combobox_PSD_plot.currentTextChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) + + # self.horizontalLayout_groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) + # self.pushbutton_class_PSD = QPushButton() + # self.pushbutton_class_PSD.setText("Class PSD") + # self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_class_PSD) + + # self.pushbutton_class_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_class) # self.pushbutton_class_PSD.clicked_signal[str].connect(self.on_clicked) @@ -233,11 +243,11 @@ class SampleDataTab(QWidget): # else: # self.pushbutton_class_PSD.clicked.connect(self.update_plot_fine_sediment_PSD_class_cumul) - self.pushbutton_cumulative_PSD = QPushButton() - self.pushbutton_cumulative_PSD.setText("Cumulative PSD") - self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_cumulative_PSD) + # self.pushbutton_cumulative_PSD = QPushButton() + # self.pushbutton_cumulative_PSD.setText("Cumulative PSD") + # self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_cumulative_PSD) - self.pushbutton_cumulative_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_cumul) + # self.pushbutton_cumulative_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_cumul) # if self.tableWidget_sample.columnCount() == 10: # self.pushbutton_cumulative_PSD.clicked.connect(self.empty_field_to_plot_fine_sediment_distribution) @@ -259,8 +269,6 @@ class SampleDataTab(QWidget): # self.combobox_calibration_sample_vertical_profile.addItems(["S1, S2, S3", "S4, S5, S6, S7", "S8, S9, S10, S11"]) # self.horizontalLayout_calibration_sample_vertical_profile.addWidget( # self.combobox_calibration_sample_vertical_profile) - # - self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_display_option, 5) # -------------------------------------------------------------------------------------------------------------- ### --- Layout of groupbox in the Bottom horizontal layout box @@ -389,7 +397,7 @@ class SampleDataTab(QWidget): eval(f"self.comboBox_sample_table{i}.currentTextChanged." f"connect(self.update_plot_total_concentration)") eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_fine_and_sand_sediments_PSD_class)") + f"connect(self.update_plot_PSD_fine_and_sand_sediments)") # --- Fill Sample column with checkbox --- for i in range(self.tableWidget_sample.rowCount()): @@ -421,7 +429,7 @@ class SampleDataTab(QWidget): self.tableWidget_sample.itemChanged.connect( self.extract_position_list_and_color_list_from_table_checkboxes) self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) - self.tableWidget_sample.itemChanged.connect(self.update_plot_fine_and_sand_sediments_PSD_class) + self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) else: # print("PLease download first file") @@ -802,7 +810,13 @@ class SampleDataTab(QWidget): # # self.canvas_plot_PSD.draw() - def update_plot_fine_and_sand_sediments_PSD_class(self): + # def mouseClickEvent(self, event): + # super().mousePressEvent(event) + # if event.button() == Qt.LeftButton: + # self.pressedState.emit(True) + # print(self.pressedState.emit(True)) + + def update_plot_PSD_fine_and_sand_sediments(self): if self.tableWidget_sample.columnCount() > 15: # --- Read sample data --- @@ -833,20 +847,39 @@ class SampleDataTab(QWidget): self.axis_plot_PSD[0].cla() self.axis_plot_PSD[1].cla() - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(granulo_data._r_grain, - granulo_data._frac_vol_fine[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + if self.combobox_PSD_plot.currentIndex() == 0: - self.axis_plot_PSD[1].plot(granulo_data._r_grain, - granulo_data._frac_vol_sand[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + for profil_position_num, color_plot in zip(position_list, color_list): + self.axis_plot_PSD[0].plot(granulo_data._r_grain, + granulo_data._frac_vol_fine[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + + self.axis_plot_PSD[1].plot(granulo_data._r_grain, + granulo_data._frac_vol_sand[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + + elif self.combobox_PSD_plot.currentIndex() == 1: + + for profil_position_num, color_plot in zip(position_list, color_list): + self.axis_plot_PSD[0].plot(granulo_data._r_grain, + granulo_data._frac_vol_fine_cumul[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + + self.axis_plot_PSD[1].plot(granulo_data._r_grain, + granulo_data._frac_vol_sand_cumul[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') self.canvas_plot_PSD.draw() @@ -858,61 +891,61 @@ class SampleDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - def update_plot_fine_and_sand_sediments_PSD_cumul(self): - if self.tableWidget_sample.columnCount() > 15: - - # --- Read sample data --- - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - - # --- Read selected samples (checkboxes) --- - position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() - - if position_list == []: - - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Select sample(s) before changing axis") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - # --- Create canvas of Matplotlib figure --- - if self.canvas_plot_PSD == None: - self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") - self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) - self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) - else: - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(granulo_data._r_grain, - granulo_data._frac_vol_fine_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') - - self.axis_plot_PSD[1].plot(granulo_data._r_grain, - granulo_data._frac_vol_sand_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') - - self.canvas_plot_PSD.draw() - - else: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot PSD Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Fill table and select sample(s) before plotting PSD") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() + # def update_plot_fine_and_sand_sediments_PSD_cumul(self): + # if self.tableWidget_sample.columnCount() > 15: + # + # # --- Read sample data --- + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # + # # --- Read selected samples (checkboxes) --- + # position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() + # + # if position_list == []: + # + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Axis choice Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Select sample(s) before changing axis") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # else: + # + # # --- Create canvas of Matplotlib figure --- + # if self.canvas_plot_PSD == None: + # self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") + # self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) + # self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) + # else: + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[1].cla() + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, + # granulo_data._frac_vol_fine_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + # + # self.axis_plot_PSD[1].plot(granulo_data._r_grain, + # granulo_data._frac_vol_sand_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + # + # self.canvas_plot_PSD.draw() + # + # else: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot PSD Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Fill table and select sample(s) before plotting PSD") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() # def update_plot_fine_PSD_class(self, profil_position, color_list): # granulo_data = deepcopy(