source: sasview/src/sas/qtgui/PlotHelper.py @ 7743c09

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 7743c09 was 8cb6cd6, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago

Plot handler prototype + append plot functionality

  • Property mode set to 100755
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[this._plot_id] = plot
25
26def deletePlot(plot_id):
27    """
28    Deletes an existing plot from the dictionary
29    """
30    assert 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    assert plot_id in this._plots
44
45    return this._plots[plot_id]
46
47def idOfPlot(plot):
48    """
49    Returns the ID of the plot
50    """
51    plot_id = None
52    for key in this._plots.keys():
53        if this._plots[key] == plot:
54            plot_id = key
55            break
56
57    return plot_id
Note: See TracBrowser for help on using the repository browser.