Skip to content

Commit

Permalink
working on reconstructed table. this refs #76
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Aug 17, 2023
1 parent babef90 commit 03e285e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/hyperctui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class EvaluationRegionKeys:
label_id = "id of the label naming the region"
from_index = "from file index"
to_index = "to file index"
str_from_to_value = "string form of from -> to range"


def load_ui(ui_filename, baseinstance):
Expand Down
7 changes: 7 additions & 0 deletions src/hyperctui/autonomous_reconstruction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ class ProjectionsTableColumnIndex:
meta = 3
preview = 4
status = 5


class ReconstructionTableColumnIndex:

folder_name = 0
preview = 1
status = 2
41 changes: 34 additions & 7 deletions src/hyperctui/autonomous_reconstruction/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from hyperctui.autonomous_reconstruction.help_golden_angle import HelpGoldenAngle
from hyperctui.autonomous_reconstruction.select_evaluation_regions import SelectEvaluationRegions
from hyperctui.autonomous_reconstruction.select_tof_regions import SelectTofRegions
from hyperctui.autonomous_reconstruction import ProjectionsTableColumnIndex
from hyperctui.autonomous_reconstruction import ProjectionsTableColumnIndex, ReconstructionTableColumnIndex
from hyperctui.autonomous_reconstruction.get import Get as AutonomousGet


class EventHandler:
Expand Down Expand Up @@ -344,12 +345,38 @@ def checking_state_of_widgets_post_reconstruction(self):
self.parent.ui.autonomous_reconstruction_tabWidget.setCurrentIndex(1)

# fill table with as many as TOF regions reconstruction requested
# FIXME





o_get = AutonomousGet(parent=self.parent)
nbr_tof_regions = o_get.get_nbr_tof_regions()

tof_regions_dict = self.parent.session_dict[SessionKeys.tof_regions]

o_table = TableHandler(table_ui=self.parent.ui.autonomous_reconstructions_tableWidget)
o_table.insert_empty_row(row=nbr_tof_regions)

row_index = 0
for _key in tof_regions_dict.keys():
if tof_regions_dict[_key][EvaluationRegionKeys.state]:
o_table.insert_empty_row(row=row_index)

# temporary folder name holder
o_table.insert_item(row=row_index,
column=ReconstructionTableColumnIndex.folder_name,
value=tof_regions_dict[_key][EvaluationRegionKeys.str_from_to_value])

if row_index == 0:
message = DataStatus.in_progress
background_color = IN_PROGRESS

else:
message = DataStatus.in_queue
background_color = IN_QUEUE

o_table.insert_item(row=row_index,
column=ReconstructionTableColumnIndex.status,
value=message)
o_table.set_background_color(row=row_index,
column=ReconstructionTableColumnIndex.status,
qcolor=background_color)

# checking if any reconstruction showed up
if self.is_reconstruction_done():
Expand Down
17 changes: 17 additions & 0 deletions src/hyperctui/autonomous_reconstruction/get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from hyperctui.utilities.get import Get as TopGet
from hyperctui.session import SessionKeys
from hyperctui import EvaluationRegionKeys


class Get(TopGet):

def get_nbr_tof_regions(self):
"""
returns the number of TOF selected in the autonomous reconstruction tab
"""
tof_regions_dict = self.parent.session_dict[SessionKeys.tof_regions]
nbr_tof_regions = 0
for _key in tof_regions_dict.keys():
if tof_regions_dict[_key][EvaluationRegionKeys.state]:
nbr_tof_regions +=1
return nbr_tof_regions
11 changes: 10 additions & 1 deletion src/hyperctui/autonomous_reconstruction/select_tof_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ def save_table(self):
column=ColumnIndex.to_value))
_from, _to = self.sort(_from, _to)

_str_from_value = f"{_from:06.3f}"
_from_pre, _from_post = _str_from_value.split(".")
_str_from = "{:03d}_{:d}".format(int(_from_pre), int(_from_post))
_str_to_value = f"{_to:06.3f}"
_to_pre, _to_post = _str_to_value.split(".")
_str_to = "{:03d}_{:d}".format(int(_to_pre), int(_to_post))
str_from_to_value = f"from_{_str_from}Ang_to_{_str_to}Ang"

_from_index = self.get_corresponding_index(lambda_value=_from,
lambda_array=self.lambda_array)
_to_index = self.get_corresponding_index(lambda_value=_to,
Expand All @@ -207,7 +215,8 @@ def save_table(self):
EvaluationRegionKeys.to_value: float(_to),
EvaluationRegionKeys.id: None,
EvaluationRegionKeys.from_index: _from_index,
EvaluationRegionKeys.to_index: _to_index}
EvaluationRegionKeys.to_index: _to_index,
EvaluationRegionKeys.str_from_to_value: str_from_to_value,}
self.parent.tof_regions = tof_regions

def get_corresponding_index(self, lambda_value=None, lambda_array=None):
Expand Down
4 changes: 2 additions & 2 deletions src/hyperctui/ui/main_application.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@
<item>
<widget class="QTabWidget" name="autonomous_reconstruction_tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_7">
<attribute name="title">
Expand Down Expand Up @@ -1532,7 +1532,7 @@
</layout>
</item>
<item>
<widget class="QTableWidget" name="tableWidget"/>
<widget class="QTableWidget" name="autonomous_reconstructions_tableWidget"/>
</item>
</layout>
</widget>
Expand Down
2 changes: 1 addition & 1 deletion src/hyperctui/utilities/folder_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def update(self):
self.root = homepath
ipts = self.parent.session_dict[SessionKeys.ipts_selected]
instrument = self.parent.session_dict[SessionKeys.instrument]
title = self.parent.session_dict[SessionKeys.run_title]
title = self.parent.session_dict.get(SessionKeys.run_title, "")

if (instrument is None) | (ipts is None):
return
Expand Down
7 changes: 3 additions & 4 deletions src/hyperctui/utilities/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
from collections import OrderedDict
from PIL import Image

from hyperctui.utilities.status_message_config import StatusMessageStatus, show_status_message
from hyperctui.utilities.parent import Parent

from hyperctui.utilities.status_message_config import StatusMessageStatus, show_status_message

class Get:

def __init__(self, parent=None):
self.parent = parent
class Get(Parent):

def get_log_file_name(self):
log_file_name = self.parent.config['log_file_name']
Expand Down
4 changes: 4 additions & 0 deletions src/hyperctui/utilities/parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Parent:

def __init__(self, parent=None):
self.parent = parent

0 comments on commit 03e285e

Please sign in to comment.