MDA File#
Display content of the currently selected files.
|
User: tabCloseRequested.connect (emit: index)
–> onTabCloseRequested(index –> file_path) –> tabManager.removeTab(file_path) –> tabManager.tabRemoved.emit(file_path) –> onTabRemoved(file_path –> index)
User: clearButton.clicked (emit: no data)
–> onClearAllTabsRequested() –> tabManager.removeAllTabs() –> tabManager.allTabsRemoved.emit() –> onAllTabsRemoved() –> removeAllFileTabs()
- class mdaviz.mda_file.MDAFile(*args: Any, **kwargs: Any)[source]#
- addFileTab(index, selection_field)[source]#
Handles adding or activating a file tab within the tab widget. - Retrieves data for the selected file based on its index in the MDA file list. - Updates display for metadata and table data in the visualization panel. - Determines and applies the default selection of fields if necessary. - Checks if a tab for the file already exists; if so, activates it. - If the file is new, depending on the mode (Auto-add, Auto-replace, Auto-off), it creates a new tab or replaces existing tabs with the new file tab.
Parameters: - index (int): The index of the file in the MDA file list. - selection_field (dict): Specifies the fields (positioners/detectors) for display and plotting.
- buttonPushed#
alias of
str
- createNewTab(file_name, file_path, selection_field)[source]#
Creates and activates a new tab with a MDAFileTableView for the selected file. - Initializes a new MDAFileTableView with data based on the provided file and selection field. - Adds a new tab to the tab widget. - Labels the new tab with the file’s name. - Sets the new tab as the current active tab. - Updates the file path Qlabel (named filePath) within MDAFileTableView to reflect the selected file’s path.
Parameters: - file_name (str): The name of the file, used as the tab’s label. - file_path (str): The full path to the file, used to populate the table view and label. - selection_field (dict): Specifies the data fields (positioners/detectors) for display in the table view.
- defaultSelection(first_pos, first_det, selection_field)[source]#
Sets the default field selection if no selection is provided.
- Args:
first_pos (int): The index of the first positioner. first_det (int): The index of the first detector. selection_field (dict): The current selection fields, if any.
- Returns:
dict: The updated selection field.
- displayData(tabledata)[source]#
Display pos(s) & det(s) values as a tableview in the vizualization panel.
- highlightRowInTab(file_path, row)[source]#
Switch to the tab corresponding to the given file path and highlight a specific row.
- Args:
file_path (str): _description_ row (int): _description_
- onTabRemoved(file_path)[source]#
Removes a tab from the tab widget based on its file_path. If it’s the last tab, it calls removeAllTabs() to ensure consistent cleanup.
- responder(action)[source]#
Modify the plot with the described action. action:
from buttons: add, clear, replace
- selectAndShowRow(tab_index, row)[source]#
Selects a field by its row in the file table view and ensures it is visible to the user by adjusting scroll position based on the field’s position in the list
Args: - row (int): row of the selected field.
- setData(index=None)[source]#
Populates the _data attribute with file information and data extracted from a specified file in the MDA file list at the provided index, if any. If no index is provided, _data is set to an empty dictionary.
Parameters: - index (int, optional): The index of the file in the MDA file list to read and extract data from.
Defaults to None, resulting in self._data = {}.
The populated _data dictionary includes: - fileName (str): The name of the file without its extension. - filePath (str): The full path of the file. - folderPath (str): The full path of the parent folder. - metadata (dict): The extracted metadata from the file. - scanDict (dict): A dictionary of positioner & detector information
“object”: mda object X (scanPositioner or scanDetector) “type”: “POS” (if scanPositioner) or “DET” (if scanDetector), “data”: X.data or [], “unit”: byte2str(X.unit) if X.unit else “”, “name”: byte2str(X.name) if X.name else “n/a”, “desc”: byte2str(X.desc) if X.desc else “”, “fieldName”: byte2str(X.fieldName)
firstPos (float): The first positioner (P1, or if no positioner, P0 = index).
firstDet (float): The first detector (D01).
pvList (list of str): List of detectors PV names as strings.
- tabChanged#
alias of
int
- tabPath2Index(file_path)[source]#
Finds and returns the index of a tab based on its associated file path.
- tabPath2Tableview(file_path)[source]#
Finds and returns the tableview of a tab based on its associated file path.
- updateButtonVisibility()[source]#
Check the current text in “mode” pull down and show/hide buttons accordingly
- updateCurrentTabInfo(new_tab_index)[source]#
When the current tab is changed, sends a signal to the MDA_MVC with the info corresponding to the new selected tab:
new_tab_index, new_file_path, new_tab_data, new_selection_field
- x2ValueChanged#
alias of
int
- class mdaviz.mda_file.TabManager(*args: Any, **kwargs: Any)[source]#
Manages the content of the currently opened tabs (data aspect only).
The TabManager does not handle UI elements (i.e. nothing related to tab index, such as switching tabs), maintaining a clear separation between the application’s data layer and its presentation (UI) layer.
Features: - Tracks metadata and table data for each open tab. - Allows adding and removing tabs dynamically. - Emits signals to notify other components of tab-related changes.
Signals: - tabAdded: Emitted when a new tab is added. Passes the file path of the added tab. - tabRemoved: Emitted when a tab is removed. Passes the file path of the removed tab. - allTabRemoved: Emitted when all tabs are removed. No parameters.
- addTab(file_path, metadata, tabledata)[source]#
Adds a new tab with specified metadata and table data.
- getTabData(file_path)[source]#
Returns the metatdata & data for the tab associated with the given file path.
- removeTab(file_path)[source]#
Removes the tab associated with the given file path. Emits corresponding file path & index.
- tabAdded#
alias of
str
- tabRemoved#
alias of
str