Error message is added when user click on import/compute calibration without acoustic data #37

dev-brahim
brahim 2025-03-14 11:52:27 +01:00
parent 22be597d75
commit 22cd451b24
1 changed files with 61 additions and 43 deletions

View File

@ -1716,32 +1716,47 @@ class SedimentCalibrationTab(QWidget):
self.animaiton_groupbox_compute.start() self.animaiton_groupbox_compute.start()
def import_calibration_file(self): def import_calibration_file(self):
filename = QFileDialog.getOpenFileName(
self, "Open calibration",
[
stg.path_calibration_file
if stg.path_calibration_file
else stg.path_BS_raw_data[-1]
if self.combobox_acoustic_data_choice.count() > 0
else ""
][0],
"Calibration file (*.xls, *.ods, *csv)",
options=QFileDialog.DontUseNativeDialog
)
dir_name = os.path.dirname(filename[0]) if self.combobox_acoustic_data_choice.count() == 0:
name = os.path.basename(filename[0]) msgBox = QMessageBox()
msgBox.setWindowTitle("Calibration import error")
msgBox.setIconPixmap(
QPixmap(
self._path_icon("no_approved.png")
).scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText("Update data before importing calibration")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
stg.path_calibration_file = dir_name else:
stg.filename_calibration_file = name
self.lineEdit_import_calibration.clear() filename = QFileDialog.getOpenFileName(
self.lineEdit_import_calibration.setText(name) self, "Open calibration",
[
stg.path_calibration_file
if stg.path_calibration_file
else stg.path_BS_raw_data[-1]
if self.combobox_acoustic_data_choice.count() > 0
else ""
][0],
"Calibration file (*.xls, *.ods, *csv)",
options=QFileDialog.DontUseNativeDialog
)
self.lineEdit_import_calibration.setToolTip(dir_name) dir_name = os.path.dirname(filename[0])
name = os.path.basename(filename[0])
self.compute_depth_2D() stg.path_calibration_file = dir_name
self.read_calibration_file_and_fill_parameter() stg.filename_calibration_file = name
self.lineEdit_import_calibration.clear()
self.lineEdit_import_calibration.setText(name)
self.lineEdit_import_calibration.setToolTip(dir_name)
self.compute_depth_2D()
self.read_calibration_file_and_fill_parameter()
def update_label_freq1_for_calibration(self): def update_label_freq1_for_calibration(self):
self.label_freq1.clear() self.label_freq1.clear()
@ -1784,19 +1799,8 @@ class SedimentCalibrationTab(QWidget):
) )
def read_calibration_file_and_fill_parameter(self): def read_calibration_file_and_fill_parameter(self):
if self.combobox_acoustic_data_choice.count() == 0:
msgBox = QMessageBox()
msgBox.setWindowTitle("Calibration import error")
msgBox.setIconPixmap(
QPixmap(
self._path_icon("no_approved.png")
).scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText("Update data before importing calibration")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
elif stg.filename_calibration_file == "": if stg.filename_calibration_file == "":
pass pass
@ -1996,17 +2000,31 @@ class SedimentCalibrationTab(QWidget):
def function_pushbutton_compute_calibration(self): def function_pushbutton_compute_calibration(self):
self.label_temperature.clear() if self.combobox_acoustic_data_choice.count() == 0:
self.label_temperature.setText("T = " + str(stg.temperature) + " °C") msgBox = QMessageBox()
msgBox.setWindowTitle("Calibration computation error")
msgBox.setIconPixmap(
QPixmap(
self._path_icon("no_approved.png")
).scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText("Update data before importing calibration")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
self.compute_depth_2D() else:
self.compute_ks()
self.compute_sv() self.label_temperature.clear()
self.compute_X() self.label_temperature.setText("T = " + str(stg.temperature) + " °C")
self.compute_kt2D_kt3D()
self.compute_J_cross_section() self.compute_depth_2D()
self.compute_alpha_s() self.compute_ks()
self.compute_zeta() self.compute_sv()
self.compute_X()
self.compute_kt2D_kt3D()
self.compute_J_cross_section()
self.compute_alpha_s()
self.compute_zeta()
def compute_ks(self): def compute_ks(self):
data_id = self.combobox_acoustic_data_choice.currentIndex() data_id = self.combobox_acoustic_data_choice.currentIndex()