Skip to content

Commit

Permalink
Updated moments, sqw, trans and symm
Browse files Browse the repository at this point in the history
Refs #10960
  • Loading branch information
DanNixon committed Jan 27, 2015
1 parent a420eba commit af7155a
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 1,252 deletions.

Large diffs are not rendered by default.

Expand Up @@ -3,6 +3,7 @@

#include "IndirectDataReductionTab.h"

#include "ui_IndirectMoments.h"
#include "MantidKernel/System.h"

#include <QFont>
Expand All @@ -12,7 +13,7 @@ namespace MantidQt
namespace CustomInterfaces
{
/** IndirectMoments : TODO: DESCRIPTION
@author Samuel Jackson
@date 13/08/2013
Expand Down Expand Up @@ -61,6 +62,9 @@ namespace CustomInterfaces
/// Called when the algorithm completes to update preview plot
void momentsAlgComplete(bool error);

private:
Ui::IndirectMoments m_uiForm;

};
} // namespace CustomInterfaces
} // namespace Mantid
Expand Down
Expand Up @@ -225,7 +225,7 @@
<customwidget>
<class>MantidQt::MantidWidgets::DataSelector</class>
<extends>QWidget</extends>
<header>mantidqt::mantidwidgets::dataselector.h</header>
<header>MantidQtMantidWidgets/DataSelector.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Expand Up @@ -3,6 +3,7 @@

#include "IndirectDataReductionTab.h"

#include "ui_IndirectSqw.h"
#include "MantidKernel/System.h"

namespace MantidQt
Expand Down Expand Up @@ -47,10 +48,12 @@ namespace CustomInterfaces
virtual bool validate();

private slots:
void energyRebinToggle(bool state);
void plotContour();
void sqwAlgDone(bool error);

private:
Ui::IndirectSqw m_uiForm;

};
} // namespace CustomInterfaces
} // namespace Mantid
Expand Down
Expand Up @@ -412,7 +412,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="bcPlotType">
<widget class="QComboBox" name="cbPlotType">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -471,7 +471,7 @@
<customwidget>
<class>MantidQt::MantidWidgets::DataSelector</class>
<extends>QWidget</extends>
<header>mantidqt::mantidwidgets::dataselector.h</header>
<header>MantidQtMantidWidgets/DataSelector.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Expand Up @@ -3,6 +3,7 @@

#include "IndirectDataReductionTab.h"

#include "ui_IndirectSymmetrise.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidKernel/System.h"

Expand Down Expand Up @@ -76,6 +77,9 @@ namespace CustomInterfaces
void xRangeMaxChanged(double value);
void xRangeMinChanged(double value);

private:
Ui::IndirectSymmetrise m_uiForm;

};
} // namespace CustomInterfaces
} // namespace Mantid
Expand Down
Expand Up @@ -154,7 +154,7 @@
<customwidget>
<class>MantidQt::MantidWidgets::DataSelector</class>
<extends>QWidget</extends>
<header>mantidqt::mantidwidgets::dataselector.h</header>
<header>MantidQtMantidWidgets/DataSelector.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Expand Up @@ -2,14 +2,18 @@
#define MANTID_CUSTOMINTERFACES_INDIRECTTRANSMISSION_H_

#include "IndirectDataReductionTab.h"
#include "ui_IndirectTransmission.h"
#include "MantidKernel/System.h"


namespace MantidQt
{
namespace CustomInterfaces
{
/** IndirectTransmission : TODO: DESCRIPTION
/** IndirectTransmission
Provides the UI interface to the IndirectTransmissionMonitor algorithm to calculate
sample transmission using a sample and container raw run file.
@author Samuel Jackson
Expand Down Expand Up @@ -51,6 +55,10 @@ namespace CustomInterfaces
void dataLoaded();
void previewPlot();
void transAlgDone(bool error);

private:
Ui::IndirectTransmission m_uiForm;

};

} // namespace CustomInterfaces
Expand Down
Expand Up @@ -216,7 +216,7 @@
<customwidget>
<class>MantidQt::MantidWidgets::DataSelector</class>
<extends>QWidget</extends>
<header>mantidqt::mantidwidgets::dataselector.h</header>
<header>MantidQtMantidWidgets/DataSelector.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Expand Up @@ -79,8 +79,8 @@ IndirectDataReduction::~IndirectDataReduction()
void IndirectDataReduction::helpClicked()
{

QString tabName = m_uiForm.tabWidget->tabText(
m_uiForm.tabWidget->currentIndex());
QString tabName = m_uiForm.twIDRTabs->tabText(
m_uiForm.twIDRTabs->currentIndex());

QString url = "http://www.mantidproject.org/Indirect:";

Expand Down Expand Up @@ -108,7 +108,7 @@ void IndirectDataReduction::helpClicked()
*/
void IndirectDataReduction::exportTabPython()
{
QString tabName = m_uiForm.tabWidget->tabText(m_uiForm.tabWidget->currentIndex());
QString tabName = m_uiForm.twIDRTabs->tabText(m_uiForm.twIDRTabs->currentIndex());
m_tabs[tabName]->exportPythonScript();
}

Expand All @@ -119,7 +119,7 @@ void IndirectDataReduction::exportTabPython()
*/
void IndirectDataReduction::runClicked()
{
QString tabName = m_uiForm.tabWidget->tabText(m_uiForm.tabWidget->currentIndex());
QString tabName = m_uiForm.twIDRTabs->tabText(m_uiForm.twIDRTabs->currentIndex());
m_tabs[tabName]->runTab();
}

Expand All @@ -135,13 +135,14 @@ void IndirectDataReduction::initLayout()
updateRunButton(false, "Loading UI", "Initialising user interface components...");

// Create the tabs
m_tabs["Energy Transfer"] = new IndirectConvertToEnergy(m_uiForm, this);
m_tabs["Calibration"] = new IndirectCalibration(m_uiForm, this);
m_tabs["Diagnostics"] = new IndirectDiagnostics(m_uiForm, this);
m_tabs["Transmission"] = new IndirectTransmission(m_uiForm, this);
m_tabs["Symmetrise"] = new IndirectSymmetrise(m_uiForm, this);
m_tabs["S(Q, w)"] = new IndirectSqw(m_uiForm, this);
m_tabs["Moments"] = new IndirectMoments(m_uiForm, this);
//TODO
/* m_tabs["Energy Transfer"] = new IndirectConvertToEnergy(m_uiForm, m_uiForm.twIDRTabs->widget(0)); */
/* m_tabs["Calibration"] = new IndirectCalibration(m_uiForm, m_uiForm.twIDRTabs->widget(1)); */
/* m_tabs["Diagnostics"] = new IndirectDiagnostics(m_uiForm, m_uiForm.twIDRTabs->widget(2)); */
/* m_tabs["Transmission"] = new IndirectTransmission(m_uiForm, m_uiForm.twIDRTabs->widget(3)); */
/* m_tabs["Symmetrise"] = new IndirectSymmetrise(m_uiForm, m_uiForm.twIDRTabs->widget(4)); */
/* m_tabs["S(Q, w)"] = new IndirectSqw(m_uiForm, m_uiForm.twIDRTabs->widget(5)); */
/* m_tabs["Moments"] = new IndirectMoments(m_uiForm, m_uiForm.twIDRTabs->widget(6)); */

// Connect "?" (Help) Button
connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(helpClicked()));
Expand All @@ -153,7 +154,7 @@ void IndirectDataReduction::initLayout()
connect(m_uiForm.pbManageDirectories, SIGNAL(clicked()), this, SLOT(openDirectoryDialog()));

// Reset the Run button state when the tab is changed
connect(m_uiForm.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateRunButton()));
connect(m_uiForm.twIDRTabs, SIGNAL(currentChanged(int)), this, SLOT(updateRunButton()));

// Connect tab signals and run any setup code
for(auto it = m_tabs.begin(); it != m_tabs.end(); ++it)
Expand Down Expand Up @@ -401,21 +402,22 @@ void IndirectDataReduction::readSettings()
QSettings settings;

// Load settings for MWRunFile widgets
settings.beginGroup(m_settingsGroup + "DataFiles");
settings.setValue("last_directory", m_dataDir);
m_uiForm.ind_runFiles->readSettings(settings.group());
m_uiForm.cal_leRunNo->readSettings(settings.group());
m_uiForm.slice_inputFile->readSettings(settings.group());
settings.endGroup();

settings.beginGroup(m_settingsGroup + "ProcessedFiles");
settings.setValue("last_directory", m_saveDir);
m_uiForm.ind_calibFile->readSettings(settings.group());
m_uiForm.ind_mapFile->readSettings(settings.group());
m_uiForm.slice_dsCalibFile->readSettings(settings.group());
m_uiForm.moment_dsInput->readSettings(settings.group());
m_uiForm.sqw_dsSampleInput->readSettings(settings.group());
settings.endGroup();
//TODO
/* settings.beginGroup(m_settingsGroup + "DataFiles"); */
/* settings.setValue("last_directory", m_dataDir); */
/* m_uiForm.ind_runFiles->readSettings(settings.group()); */
/* m_uiForm.cal_leRunNo->readSettings(settings.group()); */
/* m_uiForm.slice_inputFile->readSettings(settings.group()); */
/* settings.endGroup(); */

/* settings.beginGroup(m_settingsGroup + "ProcessedFiles"); */
/* settings.setValue("last_directory", m_saveDir); */
/* m_uiForm.ind_calibFile->readSettings(settings.group()); */
/* m_uiForm.ind_mapFile->readSettings(settings.group()); */
/* m_uiForm.slice_dsCalibFile->readSettings(settings.group()); */
/* m_uiForm.moment_dsInput->readSettings(settings.group()); */
/* m_uiForm.sqw_dsSampleInput->readSettings(settings.group()); */
/* settings.endGroup(); */

// Load the last used instrument
settings.beginGroup(m_settingsGroup);
Expand Down
Expand Up @@ -17,6 +17,8 @@ namespace CustomInterfaces
*/
IndirectMoments::IndirectMoments(Ui::IndirectDataReduction& uiForm, QWidget * parent) : IndirectDataReductionTab(uiForm, parent)
{
m_uiForm.setupUi(parent);

const unsigned int NUM_DECIMALS = 6;

// RAW PLOT
Expand All @@ -31,7 +33,7 @@ namespace CustomInterfaces
m_plots["MomentsPlot"]->setAxisFont(QwtPlot::yLeft, parent->font());

// Add plot to UI
m_uiForm.moment_plotSpace->addWidget(m_plots["MomentsPlot"]);
m_uiForm.plotRaw->addWidget(m_plots["MomentsPlot"]);

// PREVIEW PLOT
m_plots["MomentsPreviewPlot"] = new QwtPlot(m_parentWidget);
Expand All @@ -42,12 +44,12 @@ namespace CustomInterfaces
m_plots["MomentsPreviewPlot"]->setAxisFont(QwtPlot::yLeft, parent->font());

// Add plot to UI
m_uiForm.moment_plotPreview->addWidget(m_plots["MomentsPreviewPlot"]);
m_uiForm.plotPreview->addWidget(m_plots["MomentsPreviewPlot"]);

// PROPERTY TREE
m_propTrees["MomentsPropTree"] = new QtTreePropertyBrowser();
m_propTrees["MomentsPropTree"]->setFactoryForManager(m_dblManager, m_dblEdFac);
m_uiForm.moment_treeSpace->addWidget(m_propTrees["MomentsPropTree"]);
m_uiForm.properties->addWidget(m_propTrees["MomentsPropTree"]);
m_properties["EMin"] = m_dblManager->addProperty("EMin");
m_properties["EMax"] = m_dblManager->addProperty("EMax");

Expand All @@ -57,19 +59,13 @@ namespace CustomInterfaces
m_dblManager->setDecimals(m_properties["EMin"], NUM_DECIMALS);
m_dblManager->setDecimals(m_properties["EMax"], NUM_DECIMALS);

m_uiForm.moment_leScale->setValidator(new QDoubleValidator());

connect(m_uiForm.moment_dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(handleSampleInputReady(const QString&)));
connect(m_uiForm.moment_ckScale, SIGNAL(toggled(bool)), m_uiForm.moment_leScale, SLOT(setEnabled(bool)));
connect(m_uiForm.moment_ckScale, SIGNAL(toggled(bool)), m_uiForm.moment_validScale, SLOT(setVisible(bool)));
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(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateProperties(QtProperty*, double)));

// Update the preview plot when the algorithm completes
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(momentsAlgComplete(bool)));

m_uiForm.moment_validScale->setStyleSheet("QLabel { color : #aa0000; }");
}

//----------------------------------------------------------------------------------------------
Expand All @@ -85,33 +81,31 @@ namespace CustomInterfaces

void IndirectMoments::run()
{
QString workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();
QString workspaceName = m_uiForm.dsInput->getCurrentDataName();
QString outputName = workspaceName.left(workspaceName.length() - 4);
QString scaleString = m_uiForm.moment_leScale->text();
double scale = 1.0;
double scale = m_uiForm.spScale->value();
double eMin = m_dblManager->value(m_properties["EMin"]);
double eMax = m_dblManager->value(m_properties["EMax"]);

bool plot = m_uiForm.moment_ckPlot->isChecked();
bool verbose = m_uiForm.moment_ckVerbose->isChecked();
bool save = m_uiForm.moment_ckSave->isChecked();

if(!scaleString.isEmpty())
scale = scaleString.toDouble();
bool plot = m_uiForm.ckPlot->isChecked();
bool verbose = m_uiForm.ckVerbose->isChecked();
bool save = m_uiForm.ckSave->isChecked();

std::string outputWorkspaceName = outputName.toStdString() + "_Moments";

IAlgorithm_sptr momentsAlg = AlgorithmManager::Instance().create("SofQWMoments", -1);
momentsAlg->initialize();
momentsAlg->setProperty("Sample", workspaceName.toStdString());
momentsAlg->setProperty("Scale", scale);
momentsAlg->setProperty("EnergyMin", eMin);
momentsAlg->setProperty("EnergyMax", eMax);
momentsAlg->setProperty("Plot", plot);
momentsAlg->setProperty("Verbose", verbose);
momentsAlg->setProperty("Save", save);
momentsAlg->setProperty("OutputWorkspace", outputWorkspaceName);

if(m_uiForm.ckScale->isChecked())
momentsAlg->setProperty("Scale", scale);

// Set the workspace name for Python script export
m_pythonExportWsName = outputWorkspaceName + "_M0";

Expand All @@ -123,10 +117,7 @@ namespace CustomInterfaces
{
UserInputValidator uiv;

uiv.checkDataSelectorIsValid("Sample input", m_uiForm.moment_dsInput);

if (m_uiForm.moment_ckScale->isChecked())
uiv.checkFieldIsValid("A valid scale must be supplied.\n", m_uiForm.moment_leScale, m_uiForm.moment_validScale);
uiv.checkDataSelectorIsValid("Sample input", m_uiForm.dsInput);

QString msg = uiv.generateErrorMessage();
if (!msg.isEmpty())
Expand Down Expand Up @@ -209,32 +200,30 @@ namespace CustomInterfaces
void IndirectMoments::updatePreviewPlot(QString workspaceName)
{
if(workspaceName.isEmpty())
workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();
workspaceName = m_uiForm.dsInput->getCurrentDataName();

QString outputName = workspaceName.left(workspaceName.length() - 4);
QString scaleString = m_uiForm.moment_leScale->text();
double scale = 1.0;
double scale = m_uiForm.spScale->value();
double eMin = m_dblManager->value(m_properties["EMin"]);
double eMax = m_dblManager->value(m_properties["EMax"]);

bool verbose = m_uiForm.moment_ckVerbose->isChecked();

if(!scaleString.isEmpty())
scale = scaleString.toDouble();
bool verbose = m_uiForm.ckVerbose->isChecked();

std::string outputWorkspaceName = outputName.toStdString() + "_Moments";

IAlgorithm_sptr momentsAlg = AlgorithmManager::Instance().create("SofQWMoments");
momentsAlg->initialize();
momentsAlg->setProperty("Sample", workspaceName.toStdString());
momentsAlg->setProperty("Scale", scale);
momentsAlg->setProperty("EnergyMin", eMin);
momentsAlg->setProperty("EnergyMax", eMax);
momentsAlg->setProperty("Plot", false);
momentsAlg->setProperty("Verbose", verbose);
momentsAlg->setProperty("Save", false);
momentsAlg->setProperty("OutputWorkspace", outputWorkspaceName);

if(m_uiForm.ckScale->isChecked())
momentsAlg->setProperty("Scale", scale);

// Make sure there are no other algorithms in the queue.
// It seems to be possible to have the selctionChangedLazy signal fire multiple times
// if the renage selector is moved in a certain way.
Expand All @@ -252,7 +241,7 @@ namespace CustomInterfaces
if(error)
return;

QString workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();
QString workspaceName = m_uiForm.dsInput->getCurrentDataName();
QString outputName = workspaceName.left(workspaceName.length() - 4);
std::string outputWorkspaceName = outputName.toStdString() + "_Moments";

Expand Down

0 comments on commit af7155a

Please sign in to comment.