Skip to content

Commit

Permalink
Re-use plots when possible in Refl_Gui.py
Browse files Browse the repository at this point in the history
Refs #10099.
  • Loading branch information
Harry Jeffery committed Aug 28, 2014
1 parent 36760b3 commit 3819c7b
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -48,6 +48,8 @@ def __init__(self):
self.stitch_col = 17
self.plot_col = 18

self.graphs = dict()

self._last_trans = ""
self.__icat_file_map = None

Expand Down Expand Up @@ -788,7 +790,6 @@ def _plot(self, plotbutton):
overlapLow = plotbutton.property('overlapLow')
overlapHigh = plotbutton.property('overlapHigh')
row = plotbutton.property('row')
g = ['g1', 'g2', 'g3']
wkspBinned = []
w1 = getWorkspace(wksp[0])
w2 = getWorkspace(wksp[len(wksp) - 1])
Expand All @@ -815,15 +816,25 @@ def _plot(self, plotbutton):
Imax = max(wsb.readY(0))

if canMantidPlot:
g[i] = plotSpectrum(ws_name_binned, 0, True)
#Get the existing graph if it exists
base_graph = self.graphs.get(wksp[0], None)

#Clear the window if we're the first of a new set of curves
clearWindow = (i == 0)

#Plot the new curve
base_graph = plotSpectrum(ws_name_binned, 0, True, window = base_graph, clearWindow = clearWindow)

#Save the graph so we can re-use it
self.graphs[wksp[i]] = base_graph

titl = groupGet(ws_name_binned, 'samp', 'run_title')
if (i > 0):
mergePlots(g[0], g[i])
if (type(titl) == str):
g[0].activeLayer().setTitle(titl)
g[0].activeLayer().setAxisScale(Layer.Left, Imin * 0.1, Imax * 10, Layer.Log10)
g[0].activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
g[0].activeLayer().setAutoScale()
base_graph.activeLayer().setTitle(titl)
base_graph.activeLayer().setAxisScale(Layer.Left, Imin * 0.1, Imax * 10, Layer.Log10)
base_graph.activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
base_graph.activeLayer().setAutoScale()


# Create and plot stitched outputs
if self.__checked_row_stiched(row):
Expand All @@ -838,11 +849,13 @@ def _plot(self, plotbutton):
Qmin = min(getWorkspace(outputwksp).readX(0))
Qmax = max(getWorkspace(outputwksp).readX(0))
if canMantidPlot:
gcomb = plotSpectrum(outputwksp, 0, True)
stitched_graph = self.graphs.get(outputwksp, None)
stitched_graph = plotSpectrum(outputwksp, 0, True, window = stitched_graph, clearWindow = True)
titl = groupGet(outputwksp, 'samp', 'run_title')
gcomb.activeLayer().setTitle(titl)
gcomb.activeLayer().setAxisScale(Layer.Left, 1e-8, 100.0, Layer.Log10)
gcomb.activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
stitched_graph.activeLayer().setTitle(titl)
stitched_graph.activeLayer().setAxisScale(Layer.Left, 1e-8, 100.0, Layer.Log10)
stitched_graph.activeLayer().setAxisScale(Layer.Bottom, Qmin * 0.9, Qmax * 1.1, Layer.Log10)
self.graphs[outputwksp] = stitched_graph


def __name_trans(self, transrun):
Expand Down Expand Up @@ -870,7 +883,6 @@ def _do_run(self, runno, row, which):
"""
Run quick on the given run and row
"""
g = ['g1', 'g2', 'g3']
transrun = str(self.tableMain.item(row, (which * 5) + 2).text())
# Formulate a WS Name for the processed transmission run.
transrun_named = self.__name_trans(transrun)
Expand Down

0 comments on commit 3819c7b

Please sign in to comment.