def getSliceViewer(source, label=""): """Retrieves a handle to a previously-open SliceViewerWindow. This allows you to get a handle on, e.g., a SliceViewer that was open by the MultiSlice view in VATES Simple Interface. Will raise an exception if not found. Args: source :: name of the workspace that was open label :: additional label string that was used to identify the window. Returns: a handle to the SliceViewerWindow object that was created before. """ import mantidqtpython workspace_names = getWorkspaceNames(source) if len(workspace_names) != 1: raise Exception("Please specify only one workspace.") else: svw = threadsafe_call( mantidqtpython.MantidQt.Factory.WidgetFactory.Instance(). getSliceViewerWindow, workspace_names[0], label) if svw is not None: return proxies.SliceViewerWindowProxy(svw) else: return None
def plotSlice(source, label="", xydim=None, slicepoint=None, colormin=None, colormax=None, colorscalelog=False, normalization=1, limits=None, **kwargs): """Opens the SliceViewer with the given MDWorkspace(s). Args: source :: one workspace, or a list of workspaces Optional Keyword Args: label :: label for the window title xydim :: indexes or names of the dimensions to plot, as an (X,Y) list or tuple. See `SliceViewer::setXYDim()` slicepoint :: list with the slice point in each dimension.Must be the same length as the number of \ dimensions of the workspace. See SliceViewer::setSlicePoint() colormin :: value of the minimum color in the scale. See `SliceViewer::setColorScaleMin()` colormax :: value of the maximum color in the scale. See `SliceViewer::setColorScaleMax()` colorscalelog :: value of the maximum color in the scale. See `SliceViewer::setColorScaleLog()` limits :: list with the (xleft, xright, ybottom, ytop) limits to the view to show. See `SliceViewer::setXYLimits()` normalization :: 0=none; 1=volume (default); 2=# of events. Returns: a (list of) handle(s) to the SliceViewerWindow widgets that were open. Use SliceViewerWindow.getSlicer() to get access to the functions of the SliceViewer, e.g. setting the view and slice point. """ workspace_names = getWorkspaceNames(source) __checkPlotSliceWorkspaces(workspace_names) # Make a list of widgets to return out = [] for wsname in workspace_names: window = __doSliceViewer(wsname, label=label, xydim=xydim, slicepoint=slicepoint, colormin=colormin, colormax=colormax, colorscalelog=colorscalelog, limits=limits, normalization=normalization, **kwargs) pxy = proxies.SliceViewerWindowProxy(window) out.append(pxy) # Return the widget alone if only 1 if len(out) == 1: return out[0] else: return out