Example Usage: RawDataView¶
@log(logger=logger)
def _apply_filter(self, data_filter, channel_data):
try:
filter_data_args = (channel_data,)
self.global_signal.emit('MetaFilter', data_filter, 'filter_data', filter_data_args, 'update_plot_data', ())
return self.plot_data # Assuming the plot_data is updated by the filter
except Exception as e:
self.logger.error(f"Unable to filter data with {data_filter}: {repr(e)}")
return channel_data # Return unfiltered data if the filter fails
Detailed Explanation¶
This function in a specific view, needs to edit the “selected” plugin settings.
User Interaction: The user interacts with a dropdown menu in the
RawDataControlswidget located within theRawDataView. This dropdown menu allows the user to select a PluginKey which uniquely identifies a plugin.Data Fetching: The
RawDataControlswidget reads a JSON file to fetch current plugins’ metadata, including metaclass and pluginKey (identifying which plugin the user wishes to manipulate).Signal Emission: Upon selection and info button activation within the
RawDataControls, a signal is emitted. This signal triggers the data_plugin_controller_signal withinRawDataView. The purpose of this signal is to initiate the plugin editing process via a dedicated functionedit_plugin_settings.Function Invocation: The
edit_plugin_settingsfunction is called. This function is designed to manage the editing of plugin settings effectively and is structured following abbr: MVC (Model-View-Controller) principles:Model: Handles data manipulation and business logic -> get,set,unregister,etc
View: Manages the presentation and user interaction layer -> Edit Settings
Controller: Acts as an intermediary, coordinating actions between the model and the view.
View Interaction: The editing interface for the plugin settings is handled within the abbr: DPView (DataPluginView). This approach prevents the unnecessary spread of data across components that do not require direct access to it, ensuring that each plugin’s settings are isolated and managed within a controlled environment.
Data Update and Signal Processing: Post interaction in the
DPView, methods are executed to update the plugins based on the changes made. These updates are propagated back to the system, ensuring all components that depend on these plugins are aware of the new settings.
Note
It would not be possible to use the global signal to perform this action:
Using a global signal for specific plugin settings adjustments is inefficient as it involves complex routing that doesn’t terminate at the
DPControllerbut extends to individual plugin instances.- The
data_plugin_controller_signaloffers a streamlined pathway for direct communication with theDPController, enabling: Direct Action Execution: Immediate effect on plugin settings without traversing through multiple (without this signal, single signals would have to be scaled up to the
MainController, then access theDPController) and specific signals depending on the particular instance to be affected/data retrieved.Optional Return Handling: The signal supports an optional return function, enhancing flexibility by allowing operations that do not require post-execution feedback (edit plugins does not need to trigger another action in the view, could do it, but is not necessary, it just gets the updated data.).
- The
Tip
The
data_plugin_controller_signalin theMainControllerfacilitates targeted communication between Analysis Tabs and theDataPluginController-> It optimizes plugin management by focusing on centralized interactionsUsing this dedicated signal prevents the inefficiencies of cascading requests through the system’s hierarchy— a process that would typically scaling up to Main MVC and down to the DPMVC manually-resulting in delayed actions. This method not only simplifies maintenance but also supports easier scalability