Skip to content

Commit

Permalink
Refs #5421 Stretch interface now connected to Quest routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Sep 17, 2013
1 parent 9d8570e commit fb774d9
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</property>
<property name="fileBrowserSuffixes" stdset="0">
<stringlist>
<string>_res</string>
<string>_res.nxs</string>
</stringlist>
</property>
<property name="showLoad">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ namespace MantidQt
virtual void minValueChanged(double min);
/// Slot for when the min range on the range selector changes
virtual void maxValueChanged(double max);
/// Slot to update the guides when the range properties change
void updateProperties(QtProperty* prop, double val);
/// Slot to handle when a new sample file is available
void handleSampleInputReady(const QString& filename);

private:
virtual QString help() { return "Stretch"; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
<property name="loadLabelText" stdset="0">
<string>Plot</string>
</property>
<property name="workspaceSuffixes" stdset="0">
<stringlist>
<string>_red</string>
</stringlist>
</property>
<property name="fileBrowserSuffixes" stdset="0">
<stringlist>
<string>_red.nxs</string>
</stringlist>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -85,15 +95,6 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QComboBox" name="cbMode">
<item>
<property name="text">
<string>Fit</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblBackground">
<property name="sizePolicy">
Expand All @@ -107,41 +108,40 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="chkElasticPeak">
<property name="text">
<string>Elastic Peak</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbBackground">
<item>
<property name="text">
<string>Sloping</string>
</property>
</item>
<item>
<property name="text">
<string>Flat</string>
</property>
</item>
<item>
<property name="text">
<string>Sloped</string>
<string>Zero</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="0" column="4">
<widget class="QCheckBox" name="chkSequence">
<property name="text">
<string>Sequence</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="chkElasticPeak">
<property name="text">
<string>Mode</string>
<string>Elastic Peak</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down Expand Up @@ -198,12 +198,36 @@
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkPlot">
<widget class="QLabel" name="lblPlotResult">
<property name="text">
<string>Plot Result</string>
<string>Plot Result: </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbPlot">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Sigma</string>
</property>
</item>
<item>
<property name="text">
<string>Beta</string>
</property>
</item>
<item>
<property name="text">
<string>All</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_18">
<property name="orientation">
Expand Down
8 changes: 5 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace MantidQt
QString useResNorm("0");
QString resNormFile("");

QString background("0");

QString pyInput =
"from IndirectBayes import QLRun\n";

Expand All @@ -94,12 +96,12 @@ namespace MantidQt
QString program = m_uiForm.cbProgram->currentText();

// Collect input from fit options section
QString background = m_uiForm.cbBackground->currentText();
if(background == "Sloping")
QString backgroundTxt = m_uiForm.cbBackground->currentText();
if(backgroundTxt == "Sloping")
{
background = "2";
}
else if( background == "Flat")
else if( backgroundTxt == "Flat")
{
background = "1";
}
Expand Down
80 changes: 80 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,96 @@ namespace MantidQt
m_dblManager->setValue(m_properties["Sigma"], 50);
m_dblManager->setValue(m_properties["Beta"], 50);
m_dblManager->setValue(m_properties["SampleBinning"], 1);

//Connect the data selector for the sample to the mini plot
connect(m_uiForm.dsSample, SIGNAL(dataReady(const QString&)), this, SLOT(handleSampleInputReady(const QString&)));
}

bool Stretch::validate()
{
if(m_uiForm.dsSample->getCurrentDataName().isEmpty())
{
emit showMessageBox("Please correct the following:\n Could not find the specified reduction file");
return false;
}
if(m_uiForm.dsResolution->getCurrentDataName().isEmpty())
{
emit showMessageBox("Please correct the following:\n Could not find the specified resolution file");
return false;
}
return true;
}

void Stretch::run()
{
QString save("False");
QString verbose("False");

QString elasticPeak("0");
QString background("0");
QString sequence("False");

QString pyInput =
"from IndirectBayes import QuestRun\n";

QString sampleName = m_uiForm.dsSample->getCurrentDataName();
QString resName = m_uiForm.dsResolution->getCurrentDataName();

// Collect input from options section
QString backgroundTxt = m_uiForm.cbBackground->currentText();
if(backgroundTxt == "Sloping")
{
background = "2";
}
else if( backgroundTxt == "Flat")
{
background = "1";
}

if(m_uiForm.chkElasticPeak->isChecked()) { elasticPeak = "1"; }
if(m_uiForm.chkSequence->isChecked()) { sequence = "True"; }

QString fitOps = "[" + elasticPeak + ", " + background + ", 0, 0]";

//Collect input from the properties browser
QString eMin = m_properties["EMin"]->valueText();
QString eMax = m_properties["EMax"]->valueText();
QString eRange = "[" + eMin + "," + eMax + "]";

QString beta = m_properties["Beta"]->valueText();
QString sigma = m_properties["Sigma"]->valueText();
QString betaSig = "[" + beta + ", " + sigma + "]";

QString nBins = m_properties["SampleBinning"]->valueText();

//Output options
if(m_uiForm.chkVerbose->isChecked()) { verbose = "True"; }
if(m_uiForm.chkSave->isChecked()) { save = "True"; }
QString plot = m_uiForm.cbPlot->currentText();

pyInput += "QuestRun('"+sampleName+"','"+resName+"',"+betaSig+","+eRange+","+nBins+","+fitOps+","+sequence+","
" Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n";

runPythonScript(pyInput);
}

void Stretch::handleSampleInputReady(const QString& filename)
{
plotMiniPlot(filename, 0);
std::pair<double,double> res;
std::pair<double,double> range = getCurveRange();

//Use the values from the instrument parameter file if we can
if(getInstrumentResolution(filename, res))
{
setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], res);
}
else
{
setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], range);
}

setPlotRange(m_properties["EMin"], m_properties["EMax"], range);
}

void Stretch::minValueChanged(double min)
Expand Down

0 comments on commit fb774d9

Please sign in to comment.