@@ -859,12 +859,9 @@ def update_reduction_table(self, table_widget: QtWidgets.QTableWidget, idx: int,
859859 direct_beam = d .configuration .direct_beam
860860 table_widget .setItem (idx , 12 , QtWidgets .QTableWidgetItem (str (direct_beam )))
861861 if d .configuration .do_final_rebin_run :
862- item = QtWidgets .QTableWidgetItem (str ( d .configuration .final_rebin_step_run ) )
862+ item = QtWidgets .QTableWidgetItem (f" { d .configuration .final_rebin_step_run :.3f } " )
863863 else :
864864 item = QtWidgets .QTableWidgetItem ("" )
865- if d .configuration .do_final_rebin_global :
866- item .setFlags (item .flags () & ~ QtCore .Qt .ItemIsEditable )
867- item .setBackground (QColors .light_grey )
868865 table_widget .setItem (idx , 13 , item )
869866
870867 self .main_window .auto_change_active = False
@@ -1350,15 +1347,6 @@ def check_region_values_changed(self):
13501347 valid_change or not configuration .direct_angle_offset_overwrite == self .ui .dangle0Overwrite .value ()
13511348 )
13521349
1353- # Final rebin
1354- valid_change = (
1355- valid_change or not configuration .do_final_rebin_global == self .ui .final_rebin_checkbox_global .isChecked ()
1356- )
1357-
1358- valid_change = (
1359- valid_change or not configuration .final_rebin_step_global == self .ui .q_rebin_spinbox_global .value ()
1360- )
1361-
13621350 valid_change = (
13631351 valid_change or not configuration .do_final_rebin_run == self .ui .final_rebin_checkbox_run .isChecked ()
13641352 )
@@ -1429,7 +1417,6 @@ def get_configuration(self) -> Configuration:
14291417 configuration .direct_pixel_overwrite = self .ui .directPixelOverwrite .value ()
14301418 configuration .direct_angle_offset_overwrite = self .ui .dangle0Overwrite .value ()
14311419 Configuration .sample_size = self .ui .sample_size_spinbox .value ()
1432- Configuration .do_final_rebin_global = self .ui .final_rebin_checkbox_global .isChecked ()
14331420 Configuration .final_rebin_step_global = self .ui .q_rebin_spinbox_global .value ()
14341421
14351422 Configuration .apply_deadtime = self .ui .deadtime_entry .applyCheckBox .isChecked ()
@@ -1537,7 +1524,6 @@ def populate_from_configuration(self, configuration=None):
15371524 self .ui .directPixelOverwrite .setValue (configuration .direct_pixel_overwrite )
15381525 self .ui .dangle0Overwrite .setValue (configuration .direct_angle_offset_overwrite )
15391526 self .ui .sample_size_spinbox .setValue (configuration .sample_size )
1540- self .ui .final_rebin_checkbox_global .setChecked (configuration .do_final_rebin_global )
15411527 self .ui .q_rebin_spinbox_global .setValue (configuration .final_rebin_step_global )
15421528
15431529 self .ui .deadtime_entry .applyCheckBox .setChecked (configuration .apply_deadtime )
@@ -1770,40 +1756,34 @@ def show_results(self):
17701756 self .main_window .update_gisans_viewer .connect (dialog .update_gisans )
17711757 dialog .show ()
17721758
1773- def toggle_final_rebin_global (self , state : int ):
1774- """Toggle global rebin checkbox .
1759+ def propagate_final_rebin_to_run_config (self ):
1760+ """Enable final rebin with the given Q-step for all runs in the active data tab .
17751761
1776- Ensure mutual exclusivity with the per-run rebin checkbox.
1762+ Note: This function updates the UI and internal configuration state while blocking all signals.
1763+ The caller is responsible for triggering recalculation and replotting.
17771764 """
1778- if state == QtCore .Qt .Checked :
1779- self .ui .final_rebin_checkbox_run .blockSignals (True )
1780- self .ui .final_rebin_checkbox_run .setChecked (False )
1781- self .ui .final_rebin_checkbox_run .blockSignals (False )
1782-
1783- # col_index = self.ui.reductionTable.get_column_index("Q-Steps")
1784- col_index = 13
1785- self .ui .reductionTable .blockSignals (True )
1786- for row in range (self .ui .reductionTable .rowCount ()):
1787- item = self .ui .reductionTable .item (row , col_index )
1788- if item is None :
1789- item = QtWidgets .QTableWidgetItem ("" )
1790- if item :
1791- if state == QtCore .Qt .Checked :
1792- _item = QtWidgets .QTableWidgetItem (item .text ())
1793- _item .setFlags (item .flags () & ~ QtCore .Qt .ItemIsEditable )
1794- _item .setBackground (QColors .light_grey )
1795- self .ui .reductionTable .setItem (row , col_index , _item )
1796- else :
1797- _item = QtWidgets .QTableWidgetItem (item .text ())
1798- _item .setFlags (item .flags () | QtCore .Qt .ItemIsEditable )
1799- _item .setBackground (QColors .white )
1800- self .ui .reductionTable .setItem (row , col_index , _item )
1801- self .ui .reductionTable .blockSignals (False )
1802-
1803- def toggle_final_rebin_run (self , state : int ):
1804- """Toggle per-run rebin checkbox.
1765+ q_step = self .ui .q_rebin_spinbox_global .value ()
18051766
1806- Ensure mutual exclusivity with the global rebin checkbox.
1807- """
1808- if state == QtCore .Qt .Checked :
1809- self .ui .final_rebin_checkbox_global .setChecked (False )
1767+ # loop over runs in the active data tab to update internal state and UI state
1768+ reduct_list = self ._data_manager .reduction_list
1769+ for idx , nexus_data in enumerate (reduct_list ):
1770+ active_cross_section_name : str = self ._data_manager .active_cross_section .name
1771+ active_cross_section = nexus_data .cross_sections [active_cross_section_name ]
1772+ # get the current configuration state
1773+ conf = active_cross_section .configuration
1774+ # update the run final rebin configuration state
1775+ conf .do_final_rebin_run = True
1776+ conf .final_rebin_step_run = q_step
1777+ nexus_data .update_configuration (conf )
1778+ # update the UI reduction table to reflect the configuration state (signals are blocked)
1779+ self .update_reduction_table (self .reduction_table , idx , active_cross_section )
1780+
1781+ # update the run final rebin spinbox value
1782+ self .ui .q_rebin_spinbox_run .blockSignals (True )
1783+ self .ui .q_rebin_spinbox_run .setValue (q_step )
1784+ self .ui .q_rebin_spinbox_run .blockSignals (False )
1785+
1786+ # update the run final rebin checkbox
1787+ self .ui .final_rebin_checkbox_run .blockSignals (True )
1788+ self .ui .final_rebin_checkbox_run .setChecked (True )
1789+ self .ui .final_rebin_checkbox_run .blockSignals (False )
0 commit comments