Skip to content

Commit

Permalink
Remove potentially dangerous _qti calls. Refs #5222
Browse files Browse the repository at this point in the history
They call GUI methods and so need to be correctly proxied.
  • Loading branch information
martyngigg committed May 2, 2012
1 parent 2d9ee98 commit fd2540a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
9 changes: 7 additions & 2 deletions Code/Mantid/MantidPlot/mantidplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,19 @@ def plot3D(*args):
return proxies.Graph3D(threadsafe_call(_qti.app.plot3D, args[0]._getHeldObject(),*args[1:]))

#-----------------------------------------------------------------------------
def selectMultiPeak(source, showFitPropertyBrowser = True):
def selectMultiPeak(source, showFitPropertyBrowser = True, xmin = None, xmax = None):
"""Switch on the multi-peak selecting tool for fitting with the Fit algorithm.
Args:
source: A reference to a MultiLayer with the data to fit.
showFitPropertyBrowser: Whether to show the FitPropertyBrowser or not.
xmin: An optionall minimum X value to select
xmax: An optionall maximum X value to select
"""
threadsafe_call(_qti.app.selectMultiPeak, source._getHeldObject(), showFitPropertyBrowser)
if xmin is not None and xmax is not None:
threadsafe_call(_qti.app.selectMultiPeak, source._getHeldObject(), showFitPropertyBrowser, xmin, xmax)
else:
threadsafe_call(_qti.app.selectMultiPeak, source._getHeldObject(), showFitPropertyBrowser)

#-----------------------------------------------------------------------------
#-------------------------- Project/Folder functions -----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

IS_IN_MANTIDPLOT = False
try:
import _qti
import mantidplot
from MantidFramework import *
mtd.initialise(False)
from mantidsimple import *
Expand Down Expand Up @@ -154,7 +154,7 @@ def _show_ws_instrument(ws):
else:
return True

self._instrument_view = _qti.app.mantidUI.getInstrumentView(ws, tab)
self._instrument_view = mantidplot.getInstrumentView(ws, tab)
if self._instrument_view is not None:
self._instrument_view.show()
self._data_set_viewed = file_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from MantidFramework import *
mtd.initialise(False)
from mantidsimple import *
import _qti
import mantidplot
from reduction.instruments.reflectometer import data_manipulation

IS_IN_MANTIDPLOT = True
Expand Down Expand Up @@ -839,9 +839,9 @@ def set_state(self, state):
if False and IS_IN_MANTIDPLOT:
ws_name = "reflectivity"
ws_list = [n for n in mtd.keys() if n.startswith(ws_name)]
g = _qti.app.graph(ws_name)
if g is None and len(ws_list)>0:
g = _qti.app.mantidUI.pyPlotSpectraList(ws_list,[0],True)
g = mantidplot.graph(ws_name)
if g._getHeldObject() is None and len(ws_list)>0:
g = mantidplot.plotSpectrum(ws_list,[0],True)
g.setName(ws_name)

self._summary.angle_list.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import reduction_gui.widgets.util as util
import ui.reflectometer.ui_refl_stitching

import _qti
import mantidplot
from MantidFramework import *
mtd.initialise(False)
Expand Down Expand Up @@ -377,11 +376,10 @@ def plot_result(self):
s.get_scaled_data(combined_ws)

plot_name = '%s: %s' % (self._graph, pol)
g = _qti.app.graph(plot_name)
g = mantidplot.graph(plot_name)
if g is not None:
continue
g_proxy = mantidplot.plotSpectrum(ws_list, [0], True)
g = g_proxy._getHeldObject()
g = mantidplot.plotSpectrum(ws_list, [0], True)
g.setName(plot_name)
l=g.activeLayer()
l.logYlinX()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import reduction_gui.widgets.util as util
import ui.ui_stitcher

import _qti
import mantidplot
from MantidFramework import *
mtd.initialise(False)
Expand Down Expand Up @@ -438,10 +437,9 @@ def plot_result(self):
ws_list.append(self._high_q_data.get_scaled_ws())

if len(ws_list)>0:
g = _qti.app.graph(self._graph)
g = mantidplot.graph(self._graph)
if g is None or not self._plotted:
g_proxy = mantidplot.plotSpectrum(ws_list, [0], True)
g = g_proxy._getHeldObject()
g = mantidplot.plotSpectrum(ws_list, [0], True)
g.setName(self._graph)
self._plotted = True

Expand Down
9 changes: 4 additions & 5 deletions Code/Mantid/scripts/LargeScaleStructures/data_stitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ def connect(self, ws, call_back, xmin=None, xmax=None,
_qti.app.connect(_qti.app.mantidUI,
QtCore.SIGNAL("x_range_update(double,double)"),
self._call_back)
g = _qti.app.graph(self._graph)
g = mantidplot.graph(self._graph)

if g is not None:
g.close()

g_proxy = mantidplot.plotSpectrum(ws, [0], True)
g = g_proxy._getHeldObject()
g = mantidplot.plotSpectrum(ws, [0], True)
g.setName(self._graph)
l=g.activeLayer()
try:
Expand All @@ -61,9 +60,9 @@ def connect(self, ws, call_back, xmin=None, xmax=None,
l.setScale(2,xmin,xmax)

if range_min is not None and range_max is not None:
_qti.app.selectMultiPeak(g, False, range_min, range_max)
mantidplot.selectMultiPeak(g, False, range_min, range_max)
else:
_qti.app.selectMultiPeak(g, False)
mantidplot.selectMultiPeak(g, False)

@classmethod
def connect(cls, ws, call_back, xmin=None, xmax=None,
Expand Down

0 comments on commit fd2540a

Please sign in to comment.