def __init__(self, ws, plot=None, parent=None, model=None, view=None, ads_observer=None, container=None, window_width=600, window_height=400): """ Creates a display for the provided workspace. :param ws: Workspace to be displayed :param plot: Plotting function that will be used to plot workspaces. Passed in as parameter to allow mocking :param parent: Parent of the widget :param model: Model to be used by the widget. Passed in as parameter to allow mocking :param view: View to be used by the widget. Passed in as parameter to allow mocking :param ads_observer: ADS observer to be used by the presenter. If not provided the default one is used. Mainly intended for testing. """ # Create model and view, or accept mocked versions self.model = model if model else MatrixWorkspaceDisplayModel(ws) self.view = view if view else MatrixWorkspaceDisplayView(self, parent) self.container = container if container else StatusBarView(parent, self.view, self.model.get_name(), window_width=window_width, window_height=window_height, presenter=self) super(MatrixWorkspaceDisplay, self).__init__(self.container.status_bar) self.plot = plot self.ads_observer = ads_observer if ads_observer else WorkspaceDisplayADSObserver(self) self.setup_tables() self.view.set_context_menu_actions(self.view.table_y) self.view.set_context_menu_actions(self.view.table_x) self.view.set_context_menu_actions(self.view.table_e)
def __init__(self, ws, plot=None, parent=None, window_flags=Qt.Window, model=None, view=None, ads_observer=None, container=None, window_width=600, window_height=400): """ Creates a display for the provided workspace. :param ws: Workspace to be displayed :param plot: Plotting function that will be used to plot workspaces. Passed in as parameter to allow mocking :param parent: Parent of the widget :param model: Model to be used by the widget. Passed in as parameter to allow mocking :param view: View to be used by the widget. Passed in as parameter to allow mocking :param ads_observer: ADS observer to be used by the presenter. If not provided the default one is used. Mainly intended for testing. """ self.hasDx = any( [ws.hasDx(i) for i in range(ws.getNumberHistograms())]) # Create model and view, or accept mocked versions self.model = model if model else MatrixWorkspaceDisplayModel(ws) self.view = view if view else MatrixWorkspaceDisplayView( self, parent, window_flags) self.container = container if container else StatusBarView( parent, self.view, self.model.get_name(), window_width=window_width, window_height=window_height, presenter=self, window_flags=window_flags) super(MatrixWorkspaceDisplay, self).__init__(self.container.status_bar) self.plot = plot self.ads_observer = ads_observer if ads_observer else WorkspaceDisplayADSObserver( self) self.setup_tables() self.view.set_context_menu_actions(self.view.table_y) self.view.set_context_menu_actions(self.view.table_x) self.view.set_context_menu_actions(self.view.table_e) if self.hasDx: self.view.set_context_menu_actions(self.view.table_dx) # connect to replace_signal signal to handle replacement of the workspace self.container.replace_signal.connect(self.action_replace_workspace) self.container.rename_signal.connect(self.action_rename_workspace)
def __init__( self, ws, parent=None, window_flags=Qt.Window, plot=None, model=None, view=None, name=None, ads_observer=None, container=None, window_width=600, window_height=400, batch=False, ): """ Creates a display for the provided workspace. :param ws: Workspace to be displayed :param parent: Parent of the widget :param window_flags: An optional set of window flags :param plot: Plotting function that will be used to plot workspaces. This requires Matplotlib directly. Passed in as parameter to allow mocking :param model: Model to be used by the widget. Passed in as parameter to allow mocking :param view: View to be used by the widget. Passed in as parameter to allow mocking :param name: Custom name for the window :param ads_observer: ADS observer to be used by the presenter. If not provided the default one is used. Mainly intended for testing. """ view, model = self.create_table(ws, parent, window_flags, model, view, batch) self.view = view self.model = model self.name = name if name else model.get_name() self.container = (container if container else StatusBarView( parent, view, self.name, window_width=window_width, window_height=window_height, window_flags=window_flags, presenter=self, )) DataCopier.__init__(self, self.container.status_bar) self.parent = parent self.plot = plot self.ads_observer = (ads_observer if ads_observer else WorkspaceDisplayADSObserver(self)) self.presenter.refresh()
def __init__(self, ws, plot=None, parent=None, model=None, view=None, name=None, ads_observer=None, container=None, window_width=600, window_height=400): """ Creates a display for the provided workspace. :param ws: Workspace to be displayed :param parent: Parent of the widget :param plot: Plotting function that will be used to plot workspaces. This requires Matplotlib directly. Passed in as parameter to allow mocking :param model: Model to be used by the widget. Passed in as parameter to allow mocking :param view: View to be used by the widget. Passed in as parameter to allow mocking :param name: Custom name for the window :param ads_observer: ADS observer to be used by the presenter. If not provided the default one is used. Mainly intended for testing. """ model = model if model is not None else TableWorkspaceDisplayModel(ws) view = view if view else TableWorkspaceDisplayView(self, parent) TableWorkspaceDataPresenter.__init__(self, model, view) self.name = name if name else self.model.get_name() self.container = container if container else StatusBarView( parent, self.view, self.name, window_width=window_width, window_height=window_height, presenter=self) DataCopier.__init__(self, self.container.status_bar) self.parent = parent self.plot = plot self.view.set_context_menu_actions(self.view) self.ads_observer = ads_observer if ads_observer else WorkspaceDisplayADSObserver( self) self.refresh() # connect to cellChanged signal after the data has been loaded self.view.itemChanged.connect(self.handleItemChanged)