Skip to content

Commit

Permalink
ob moved when found. this refs #84
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Aug 16, 2024
1 parent abcb187 commit 72b265e
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/hyperctui/hyperctui.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def inform_of_output_location(self):
"autoreduce",
"mcp",
])
ob_output_location = os.path.join(HOME_FOLDER, output_location)
ob_output_location = os.path.join(HOME_FOLDER, ob_output_location)

final_ob_output_location = os.sep.join([facility,
instrument,
Expand Down
11 changes: 8 additions & 3 deletions src/hyperctui/pre_processing_monitor/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,25 @@ def move_obs_to_final_folder(self):
same time to make sure we are now pointing to the final location.
"""
logging.info(f"Moving obs to final folder!")
list_ob_folders = self.grand_parent.session_dict[SessionKeys.list_ob_folders_initially_there]
o_table = TableHandler(table_ui=self.parent.ui.obs_tableWidget)
list_obs_folders = o_table.get_elements_from_column()
# list_ob_folders = self.grand_parent.session_dict[SessionKeys.list_ob_folders_initially_there]

final_location = self.grand_parent.ui.final_location_of_ob_created.text()

make_folder(final_location)
move_list_files_to_folder(list_of_files=list_ob_folders,
move_list_files_to_folder(list_of_files=list_obs_folders,
folder=final_location)

logging.info(f"Updating table with new location of obs!")
o_table = TableHandler(table_ui=self.parent.ui.obs_tableWidget)
new_list_ob_folders = []
for _row, _folder in enumerate(list_ob_folders):
for _row, _folder in enumerate(list_obs_folders):
_new_final_location = os.path.join(final_location, os.path.basename(_folder))
new_list_ob_folders.append(_new_final_location)
o_table.set_item_with_str(row=_row,
column=0,
value=_new_final_location)
self.grand_parent.session_dict[SessionKeys.list_ob_folders_initially_there] = new_list_ob_folders
# self.grand_parent.session_dict[SessionKeys.list_ob_folders_requested]
self.parent.all_obs_moved = True
37 changes: 20 additions & 17 deletions src/hyperctui/pre_processing_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Monitor(QMainWindow):
dict_projections_log_err_metadata = None

all_obs_found = False
all_obs_moved = False
all_projections_found = False

def __init__(self, parent=None):
Expand Down Expand Up @@ -84,23 +85,25 @@ def refresh_button_clicked(self):

if self.all_obs_found:

logging.info(f"-> all obs found!")

#FIXME for now, hide those buttons
self.ui.monitor_moving_obs_label.setVisible(False)
self.ui.final_ob_folder_label.setVisible(False)
self.ui.final_ob_folder_status.setVisible(False)

o_event.checking_status_of_expected_projections()
if self.all_projections_found:

logging.info(f"-> all projections found!")
if not self.parent.session_dict[SessionKeys.all_tabs_visible]:
self.parent.session_dict[SessionKeys.all_tabs_visible] = True
o_widgets = UtilityWidgets(parent=self.parent)
o_widgets.make_tabs_visible(is_visible=True)
self.parent.initialize_crop()
self.parent.initialize_center_of_rotation()
if not self.all_obs_moved:
logging.info(f"-> all obs found!")
o_event.move_obs_to_final_folder()

#FIXME for now, hide those buttons
self.ui.monitor_moving_obs_label.setVisible(False)
self.ui.final_ob_folder_label.setVisible(False)
self.ui.final_ob_folder_status.setVisible(False)

o_event.checking_status_of_expected_projections()
if self.all_projections_found:

logging.info(f"-> all projections found!")
if not self.parent.session_dict[SessionKeys.all_tabs_visible]:
self.parent.session_dict[SessionKeys.all_tabs_visible] = True
o_widgets = UtilityWidgets(parent=self.parent)
o_widgets.make_tabs_visible(is_visible=True)
self.parent.initialize_crop()
self.parent.initialize_center_of_rotation()

def closeEvent(self, c):
self.parent.monitor_ui = None
Expand Down
116 changes: 63 additions & 53 deletions src/hyperctui/utilities/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,59 +51,6 @@ def full_reset(self):
self.remove_all_rows()
self.remove_all_columns()

def get_rows_of_table_selected(self):
if self.table_ui is None:
return None

selected_ranges = self.table_ui.selectedRanges()
if selected_ranges == []:
return None

list_row_selected = []
for _selection in selected_ranges:
top_row = _selection.topRow()
bottom_row = _selection.bottomRow()
if top_row == bottom_row:
list_row_selected.append(top_row)
else:
_range = np.arange(top_row, bottom_row + 1)
for _row in _range:
list_row_selected.append(_row)

return list_row_selected

def get_row_selected(self):
if self.table_ui is None:
return -1
list_selection = self.table_ui.selectedRanges()
try:
first_selection = list_selection[0]
except IndexError:
return -1
return first_selection.topRow()

def get_cell_selected(self):
list_selection = self.table_ui.selectedRanges()
first_selection = list_selection[0]
row = first_selection.topRow()
col = first_selection.leftColumn()
return (row, col)

def get_item_str_from_cell(self, row=-1, column=-1):
item_selected = self.table_ui.item(row, column).text()
return str(item_selected)

def get_widget(self, row=-1, column=-1):
_widget = self.table_ui.cellWidget(row, column)
return _widget

def get_inner_widget(self, row=-1, column=-1, position_index=0):
"""
when the widget is inside another widget
"""
_widget = self.get_widget(row=row, column=column)
return _widget.children()[position_index]

def select_cell(self, row=0, column=0):
self.select_everything(False)
range_selected = QtGui.QTableWidgetSelectionRange(row, column, row, column)
Expand Down Expand Up @@ -211,3 +158,66 @@ def block_signals(self):

def unblock_signals(self):
self.table_ui.blockSignals(False)

## GETTER

def get_rows_of_table_selected(self):
if self.table_ui is None:
return None

selected_ranges = self.table_ui.selectedRanges()
if selected_ranges == []:
return None

list_row_selected = []
for _selection in selected_ranges:
top_row = _selection.topRow()
bottom_row = _selection.bottomRow()
if top_row == bottom_row:
list_row_selected.append(top_row)
else:
_range = np.arange(top_row, bottom_row + 1)
for _row in _range:
list_row_selected.append(_row)

return list_row_selected

def get_row_selected(self):
if self.table_ui is None:
return -1
list_selection = self.table_ui.selectedRanges()
try:
first_selection = list_selection[0]
except IndexError:
return -1
return first_selection.topRow()

def get_cell_selected(self):
list_selection = self.table_ui.selectedRanges()
first_selection = list_selection[0]
row = first_selection.topRow()
col = first_selection.leftColumn()
return (row, col)

def get_item_str_from_cell(self, row=-1, column=-1):
item_selected = self.table_ui.item(row, column).text()
return str(item_selected)

def get_widget(self, row=-1, column=-1):
_widget = self.table_ui.cellWidget(row, column)
return _widget

def get_inner_widget(self, row=-1, column=-1, position_index=0):
"""
when the widget is inside another widget
"""
_widget = self.get_widget(row=row, column=column)
return _widget.children()[position_index]

def get_elements_from_column(self, column=0):
list_element = []
row_count = self.row_count()
for _row in np.arange(row_count):
list_element.append(self.get_item_str_from_cell(row=_row,
column=column))
return list_element

0 comments on commit 72b265e

Please sign in to comment.