refactor(MainWindow.py): rename 'completed' variable to 'completed_tasks' and 'comboBoxes' to 'combo_boxes' for better semantics
feat(MainWindow.py): add 'has_changed' and 'old_discretisation_value' variables to track changes in the discretisation value selector and avoid unnecessary computations fix(MainWindow.py): set status message when rendering graphs to inform the user of the process
This commit is contained in:
parent
18eaf6a016
commit
2ef063f4b3
@ -50,10 +50,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.raw_data= None
|
self.raw_data= None
|
||||||
self.discrete_data = None
|
self.discrete_data = None
|
||||||
|
|
||||||
self.completed = 0
|
self.completed_tasks = 0
|
||||||
self.total = 2
|
self.total_tasks = 2
|
||||||
|
|
||||||
self.comboBoxes = [
|
self.combo_boxes = [
|
||||||
self.slot0ComboBox,
|
self.slot0ComboBox,
|
||||||
self.slot1ComboBox,
|
self.slot1ComboBox,
|
||||||
self.slot2ComboBox,
|
self.slot2ComboBox,
|
||||||
@ -67,8 +67,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.slot10ComboBox
|
self.slot10ComboBox
|
||||||
]
|
]
|
||||||
|
|
||||||
for cb in self.comboBoxes:
|
for combo_box in self.combo_boxes:
|
||||||
cb.addItems(self.graphType)
|
combo_box.addItems(self.graphType)
|
||||||
|
|
||||||
self.slots = [
|
self.slots = [
|
||||||
[self.slot0,"Aucun"],
|
[self.slot0,"Aucun"],
|
||||||
@ -86,11 +86,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
for slot_nb,slot in enumerate(self.slots):
|
for slot_nb,slot in enumerate(self.slots):
|
||||||
slot[1] = SettingManager.get_instance().get_last_graph(slot_nb)
|
slot[1] = SettingManager.get_instance().get_last_graph(slot_nb)
|
||||||
self.comboBoxes[slot_nb].setCurrentText(slot[1])
|
self.combo_boxes[slot_nb].setCurrentText(slot[1])
|
||||||
|
|
||||||
self.settings_window = Settings()
|
self.settings_window = Settings()
|
||||||
|
|
||||||
self.threads = []
|
self.has_changed = True
|
||||||
|
self.old_discretisation_value = None
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# #
|
# #
|
||||||
@ -108,12 +109,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.output_file_prefix.setText(os.path.splitext(os.path.basename(file))[0])
|
self.output_file_prefix.setText(os.path.splitext(os.path.basename(file))[0])
|
||||||
if self.output_folder_path.toPlainText() is None or self.output_folder_path.toPlainText() == "":
|
if self.output_folder_path.toPlainText() is None or self.output_folder_path.toPlainText() == "":
|
||||||
self.output_folder_path.setPlainText(os.path.dirname(file))
|
self.output_folder_path.setPlainText(os.path.dirname(file))
|
||||||
|
self.has_changed = True
|
||||||
|
|
||||||
def select_folder(self):
|
def select_folder(self):
|
||||||
"""
|
"""
|
||||||
Open a file dialog to select the output folder
|
Open a file dialog to select the output folder
|
||||||
"""
|
"""
|
||||||
self.output_folder_path.setPlainText(QFileDialog.getExistingDirectory())
|
self.output_folder_path.setPlainText(QFileDialog.getExistingDirectory())
|
||||||
|
self.has_changed = True
|
||||||
|
|
||||||
def check_input_file(self):
|
def check_input_file(self):
|
||||||
"""
|
"""
|
||||||
@ -152,11 +155,18 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
settings = SettingManager.get_instance()
|
settings = SettingManager.get_instance()
|
||||||
for count,_ in enumerate(self.slots):
|
for count,_ in enumerate(self.slots):
|
||||||
self.slots[count][1] = self.comboBoxes[count].currentText()
|
self.slots[count][1] = self.combo_boxes[count].currentText()
|
||||||
settings.set_last_graph(count,self.slots[count][1])
|
settings.set_last_graph(count,self.slots[count][1])
|
||||||
|
|
||||||
self.clear_graphs()
|
self.clear_graphs()
|
||||||
self.completed = 0
|
self.completed_tasks = 0
|
||||||
|
if not self.has_changed and self.old_discretisation_value == self.discretisation_value_selector.value():
|
||||||
|
self.completed_tasks = self.total_tasks -1
|
||||||
|
self.finish_analyse()
|
||||||
|
return
|
||||||
|
self.has_changed = False
|
||||||
|
self.old_discretisation_value = self.discretisation_value_selector.value()
|
||||||
|
|
||||||
# Create the thread to run the analyse
|
# Create the thread to run the analyse
|
||||||
self.preprocess_thread = QThread()
|
self.preprocess_thread = QThread()
|
||||||
self.preprocess_worker = PreProcessWorker("PreProcessWorker",self.input_file_path.toPlainText())
|
self.preprocess_worker = PreProcessWorker("PreProcessWorker",self.input_file_path.toPlainText())
|
||||||
@ -290,8 +300,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
:param raw_data: The raw data
|
:param raw_data: The raw data
|
||||||
:param discrete_data: The discrete data
|
:param discrete_data: The discrete data
|
||||||
"""
|
"""
|
||||||
|
# Clear the graphs
|
||||||
if not self.show_graph_checkbox.isChecked():
|
if not self.show_graph_checkbox.isChecked():
|
||||||
return
|
return
|
||||||
|
self.set_status("Rendering graphs... this may take a moment")
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
current_slot = slot[0]
|
current_slot = slot[0]
|
||||||
graph_type = slot[1]
|
graph_type = slot[1]
|
||||||
@ -317,6 +329,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
"Z (en mm)",
|
"Z (en mm)",
|
||||||
"Rayon moyen (en mm)\n",
|
"Rayon moyen (en mm)\n",
|
||||||
False).native)
|
False).native)
|
||||||
|
self.set_status("Graphs rendered!")
|
||||||
|
|
||||||
def clear_graphs(self):
|
def clear_graphs(self):
|
||||||
"""
|
"""
|
||||||
@ -341,8 +354,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
Finish the analyse
|
Finish the analyse
|
||||||
"""
|
"""
|
||||||
self.completed += 1
|
self.completed_tasks += 1
|
||||||
if self.completed == self.total:
|
if self.completed_tasks == self.total_tasks:
|
||||||
self.status_text.setText("Done")
|
self.status_text.setText("Done")
|
||||||
self.analyse_progress_bar.setValue(100)
|
self.analyse_progress_bar.setValue(100)
|
||||||
self.renderGraphs(self.obj,self.raw_data,self.discrete_data)
|
self.renderGraphs(self.obj,self.raw_data,self.discrete_data)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user