quicknxs.interfaces.event_handlers package
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]
Generate 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.
- Parameters:
qwidget (QWidget) – UI widget
config_name (str) – Name of the Configuration variable to update
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
- add_direct_beam(silent=False)[source]
Add / remove dataset to the available normalizations or clear the normalization list.
- 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.
- ask_question(message)[source]
Display a popup dialog with a message and choices “Ok” and “Cancel” :param str message: question to ask :returns: bool
- automated_file_selection()[source]
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.
- Return values:
- -1 = no valid change
0 = replot needed 1 = recalculation needed
- get_configuration() Configuration[source]
@brief Gather the reduction options. @details Retrieve the reduction options either from the active channel or from the current settings in the graphical interface.
- 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 | None = False, silent: bool | None = False) None[source]
@brief Read one or more data files. If more than one, merge their data. @param file_path: absolute path to data files. If more than one file, paths are joined with the plus symbol ‘+’ @param force: if true, the file will be reloaded even if it was loaded previously @param 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=None)[source]
@brief Open a data file by typing a run number or a composite run number for merging data sets @details 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.
- property reduction_table
Returns the active reduction table widget if one of the data tabs is active, else the first one
- Return type:
QTableWidget
- reduction_table_right_click(pos, is_reduction_table=True)[source]
Handle right-click on the reduction table. :param QPoint pos: mouse position :param bool 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, informative_message=None, detailed_message=None, pop_up=False, is_error=False)[source]
Report a message or error to the status bar at the bottom of the window. :param str message: message string to be reported :param str informative_message: extra information :param str detailed_message: detailed message for the log :param bool pop_up: if True, a dialog will pop up :param bool is_error: if True, the message is logged on the error channel
- save_run_data(nexus_data: NexusData)[source]
Save run data to file :param NexusData nexus_data: run data object
- strip_overlap()[source]
Remove overlapping points in the reflectivity, cutting always from the lower Qz measurements.
- toggle_final_rebin_global(state)[source]
When the global rebin checkbox is toggled, update the run rebin checkbox so that only one of them can be checked at a time.
- toggle_final_rebin_run(state)[source]
When the run rebin checkbox is toggled, update the global rebin checkbox so that only one of them can be checked at a time.
- 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, d)[source]
Update a direct beam table entry :param int idx: row index :param CrossSectionData d: data object
- update_file_list(query_path: str | None = None) None[source]
@brief Update the list of data files @param 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, d: CrossSectionData)[source]
Update the reduction table
- Parameters:
table_widget (QtWidgets.QTableWidget) – Table widget of the table to update
idx (int) – Row to update
d (CrossSectionData) – 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)[source]
Show the mouse position of any plot in the main window status bar, as the single plot status indicator is only visible for larger plot toolbars. :param event: event object
- plot_pick_xy(event)[source]
Plot for xy-map has been clicked. :param self QMainWindow: main window object :param event: event object
- plot_pick_y(event)[source]
Plot for y-projection has been clicked. :param self QMainWindow: main window object :param event: event object
- 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=100, call_back=None, status_bar=None, progress_bar=None)[source]
Bases:
objectProgress reporter class that allows for sub-tasks.
- create_sub_task(max_value)[source]
Create a sub-task, with max_value being its portion of the complete task. Returns a call-back function to be called by the worker to update the progress.
- Parameters:
max_value (int) – portion of the task
quicknxs.interfaces.event_handlers.widgets module
Zoo for customized simple widgets