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 0cd98a1 was
b8080e1,
checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago
|
cherry picking sascalc changes from master SASVIEW-996
minor unit test fixes
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[8cb6cd6] | 1 | """ |
---|
| 2 | `Singleton` plot helper module |
---|
| 3 | All its variables are bound to the module, |
---|
| 4 | which can not be instantiated repeatedly so IDs are session-specific. |
---|
| 5 | """ |
---|
| 6 | import sys |
---|
| 7 | |
---|
| 8 | this = sys.modules[__name__] |
---|
| 9 | |
---|
| 10 | this._plots = {} |
---|
| 11 | this._plot_id = 0 |
---|
| 12 | |
---|
| 13 | def clear(): |
---|
| 14 | """ |
---|
| 15 | Reset the plot dictionary |
---|
| 16 | """ |
---|
| 17 | this._plots = {} |
---|
| 18 | |
---|
| 19 | def 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 | |
---|
| 26 | def 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 | |
---|
| 33 | def currentPlots(): |
---|
| 34 | """ |
---|
| 35 | Returns a list of IDs for all currently active plots |
---|
| 36 | """ |
---|
[b3e8629] | 37 | return list(this._plots.keys()) |
---|
[8cb6cd6] | 38 | |
---|
| 39 | def 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 | |
---|
| 45 | def 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.