source: sasview/src/sas/qtgui/Plotting/PlotHelper.py @ cd4f421

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since cd4f421 was 83eb5208, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

Putting files in more ordered fashion

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"""
2`Singleton` plot helper module
3All its variables are bound to the module,
4which can not be instantiated repeatedly so IDs are session-specific.
5"""
6import sys
7
8this = sys.modules[__name__]
9
10this._plots = {}
11this._plot_id = 0
12
13def clear():
14    """
15    Reset the plot dictionary
16    """
17    this._plots = {}
18
19def addPlot(plot):
20    """
21    Adds a new plot to the current dictionary of plots
22    """
23    this._plot_id += 1
24    this._plots["Graph%s"%str(this._plot_id)] = plot
25
26def deletePlot(plot_id):
27    """
28    Deletes an existing plot from the dictionary
29    """
30    if plot_id in this._plots:
31        del this._plots[plot_id]
32
33def currentPlots():
34    """
35    Returns a list of IDs for all currently active plots
36    """
37    return this._plots.keys()
38
39def plotById(plot_id):
40    """
41    Returns the plot referenced by the ID
42    """
43    return this._plots[plot_id] if plot_id in this._plots else None
44
45def idOfPlot(plot):
46    """
47    Returns the ID of the plot
48    """
49    plot_id = None
50    for key in this._plots.keys():
51        if this._plots[key] == plot:
52            plot_id = key
53            break
54
55    return plot_id
Note: See TracBrowser for help on using the repository browser.