diff --git a/Code/Mantid/Build/CMake/FindQwt.cmake b/Code/Mantid/Build/CMake/FindQwt.cmake index 389fc8a99c831c8830e6f903c65b2d3380562092..14cb76f7ba710c294a87c7b52cf61e717256b51b 100644 --- a/Code/Mantid/Build/CMake/FindQwt.cmake +++ b/Code/Mantid/Build/CMake/FindQwt.cmake @@ -9,7 +9,7 @@ find_path ( QWT_INCLUDE_DIR qwt.h PATHS /opt/include /usr/local/include /usr/include ${CMAKE_INCLUDE_PATH} PATH_SUFFIXES qwt5 qwt5-qt4 qwt-qt4 qwt ) -find_library ( QWT_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt ) +find_library ( QWT_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt5 qwt ) find_library ( QWT_LIBRARY_DEBUG qwtd ) # in REQUIRED mode: terminate if one of the above find commands failed diff --git a/Code/Mantid/Build/Jenkins/buildscript b/Code/Mantid/Build/Jenkins/buildscript index 40f6003fab63ebfa08448f47edca10bb313ac689..bf9df07b22372756d094a2184f3d54b6f09eda26 100755 --- a/Code/Mantid/Build/Jenkins/buildscript +++ b/Code/Mantid/Build/Jenkins/buildscript @@ -85,6 +85,10 @@ else SCL_ON_RHEL6="eval" fi +if [[ ${NODE_LABELS} == *rhel7* ]]; then + ON_RHEL7=true +fi + ############################################################################### # Check job requirements from the name ############################################################################### @@ -212,6 +216,6 @@ fi # Run the system tests on RHEL6 when doing a pull request build. Run # from a package to have at least one Linux checks it install okay ############################################################################### -if [[ "${ON_RHEL6}" == true ]] && [[ ${JOB_NAME} == *pull_requests* ]]; then +if [[ "${ON_RHEL7}" == true ]] && [[ ${JOB_NAME} == *pull_requests* ]]; then $SCRIPT_DIR/systemtests fi diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py index 0c23a331d770b5e83ad713692ac093465e926186..6cf85ddcff9fd64c92670ced19203ebdc5636c6c 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py @@ -20,7 +20,6 @@ class FlatPlatePaalmanPingsCorrection(PythonAlgorithm): _can_number_density = None _can_front_thickness = None _can_back_thickness = None - _can_scale = 1.0 _number_wavelengths = 10 _emode = None _efixed = 0.0 @@ -73,9 +72,6 @@ class FlatPlatePaalmanPingsCorrection(PythonAlgorithm): validator=FloatBoundedValidator(0.0), doc='Container back thickness in cm') - self.declareProperty(name='CanScaleFactor', defaultValue=1.0, - doc='Scale factor to multiply can data') - self.declareProperty(name='NumberWavelengths', defaultValue=10, validator=IntBoundedValidator(1), doc='Number of wavelengths for calculation') @@ -203,7 +199,6 @@ class FlatPlatePaalmanPingsCorrection(PythonAlgorithm): self._can_number_density = self.getProperty('CanNumberDensity').value self._can_front_thickness = self.getProperty('CanFrontThickness').value self._can_back_thickness = self.getProperty('CanBackThickness').value - self._can_scale = self.getProperty('CanScaleFactor').value self._number_wavelengths = self.getProperty('NumberWavelengths').value self._interpolate = self.getProperty('Interpolate').value diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py new file mode 100644 index 0000000000000000000000000000000000000000..ce5d2aa46a2964f13e5a51a15990c675cd733325 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py @@ -0,0 +1,158 @@ +from mantid.simpleapi import * +from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress +from mantid.kernel import StringMandatoryValidator, Direction, logger + + +class IndirectAnnulusAbsorption(DataProcessorAlgorithm): + + def category(self): + return "Workflow\\Inelastic;PythonAlgorithms;CorrectionFunctions\\AbsorptionCorrections;Workflow\\MIDAS" + + + def summary(self): + return "Calculates indirect absorption corrections for an annulus sample shape." + + + def PyInit(self): + self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input), + doc='Sample workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '', optional=PropertyMode.Optional, + direction=Direction.Input), + doc='Container workspace.') + + self.declareProperty(name='CanScaleFactor', defaultValue=1.0, doc='Scale factor to multiply can data') + + self.declareProperty(name='ChemicalFormula', defaultValue='', validator=StringMandatoryValidator(), + doc='Chemical formula') + + self.declareProperty(name='CanInnerRadius', defaultValue=0.2, doc='Sample radius') + self.declareProperty(name='SampleInnerRadius', defaultValue=0.15, doc='Sample radius') + self.declareProperty(name='SampleOuterRadius', defaultValue=0.16, doc='Sample radius') + self.declareProperty(name='CanOuterRadius', defaultValue=0.22, doc='Sample radius') + self.declareProperty(name='SampleNumberDensity', defaultValue=0.1, doc='Sample number density') + self.declareProperty(name='Events', defaultValue=5000, doc='Number of neutron events') + self.declareProperty(name='Plot', defaultValue=False, doc='Plot options') + + self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), + doc='The output corrected workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CorrectionsWorkspace', '', direction=Direction.Output, + optional=PropertyMode.Optional), + doc='The corrections workspace for scattering and absorptions in sample.') + + + def PyExec(self): + from IndirectCommon import getEfixed, addSampleLogs + + self._setup() + + # Set up progress reporting + n_prog_reports = 4 + if self._can_ws is not None: + n_prog_reports += 2 + prog_reporter = Progress(self, 0.0, 1.0, n_prog_reports) + + prog_reporter.report('Processing sample') + efixed = getEfixed(self._sample_ws_name) + + sample_wave_ws = '__sam_wave' + ConvertUnits(InputWorkspace=self._sample_ws_name, OutputWorkspace=sample_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + sample_thickness = self._sample_outer_radius - self._sample_inner_radius + + prog_reporter.report('Calculating sample corrections') + AnnularRingAbsorption(InputWorkspace=sample_wave_ws, + OutputWorkspace=self._ass_ws, + SampleHeight=3.0, + SampleThickness=sample_thickness, + CanInnerRadius=self._can_inner_radius, + CanOuterRadius=self._can_outer_radius, + SampleChemicalFormula=self._chemical_formula, + SampleNumberDensity=self._number_density, + NumberOfWavelengthPoints=10, + EventsPerPoint=self._events) + + plot_list = [self._output_ws, self._sample_ws_name] + + if self._can_ws is not None: + prog_reporter.report('Processing can') + can_wave_ws = '__can_wave' + ConvertUnits(InputWorkspace=self._can_ws, OutputWorkspace=can_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + if self._can_scale != 1.0: + logger.information('Scaling can by: ' + str(self._can_scale)) + Scale(InputWorkspace=can_wave_ws, OutputWorkspace=can_wave_ws, Factor=self._can_scale, Operation='Multiply') + + prog_reporter.report('Applying can corrections') + Minus(LHSWorkspace=sample_wave_ws, RHSWorkspace=can_wave_ws, OutputWorkspace=sample_wave_ws) + DeleteWorkspace(can_wave_ws) + + plot_list.append(self._can_ws) + + prog_reporter.report('Applying corrections') + Divide(LHSWorkspace=sample_wave_ws, RHSWorkspace=self._ass_ws, OutputWorkspace=sample_wave_ws) + ConvertUnits(InputWorkspace=sample_wave_ws, OutputWorkspace=self._output_ws, Target='DeltaE', + EMode='Indirect', EFixed=efixed) + DeleteWorkspace(sample_wave_ws) + + prog_reporter.report('Recording sample logs') + sample_logs = {'sample_shape': 'annulus', + 'sample_filename': self._sample_ws_name, + 'sample_inner': self._sample_inner_radius, + 'sample_outer': self._sample_outer_radius, + 'can_inner': self._can_inner_radius, + 'can_outer': self._can_outer_radius} + addSampleLogs(self._ass_ws, sample_logs) + addSampleLogs(self._output_ws, sample_logs) + + if self._can_ws is not None: + AddSampleLog(Workspace=self._ass_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._output_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._ass_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + AddSampleLog(Workspace=self._output_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + + self.setProperty('OutputWorkspace', self._output_ws) + + # Output the Ass workspace if it is wanted, delete if not + if self._ass_ws == '_ass': + DeleteWorkspace(self._ass_ws) + else: + self.setProperty('CorrectionsWorkspace', self._ass_ws) + + if self._plot: + from IndirectImport import import_mantidplot + mantid_plot = import_mantidplot() + mantid_plot.plotSpectrum(plot_list, 0) + + + def _setup(self): + """ + Get algorithm properties. + """ + + self._sample_ws_name = self.getPropertyValue('SampleWorkspace') + self._can_scale = self.getProperty('CanScaleFactor').value + self._chemical_formula = self.getPropertyValue('ChemicalFormula') + self._number_density = self.getProperty('SampleNumberDensity').value + self._can_inner_radius = self.getProperty('CanInnerRadius').value + self._sample_inner_radius = self.getProperty('SampleInnerRadius').value + self._sample_outer_radius = self.getProperty('SampleOuterRadius').value + self._can_outer_radius = self.getProperty('CanOuterRadius').value + self._events = self.getProperty('Events').value + self._plot = self.getProperty('Plot').value + self._output_ws = self.getPropertyValue('OutputWorkspace') + + self._ass_ws = self.getPropertyValue('CorrectionsWorkspace') + if self._ass_ws == '': + self._ass_ws = '__ass' + + self._can_ws = self.getPropertyValue('CanWorkspace') + if self._can_ws == '': + self._can_ws = None + + +# Register algorithm with Mantid +AlgorithmFactory.subscribe(IndirectAnnulusAbsorption) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py new file mode 100644 index 0000000000000000000000000000000000000000..d22e65e0440492c48e4fe33a2c5333bccf2e6785 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py @@ -0,0 +1,145 @@ +from mantid.simpleapi import * +from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress +from mantid.kernel import StringMandatoryValidator, Direction, logger + + +class IndirectCylinderAbsorption(DataProcessorAlgorithm): + + def category(self): + return "Workflow\\Inelastic;PythonAlgorithms;CorrectionFunctions\\AbsorptionCorrections;Workflow\\MIDAS" + + + def summary(self): + return "Calculates indirect absorption corrections for a cylinder sample shape." + + + def PyInit(self): + self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input), + doc='Sample workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '', optional=PropertyMode.Optional, + direction=Direction.Input), + doc='Container workspace.') + + self.declareProperty(name='CanScaleFactor', defaultValue=1.0, doc='Scale factor to multiply can data') + + self.declareProperty(name='ChemicalFormula', defaultValue='', validator=StringMandatoryValidator(), + doc='Chemical formula') + + self.declareProperty(name='SampleRadius', defaultValue=0.5, doc='Sample radius') + self.declareProperty(name='SampleNumberDensity', defaultValue=0.1, doc='Sample number density') + self.declareProperty(name='Plot', defaultValue=False, doc='Plot options') + + self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), + doc='The output corrected workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CorrectionsWorkspace', '', direction=Direction.Output, + optional=PropertyMode.Optional), + doc='The corrections workspace for scattering and absorptions in sample.') + + + def PyExec(self): + from IndirectCommon import getEfixed, addSampleLogs + + self._setup() + + # Set up progress reporting + n_prog_reports = 4 + if self._can_ws is not None: + n_prog_reports += 2 + prog_reporter = Progress(self, 0.0, 1.0, n_prog_reports) + + prog_reporter.report('Processing sample') + efixed = getEfixed(self._sample_ws) + + sample_wave_ws = '__sam_wave' + ConvertUnits(InputWorkspace=self._sample_ws, OutputWorkspace=sample_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + SetSampleMaterial(sample_wave_ws, ChemicalFormula=self._chemical_formula, SampleNumberDensity=self._number_density) + + prog_reporter.report('Calculating sample corrections') + CylinderAbsorption(InputWorkspace=sample_wave_ws, + OutputWorkspace=self._ass_ws, + SampleNumberDensity=self._number_density, + NumberOfWavelengthPoints=10, + CylinderSampleHeight=3.0, + CylinderSampleRadius=self._sample_radius, + NumberOfSlices=1, + NumberOfAnnuli=10) + + plot_list = [self._output_ws, self._sample_ws] + + if self._can_ws is not None: + prog_reporter.report('Processing can') + can_wave_ws = '__can_wave' + ConvertUnits(InputWorkspace=self._can_ws, OutputWorkspace=can_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + if self._can_scale != 1.0: + logger.information('Scaling can by: ' + str(self._can_scale)) + Scale(InputWorkspace=can_wave_ws, OutputWorkspace=can_wave_ws, Factor=self._can_scale, Operation='Multiply') + + prog_reporter.report('Applying can corrections') + Minus(LHSWorkspace=sample_wave_ws, RHSWorkspace=can_wave_ws, OutputWorkspace=sample_wave_ws) + DeleteWorkspace(can_wave_ws) + + plot_list.append(self._can_ws) + + prog_reporter.report('Applying corrections') + Divide(LHSWorkspace=sample_wave_ws, RHSWorkspace=self._ass_ws, OutputWorkspace=sample_wave_ws) + ConvertUnits(InputWorkspace=sample_wave_ws, OutputWorkspace=self._output_ws, + Target='DeltaE', EMode='Indirect', EFixed=efixed) + DeleteWorkspace(sample_wave_ws) + + prog_reporter.report('Recording sample logs') + sample_logs = {'sample_shape': 'cylinder', + 'sample_filename': self._sample_ws, + 'sample_radius': self._sample_radius} + addSampleLogs(self._ass_ws, sample_logs) + addSampleLogs(self._output_ws, sample_logs) + + if self._can_ws is not None: + AddSampleLog(Workspace=self._ass_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._output_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._ass_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + AddSampleLog(Workspace=self._output_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + + self.setProperty('OutputWorkspace', self._output_ws) + + # Output the Ass workspace if it is wanted, delete if not + if self._ass_ws == '_ass': + DeleteWorkspace(self._ass_ws) + else: + self.setProperty('CorrectionsWorkspace', self._ass_ws) + + if self._plot: + from IndirectImport import import_mantidplot + mantid_plot = import_mantidplot() + mantid_plot.plotSpectrum(plot_list, 0) + + + def _setup(self): + """ + Get algorithm properties. + """ + + self._sample_ws = self.getPropertyValue('SampleWorkspace') + self._can_scale = self.getProperty('CanScaleFactor').value + self._chemical_formula = self.getPropertyValue('ChemicalFormula') + self._number_density = self.getProperty('SampleNumberDensity').value + self._sample_radius = self.getProperty('SampleRadius').value + self._plot = self.getProperty('Plot').value + self._output_ws = self.getPropertyValue('OutputWorkspace') + + self._ass_ws = self.getPropertyValue('CorrectionsWorkspace') + if self._ass_ws == '': + self._ass_ws = '__ass' + + self._can_ws = self.getPropertyValue('CanWorkspace') + if self._can_ws == '': + self._can_ws = None + + +# Register algorithm with Mantid +AlgorithmFactory.subscribe(IndirectCylinderAbsorption) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py new file mode 100644 index 0000000000000000000000000000000000000000..0fb3e2c3fe040c9a804c0f2a61a128f5c6febf69 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py @@ -0,0 +1,155 @@ +from mantid.simpleapi import * +from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress +from mantid.kernel import StringMandatoryValidator, Direction, logger + + +class IndirectFlatPlateAbsorption(DataProcessorAlgorithm): + + def category(self): + return "Workflow\\Inelastic;PythonAlgorithms;CorrectionFunctions\\AbsorptionCorrections;Workflow\\MIDAS" + + + def summary(self): + return "Calculates indirect absorption corrections for a flat sample shape." + + + def PyInit(self): + self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input), + doc='Sample workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '', optional=PropertyMode.Optional, + direction=Direction.Input), + doc='Container workspace.') + + self.declareProperty(name='CanScaleFactor', defaultValue=1.0, doc='Scale factor to multiply can data') + + self.declareProperty(name='ChemicalFormula', defaultValue='', validator=StringMandatoryValidator(), + doc='Chemical formula') + + self.declareProperty(name='SampleHeight', defaultValue=1.0, doc='Sample height') + self.declareProperty(name='SampleWidth', defaultValue=1.0, doc='Sample width') + self.declareProperty(name='SampleThickness', defaultValue=0.1, doc='Sample thickness') + self.declareProperty(name='ElementSize', defaultValue=0.1, doc='Element size in mm') + self.declareProperty(name='SampleNumberDensity', defaultValue=0.1, doc='Sample number density') + self.declareProperty(name='Plot', defaultValue=False, doc='Plot options') + + self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), + doc='The output corrected workspace.') + + self.declareProperty(MatrixWorkspaceProperty('CorrectionsWorkspace', '', direction=Direction.Output, + optional=PropertyMode.Optional), + doc='The corrections workspace for scattering and absorptions in sample.') + + def PyExec(self): + from IndirectCommon import getEfixed, addSampleLogs + + self._setup() + + # Set up progress reporting + n_prog_reports = 4 + if self._can_ws is not None: + n_prog_reports += 2 + prog_reporter = Progress(self, 0.0, 1.0, n_prog_reports) + + prog_reporter.report('Processing sample') + efixed = getEfixed(self._sample_ws) + + sample_wave_ws = '__sam_wave' + ConvertUnits(InputWorkspace=self._sample_ws, OutputWorkspace=sample_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + SetSampleMaterial(sample_wave_ws, ChemicalFormula=self._chemical_formula, SampleNumberDensity=self._number_density) + + prog_reporter.report('Calculating sample corrections') + FlatPlateAbsorption(InputWorkspace=sample_wave_ws, + OutputWorkspace=self._ass_ws, + SampleHeight=self._sample_height, + SampleWidth=self._sample_width, + SampleThickness=self._sample_thichness, + ElementSize=self._element_size, + EMode='Indirect', + EFixed=efixed, + NumberOfWavelengthPoints=10) + + plot_list = [self._output_ws, self._sample_ws] + + if self._can_ws is not None: + prog_reporter.report('Processing can') + can_wave_ws = '__can_wave' + ConvertUnits(InputWorkspace=self._can_ws, OutputWorkspace=can_wave_ws, + Target='Wavelength', EMode='Indirect', EFixed=efixed) + + if self._can_scale != 1.0: + logger.information('Scaling can by: ' + str(self._can_scale)) + Scale(InputWorkspace=can_wave_ws, OutputWorkspace=can_wave_ws, Factor=self._can_scale, Operation='Multiply') + + prog_reporter.report('Applying can corrections') + Minus(LHSWorkspace=sample_wave_ws, RHSWorkspace=can_wave_ws, OutputWorkspace=sample_wave_ws) + DeleteWorkspace(can_wave_ws) + + plot_list.append(self._can_ws) + + prog_reporter.report('Applying corrections') + Divide(LHSWorkspace=sample_wave_ws, RHSWorkspace=self._ass_ws, OutputWorkspace=sample_wave_ws) + ConvertUnits(InputWorkspace=sample_wave_ws, OutputWorkspace=self._output_ws, + Target='DeltaE', EMode='Indirect', EFixed=efixed) + DeleteWorkspace(sample_wave_ws) + + prog_reporter.report('Recording sample logs') + sample_logs = {'sample_shape': 'flatplate', + 'sample_filename': self._sample_ws, + 'sample_height': self._sample_height, + 'sample_width': self._sample_width, + 'sample_thickness': self._sample_thichness, + 'element_size': self._element_size} + addSampleLogs(self._ass_ws, sample_logs) + addSampleLogs(self._output_ws, sample_logs) + + if self._can_ws is not None: + AddSampleLog(Workspace=self._ass_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._output_ws, LogName='can_filename', LogType='String', LogText=str(self._can_ws)) + AddSampleLog(Workspace=self._ass_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + AddSampleLog(Workspace=self._output_ws, LogName='can_scale', LogType='String', LogText=str(self._can_scale)) + + self.setProperty('OutputWorkspace', self._output_ws) + + # Output the Ass workspace if it is wanted, delete if not + if self._ass_ws == '_ass': + DeleteWorkspace(self._ass_ws) + else: + self.setProperty('CorrectionsWorkspace', self._ass_ws) + + if self._plot: + prog_reporter.report('Plotting') + from IndirectImport import import_mantidplot + mantid_plot = import_mantidplot() + mantid_plot.plotSpectrum(plot_list, 0) + + + def _setup(self): + """ + Get algorithm properties. + """ + + self._sample_ws = self.getPropertyValue('SampleWorkspace') + self._can_scale = self.getProperty('CanScaleFactor').value + self._chemical_formula = self.getPropertyValue('ChemicalFormula') + self._number_density = self.getProperty('SampleNumberDensity').value + self._sample_height = self.getProperty('SampleHeight').value + self._sample_width = self.getProperty('SampleWidth').value + self._sample_thichness = self.getProperty('SampleThickness').value + self._element_size = self.getProperty('ElementSize').value + self._plot = self.getProperty('Plot').value + self._output_ws = self.getPropertyValue('OutputWorkspace') + + self._ass_ws = self.getPropertyValue('CorrectionsWorkspace') + if self._ass_ws == '': + self._ass_ws = '__ass' + + self._can_ws = self.getPropertyValue('CanWorkspace') + if self._can_ws == '': + self._can_ws = None + + +# Register algorithm with Mantid +AlgorithmFactory.subscribe(IndirectFlatPlateAbsorption) diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt index 1424514d62ed4783c2028e8ac945f7e4734d74c9..c743e5d6eb0165e5e62cb64cb70e2f54b5bc7d6b 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt @@ -17,6 +17,9 @@ set ( TEST_PY_FILES FindReflectometryLinesTest.py FlatPlatePaalmanPingsCorrectionTest.py GetEiT0atSNSTest.py + IndirectAnnulusAbsorptionTest.py + IndirectCylinderAbsorptionTest.py + IndirectFlatPlateAbsorptionTest.py IndirectILLReductionTest.py InelasticIndirectReductionTest.py IndirectTransmissionTest.py diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectAnnulusAbsorptionTest.py b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectAnnulusAbsorptionTest.py new file mode 100644 index 0000000000000000000000000000000000000000..115a9f241e98ea38b8858ff85698a0f8c2c31001 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectAnnulusAbsorptionTest.py @@ -0,0 +1,91 @@ +import unittest +from mantid.simpleapi import * +from mantid.api import * + + +class IndirectAnnulusAbsorptionTest(unittest.TestCase): + + def setUp(self): + """ + Loads the reduced container and sample files. + """ + + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + + self._can_ws = can_ws + self._red_ws = red_ws + + + def _test_workspaces(self, corrected, ass): + """ + Checks the units of the Ass and corrected workspaces. + + @param corrected Corrected workspace + @param ass Assc corrections workspace + """ + + corrected_x_unit = corrected.getAxis(0).getUnit().unitID() + self.assertEqual(corrected_x_unit, 'DeltaE') + + ass_x_unit = ass.getAxis(0).getUnit().unitID() + self.assertEquals(ass_x_unit, 'Wavelength') + + ass_y_unit = ass.YUnitLabel() + self.assertEqual(ass_y_unit, 'Attenuation factor') + + + def test_sample_corrections_only(self): + """ + Tests corrections for the sample only. + """ + + corrected, ass = IndirectAnnulusAbsorption(SampleWorkspace=self._red_ws, + ChemicalFormula='H2-O', + CanInnerRadius=0.2, + SampleInnerRadius=0.15, + SampleOuterRadius=0.16, + CanOuterRadius=0.22, + Events=200) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction(self): + """ + Tests corrections for the sample and simple container subtraction. + """ + + corrected, ass = IndirectAnnulusAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + ChemicalFormula='H2-O', + CanInnerRadius=0.2, + SampleInnerRadius=0.15, + SampleOuterRadius=0.16, + CanOuterRadius=0.22, + Events=200) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction_with_scale(self): + """ + Tests corrections for the sample and simple container subtraction + with can scale. + """ + + corrected, ass = IndirectAnnulusAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + CanInnerRadius=0.2, + SampleInnerRadius=0.15, + SampleOuterRadius=0.16, + CanOuterRadius=0.22, + Events=200) + + self._test_workspaces(corrected, ass) + + +if __name__ == '__main__': + unittest.main() diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectCylinderAbsorptionTest.py b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectCylinderAbsorptionTest.py new file mode 100644 index 0000000000000000000000000000000000000000..d97057f84b35b200c284825f0ce5bfb3910f8023 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectCylinderAbsorptionTest.py @@ -0,0 +1,79 @@ +import unittest +from mantid.simpleapi import * +from mantid.api import * + + +class IndirectCylinderAbsorptionTest(unittest.TestCase): + + def setUp(self): + """ + Loads the reduced container and sample files. + """ + + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + + self._can_ws = can_ws + self._red_ws = red_ws + + + def _test_workspaces(self, corrected, ass): + """ + Checks the units of the Ass and corrected workspaces. + + @param corrected Corrected workspace + @param ass Assc corrections workspace + """ + + corrected_x_unit = corrected.getAxis(0).getUnit().unitID() + self.assertEqual(corrected_x_unit, 'DeltaE') + + ass_x_unit = ass.getAxis(0).getUnit().unitID() + self.assertEquals(ass_x_unit, 'Wavelength') + + ass_y_unit = ass.YUnitLabel() + self.assertEqual(ass_y_unit, 'Attenuation factor') + + + def test_sample_corrections_only(self): + """ + Tests corrections for the sample only. + """ + + corrected, ass = IndirectCylinderAbsorption(SampleWorkspace=self._red_ws, + ChemicalFormula='H2-O', + SampleRadius=0.2) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction(self): + """ + Tests corrections for the sample and simple container subtraction. + """ + + corrected, ass = IndirectCylinderAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + ChemicalFormula='H2-O', + SampleRadius=0.2) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction_with_scale(self): + """ + Tests corrections for the sample and simple container subtraction + with can scale. + """ + + corrected, ass = IndirectCylinderAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + SampleRadius=0.2) + + self._test_workspaces(corrected, ass) + + +if __name__ == '__main__': + unittest.main() diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectFlatPlateAbsorptionTest.py b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectFlatPlateAbsorptionTest.py new file mode 100644 index 0000000000000000000000000000000000000000..829d8688e685f955632b17e9c86835d4557b4ab2 --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/IndirectFlatPlateAbsorptionTest.py @@ -0,0 +1,88 @@ +import unittest +from mantid.simpleapi import * +from mantid.api import * + + +class IndirectFlatPlateAbsorptionTest(unittest.TestCase): + + def setUp(self): + """ + Loads the reduced container and sample files. + """ + + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + + self._can_ws = can_ws + self._red_ws = red_ws + + + def _test_workspaces(self, corrected, ass): + """ + Checks the units of the Ass and corrected workspaces. + + @param corrected Corrected workspace + @param ass Assc corrections workspace + """ + + corrected_x_unit = corrected.getAxis(0).getUnit().unitID() + self.assertEqual(corrected_x_unit, 'DeltaE') + + ass_x_unit = ass.getAxis(0).getUnit().unitID() + self.assertEquals(ass_x_unit, 'Wavelength') + + ass_y_unit = ass.YUnitLabel() + self.assertEqual(ass_y_unit, 'Attenuation factor') + + + def test_sample_corrections_only(self): + """ + Tests corrections for the sample only. + """ + + corrected, ass = IndirectFlatPlateAbsorption(SampleWorkspace=self._red_ws, + ChemicalFormula='H2-O', + SampleHeight=1, + SampleWidth=1, + SampleThickness=1, + ElementSize=1) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction(self): + """ + Tests corrections for the sample and simple container subtraction. + """ + + corrected, ass = IndirectFlatPlateAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + ChemicalFormula='H2-O', + SampleHeight=1, + SampleWidth=1, + SampleThickness=1, + ElementSize=1) + + self._test_workspaces(corrected, ass) + + + def test_sample_and_can_subtraction_with_scale(self): + """ + Tests corrections for the sample and simple container subtraction + with can scale. + """ + + corrected, ass = IndirectFlatPlateAbsorption(SampleWorkspace=self._red_ws, + CanWorkspace=self._can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + SampleHeight=1, + SampleWidth=1, + SampleThickness=1, + ElementSize=1) + + self._test_workspaces(corrected, ass) + + +if __name__ == '__main__': + unittest.main() diff --git a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/InelasticIndirectReductionTest.py b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/InelasticIndirectReductionTest.py index 576a0bbf5e5c922f1310071f189b006c377124f8..ef51954f33eb75801cbdd116de8c1f1f37c8e997 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/InelasticIndirectReductionTest.py +++ b/Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/InelasticIndirectReductionTest.py @@ -11,8 +11,7 @@ class InelasticIndirectReductionTest(unittest.TestCase): Instrument='IRIS', Analyser='graphite', Reflection='002', - DetectorRange=[3, 53], - SaveFormats=['nxs']) + DetectorRange=[3, 53]) reduction_workspace = mtd['IndirectReductions'].getItem(0) self.assertEquals(reduction_workspace.getName(), 'irs26176_graphite002_red') diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IndirectTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IndirectTab.h index 1c6750a08434ed347528256c1637a1fcac3422ae..2664203f1fc7f8d0aa4341d4e4a5a252938ae462 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IndirectTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IndirectTab.h @@ -42,7 +42,9 @@ namespace MantidQt { namespace CustomInterfaces { - /** IndirectTab : TODO: DESCRIPTION + /** IndirectTab + + Provided common functionality of all indirect interface tabs. @author Dan Nixon @date 08/10/2014 @@ -90,9 +92,13 @@ namespace CustomInterfaces bool loadFile(const QString& filename, const QString& outputName, const int specMin = -1, const int specMax = -1); /// Function to set the range limits of the plot - void setPlotPropertyRange(const QString& rsID, QtProperty* min, QtProperty* max, const QPair<double, double> & bounds); + void setPlotPropertyRange(MantidQt::MantidWidgets::RangeSelector * rs, + QtProperty* min, QtProperty* max, + const QPair<double, double> & bounds); /// Function to set the range selector on the mini plot - void setRangeSelector(const QString& rsID, QtProperty* lower, QtProperty* upper, const QPair<double, double> & bounds); + void setRangeSelector(MantidQt::MantidWidgets::RangeSelector * rs, + QtProperty* lower, QtProperty* upper, + const QPair<double, double> & bounds); /// Function to run an algorithm on a seperate thread void runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm); @@ -102,8 +108,6 @@ namespace CustomInterfaces /// Parent QWidget (if applicable) QWidget *m_parentWidget; - /// Range selector widget for mini plot - std::map<QString, MantidQt::MantidWidgets::RangeSelector *> m_rangeSelectors; /// Tree of the properties std::map<QString, QtTreePropertyBrowser *> m_propTrees; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index 58ba4caaaf9e33ab65a7c9785485f442e4c2045e..56fbf8531693c779d2364677204574fa333949a8 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -51,13 +51,13 @@ namespace IDA m_cfTree->setFactoryForManager(m_dblManager, m_dblEdFac); // Create Range Selectors - m_rangeSelectors["ConvFitRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot); - m_rangeSelectors["ConvFitBackRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot, - MantidQt::MantidWidgets::RangeSelector::YSINGLE); - m_rangeSelectors["ConvFitBackRange"]->setColour(Qt::darkGreen); - m_rangeSelectors["ConvFitBackRange"]->setRange(0.0, 1.0); - m_rangeSelectors["ConvFitHWHM"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot); - m_rangeSelectors["ConvFitHWHM"]->setColour(Qt::red); + auto fitRangeSelector = m_uiForm.ppPlot->addRangeSelector("ConvFitRange"); + auto backRangeSelector = m_uiForm.ppPlot->addRangeSelector("ConvFitBackRange", + MantidWidgets::RangeSelector::YSINGLE); + auto hwhmRangeSelector = m_uiForm.ppPlot->addRangeSelector("ConvFitHWHM"); + backRangeSelector->setColour(Qt::darkGreen); + backRangeSelector->setRange(0.0, 1.0); + hwhmRangeSelector->setColour(Qt::red); // Populate Property Widget @@ -98,11 +98,11 @@ namespace IDA m_uiForm.leTempCorrection->setValidator(new QDoubleValidator(m_parentWidget)); // Connections - connect(m_rangeSelectors["ConvFitRange"], SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); - connect(m_rangeSelectors["ConvFitRange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); - connect(m_rangeSelectors["ConvFitBackRange"], SIGNAL(minValueChanged(double)), this, SLOT(backgLevel(double))); - connect(m_rangeSelectors["ConvFitHWHM"], SIGNAL(minValueChanged(double)), this, SLOT(hwhmChanged(double))); - connect(m_rangeSelectors["ConvFitHWHM"], SIGNAL(maxValueChanged(double)), this, SLOT(hwhmChanged(double))); + connect(fitRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); + connect(fitRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); + connect(backRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(backgLevel(double))); + connect(hwhmRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(hwhmChanged(double))); + connect(hwhmRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(hwhmChanged(double))); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double))); connect(m_blnManager, SIGNAL(valueChanged(QtProperty*, bool)), this, SLOT(checkBoxUpdate(QtProperty*, bool))); connect(m_uiForm.ckTempCorrection, SIGNAL(toggled(bool)), m_uiForm.leTempCorrection, SLOT(setEnabled(bool))); @@ -113,8 +113,9 @@ namespace IDA connect(m_uiForm.ckPlotGuess, SIGNAL(stateChanged(int)), this, SLOT(plotGuess())); // Have FWHM Range linked to Fit Start/End Range - connect(m_rangeSelectors["ConvFitRange"], SIGNAL(rangeChanged(double, double)), m_rangeSelectors["ConvFitHWHM"], SLOT(setRange(double, double))); - m_rangeSelectors["ConvFitHWHM"]->setRange(-1.0,1.0); + connect(fitRangeSelector, SIGNAL(rangeChanged(double, double)), + hwhmRangeSelector, SLOT(setRange(double, double))); + hwhmRangeSelector->setRange(-1.0,1.0); hwhmUpdateRS(0.02); typeSelection(m_uiForm.cbFitType->currentIndex()); @@ -643,19 +644,21 @@ namespace IDA m_cfTree->removeProperty(m_properties["Lorentzian1"]); m_cfTree->removeProperty(m_properties["Lorentzian2"]); + auto hwhmRangeSelector = m_uiForm.ppPlot->getRangeSelector("ConvFitHWHM"); + switch ( index ) { case 0: - m_rangeSelectors["ConvFitHWHM"]->setVisible(false); + hwhmRangeSelector->setVisible(false); break; case 1: m_cfTree->addProperty(m_properties["Lorentzian1"]); - m_rangeSelectors["ConvFitHWHM"]->setVisible(true); + hwhmRangeSelector->setVisible(true); break; case 2: m_cfTree->addProperty(m_properties["Lorentzian1"]); m_cfTree->addProperty(m_properties["Lorentzian2"]); - m_rangeSelectors["ConvFitHWHM"]->setVisible(true); + hwhmRangeSelector->setVisible(true); break; } } @@ -694,7 +697,7 @@ namespace IDA { const QPair<double, double> curveRange = m_uiForm.ppPlot->getCurveRange("Sample"); const std::pair<double, double> range(curveRange.first, curveRange.second); - m_rangeSelectors["ConvFitRange"]->setRange(range.first, range.second); + m_uiForm.ppPlot->getRangeSelector("ConvFitRange")->setRange(range.first, range.second); m_uiForm.ckPlotGuess->setChecked(plotGuess); } catch(std::invalid_argument & exc) @@ -954,9 +957,10 @@ namespace IDA // Always want FWHM to display as positive. const double hwhm = std::fabs(val-peakCentre); // Update the property - m_rangeSelectors["ConvFitHWHM"]->blockSignals(true); + auto hwhmRangeSelector = m_uiForm.ppPlot->getRangeSelector("ConvFitHWHM"); + hwhmRangeSelector->blockSignals(true); m_dblManager->setValue(m_properties["Lorentzian 1.FWHM"], hwhm*2); - m_rangeSelectors["ConvFitHWHM"]->blockSignals(false); + hwhmRangeSelector->blockSignals(false); } void ConvFit::backgLevel(double val) @@ -966,9 +970,12 @@ namespace IDA void ConvFit::updateRS(QtProperty* prop, double val) { - if ( prop == m_properties["StartX"] ) { m_rangeSelectors["ConvFitRange"]->setMinimum(val); } - else if ( prop == m_properties["EndX"] ) { m_rangeSelectors["ConvFitRange"]->setMaximum(val); } - else if ( prop == m_properties["BGA0"] ) { m_rangeSelectors["ConvFitBackRange"]->setMinimum(val); } + auto fitRangeSelector = m_uiForm.ppPlot->getRangeSelector("ConvFitRange"); + auto backRangeSelector = m_uiForm.ppPlot->getRangeSelector("ConvFitBackRange"); + + if ( prop == m_properties["StartX"] ) { fitRangeSelector->setMinimum(val); } + else if ( prop == m_properties["EndX"] ) { fitRangeSelector->setMaximum(val); } + else if ( prop == m_properties["BGA0"] ) { backRangeSelector->setMinimum(val); } else if ( prop == m_properties["Lorentzian 1.FWHM"] ) { hwhmUpdateRS(val); } else if ( prop == m_properties["Lorentzian 1.PeakCentre"] ) { @@ -979,8 +986,9 @@ namespace IDA void ConvFit::hwhmUpdateRS(double val) { const double peakCentre = m_dblManager->value(m_properties["Lorentzian 1.PeakCentre"]); - m_rangeSelectors["ConvFitHWHM"]->setMinimum(peakCentre-val/2); - m_rangeSelectors["ConvFitHWHM"]->setMaximum(peakCentre+val/2); + auto hwhmRangeSelector = m_uiForm.ppPlot->getRangeSelector("ConvFitHWHM"); + hwhmRangeSelector->setMinimum(peakCentre-val/2); + hwhmRangeSelector->setMaximum(peakCentre+val/2); } void ConvFit::checkBoxUpdate(QtProperty* prop, bool checked) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Elwin.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Elwin.cpp index db1e27990a7cbd21d225c3d37aeebbe4d8b6c98d..3cc9867a2a20e66c5ebabce68ce73de73aed9f8f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Elwin.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Elwin.cpp @@ -65,16 +65,17 @@ namespace IDA // We always want one range selector... the second one can be controlled from // within the elwinTwoRanges(bool state) function - m_rangeSelectors["ElwinIntegrationRange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["ElwinIntegrationRange"], SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); - connect(m_rangeSelectors["ElwinIntegrationRange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); + auto integrationRangeSelector = m_uiForm.ppPlot->addRangeSelector("ElwinIntegrationRange"); + connect(integrationRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); + connect(integrationRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); // create the second range - m_rangeSelectors["ElwinBackgroundRange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - m_rangeSelectors["ElwinBackgroundRange"]->setColour(Qt::darkGreen); // dark green for background - connect(m_rangeSelectors["ElwinIntegrationRange"], SIGNAL(rangeChanged(double, double)), m_rangeSelectors["ElwinBackgroundRange"], SLOT(setRange(double, double))); - connect(m_rangeSelectors["ElwinBackgroundRange"], SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); - connect(m_rangeSelectors["ElwinBackgroundRange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); - m_rangeSelectors["ElwinBackgroundRange"]->setRange(m_rangeSelectors["ElwinIntegrationRange"]->getRange()); + auto backgroundRangeSelector = m_uiForm.ppPlot->addRangeSelector("ElwinBackgroundRange"); + backgroundRangeSelector->setColour(Qt::darkGreen); // dark green for background + connect(integrationRangeSelector, SIGNAL(rangeChanged(double, double)), + backgroundRangeSelector, SLOT(setRange(double, double))); + connect(backgroundRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); + connect(backgroundRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); + backgroundRangeSelector->setRange(integrationRangeSelector->getRange()); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double))); connect(m_blnManager, SIGNAL(valueChanged(QtProperty*, bool)), this, SLOT(twoRanges(QtProperty*, bool))); @@ -360,7 +361,7 @@ namespace IDA try { QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample"); - m_rangeSelectors["ElwinIntegrationRange"]->setRange(range.first, range.second); + m_uiForm.ppPlot->getRangeSelector("ElwinIntegrationRange")->setRange(range.first, range.second); } catch(std::invalid_argument & exc) { @@ -371,17 +372,21 @@ namespace IDA void Elwin::twoRanges(QtProperty* prop, bool val) { if(prop == m_properties["BackgroundSubtraction"]) - m_rangeSelectors["ElwinBackgroundRange"]->setVisible(val); + m_uiForm.ppPlot->getRangeSelector("ElwinBackgroundRange")->setVisible(val); } void Elwin::minChanged(double val) { + auto integrationRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinIntegrationRange"); + auto backgroundRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinBackgroundRange"); + MantidWidgets::RangeSelector* from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if ( from == m_rangeSelectors["ElwinIntegrationRange"] ) + + if(from == integrationRangeSelector) { m_dblManager->setValue(m_properties["IntegrationStart"], val); } - else if ( from == m_rangeSelectors["ElwinBackgroundRange"] ) + else if(from == backgroundRangeSelector) { m_dblManager->setValue(m_properties["BackgroundStart"], val); } @@ -389,12 +394,16 @@ namespace IDA void Elwin::maxChanged(double val) { + auto integrationRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinIntegrationRange"); + auto backgroundRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinBackgroundRange"); + MantidWidgets::RangeSelector* from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if ( from == m_rangeSelectors["ElwinIntegrationRange"] ) + + if(from == integrationRangeSelector) { m_dblManager->setValue(m_properties["IntegrationEnd"], val); } - else if ( from == m_rangeSelectors["ElwinBackgroundRange"] ) + else if(from == backgroundRangeSelector) { m_dblManager->setValue(m_properties["BackgroundEnd"], val); } @@ -402,11 +411,15 @@ namespace IDA void Elwin::updateRS(QtProperty* prop, double val) { - if ( prop == m_properties["IntegrationStart"] ) m_rangeSelectors["ElwinIntegrationRange"]->setMinimum(val); - else if ( prop == m_properties["IntegrationEnd"] ) m_rangeSelectors["ElwinIntegrationRange"]->setMaximum(val); - else if ( prop == m_properties["BackgroundStart"] ) m_rangeSelectors["ElwinBackgroundRange"]->setMinimum(val); - else if ( prop == m_properties["BackgroundEnd"] ) m_rangeSelectors["ElwinBackgroundRange"]->setMaximum(val); + auto integrationRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinIntegrationRange"); + auto backgroundRangeSelector = m_uiForm.ppPlot->getRangeSelector("ElwinBackgroundRange"); + + if ( prop == m_properties["IntegrationStart"] ) integrationRangeSelector->setMinimum(val); + else if ( prop == m_properties["IntegrationEnd"] ) integrationRangeSelector->setMaximum(val); + else if ( prop == m_properties["BackgroundStart"] ) backgroundRangeSelector->setMinimum(val); + else if ( prop == m_properties["BackgroundEnd"] ) backgroundRangeSelector->setMaximum(val); } + } // namespace IDA } // namespace CustomInterfaces } // namespace MantidQt diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Fury.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Fury.cpp index e131644b51ea61023537690fe00db8d975b25f8d..87c3b3416da06f74275c0db18fc57d6105fd32eb 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Fury.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Fury.cpp @@ -68,10 +68,10 @@ namespace IDA m_furTree->setFactoryForManager(m_dblManager, m_dblEdFac); - m_rangeSelectors["FuryRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot); + auto xRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryRange"); // signals / slots & validators - connect(m_rangeSelectors["FuryRange"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rsRangeChangedLazy(double, double))); + connect(xRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rsRangeChangedLazy(double, double))); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double))); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePropertyValues(QtProperty*, double))); connect(m_uiForm.dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(plotInput(const QString&))); @@ -252,6 +252,8 @@ namespace IDA m_uiForm.ppPlot->clear(); m_uiForm.ppPlot->addSpectrum("Sample", workspace, 0); + auto xRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryRange"); + try { QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample"); @@ -260,7 +262,7 @@ namespace IDA const std::string instrName(workspace->getInstrument()->getName()); if(instrName == "BASIS") { - m_rangeSelectors["FuryRange"]->setRange(range.first, range.second); + xRangeSelector->setRange(range.first, range.second); m_dblManager->setValue(m_properties["ELow"], rounded_min); m_dblManager->setValue(m_properties["EHigh"], rounded_max); m_dblManager->setValue(m_properties["EWidth"], 0.0004); @@ -285,13 +287,13 @@ namespace IDA //check incase we have a really small range if (fabs(rounded_min) > 0 && fabs(rounded_max) > 0) { - m_rangeSelectors["FuryRange"]->setRange(rounded_min, rounded_max); + xRangeSelector->setRange(rounded_min, rounded_max); m_dblManager->setValue(m_properties["ELow"], rounded_min); m_dblManager->setValue(m_properties["EHigh"], rounded_max); } else { - m_rangeSelectors["FuryRange"]->setRange(range.first, range.second); + xRangeSelector->setRange(range.first, range.second); m_dblManager->setValue(m_properties["ELow"], range.first); m_dblManager->setValue(m_properties["EHigh"], range.second); } @@ -327,10 +329,12 @@ namespace IDA void Fury::updateRS(QtProperty* prop, double val) { + auto xRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryRange"); + if(prop == m_properties["ELow"]) - m_rangeSelectors["FuryRange"]->setMinimum(val); + xRangeSelector->setMinimum(val); else if(prop == m_properties["EHigh"]) - m_rangeSelectors["FuryRange"]->setMaximum(val); + xRangeSelector->setMaximum(val); } } // namespace IDA diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/FuryFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/FuryFit.cpp index 8c8840ab7ace64910c13941f344f8c07b0f7815a..e806dabff5c11fc2f283f0d9b54ef741095ab6bf 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/FuryFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/FuryFit.cpp @@ -47,15 +47,15 @@ namespace IDA m_ffTree = new QtTreePropertyBrowser(m_parentWidget); m_uiForm.properties->addWidget(m_ffTree); - m_rangeSelectors["FuryFitRange"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["FuryFitRange"], SIGNAL(minValueChanged(double)), this, SLOT(xMinSelected(double))); - connect(m_rangeSelectors["FuryFitRange"], SIGNAL(maxValueChanged(double)), this, SLOT(xMaxSelected(double))); + auto fitRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryFitRange"); + connect(fitRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(xMinSelected(double))); + connect(fitRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(xMaxSelected(double))); - m_rangeSelectors["FuryFitBackground"] = new MantidQt::MantidWidgets::RangeSelector(m_uiForm.ppPlot, - MantidQt::MantidWidgets::RangeSelector::YSINGLE); - m_rangeSelectors["FuryFitBackground"]->setRange(0.0,1.0); - m_rangeSelectors["FuryFitBackground"]->setColour(Qt::darkGreen); - connect(m_rangeSelectors["FuryFitBackground"], SIGNAL(minValueChanged(double)), this, SLOT(backgroundSelected(double))); + auto backgroundRangeSelector = m_uiForm.ppPlot->addRangeSelector("FuryFitBackground", + MantidWidgets::RangeSelector::YSINGLE); + backgroundRangeSelector->setRange(0.0,1.0); + backgroundRangeSelector->setColour(Qt::darkGreen); + connect(backgroundRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(backgroundSelected(double))); // setupTreePropertyBrowser m_ffRangeManager = new QtDoublePropertyManager(m_parentWidget); @@ -399,7 +399,7 @@ namespace IDA { const QPair<double, double> curveRange = m_uiForm.ppPlot->getCurveRange("Sample"); const std::pair<double, double> range(curveRange.first, curveRange.second); - m_rangeSelectors["FuryFitRange"]->setRange(range.first, range.second); + m_uiForm.ppPlot->getRangeSelector("FuryFitRange")->setRange(range.first, range.second); m_ffRangeManager->setRange(m_properties["StartX"], range.first, range.second); m_ffRangeManager->setRange(m_properties["EndX"], range.first, range.second); @@ -489,17 +489,20 @@ namespace IDA void FuryFit::propertyChanged(QtProperty* prop, double val) { + auto fitRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryFitRange"); + auto backgroundRangeSelector = m_uiForm.ppPlot->getRangeSelector("FuryFitBackground"); + if ( prop == m_properties["StartX"] ) { - m_rangeSelectors["FuryFitRange"]->setMinimum(val); + fitRangeSelector->setMinimum(val); } else if ( prop == m_properties["EndX"] ) { - m_rangeSelectors["FuryFitRange"]->setMaximum(val); + fitRangeSelector->setMaximum(val); } else if ( prop == m_properties["BackgroundA0"]) { - m_rangeSelectors["FuryFitBackground"]->setMinimum(val); + backgroundRangeSelector->setMinimum(val); m_dblManager->setValue(m_properties["Exponential1.Intensity"], 1.0-val); m_dblManager->setValue(m_properties["Exponential2.Intensity"], 1.0-val); m_dblManager->setValue(m_properties["StretchedExp.Intensity"], 1.0-val); @@ -508,7 +511,7 @@ namespace IDA || prop == m_properties["Exponential2.Intensity"] || prop == m_properties["StretchedExp.Intensity"]) { - m_rangeSelectors["FuryFitBackground"]->setMinimum(1.0-val); + backgroundRangeSelector->setMinimum(1.0-val); m_dblManager->setValue(m_properties["Exponential1.Intensity"], val); m_dblManager->setValue(m_properties["Exponential2.Intensity"], val); m_dblManager->setValue(m_properties["StretchedExp.Intensity"], val); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp index 058459d8cc980e131cf80bdc5f905b5307184e60..f7d72f27df3d7666af4a7f673b0d272128161fe3 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp @@ -46,9 +46,9 @@ namespace CustomInterfaces m_propTrees["CalPropTree"]->addProperty(m_properties["CalBackMax"]); // Cal plot range selectors - m_rangeSelectors["CalPeak"] = new MantidWidgets::RangeSelector(m_uiForm.ppCalibration); - m_rangeSelectors["CalBackground"] = new MantidWidgets::RangeSelector(m_uiForm.ppCalibration); - m_rangeSelectors["CalBackground"]->setColour(Qt::darkGreen); //Dark green to signify background range + auto calPeak = m_uiForm.ppCalibration->addRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->addRangeSelector("CalBackground"); + calBackground->setColour(Qt::darkGreen); //Dark green to signify background range // RES PROPERTY TREE m_propTrees["ResPropTree"] = new QtTreePropertyBrowser(); @@ -97,27 +97,28 @@ namespace CustomInterfaces // Res plot range selectors // Create ResBackground first so ResPeak is drawn above it - m_rangeSelectors["ResBackground"] = new MantidWidgets::RangeSelector(m_uiForm.ppResolution, - MantidQt::MantidWidgets::RangeSelector::XMINMAX, true, false); - m_rangeSelectors["ResBackground"]->setColour(Qt::darkGreen); - m_rangeSelectors["ResPeak"] = new MantidWidgets::RangeSelector(m_uiForm.ppResolution, - MantidQt::MantidWidgets::RangeSelector::XMINMAX, true, true); + auto resBackground = m_uiForm.ppResolution->addRangeSelector("ResBackground"); + resBackground->setColour(Qt::darkGreen); + auto resPeak = m_uiForm.ppResolution->addRangeSelector("ResPeak"); + resPeak->setInfoOnly(true); // SIGNAL/SLOT CONNECTIONS // Update instrument information when a new instrument config is selected connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setDefaultInstDetails())); - connect(m_rangeSelectors["ResPeak"], SIGNAL(rangeChanged(double, double)), m_rangeSelectors["ResBackground"], SLOT(setRange(double, double))); + connect(resPeak, SIGNAL(rangeChanged(double, double)), + resBackground, SLOT(setRange(double, double))); // Update property map when a range seclector is moved - connect(m_rangeSelectors["CalPeak"], SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); - connect(m_rangeSelectors["CalPeak"], SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); - connect(m_rangeSelectors["CalBackground"], SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); - connect(m_rangeSelectors["CalBackground"], SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); - connect(m_rangeSelectors["ResPeak"], SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); - connect(m_rangeSelectors["ResPeak"], SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); - connect(m_rangeSelectors["ResBackground"], SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); - connect(m_rangeSelectors["ResBackground"], SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); + connect(calPeak, SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); + connect(calPeak, SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); + connect(calBackground, SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); + connect(calBackground, SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); + connect(resPeak, SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); + connect(resPeak, SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); + connect(resBackground, SIGNAL(minValueChanged(double)), this, SLOT(calMinChanged(double))); + connect(resBackground, SIGNAL(maxValueChanged(double)), this, SLOT(calMaxChanged(double))); + // Update range selctor positions when a value in the double manager changes connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(calUpdateRS(QtProperty*, double))); // Plot miniplots after a file has loaded @@ -348,8 +349,10 @@ namespace CustomInterfaces QPair<double, double> peakRange(ranges["peak-start-tof"], ranges["peak-end-tof"]); QPair<double, double> backgroundRange(ranges["back-start-tof"], ranges["back-end-tof"]); - setRangeSelector("CalPeak", m_properties["CalPeakMin"], m_properties["CalPeakMax"], peakRange); - setRangeSelector("CalBackground", m_properties["CalBackMin"], m_properties["CalBackMax"], backgroundRange); + auto calPeak = m_uiForm.ppCalibration->getRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->getRangeSelector("CalBackground"); + setRangeSelector(calPeak, m_properties["CalPeakMin"], m_properties["CalPeakMax"], peakRange); + setRangeSelector(calBackground, m_properties["CalBackMin"], m_properties["CalBackMax"], backgroundRange); } /** @@ -396,8 +399,10 @@ namespace CustomInterfaces m_uiForm.ppCalibration->addSpectrum("Raw", input, 0); m_uiForm.ppCalibration->resizeX(); - setPlotPropertyRange("CalPeak", m_properties["CalELow"], m_properties["CalEHigh"], range); - setPlotPropertyRange("CalBackground", m_properties["CalStart"], m_properties["CalEnd"], range); + auto calPeak = m_uiForm.ppCalibration->getRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->getRangeSelector("CalBackground"); + setPlotPropertyRange(calPeak, m_properties["CalELow"], m_properties["CalEHigh"], range); + setPlotPropertyRange(calBackground, m_properties["CalStart"], m_properties["CalEnd"], range); m_uiForm.ppCalibration->replot(); @@ -456,7 +461,8 @@ namespace CustomInterfaces const Mantid::MantidVec & dataX = energyWs->readX(0); QPair<double, double> range(dataX.front(), dataX.back()); - setPlotPropertyRange("ResBackground", m_properties["ResStart"], m_properties["ResEnd"], range); + auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); + setPlotPropertyRange(resBackground, m_properties["ResStart"], m_properties["ResEnd"], range); m_uiForm.ppResolution->clear(); m_uiForm.ppResolution->addSpectrum("Energy", energyWs, 0); @@ -494,11 +500,13 @@ namespace CustomInterfaces // Set default rebinning bounds QPair<double, double> peakRange(-res*10, res*10); - setRangeSelector("ResPeak", m_properties["ResELow"], m_properties["ResEHigh"], peakRange); + auto resPeak = m_uiForm.ppResolution->getRangeSelector("ResPeak"); + setRangeSelector(resPeak, m_properties["ResELow"], m_properties["ResEHigh"], peakRange); // Set default background bounds QPair<double, double> backgroundRange(-res*9, -res*8); - setRangeSelector("ResBackground", m_properties["ResStart"], m_properties["ResEnd"], backgroundRange); + auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); + setRangeSelector(resBackground, m_properties["ResStart"], m_properties["ResEnd"], backgroundRange); } } } @@ -511,20 +519,26 @@ namespace CustomInterfaces */ void ISISCalibration::calMinChanged(double val) { + auto calPeak = m_uiForm.ppCalibration->getRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->getRangeSelector("CalBackground"); + auto resPeak = m_uiForm.ppResolution->getRangeSelector("ResPeak"); + auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); + MantidWidgets::RangeSelector* from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if ( from == m_rangeSelectors["CalPeak"] ) + + if(from == calPeak) { m_dblManager->setValue(m_properties["CalPeakMin"], val); } - else if ( from == m_rangeSelectors["CalBackground"] ) + else if(from == calBackground) { m_dblManager->setValue(m_properties["CalBackMin"], val); } - else if ( from == m_rangeSelectors["ResPeak"] ) + else if(from == resPeak) { m_dblManager->setValue(m_properties["ResELow"], val); } - else if ( from == m_rangeSelectors["ResBackground"] ) + else if(from == resBackground) { m_dblManager->setValue(m_properties["ResStart"], val); } @@ -538,20 +552,26 @@ namespace CustomInterfaces */ void ISISCalibration::calMaxChanged(double val) { + auto calPeak = m_uiForm.ppCalibration->getRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->getRangeSelector("CalBackground"); + auto resPeak = m_uiForm.ppResolution->getRangeSelector("ResPeak"); + auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); + MantidWidgets::RangeSelector* from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if ( from == m_rangeSelectors["CalPeak"] ) + + if(from == calPeak) { m_dblManager->setValue(m_properties["CalPeakMax"], val); } - else if ( from == m_rangeSelectors["CalBackground"] ) + else if(from == calBackground) { m_dblManager->setValue(m_properties["CalBackMax"], val); } - else if ( from == m_rangeSelectors["ResPeak"] ) + else if(from == resPeak) { m_dblManager->setValue(m_properties["ResEHigh"], val); } - else if ( from == m_rangeSelectors["ResBackground"] ) + else if(from == resBackground) { m_dblManager->setValue(m_properties["ResEnd"], val); } @@ -565,14 +585,19 @@ namespace CustomInterfaces */ void ISISCalibration::calUpdateRS(QtProperty* prop, double val) { - if ( prop == m_properties["CalPeakMin"] ) m_rangeSelectors["CalPeak"]->setMinimum(val); - else if ( prop == m_properties["CalPeakMax"] ) m_rangeSelectors["CalPeak"]->setMaximum(val); - else if ( prop == m_properties["CalBackMin"] ) m_rangeSelectors["CalBackground"]->setMinimum(val); - else if ( prop == m_properties["CalBackMax"] ) m_rangeSelectors["CalBackground"]->setMaximum(val); - else if ( prop == m_properties["ResStart"] ) m_rangeSelectors["ResBackground"]->setMinimum(val); - else if ( prop == m_properties["ResEnd"] ) m_rangeSelectors["ResBackground"]->setMaximum(val); - else if ( prop == m_properties["ResELow"] ) m_rangeSelectors["ResPeak"]->setMinimum(val); - else if ( prop == m_properties["ResEHigh"] ) m_rangeSelectors["ResPeak"]->setMaximum(val); + auto calPeak = m_uiForm.ppCalibration->getRangeSelector("CalPeak"); + auto calBackground = m_uiForm.ppCalibration->getRangeSelector("CalBackground"); + auto resPeak = m_uiForm.ppResolution->getRangeSelector("ResPeak"); + auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); + + if ( prop == m_properties["CalPeakMin"] ) calPeak->setMinimum(val); + else if ( prop == m_properties["CalPeakMax"] ) calPeak->setMaximum(val); + else if ( prop == m_properties["CalBackMin"] ) calBackground->setMinimum(val); + else if ( prop == m_properties["CalBackMax"] ) calBackground->setMaximum(val); + else if ( prop == m_properties["ResStart"] ) resBackground->setMinimum(val); + else if ( prop == m_properties["ResEnd"] ) resBackground->setMaximum(val); + else if ( prop == m_properties["ResELow"] ) resPeak->setMinimum(val); + else if ( prop == m_properties["ResEHigh"] ) resPeak->setMaximum(val); } /** @@ -582,8 +607,8 @@ namespace CustomInterfaces */ void ISISCalibration::resCheck(bool state) { - m_rangeSelectors["ResPeak"]->setVisible(state); - m_rangeSelectors["ResBackground"]->setVisible(state); + m_uiForm.ppResolution->getRangeSelector("ResPeak")->setVisible(state); + m_uiForm.ppResolution->getRangeSelector("ResBackground")->setVisible(state); // Toggle scale and smooth options m_uiForm.ckResolutionScale->setEnabled(state); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp index 2150358f795ba0846ceaf0ddb101a5e47a633a5a..45119aee24dc67ff1224b2de335968b854a726d4 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp @@ -72,12 +72,12 @@ namespace CustomInterfaces m_propTrees["SlicePropTree"]->addProperty(m_properties["BackgroundRange"]); // Slice plot - m_rangeSelectors["SlicePeak"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot); - m_rangeSelectors["SliceBackground"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot); + auto peakRangeSelector = m_uiForm.ppRawPlot->addRangeSelector("SlicePeak"); + auto backgroundRangeSelector = m_uiForm.ppRawPlot->addRangeSelector("SliceBackground"); // Setup second range - m_rangeSelectors["SliceBackground"]->setColour(Qt::darkGreen); // Dark green for background - m_rangeSelectors["SliceBackground"]->setRange(m_rangeSelectors["SlicePeak"]->getRange()); + backgroundRangeSelector->setColour(Qt::darkGreen); // Dark green for background + backgroundRangeSelector->setRange(peakRangeSelector->getRange()); // SIGNAL/SLOT CONNECTIONS @@ -85,8 +85,8 @@ namespace CustomInterfaces connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setDefaultInstDetails())); // Update properties when a range selector is changed - connect(m_rangeSelectors["SlicePeak"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeSelectorDropped(double, double))); - connect(m_rangeSelectors["SliceBackground"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeSelectorDropped(double, double))); + connect(peakRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeSelectorDropped(double, double))); + connect(backgroundRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeSelectorDropped(double, double))); // Update range selctors when a property is changed connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(doublePropertyChanged(QtProperty*, double))); @@ -235,10 +235,13 @@ namespace CustomInterfaces // Set peak and background ranges if(instDetails.size() >= 8) { - setRangeSelector("SlicePeak", m_properties["PeakStart"], m_properties["PeakEnd"], - qMakePair(instDetails["peak-start"].toDouble(), instDetails["peak-end"].toDouble())); - setRangeSelector("SliceBackground", m_properties["BackgroundStart"], m_properties["BackgroundEnd"], - qMakePair(instDetails["back-start"].toDouble(), instDetails["back-end"].toDouble())); + setRangeSelector(m_uiForm.ppRawPlot->getRangeSelector("SlicePeak"), + m_properties["PeakStart"], m_properties["PeakEnd"], + qMakePair(instDetails["peak-start"].toDouble(), instDetails["peak-end"].toDouble())); + + setRangeSelector(m_uiForm.ppRawPlot->getRangeSelector("SliceBackground"), + m_properties["BackgroundStart"], m_properties["BackgroundEnd"], + qMakePair(instDetails["back-start"].toDouble(), instDetails["back-end"].toDouble())); } } @@ -271,8 +274,10 @@ namespace CustomInterfaces m_uiForm.ppRawPlot->clear(); m_uiForm.ppRawPlot->addSpectrum("Raw", input, previewSpec); - setPlotPropertyRange("SlicePeak", m_properties["PeakStart"], m_properties["PeakEnd"], range); - setPlotPropertyRange("SliceBackground", m_properties["BackgroundStart"], m_properties["BackgroundEnd"], range); + setPlotPropertyRange(m_uiForm.ppRawPlot->getRangeSelector("SlicePeak"), + m_properties["PeakStart"], m_properties["PeakEnd"], range); + setPlotPropertyRange(m_uiForm.ppRawPlot->getRangeSelector("SliceBackground"), + m_properties["BackgroundStart"], m_properties["BackgroundEnd"], range); m_uiForm.ppRawPlot->resizeX(); } @@ -284,7 +289,7 @@ namespace CustomInterfaces */ void ISISDiagnostics::sliceTwoRanges(QtProperty*, bool state) { - m_rangeSelectors["SliceBackground"]->setVisible(state); + m_uiForm.ppRawPlot->getRangeSelector("SliceBackground")->setVisible(state); } /** @@ -301,12 +306,12 @@ namespace CustomInterfaces { MantidWidgets::RangeSelector* from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if(from == m_rangeSelectors["SlicePeak"]) + if(from == m_uiForm.ppRawPlot->getRangeSelector("SlicePeak")) { m_dblManager->setValue(m_properties["PeakStart"], min); m_dblManager->setValue(m_properties["PeakEnd"], max); } - else if(from == m_rangeSelectors["SliceBackground"]) + else if(from == m_uiForm.ppRawPlot->getRangeSelector("SliceBackground")) { m_dblManager->setValue(m_properties["BackgroundStart"], min); m_dblManager->setValue(m_properties["BackgroundEnd"], max); @@ -321,10 +326,13 @@ namespace CustomInterfaces */ void ISISDiagnostics::doublePropertyChanged(QtProperty* prop, double val) { - if(prop == m_properties["PeakStart"]) m_rangeSelectors["SlicePeak"]->setMinimum(val); - else if(prop == m_properties["PeakEnd"]) m_rangeSelectors["SlicePeak"]->setMaximum(val); - else if(prop == m_properties["BackgroundStart"]) m_rangeSelectors["SliceBackground"]->setMinimum(val); - else if(prop == m_properties["BackgroundEnd"]) m_rangeSelectors["SliceBackground"]->setMaximum(val); + auto peakRangeSelector = m_uiForm.ppRawPlot->getRangeSelector("SlicePeak"); + auto backgroundRangeSelector = m_uiForm.ppRawPlot->getRangeSelector("SliceBackground"); + + if(prop == m_properties["PeakStart"]) peakRangeSelector->setMinimum(val); + else if(prop == m_properties["PeakEnd"]) peakRangeSelector->setMaximum(val); + else if(prop == m_properties["BackgroundStart"]) backgroundRangeSelector->setMinimum(val); + else if(prop == m_properties["BackgroundEnd"]) backgroundRangeSelector->setMaximum(val); else if(prop == m_properties["PreviewSpec"]) handleNewFile(); if(prop != m_properties["PreviewSpec"]) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectMoments.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectMoments.cpp index 48f35777924b0f3f8bde237f3508b7de8903ee93..dc1563504a4f114ac471271c79f5afd13c4e333e 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectMoments.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectMoments.cpp @@ -23,8 +23,8 @@ namespace CustomInterfaces const unsigned int NUM_DECIMALS = 6; // RAW PLOT - m_rangeSelectors["MomentsRangeSelector"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot); - m_rangeSelectors["MomentsRangeSelector"]->setInfoOnly(false); + auto xRangeSelector = m_uiForm.ppRawPlot->addRangeSelector("XRange"); + xRangeSelector->setInfoOnly(false); // PROPERTY TREE m_propTrees["MomentsPropTree"] = new QtTreePropertyBrowser(); @@ -41,7 +41,7 @@ namespace CustomInterfaces connect(m_uiForm.dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(handleSampleInputReady(const QString&))); - connect(m_rangeSelectors["MomentsRangeSelector"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeChanged(double, double))); + connect(xRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(rangeChanged(double, double))); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateProperties(QtProperty*, double))); // Update the preview plot when the algorithm completes @@ -114,8 +114,10 @@ namespace CustomInterfaces m_uiForm.ppRawPlot->clear(); m_uiForm.ppRawPlot->addSpectrum("Raw", filename, 0); QPair<double, double> range = m_uiForm.ppRawPlot->getCurveRange("Raw"); - setRangeSelector("MomentsRangeSelector", m_properties["EMin"], m_properties["EMax"], range); - setPlotPropertyRange("MomentsRangeSelector", m_properties["EMin"], m_properties["EMax"], range); + + auto xRangeSelector = m_uiForm.ppRawPlot->getRangeSelector("XRange"); + setRangeSelector(xRangeSelector, m_properties["EMin"], m_properties["EMax"], range); + setPlotPropertyRange(xRangeSelector, m_properties["EMin"], m_properties["EMax"], range); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateProperties(QtProperty*, double))); @@ -154,7 +156,7 @@ namespace CustomInterfaces } else { - m_rangeSelectors["MomentsRangeSelector"]->setMinimum(val); + m_uiForm.ppRawPlot->getRangeSelector("XRange")->setMinimum(val); } } else if (prop == m_properties["EMax"]) @@ -166,7 +168,7 @@ namespace CustomInterfaces } else { - m_rangeSelectors["MomentsRangeSelector"]->setMaximum(val); + m_uiForm.ppRawPlot->getRangeSelector("XRange")->setMaximum(val); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp index 127a699513cdc01953a36e5b5e32fdfc528d0607..b5de049ce9573a3de4f6ff19193b0c7fbd4e9466 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp @@ -69,46 +69,50 @@ namespace CustomInterfaces m_propTrees["SymmPVPropTree"]->addProperty(m_properties["DeltaY"]); // Indicators for Y value at each EMin position - m_rangeSelectors["NegativeEMinYPos"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot, - MantidWidgets::RangeSelector::YSINGLE, true, true); - m_rangeSelectors["PositiveEMinYPos"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot, - MantidWidgets::RangeSelector::YSINGLE, true, true); - - m_rangeSelectors["NegativeEMinYPos"]->setColour(Qt::red); - m_rangeSelectors["PositiveEMinYPos"]->setColour(Qt::blue); - m_rangeSelectors["NegativeEMinYPos"]->setMinimum(0); - m_rangeSelectors["PositiveEMinYPos"]->setMinimum(0); + auto negativeEMinYPos = m_uiForm.ppRawPlot->addRangeSelector("NegativeEMinYPos", + MantidWidgets::RangeSelector::YSINGLE); + negativeEMinYPos->setInfoOnly(true); + negativeEMinYPos->setColour(Qt::blue); + negativeEMinYPos->setMinimum(0.0); + + auto positiveEMinYPos = m_uiForm.ppRawPlot->addRangeSelector("PositiveEMinYPos", + MantidWidgets::RangeSelector::YSINGLE); + positiveEMinYPos->setInfoOnly(true); + positiveEMinYPos->setColour(Qt::red); + positiveEMinYPos->setMinimum(0.0); // Indicator for centre of symmetry (x=0) - m_rangeSelectors["CentreMark_Raw"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot, - MantidWidgets::RangeSelector::XSINGLE, true, true); - m_rangeSelectors["CentreMark_Raw"]->setColour(Qt::cyan); - m_rangeSelectors["CentreMark_Raw"]->setMinimum(0.0); + auto centreMarkRaw = m_uiForm.ppRawPlot->addRangeSelector("CentreMark", + MantidWidgets::RangeSelector::XSINGLE); + centreMarkRaw->setInfoOnly(true); + centreMarkRaw->setColour(Qt::cyan); + centreMarkRaw->setMinimum(0.0); // Indicators for negative and positive X range values on X axis // The user can use these to move the X range // Note that the max and min of the negative range selector corespond to the opposite X value // i.e. RS min is X max - m_rangeSelectors["NegativeE_Raw"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot); - m_rangeSelectors["PositiveE_Raw"] = new MantidWidgets::RangeSelector(m_uiForm.ppRawPlot); + auto negativeERaw = m_uiForm.ppRawPlot->addRangeSelector("NegativeE"); + negativeERaw->setColour(Qt::darkGreen); - m_rangeSelectors["NegativeE_Raw"]->setColour(Qt::darkGreen); - m_rangeSelectors["PositiveE_Raw"]->setColour(Qt::darkGreen); + auto positiveERaw = m_uiForm.ppRawPlot->addRangeSelector("PositiveE"); + positiveERaw->setColour(Qt::darkGreen); // Indicators for negative and positive X range values on X axis - m_rangeSelectors["NegativeE_PV"] = new MantidWidgets::RangeSelector(m_uiForm.ppPreviewPlot, - MantidWidgets::RangeSelector::XMINMAX, true, true); - m_rangeSelectors["PositiveE_PV"] = new MantidWidgets::RangeSelector(m_uiForm.ppPreviewPlot, - MantidWidgets::RangeSelector::XMINMAX, true, true); + auto negativeEPV = m_uiForm.ppPreviewPlot->addRangeSelector("NegativeE"); + negativeEPV->setInfoOnly(true); + negativeEPV->setColour(Qt::darkGreen); - m_rangeSelectors["NegativeE_PV"]->setColour(Qt::darkGreen); - m_rangeSelectors["PositiveE_PV"]->setColour(Qt::darkGreen); + auto positiveEPV = m_uiForm.ppPreviewPlot->addRangeSelector("PositiveE"); + positiveEPV->setInfoOnly(true); + positiveEPV->setColour(Qt::darkGreen); // Indicator for centre of symmetry (x=0) - m_rangeSelectors["CentreMark_PV"] = new MantidWidgets::RangeSelector(m_uiForm.ppPreviewPlot, - MantidWidgets::RangeSelector::XSINGLE, true, true); - m_rangeSelectors["CentreMark_PV"]->setColour(Qt::cyan); - m_rangeSelectors["CentreMark_PV"]->setMinimum(0.0); + auto centreMarkPV = m_uiForm.ppPreviewPlot->addRangeSelector("CentreMark", + MantidWidgets::RangeSelector::XSINGLE); + centreMarkPV->setInfoOnly(true); + centreMarkPV->setColour(Qt::cyan); + centreMarkPV->setMinimum(0.0); // SIGNAL/SLOT CONNECTIONS // Validate the E range when it is changed @@ -120,10 +124,10 @@ namespace CustomInterfaces // Preview symmetrise connect(m_uiForm.pbPreview, SIGNAL(clicked()), this, SLOT(preview())); // X range selectors - connect(m_rangeSelectors["PositiveE_Raw"], SIGNAL(minValueChanged(double)), this, SLOT(xRangeMinChanged(double))); - connect(m_rangeSelectors["PositiveE_Raw"], SIGNAL(maxValueChanged(double)), this, SLOT(xRangeMaxChanged(double))); - connect(m_rangeSelectors["NegativeE_Raw"], SIGNAL(minValueChanged(double)), this, SLOT(xRangeMinChanged(double))); - connect(m_rangeSelectors["NegativeE_Raw"], SIGNAL(maxValueChanged(double)), this, SLOT(xRangeMaxChanged(double))); + connect(positiveERaw, SIGNAL(minValueChanged(double)), this, SLOT(xRangeMinChanged(double))); + connect(positiveERaw, SIGNAL(maxValueChanged(double)), this, SLOT(xRangeMaxChanged(double))); + connect(negativeERaw, SIGNAL(minValueChanged(double)), this, SLOT(xRangeMinChanged(double))); + connect(negativeERaw, SIGNAL(maxValueChanged(double)), this, SLOT(xRangeMaxChanged(double))); // Set default X range values m_dblManager->setValue(m_properties["EMin"], 0.1); @@ -208,8 +212,8 @@ namespace CustomInterfaces double symmRange = std::max(fabs(axisRange.first), fabs(axisRange.second)); // Set valid range for range selectors - m_rangeSelectors["NegativeE_Raw"]->setRange(-symmRange, 0); - m_rangeSelectors["PositiveE_Raw"]->setRange(0, symmRange); + m_uiForm.ppRawPlot->getRangeSelector("NegativeE")->setRange(-symmRange, 0); + m_uiForm.ppRawPlot->getRangeSelector("PositiveE")->setRange(0, symmRange); // Set some default (and valid) values for E range m_dblManager->setValue(m_properties["EMax"], axisRange.second); @@ -401,8 +405,8 @@ namespace CustomInterfaces m_dblManager->setValue(m_properties["DeltaY"], deltaY); // Set indicator positions - m_rangeSelectors["NegativeEMinYPos"]->setMinimum(negativeY); - m_rangeSelectors["PositiveEMinYPos"]->setMinimum(positiveY); + m_uiForm.ppRawPlot->getRangeSelector("NegativeEMinYPos")->setMinimum(negativeY); + m_uiForm.ppRawPlot->getRangeSelector("PositiveEMinYPos")->setMinimum(positiveY); // Plot preview plot size_t spectrumIndex = symmWS->getIndexFromSpectrumNumber(spectrumNumber); @@ -421,24 +425,29 @@ namespace CustomInterfaces */ void IndirectSymmetrise::updateRangeSelectors(QtProperty *prop, double value) { + auto negativeERaw = m_uiForm.ppRawPlot->getRangeSelector("NegativeE"); + auto positiveERaw = m_uiForm.ppRawPlot->getRangeSelector("PositiveE"); + auto negativeEPV = m_uiForm.ppPreviewPlot->getRangeSelector("NegativeE"); + auto positiveEPV = m_uiForm.ppPreviewPlot->getRangeSelector("PositiveE"); + value = fabs(value); if(prop == m_properties["EMin"]) { - m_rangeSelectors["NegativeE_Raw"]->setMaximum(-value); - m_rangeSelectors["PositiveE_Raw"]->setMinimum(value); + negativeERaw->setMaximum(-value); + positiveERaw->setMinimum(value); - m_rangeSelectors["NegativeE_PV"]->setMinimum(-value); - m_rangeSelectors["PositiveE_PV"]->setMinimum(value); + negativeEPV->setMinimum(-value); + positiveEPV->setMinimum(value); } if(prop == m_properties["EMax"]) { - m_rangeSelectors["NegativeE_Raw"]->setMinimum(-value); - m_rangeSelectors["PositiveE_Raw"]->setMaximum(value); + negativeERaw->setMinimum(-value); + positiveERaw->setMaximum(value); - m_rangeSelectors["NegativeE_PV"]->setMaximum(-value); - m_rangeSelectors["PositiveE_PV"]->setMaximum(value); + negativeEPV->setMaximum(-value); + positiveEPV->setMaximum(value); } } @@ -449,13 +458,16 @@ namespace CustomInterfaces */ void IndirectSymmetrise::xRangeMinChanged(double value) { + auto negativeERaw = m_uiForm.ppRawPlot->getRangeSelector("NegativeE"); + auto positiveERaw = m_uiForm.ppRawPlot->getRangeSelector("PositiveE"); + MantidWidgets::RangeSelector *from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if(from == m_rangeSelectors["PositiveE_Raw"]) + if(from == positiveERaw) { m_dblManager->setValue(m_properties["EMin"], std::abs(value)); } - else if(from == m_rangeSelectors["NegativeE_Raw"]) + else if(from == negativeERaw) { m_dblManager->setValue(m_properties["EMax"], std::abs(value)); } @@ -468,13 +480,16 @@ namespace CustomInterfaces */ void IndirectSymmetrise::xRangeMaxChanged(double value) { + auto negativeERaw = m_uiForm.ppRawPlot->getRangeSelector("NegativeE"); + auto positiveERaw = m_uiForm.ppRawPlot->getRangeSelector("PositiveE"); + MantidWidgets::RangeSelector *from = qobject_cast<MantidWidgets::RangeSelector*>(sender()); - if(from == m_rangeSelectors["PositiveE_Raw"]) + if(from == positiveERaw) { m_dblManager->setValue(m_properties["EMax"], std::abs(value)); } - else if(from == m_rangeSelectors["NegativeE_Raw"]) + else if(from == negativeERaw) { m_dblManager->setValue(m_properties["EMin"], std::abs(value)); } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp index 62e87cf653f4d83d78de43ac8888096869d8b2e5..2e35ed5775cab275e89d46d050334fe3a8412936 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IndirectTab.cpp @@ -4,10 +4,12 @@ #include "MantidKernel/Logger.h" #include "MantidQtAPI/AlgorithmDialog.h" #include "MantidQtAPI/InterfaceManager.h" +#include "MantidQtMantidWidgets/RangeSelector.h" using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::Kernel; +using namespace MantidQt::MantidWidgets; namespace { @@ -22,7 +24,7 @@ namespace CustomInterfaces /** Constructor */ IndirectTab::IndirectTab(QObject* parent) : QObject(parent), - m_rangeSelectors(), m_properties(), + m_properties(), m_dblManager(new QtDoublePropertyManager()), m_blnManager(new QtBoolPropertyManager()), m_grpManager(new QtGroupPropertyManager()), m_dblEdFac(new DoubleEditorFactory()), m_pythonRunner(), @@ -146,36 +148,36 @@ namespace CustomInterfaces * Sets the edge bounds of plot to prevent the user inputting invalid values * Also sets limits for range selector movement * - * @param rsID :: The string index of the range selector in the map m_rangeSelectors + * @param rs :: Pointer to the RangeSelector * @param min :: The lower bound property in the property browser * @param max :: The upper bound property in the property browser * @param bounds :: The upper and lower bounds to be set */ - void IndirectTab::setPlotPropertyRange(const QString& rsID, QtProperty* min, QtProperty* max, + void IndirectTab::setPlotPropertyRange(RangeSelector * rs, QtProperty* min, QtProperty* max, const QPair<double, double> & bounds) { m_dblManager->setMinimum(min, bounds.first); m_dblManager->setMaximum(min, bounds.second); m_dblManager->setMinimum(max, bounds.first); m_dblManager->setMaximum(max, bounds.second); - m_rangeSelectors[rsID]->setRange(bounds.first, bounds.second); + rs->setRange(bounds.first, bounds.second); } /** * Set the position of the range selectors on the mini plot * - * @param rsID :: The string index of the range selector in the map m_rangeSelectors + * @param rs :: Pointer to the RangeSelector * @param lower :: The lower bound property in the property browser * @param upper :: The upper bound property in the property browser * @param bounds :: The upper and lower bounds to be set */ - void IndirectTab::setRangeSelector(const QString& rsID, QtProperty* lower, QtProperty* upper, + void IndirectTab::setRangeSelector(RangeSelector * rs, QtProperty* lower, QtProperty* upper, const QPair<double, double> & bounds) { m_dblManager->setValue(lower, bounds.first); m_dblManager->setValue(upper, bounds.second); - m_rangeSelectors[rsID]->setMinimum(bounds.first); - m_rangeSelectors[rsID]->setMaximum(bounds.second); + rs->setMinimum(bounds.first); + rs->setMaximum(bounds.second); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/JumpFit.cpp index 5fa2ba6da67deafac4326c88de9ce8fbd94a3a28..8e4f96c8d6df3ee2305d9ef3d25a7c96f12c57a4 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/JumpFit.cpp @@ -19,8 +19,8 @@ namespace MantidQt m_uiForm.setupUi(parent); // Create range selector - m_rangeSelectors["JumpFitQ"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["JumpFitQ"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(qRangeChanged(double, double))); + auto qRangeSelector = m_uiForm.ppPlot->addRangeSelector("JumpFitQ"); + connect(qRangeSelector, SIGNAL(selectionChangedLazy(double, double)), this, SLOT(qRangeChanged(double, double))); // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); @@ -213,6 +213,8 @@ namespace MantidQt findAllWidths(mws); + auto qRangeSelector = m_uiForm.ppPlot->getRangeSelector("JumpFitQ"); + if(m_spectraList.size() > 0) { m_uiForm.cbWidth->setEnabled(true); @@ -227,11 +229,11 @@ namespace MantidQt // Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) - setRangeSelector("JumpFitQ", m_properties["QMin"], m_properties["QMax"], res); + setRangeSelector(qRangeSelector, m_properties["QMin"], m_properties["QMax"], res); else - setRangeSelector("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); + setRangeSelector(qRangeSelector, m_properties["QMin"], m_properties["QMax"], range); - setPlotPropertyRange("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); + setPlotPropertyRange(qRangeSelector, m_properties["QMin"], m_properties["QMax"], range); } else { @@ -341,13 +343,15 @@ namespace MantidQt */ void JumpFit::updateProperties(QtProperty* prop, double val) { + auto qRangeSelector = m_uiForm.ppPlot->getRangeSelector("JumpFitQ"); + if(prop == m_properties["QMin"]) { - updateLowerGuide(m_rangeSelectors["JumpFitQ"], m_properties["QMin"], m_properties["QMax"], val); + updateLowerGuide(qRangeSelector, m_properties["QMin"], m_properties["QMax"], val); } else if (prop == m_properties["QMax"]) { - updateUpperGuide(m_rangeSelectors["JumpFitQ"], m_properties["QMin"], m_properties["QMax"], val); + updateUpperGuide(qRangeSelector, m_properties["QMin"], m_properties["QMax"], val); } } } // namespace CustomInterfaces diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/MSDFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/MSDFit.cpp index 2ce2d37c1d62f638d458b53d63d0fe3d2c7f6a06..8e9c83c25e4220db9e8badaa56f5cc1e9fc45d11 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/MSDFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/MSDFit.cpp @@ -44,10 +44,10 @@ namespace IDA m_msdTree->addProperty(m_properties["Start"]); m_msdTree->addProperty(m_properties["End"]); - m_rangeSelectors["MSDRange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); + auto fitRangeSelector = m_uiForm.ppPlot->addRangeSelector("MSDRange"); - connect(m_rangeSelectors["MSDRange"], SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); - connect(m_rangeSelectors["MSDRange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); + connect(fitRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minChanged(double))); + connect(fitRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double))); connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double))); connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString&)), this, SLOT(newDataLoaded(const QString&))); @@ -248,7 +248,7 @@ namespace IDA try { QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample"); - m_rangeSelectors["MSDRange"]->setRange(range.first, range.second); + m_uiForm.ppPlot->getRangeSelector("MSDRange")->setRange(range.first, range.second); } catch(std::invalid_argument & exc) { @@ -294,8 +294,10 @@ namespace IDA void MSDFit::updateRS(QtProperty* prop, double val) { - if ( prop == m_properties["Start"] ) m_rangeSelectors["MSDRange"]->setMinimum(val); - else if ( prop == m_properties["End"] ) m_rangeSelectors["MSDRange"]->setMaximum(val); + auto fitRangeSelector = m_uiForm.ppPlot->getRangeSelector("MSDRange"); + + if(prop == m_properties["Start"]) fitRangeSelector->setMinimum(val); + else if(prop == m_properties["End"]) fitRangeSelector->setMaximum(val); } } // namespace IDA diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp index b6c99479cf4fad51bbd6837c890f404e60f8b6a6..45f9cfb9f52c6980186d1fea721f2f2fbaccb101 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp @@ -15,9 +15,9 @@ namespace MantidQt m_uiForm.setupUi(parent); // Create range selector - m_rangeSelectors["QuasiERange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["QuasiERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); - connect(m_rangeSelectors["QuasiERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("QuasiERange"); + connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); // Add the properties browser to the UI form m_uiForm.treeSpace->addWidget(m_propTree); @@ -276,8 +276,10 @@ namespace MantidQt updateMiniPlot(); QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample"); - setRangeSelector("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); - setPlotPropertyRange("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("QuasiERange"); + + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); + setPlotPropertyRange(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); } /** @@ -308,13 +310,15 @@ namespace MantidQt */ void Quasi::updateProperties(QtProperty* prop, double val) { + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("QuasiERange"); + if(prop == m_properties["EMin"]) { - updateLowerGuide(m_rangeSelectors["QuasiERange"], m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_rangeSelectors["QuasiERange"], m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp index 6cd8e4e43a6af21c1f535575b1446e728c5002ec..ff425165cfb37cb57283e491ef3cf963f17448cb 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp @@ -14,9 +14,9 @@ namespace MantidQt m_uiForm.setupUi(parent); // Create range selector - m_rangeSelectors["ResNormERange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["ResNormERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); - connect(m_rangeSelectors["ResNormERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("ResNormERange"); + connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); @@ -132,6 +132,8 @@ namespace MantidQt MatrixWorkspace_sptr vanWs = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(filename.toStdString()); m_uiForm.spPreviewSpectrum->setMaximum(static_cast<int>(vanWs->getNumberHistograms()) - 1); + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("ResNormERange"); + //Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) { @@ -139,14 +141,14 @@ namespace MantidQt res.first = res.first * 10; res.second = res.second * 10; - setRangeSelector("ResNormERange", m_properties["EMin"], m_properties["EMax"], res); + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], res); } else { - setRangeSelector("ResNormERange", m_properties["EMin"], m_properties["EMax"], range); + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); } - setPlotPropertyRange("ResNormERange", m_properties["EMin"], m_properties["EMax"], range); + setPlotPropertyRange(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); } /** @@ -177,13 +179,15 @@ namespace MantidQt */ void ResNorm::updateProperties(QtProperty* prop, double val) { + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("ResNormERange"); + if(prop == m_properties["EMin"]) { - updateLowerGuide(m_rangeSelectors["ResNormERange"], m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_rangeSelectors["ResNormERange"], m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Stretch.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Stretch.cpp index 78f13b6113eba92606f173de483b729ec919f7ec..22186a4b8c02300cdfb290e962f2099dd43f327c 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Stretch.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/Stretch.cpp @@ -17,9 +17,9 @@ namespace MantidQt // Create range selector - m_rangeSelectors["StretchERange"] = new MantidWidgets::RangeSelector(m_uiForm.ppPlot); - connect(m_rangeSelectors["StretchERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); - connect(m_rangeSelectors["StretchERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("StretchERange"); + connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); @@ -153,8 +153,9 @@ namespace MantidQt { m_uiForm.ppPlot->addSpectrum("Sample", filename, 0); QPair<double, double> range = m_uiForm.ppPlot->getCurveRange("Sample"); - setRangeSelector("StretchERange", m_properties["EMin"], m_properties["EMax"], range); - setPlotPropertyRange("StretchERange", m_properties["EMin"], m_properties["EMax"], range); + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("StretchERange"); + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); + setPlotPropertyRange(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); } /** @@ -185,13 +186,15 @@ namespace MantidQt */ void Stretch::updateProperties(QtProperty* prop, double val) { + auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("StretchERange"); + if(prop == m_properties["EMin"]) { - updateLowerGuide(m_rangeSelectors["StretchERange"], m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_rangeSelectors["StretchERange"], m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(eRangeSelector, m_properties["EMin"], m_properties["EMax"], val); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp index 22c2f7fd75ae174cb3780ea84d4a835187038369..2721c65258697ec121827a56a268a61e343d3184 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp @@ -1999,15 +1999,12 @@ void MuonAnalysis::plotSpectrum(const QString& wsName, bool logScale) { QStringList& s = acquireWindowScript; // To keep short - s << "w = graph('%WSNAME%-1')"; - s << "if w == None:"; - s << " pw = newGraph('%WSNAME%', 0)"; - s << " w = plotSpectrum('%WSNAME%', 0, %ERRORS%, %CONNECT%, window = pw)"; - s << " w.setObjectName('%WSNAME%')"; - s << "else:"; - s << " plotSpectrum('%WSNAME%', 0, %ERRORS%, %CONNECT%, window = w, clearWindow = True)"; - s << " w.show()"; - s << " w.setFocus()"; + s << "pw = newGraph('%WSNAME%-1', 0)"; + s << "w = plotSpectrum('%WSNAME%', 0, %ERRORS%, %CONNECT%, window = pw, clearWindow = True)"; + s << "w.setName('%WSNAME%-1')"; + s << "w.setObjectName('%WSNAME%')"; + s << "w.show()"; + s << "w.setFocus()"; } QString pyS; diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PreviewPlot.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PreviewPlot.h index 13250323b0455137caf1528d1cb21b6e26e1babb..b33d9f330f01014ba3af9be08736d10c90244c83 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PreviewPlot.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/PreviewPlot.h @@ -4,6 +4,7 @@ #include "ui_PreviewPlot.h" #include "WidgetDllOption.h" +#include "MantidQtMantidWidgets/RangeSelector.h" #include "MantidQtAPI/MantidWidget.h" #include "MantidAPI/MatrixWorkspace.h" @@ -11,6 +12,7 @@ #include <QActionGroup> #include <QHBoxLayout> #include <QLabel> +#include <QMap> #include <QMenu> #include <qwt_plot.h> @@ -81,10 +83,21 @@ namespace MantidWidgets bool hasCurve(const QString & curveName); + RangeSelector * addRangeSelector(const QString & rsName, + RangeSelector::SelectType type = RangeSelector::XMINMAX); + RangeSelector * getRangeSelector(const QString & rsName); + void removeRangeSelector(const QString & rsName, bool del); + + bool hasRangeSelector(const QString & rsName); + + QString getAxisType(int axisID); + signals: /// Signals that the plot should be refreshed void needToReplot(); void needToHardReplot(); + /// Signals that the axis scale has been changed + void axisScaleChanged(); public slots: void showLegend(bool show); @@ -118,7 +131,6 @@ namespace MantidWidgets QList<QAction *> addOptionsToMenus(QString menuName, QActionGroup *group, QStringList items, QString defaultItem); - QString getAxisType(int axisID); QStringList getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr ws); private slots: @@ -129,6 +141,11 @@ namespace MantidWidgets private: Ui::PreviewPlot m_uiForm; + /// Range selector widget for mini plot + QMap<QString, MantidQt::MantidWidgets::RangeSelector *> m_rangeSelectors; + /// Cache of range selector visibility + QMap<QString, bool> m_rsVisibility; + /// Poco Observers for ADS Notifications Poco::NObserver<PreviewPlot, Mantid::API::WorkspacePreDeleteNotification> m_removeObserver; Poco::NObserver<PreviewPlot, Mantid::API::WorkspaceAfterReplaceNotification> m_replaceObserver; @@ -136,7 +153,6 @@ namespace MantidWidgets /// If the widget was initialised bool m_init; - /// The plot its self friend class RangeSelector; /// Map of curve key to plot info diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/RangeSelector.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/RangeSelector.h index 0b16b896cdcef8ec2005359653ddd98df9a21604..38c4235775d9da75a4c95fdf405c6ccbef1e902d 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/RangeSelector.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/RangeSelector.h @@ -2,7 +2,6 @@ #define MANTIDQT_MANTIDWIDGET_POSHPLOTTING_H #include "WidgetDllOption.h" -#include "PreviewPlot.h" #include <qwt_plot_picker.h> #include <qwt_plot.h> @@ -14,6 +13,8 @@ namespace MantidQt { namespace MantidWidgets { + class PreviewPlot; + /** * Allows for simpler (in a way) selection of a range on a QwtPlot in MantidQt. * @author Michael Whitty, RAL ISIS @@ -35,6 +36,9 @@ namespace MantidWidgets double getMinimum() { return m_min; } ///< Returns current min value double getMaximum() { return m_max; } ///< Reutnrs current max value + SelectType getType() { return m_type; } + bool isVisible() { return m_visible; } + signals: void minValueChanged(double); void maxValueChanged(double); diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/PreviewPlot.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/PreviewPlot.cpp index b235a39355910a550a22584e52e0c94e01a5e8d2..88b8e682820ea1c0f96308cafe7e5e27a5023e12 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/PreviewPlot.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/PreviewPlot.cpp @@ -327,6 +327,70 @@ bool PreviewPlot::hasCurve(const QString & curveName) } +/** + * Attaches a RangeSelector to the plot and stores it. + * + * @param rsName Name of range selector + * @return RangeSelector object + */ +RangeSelector * PreviewPlot::addRangeSelector(const QString & rsName, + RangeSelector::SelectType type) +{ + if(hasRangeSelector(rsName)) + throw std::runtime_error("RangeSelector already exists on PreviewPlot"); + + m_rangeSelectors[rsName] = new MantidWidgets::RangeSelector(m_uiForm.plot, type); + m_rsVisibility[rsName] = m_rangeSelectors[rsName]->isVisible(); + + return m_rangeSelectors[rsName]; +} + + +/** + * Gets a RangeSelector. + * + * @param rsName Name of range selector + * @return RangeSelector object + */ +RangeSelector * PreviewPlot::getRangeSelector(const QString & rsName) +{ + if(!hasRangeSelector(rsName)) + throw std::runtime_error("RangeSelector not found on PreviewPlot"); + + return m_rangeSelectors[rsName]; +} + + +/** + * Removes a RangeSelector from the plot. + * + * @param rsName Name of range selector + * @param del If the object should be deleted + */ +void PreviewPlot::removeRangeSelector(const QString & rsName, bool del = true) +{ + if(!hasRangeSelector(rsName)) + return; + + if(del) + delete m_rangeSelectors[rsName]; + + m_rangeSelectors.remove(rsName); +} + + +/** + * Checks to see if a range selector with a given name is on the plot. + * + * @param rsName Name of range selector + * @return True if the plot has a range selector with the given name + */ +bool PreviewPlot::hasRangeSelector(const QString & rsName) +{ + return m_rangeSelectors.contains(rsName); +} + + /** * Shows or hides the plot legend. * @@ -723,6 +787,31 @@ void PreviewPlot::handleAxisTypeSelect() if(yEngine) m_uiForm.plot->setAxisScaleEngine(QwtPlot::yLeft, yEngine); + emit axisScaleChanged(); + + // Hide range selectors on X axis when X axis scale is X^2 + bool xIsSquared = xAxisType == "Squared"; + for(auto it = m_rangeSelectors.begin(); it != m_rangeSelectors.end(); ++it) + { + QString rsName = it.key(); + RangeSelector * rs = it.value(); + RangeSelector::SelectType type = rs->getType(); + + if(type == RangeSelector:: XMINMAX || type == RangeSelector::XSINGLE) + { + // When setting to invisible save the last visibility setting + if(xIsSquared) + { + m_rsVisibility[rsName] = rs->isVisible(); + rs->setVisible(false); + } + else + { + rs->setVisible(m_rsVisibility[rsName]); + } + } + } + // Update the plot emit needToHardReplot(); } diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/RangeSelector.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/RangeSelector.cpp index 30334d6da2cbcb18b9c5d0a5c93a69c66db2c092..ad084ec45389bb207c207f52120a9241493d3287 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/RangeSelector.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/RangeSelector.cpp @@ -5,6 +5,8 @@ #include <QEvent> #include <QMouseEvent> +#include "MantidQtMantidWidgets/PreviewPlot.h" + using namespace MantidQt::MantidWidgets; RangeSelector::RangeSelector(QwtPlot* plot, SelectType type, bool visible, bool infoOnly) diff --git a/Code/Mantid/Testing/Data/DocTest/irs26173_graphite002_red.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/irs26173_graphite002_red.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..dd49338b31255373fb60d986554ea8a6ce46902c --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/irs26173_graphite002_red.nxs.md5 @@ -0,0 +1 @@ +f52ac64ec23fb50b6d4649592aee4fdb \ No newline at end of file diff --git a/Code/Mantid/Testing/Data/DocTest/irs26176_graphite002_red.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/irs26176_graphite002_red.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..1c698d0a291b8ff23c2663d216bc8082b9061928 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/irs26176_graphite002_red.nxs.md5 @@ -0,0 +1 @@ +a69078cfcdf156b59327798cc71f4d51 \ No newline at end of file diff --git a/Code/Mantid/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst b/Code/Mantid/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst new file mode 100644 index 0000000000000000000000000000000000000000..90eebc58ce6c8a7e9c96d010e4bebe236211b8c1 --- /dev/null +++ b/Code/Mantid/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst @@ -0,0 +1,63 @@ +.. algorithm:: + +.. summary:: + +.. alias:: + +.. properties:: + +Description +----------- + +Calculates and applies corrections for scattering abs absorption in a annular +sample for a run on an indirect inelastic instrument, optionally also performing +a simple can subtraction is a container workspace is provided. + +The corrections workspace (:math:`A_{s,s}`) is the standard Paalman and Pings +attenuation factor for absorption and scattering in the sample. + +Usage +----- + +.. include:: ../usagedata-note.txt + +**Example - Sample corrections for IRIS:** + +.. testcode:: SampleCorrectionsWithCanSubtraction + + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + + corrected, ass = IndirectAnnulusAbsorption(SampleWorkspace=red_ws, + CanWorkspace=can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + CanInnerRadius=0.2, + SampleInnerRadius=0.15, + SampleOuterRadius=0.16, + CanOuterRadius=0.22, + Events=200) + + print ('Corrected workspace is intensity against %s' + % (corrected.getAxis(0).getUnit().caption())) + + print ('Corrections workspace is %s against %s' + % (ass.YUnitLabel(), ass.getAxis(0).getUnit().caption())) + + +.. testcleanup:: SampleCorrectionsWithCanSubtraction + + DeleteWorkspace(red_ws) + DeleteWorkspace(can_ws) + DeleteWorkspace(corrected) + DeleteWorkspace(ass) + +**Output:** + + +.. testoutput:: SampleCorrectionsWithCanSubtraction + + Corrected workspace is intensity against Energy transfer + Corrections workspace is Attenuation factor against Wavelength + +.. categories:: diff --git a/Code/Mantid/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst b/Code/Mantid/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst new file mode 100644 index 0000000000000000000000000000000000000000..eb7c25150ad5e01ea9cf7942029c6b733b17c578 --- /dev/null +++ b/Code/Mantid/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst @@ -0,0 +1,59 @@ +.. algorithm:: + +.. summary:: + +.. alias:: + +.. properties:: + +Description +----------- + +Calculates and applies corrections for scattering abs absorption in a +cylindrical sample for a run on an indirect inelastic instrument, optionally +also performing a simple can subtraction is a container workspace is provided. + +The corrections workspace (:math:`A_{s,s}`) is the standard Paalman and Pings +attenuation factor for absorption and scattering in the sample. + +Usage +----- + +.. include:: ../usagedata-note.txt + +**Example - Sample corrections for IRIS:** + +.. testcode:: SampleCorrectionsWithCanSubtraction + + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + + corrected, ass = IndirectCylinderAbsorption(SampleWorkspace=red_ws, + CanWorkspace=can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + SampleRadius=0.2) + + print ('Corrected workspace is intensity against %s' + % (corrected.getAxis(0).getUnit().caption())) + + print ('Corrections workspace is %s against %s' + % (ass.YUnitLabel(), ass.getAxis(0).getUnit().caption())) + + +.. testcleanup:: SampleCorrectionsWithCanSubtraction + + DeleteWorkspace(red_ws) + DeleteWorkspace(can_ws) + DeleteWorkspace(corrected) + DeleteWorkspace(ass) + +**Output:** + + +.. testoutput:: SampleCorrectionsWithCanSubtraction + + Corrected workspace is intensity against Energy transfer + Corrections workspace is Attenuation factor against Wavelength + +.. categories:: diff --git a/Code/Mantid/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst b/Code/Mantid/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst new file mode 100644 index 0000000000000000000000000000000000000000..0557ecb326b9a7cfc0630f34e8ce1d1c2e70e9fe --- /dev/null +++ b/Code/Mantid/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst @@ -0,0 +1,62 @@ +.. algorithm:: + +.. summary:: + +.. alias:: + +.. properties:: + +Description +----------- + +Calculates and applies corrections for scattering abs absorption in a flat plate +sample for a run on an indirect inelastic instrument, optionally also performing +a simple can subtraction is a container workspace is provided. + +The corrections workspace (:math:`A_{s,s}`) is the standard Paalman and Pings +attenuation factor for absorption and scattering in the sample. + +Usage +----- + +.. include:: ../usagedata-note.txt + +**Example - Sample corrections for IRIS:** + +.. testcode:: SampleCorrectionsWithCanSubtraction + + red_ws = LoadNexusProcessed(Filename='irs26176_graphite002_red.nxs') + can_ws = LoadNexusProcessed(Filename='irs26173_graphite002_red.nxs') + + corrected, ass = IndirectFlatPlateAbsorption(SampleWorkspace=red_ws, + CanWorkspace=can_ws, + CanScaleFactor=0.8, + ChemicalFormula='H2-O', + SampleHeight=1, + SampleWidth=1, + SampleThickness=1, + ElementSize=1) + + print ('Corrected workspace is intensity against %s' + % (corrected.getAxis(0).getUnit().caption())) + + print ('Corrections workspace is %s against %s' + % (ass.YUnitLabel(), ass.getAxis(0).getUnit().caption())) + + +.. testcleanup:: SampleCorrectionsWithCanSubtraction + + DeleteWorkspace(red_ws) + DeleteWorkspace(can_ws) + DeleteWorkspace(corrected) + DeleteWorkspace(ass) + +**Output:** + + +.. testoutput:: SampleCorrectionsWithCanSubtraction + + Corrected workspace is intensity against Energy transfer + Corrections workspace is Attenuation factor against Wavelength + +.. categories:: diff --git a/Code/Mantid/scripts/Inelastic/Direct/dgreduce.py b/Code/Mantid/scripts/Inelastic/Direct/dgreduce.py index fd1318c9e6707dcb75146325f1518f75a441f079..0e261a7d34558240e0b0a1d8a04049259056691a 100644 --- a/Code/Mantid/scripts/Inelastic/Direct/dgreduce.py +++ b/Code/Mantid/scripts/Inelastic/Direct/dgreduce.py @@ -3,7 +3,7 @@ import Direct.DirectEnergyConversion as DRC from mantid.simpleapi import * from mantid.kernel import funcreturns - +from mantid import api # the class which is responsible for data reduction global Reducer @@ -134,6 +134,7 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file='default',monovan_run=No # -------------------------------------------------------------------------------------------------------- if sample_run: Reducer.sample_run = sample_run + sample_run = None try: n,r=funcreturns.lhs_info('both') wksp_out=r[0] @@ -149,7 +150,37 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file='default',monovan_run=No return res - +def runs_are_equal(ws1,ws2): + """Compare two run numbers, provided either as run numbers, + or as workspaces or as ws names""" + if ws1 == ws2: + return True + #----------------------------------------------- + def get_run_num(name_or_ws): + err = None + try: + if isinstance(name_or_ws,api.MatrixWorkspace): + run_num = name_or_ws.getRunNumber() + elif name_or_ws in mtd: # this is also throw Boost.Python.ArgumentError error if mtd not accepts it + ws = mtd[name_or_ws] + run_num = ws.getRunNumber() + else: + raise AttributeError + except Exception as err: + pass + if not err is None: + raise AttributeError("Input parameter is neither workspace nor ws name") + return run_num + #----------------------------------------------- + try: + run_num1 = get_run_num(ws1) + except AttributeError: + return False + try: + run_num2 = get_run_num(ws2) + except AttributeError: + return False + return run_num1==run_num2 def abs_units(wb_for_run,sample_run,monovan_run,wb_for_monovanadium,samp_rmm,samp_mass,ei_guess,rebin,map_file='default',monovan_mapfile='default',**kwargs): """ @@ -240,13 +271,14 @@ def abs_units(wb_for_run,sample_run,monovan_run,wb_for_monovanadium,samp_rmm,sam if sample_run: Reducer.sample_run = sample_run + sample_run = None try: n,r=funcreturns.lhs_info('both') results_name=r[0] except: results_name = Reducer.prop_man.get_sample_ws_name() - if wb_for_run == wb_for_monovanadium: # wb_for_monovanadium property does not accept duplicated workspace + if runs_are_equal(wb_for_run,wb_for_monovanadium):# wb_for_monovanadium property does not accept duplicated workspace wb_for_monovanadium = None # if this value is none, it is constructed to be equal to wb_for_run wksp_out = arb_units(wb_for_run,sample_run,ei_guess,rebin,map_file,monovan_run,wb_for_monovanadium,**kwargs) diff --git a/Code/Mantid/scripts/test/DirectEnergyConversionTest.py b/Code/Mantid/scripts/test/DirectEnergyConversionTest.py index 9c8e3439a26d91c9d6b32940c8c18e0b1a7810b5..0b295c6293fba87977b75302c868818fa15fa996 100644 --- a/Code/Mantid/scripts/test/DirectEnergyConversionTest.py +++ b/Code/Mantid/scripts/test/DirectEnergyConversionTest.py @@ -183,8 +183,10 @@ class DirectEnergyConversionTest(unittest.TestCase): """ Test for old interface """ run_ws = CreateSampleWorkspace( Function='Multiple Peaks', NumBanks=1, BankPixelWidth=4, NumEvents=10000) LoadInstrument(run_ws,InstrumentName='MARI') + #mono_ws = CloneWorkspace(run_ws) wb_ws = CloneWorkspace(run_ws) + AddSampleLog(wb_ws,LogName='run_number',LogText='300',LogType='Number') #wb_ws=CreateSampleWorkspace( Function='Multiple Peaks', NumBanks=1, BankPixelWidth=4, NumEvents=10000) dgreduce.setup('MAR') @@ -199,6 +201,30 @@ class DirectEnergyConversionTest(unittest.TestCase): ws = dgreduce.abs_units(wb_ws,run_ws,None,wb_ws,10,100,8.8,[-10,0.1,7],None,None,**par) self.assertTrue(isinstance(ws,api.MatrixWorkspace)) + def test_dgreduce_works_with_name(self): + """ Test for old interface """ + run_ws = CreateSampleWorkspace( Function='Multiple Peaks', NumBanks=1, BankPixelWidth=4, NumEvents=10000) + LoadInstrument(run_ws,InstrumentName='MARI') + AddSampleLog(run_ws,LogName='run_number',LogText='200',LogType='Number') + #mono_ws = CloneWorkspace(run_ws) + wb_ws = CloneWorkspace(run_ws) + AddSampleLog(wb_ws,LogName='run_number',LogText='100',LogType='Number') + #wb_ws=CreateSampleWorkspace( Function='Multiple Peaks', NumBanks=1, BankPixelWidth=4, NumEvents=10000) + + dgreduce.setup('MAR') + par = {} + par['ei_mon_spectra']=[4,5] + par['abs_units_van_range']=[-4000,8000] + # overwrite parameters, which are necessary from command line, but we want them to have test values + dgreduce.getReducer().map_file=None + dgreduce.getReducer().monovan_mapfile=None + dgreduce.getReducer().mono_correction_factor = 1 + #abs_units(wb_for_run,sample_run,monovan_run,wb_for_monovanadium,samp_rmm,samp_mass,ei_guess,rebin,map_file='default',monovan_mapfile='default',**kwargs): + ws = dgreduce.abs_units('wb_ws','run_ws',None,wb_ws,10,100,8.8,[-10,0.1,7],None,None,**par) + self.assertTrue(isinstance(ws,api.MatrixWorkspace)) + + + ## tReducet.di def test_energy_to_TOF_range(self): diff --git a/Code/Tools/DOI/authors.py b/Code/Tools/DOI/authors.py index 98bc7ecc607318db22e531003d24ff620c3aff83..a9418f58841cc6fd56e6990321b7a60022516eda 100644 --- a/Code/Tools/DOI/authors.py +++ b/Code/Tools/DOI/authors.py @@ -73,7 +73,7 @@ _translations = { 'Roman Tolchenov' : 'Tolchenov, Roman', 'MichaelWedel' : 'Wedel, Michael', 'Michael Wedel' : 'Wedel, Michael', - 'Ross Whitfield' : 'Whitfield, Robert', + 'Ross Whitfield' : 'Whitfield, Ross', 'Robert Whitley' : 'Whitley, Robert', 'Michael Whitty' : 'Whitty, Michael', 'Steve Williams' : 'Williams, Steve',