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

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 0d8b2db was b3e8629, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Initial changes to make SasView? run with python3

  • Property mode set to 100755
File size: 1.1 KB
RevLine 
[8cb6cd6]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
[0268aed]24    this._plots["Graph%s"%str(this._plot_id)] = plot
[8cb6cd6]25
26def deletePlot(plot_id):
27    """
28    Deletes an existing plot from the dictionary
29    """
[ef01be4]30    if plot_id in this._plots:
31        del this._plots[plot_id]
[8cb6cd6]32
33def currentPlots():
34    """
35    Returns a list of IDs for all currently active plots
36    """
[b3e8629]37    return list(this._plots.keys())
[8cb6cd6]38
39def plotById(plot_id):
40    """
41    Returns the plot referenced by the ID
42    """
[ef01be4]43    return this._plots[plot_id] if plot_id in this._plots else None
[8cb6cd6]44
45def idOfPlot(plot):
46    """
47    Returns the ID of the plot
48    """
49    plot_id = None
[b3e8629]50    for key in list(this._plots.keys()):
[8cb6cd6]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.