Newer
Older
from __future__ import (absolute_import, division, print_function)
import mantid.simpleapi as mantid
class FFTPresenter(object):
"""
This class links the FFT model to the GUI
"""
# set data
self.getWorkspaceNames()
#connect
self.view.tableClickSignal.connect(self.tableClicked)
self.view.buttonSignal.connect(self.handleButton)
self.view.phaseCheckSignal.connect(self.phaseCheck)
def cancel(self):
if self.thread is not None:
self.thread.cancel()
@property
def widget(self):
return self.view
def activate(self):
self.view.activateButton()
def deactivate(self):
self.view.deactivateButton()
final_options=self.load.getWorkspaceNames()
#functions
def phaseCheck(self):
self.view.phaseQuadChanged()
#check if a phase table exists
if mantid.AnalysisDataService.doesExist("PhaseTable"):
if row == self.view.getImBoxRow() and col == 1 and self.view.getWS() !="PhaseQuad":
self.view.changedHideUnTick(self.view.getImBox(),self.view.getImBoxRow()+1)
elif row == self.view.getShiftBoxRow() and col == 1:
self.view.changed(self.view.getShiftBox(),self.view.getShiftBoxRow()+1)
return thread_model.ThreadModel(self.alg)
# constructs the inputs for the FFT algorithms
# then executes them (see fft_model to see the order
def handleButton(self):
if self.load.hasDataChanged():
self.getWorkspaceNames()
return
# put this on its own thread so not to freeze Mantid
self.thread=self.createThread()
self.thread.started.connect(self.deactivate)
self.thread.finished.connect(self.handleFinished)
inputs={}
inputs["Run"]=self.load.getRunName()
#do apodization and padding to real data
preInputs=self.view.initAdvanced()
if self.view.getWS() == "PhaseQuad":
phaseTable={}
phaseTable["newTable"]= self.view.isNewPhaseTable()
phaseTable["FirstGoodData"]=self.view.getFirstGoodData()
phaseTable["LastGoodData"]=self.view.getLastGoodData()
phaseTable["Instrument"]=self.load.getInstrument()
inputs["phaseTable"]=phaseTable
self.view.RePhaseAdvanced(preInputs)
else:
self.view.ReAdvanced(preInputs)
if self.view.isRaw():
self.view.addRaw(preInputs,"InputWorkspace")
#do apodization and padding to complex data
if self.view.isComplex() and self.view.getWS()!="PhaseQuad":
ImPreInputs=self.view.initAdvanced()
self.view.ImAdvanced(ImPreInputs)
self.view.addRaw(ImPreInputs,"InputWorkspace")
inputs["preIm"]=ImPreInputs
FFTInputs = self.get_FFT_input()
if self.view.getWS()=="PhaseQuad":
self.view.getFFTRePhase(FFTInputs)
if self.view.isComplex():
self.view.getFFTImPhase(FFTInputs)
else:
if self.view.isRaw():
self.view.addRaw(FFTInputs,"OutputWorkspace")
try:
self.thread.loadData(inputs)
self.thread.start()
self.view.setPhaseBox()
except:
pass
self.thread.deleteLater()
FFTInputs=self.view.initFFTInput()
self.view.addFFTShift(FFTInputs)
self.view.addFFTComplex(FFTInputs)
return FFTInputs