quicknxs.interfaces.event_handlers package
Qt Event Handlers.
Submodules
quicknxs.interfaces.event_handlers.configuration_handler module
- class quicknxs.interfaces.event_handlers.configuration_handler.ConfigurationHandler(main_window)[source]
Bases:
objectHandles events upon changes in the configuration.
Configuration state that is global to all runs is stored as class variables in the class Configuration. This class handles updating the configuration state upon changes in the UI configuration elements, as well as triggering any recalculation and replotting needed as a consequence of the changed configuration.
- config_setter_factory(qwidget: QWidget, config_name: str)[source]
Factory function to create configuration setters.
Generates anonymous functions to serve as callback when any of the global configurations (Configuration class variables) are updated in the UI.
Each callback will be associated to one configuration parameter. Upon invoked, the Configuration class variable value will be updated.
quicknxs.interfaces.event_handlers.main_handler module
Manage file-related and UI events.
- class quicknxs.interfaces.event_handlers.main_handler.MainHandler(main_window)[source]
Bases:
objectEvent handler for the main application window.
- DIRECT_BEAM_TAB_INDEX = 0
- MAIN_DATA_TAB_INDEX = 1
- active_cross_section_changed()[source]
Update UI metadata and plots after the active cross section is changed.
- add_reflectivity(silent=False)[source]
Collect information about the current extraction settings and store them in the list of reduction items.
- Returns:
True if everything is ok, false otherwise.
- Return type:
- ask_question(message: str) bool[source]
Display a popup dialog with a message and choices “Ok” and “Cancel”.
- automated_file_selection()[source]
Automatically select files in the current directory based on incident angle.
Go through the files in the current in order of run numbers, and load files until the incident angle is no longer increasing.
- check_region_values_changed()[source]
Return true if any of the parameters tied to a particular slot has changed.
Some parameters are tied to the changeRegionValues() slot. There are time-consuming actions that we only want to take if those values actually changed, as opposed to the use simply clicking outside the box.
Some parameters don’t require a recalculation but simply a refreshing of the plots. Those are parameters such as scaling factors or the number of points clipped.
- Returns:
- -1 = no valid change,
0 = replot needed, 1 = recalculation needed
- Return type:
- property direct_beam_table: QTableWidget
Returns the direct beam table widget.
- direct_beam_table_changed(item: QTableWidgetItem)[source]
Perform action upon change in direct beam list.
- get_configuration_from_ui() Configuration[source]
Gather the reduction options.
Retrieve the reduction options either from the active cross section, or from the current settings in the graphical interface.
Note that some options are global (static members of Configuration class), while others are per-cross-section (members of Configuration instance). This is because some options are applied to all cross-sections (e.g. whether to use a ROI or not), while others are specific to each cross-section (e.g. the peak position and width).
- get_reduction_table_by_index(tab_index: int) QTableWidget[source]
Return the QTableWidget for the data tab with the given index.
- initialize_additional_reduction_table(tab_index: int)[source]
Initialize new reduction table from the main reduction table.
- Parameters:
tab_index (int) – Index of the additional tab/peak
- open_file(file_path: str, force: bool = False, silent: bool = False) None[source]
Read one or more data files. If more than one, merge their data.
- Parameters:
file_path – Absolute path to data files. If more than one file, paths are joined with the plus symbol ‘+’
force – if true, the file will be reloaded even if it was loaded previously
silent – if true, the plots currently shown in the interface will NOT be updated
- open_reduced_file_dialog()[source]
Open a reduced file and all the data files needed to reproduce it.
- open_run_number(number: List[int] | List[str] | int | str | None = None)[source]
Open a data file by typing a run number or a composite run number for merging data sets.
Example
“120:123+125+127:132” opens files with run numbers from 120 to 132 except 124 and 126
- populate_from_configuration(configuration=None)[source]
Set reduction options in UI, usually after loading a reduced data set.
- propagate_binning_options_to_run_config()[source]
Enable the selected binning type with the given Q-step for all runs in the active data tab.
Note: This function updates the UI and internal configuration state while blocking all signals. The caller is responsible for triggering recalculation and replotting.
- property reduction_table: QTableWidget
Returns the active reduction table widget if one of the data tabs is active, else the first one.
- reduction_table_binning_type_changed(combobox_index: int, row: int)[source]
Perform action upon change in binning type column in the UI reduction table.
- reduction_table_cell_changed(refl: NexusData, recalculate: bool = True)[source]
Perform action upon change in UI reduction table.
Updates the internal configuration state and recalculates the reflectivity.
- reduction_table_changed(item: QTableWidgetItem)[source]
Perform action upon change in data reduction list.
- Parameters:
item (QTableWidgetItem) – The changed table item
- reduction_table_right_click(pos: QPoint, is_reduction_table: bool = True)[source]
Handle right-click on the reduction table.
- Parameters:
pos – Mouse position
is_reduction_table – True if the reduction table is active, False if the direct beam table is active
- reload_all_files()[source]
Reload all files upon change in loading configuration.
To speed up reloading, the file cache is first cleared of files that are not used in the reduction list or direct beam list.
- report_message(message: str, informative_message: str | None = None, detailed_message: str | None = None, pop_up: bool = False, is_error: bool = False)[source]
Report a message or error to the status bar at the bottom of the window.
If is_error is True, the message is also logged on the error channel.
- strip_overlap()[source]
Remove overlapping points in the reflectivity, cutting always from the lower Qz measurements.
- trim_data_to_normalization()[source]
Cut the start and end of the active data set to 5% of its maximum intensity.
- update_calculated_data()[source]
Update the calculated entries in the overview tab.
We should call this after the peak ranges change, or after a change is made that will affect the displayed results.
- update_direct_beam_table(idx: int, data: CrossSectionData) None[source]
Update a direct beam table entry with cross-section data.
- Parameters:
idx – Row to update
data – Cross-section data
- update_file_list(query_path: str | None = None) None[source]
Update the list of data files.
- Parameters:
query_path – Full path of a directory, a Nexus file, or a list of Nexus files. If a list of files, their paths are joined by the plus symbol ‘+’.
- update_reduction_table(table_widget: QTableWidget, idx: int, data: CrossSectionData)[source]
Update the reduction table.
- Parameters:
table_widget – Table widget of the table to update
idx – Row to update
data – Cross-section data
quicknxs.interfaces.event_handlers.plot_handler module
Event handlers for the main application window.
Most of those come straight from QuickNXS.
- class quicknxs.interfaces.event_handlers.plot_handler.PlotHandler(main_window)[source]
Bases:
objectClass to handle plotting events.
- change_region_values()[source]
Called when the reflectivity extraction region has been changed.
Sets up a trigger to replot the reflectivity with a delay so a subsequent change can occur without several replots.
- control_down = False
- last_event = None
- plot_mouse_event(event: MouseEvent)[source]
Show the mouse position of any plot in the main window status bar.
The single plot status indicator is only visible for larger plot toolbars.
- plot_pick_xtof(event: MouseEvent)[source]
Plot for xtof-map has been clicked.
- plot_pick_y(event: MouseEvent)[source]
Plot for y-projection has been clicked.
- refl = None
quicknxs.interfaces.event_handlers.progress_reporter module
Class used to report on progress.
It allows for sub-tasks and computes a meaningful progress status accordingly.
- class quicknxs.interfaces.event_handlers.progress_reporter.ProgressReporter(max_value: int = 100, call_back: Callable | None = None, status_bar: StatusBarHandler | None = None, progress_bar: QProgressBar | None = None)[source]
Bases:
objectProgress reporter class that allows for sub-tasks.
Initialize the progress reporter.
- create_sub_task(max_value: int) ProgressReporter[source]
Create a sub-task, with max_value being its portion of the complete task.
- Parameters:
max_value – The maximum value for the sub-task, representing its portion of the total task.
- Returns:
A new ProgressReporter instance representing the sub-task, to be called by the worker to update the progress.
- Return type:
quicknxs.interfaces.event_handlers.widgets module
Zoo for customized simple widgets.