Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/8118_FindUBUsingIndexedP…
Browse files Browse the repository at this point in the history
…eaks_tolerance'
  • Loading branch information
wdzhou committed Oct 18, 2013
2 parents d0761cf + e6c758b commit ed730ef
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Given a set of peaks at least three of which have been assigned Miller indices,
#include "MantidGeometry/Crystal/IndexingUtils.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidKernel/System.h"
#include "MantidKernel/BoundedValidator.h"
#include <cstdio>

namespace Mantid
Expand Down Expand Up @@ -65,6 +66,9 @@ namespace Crystal
{
this->declareProperty(new WorkspaceProperty<PeaksWorkspace>(
"PeaksWorkspace","",Direction::InOut), "Input Peaks Workspace");
boost::shared_ptr<BoundedValidator<double> > mustBePositive(new BoundedValidator<double>());
mustBePositive->setLower(0.0);
this->declareProperty("Tolerance",0.1, mustBePositive, "Indexing Tolerance (0.1)");
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -130,7 +134,7 @@ namespace Crystal
{
q_vectors.push_back( peaks[i].getQSampleFrame() );
}
double tolerance = 0.1;
double tolerance = this->getProperty("Tolerance");
int num_indexed = IndexingUtils::NumberIndexed(UB, q_vectors, tolerance);

char logInfo[200];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ private slots:
/// Slot to enable/disable the find UB using FFT controls
void setEnabledFindUBFFTParams_slot( bool on );

/// Slot to enable/disable the find UB using Indexed Peaks controls
void setEnabledFindUBUsingIndexedPeaksParams_slot( bool on );

/// Slot to enable/disable the load UB controls
void setEnabledLoadUBParams_slot( bool on );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<string/>
</property>
<property name="currentIndex">
<number>4</number>
<number>2</number>
</property>
<widget class="QWidget" name="SelectData">
<attribute name="title">
Expand Down Expand Up @@ -609,7 +609,7 @@
<property name="geometry">
<rect>
<x>40</x>
<y>150</y>
<y>140</y>
<width>431</width>
<height>27</height>
</rect>
Expand Down Expand Up @@ -759,6 +759,22 @@
<string>0.12</string>
</property>
</widget>
<widget class="QLineEdit" name="IndexedPeaksTolerance_ledt">
<property name="geometry">
<rect>
<x>410</x>
<y>160</y>
<width>81</width>
<height>24</height>
</rect>
</property>
<property name="toolTip">
<string>Maximum distance of h,k or l from integer values to&lt;br&gt; consider a peak to be indexed.</string>
</property>
<property name="text">
<string>0.1</string>
</property>
</widget>
<widget class="QLabel" name="FFTTolerance_lbl">
<property name="geometry">
<rect>
Expand Down Expand Up @@ -917,6 +933,19 @@
<string>Use Current UB (if already found or loaded)</string>
</property>
</widget>
<widget class="QLabel" name="IndexedPeaksTolerance_lbl">
<property name="geometry">
<rect>
<x>70</x>
<y>160</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Tolerance</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="ChooseCell">
<attribute name="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DLLExport MantidEVWorker
double tolerance );

/// Index the peaks using the indexing of the peaks in the peaks workspace
bool findUBUsingIndexedPeaks( const std::string & peaks_ws_name );
bool findUBUsingIndexedPeaks(const std::string & peaks_ws_name, double tolerance );

/// Load the UB matrix from a file
bool loadIsawUB( const std::string & peaks_ws_name,
Expand Down
22 changes: 21 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/MantidEV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ void MantidEV::initLayout()
m_uiForm.MinD_ledt->setValidator( new QDoubleValidator(m_uiForm.MinD_ledt));
m_uiForm.MaxD_ledt->setValidator( new QDoubleValidator(m_uiForm.MaxD_ledt));
m_uiForm.FFTTolerance_ledt->setValidator( new QDoubleValidator(m_uiForm.FFTTolerance_ledt));
m_uiForm.IndexedPeaksTolerance_ledt->setValidator( new QDoubleValidator(m_uiForm.IndexedPeaksTolerance_ledt));
m_uiForm.MaxGoniometerChange_ledt->setValidator( new QDoubleValidator(m_uiForm.MaxGoniometerChange_ledt));
m_uiForm.IndexingTolerance_ledt->setValidator( new QDoubleValidator(m_uiForm.IndexingTolerance_ledt));
m_uiForm.MaxScalarError_ledt->setValidator( new QDoubleValidator(m_uiForm.MaxScalarError_ledt));
Expand Down Expand Up @@ -404,6 +405,7 @@ void MantidEV::setDefaultState_slot()
m_uiForm.MaxD_ledt->setText("15");
m_uiForm.FFTTolerance_ledt->setText("0.12");
m_uiForm.FindUBUsingIndexedPeaks_rbtn->setChecked(false);
m_uiForm.IndexedPeaksTolerance_ledt->setText("0.1");
m_uiForm.LoadISAWUB_rbtn->setChecked(false);
m_uiForm.SelectUBFile_ledt->setText("");
m_uiForm.OptimizeGoniometerAngles_ckbx->setChecked(false);
Expand Down Expand Up @@ -800,7 +802,12 @@ void MantidEV::findUB_slot()

else if ( use_IndexedPeaks )
{
if ( !worker->findUBUsingIndexedPeaks( peaks_ws_name ) )
double indPeaks_tolerance = 0.1;

if ( !getPositiveDouble( m_uiForm.IndexedPeaksTolerance_ledt, indPeaks_tolerance ) )
return;

if ( !worker->findUBUsingIndexedPeaks( peaks_ws_name,indPeaks_tolerance) )
{
errorMessage( "Find UB Using Indexed Peaks Failed" );
return;
Expand Down Expand Up @@ -1521,6 +1528,17 @@ void MantidEV::setEnabledFindUBFFTParams_slot( bool on )
m_uiForm.FFTTolerance_ledt->setEnabled( on );
}

/**
* Set the enabled state of the find UB using Indexed Peaks components to the
* specified value.
*
* @param on If true, components will be enabled, if false, disabled.
*/
void MantidEV::setEnabledFindUBUsingIndexedPeaksParams_slot( bool on )
{
m_uiForm.IndexedPeaksTolerance_lbl->setEnabled( on );
m_uiForm.IndexedPeaksTolerance_ledt->setEnabled( on );
}

/**
* Set the enabled state of the load UB file components to the
Expand Down Expand Up @@ -1907,6 +1925,7 @@ void MantidEV::saveSettings( const std::string & filename )
state->setValue("MaxD_ledt", m_uiForm.MaxD_ledt->text());
state->setValue("FFTTolerance_ledt", m_uiForm.FFTTolerance_ledt->text());
state->setValue("FindUBUsingIndexedPeaks_rbtn", m_uiForm.FindUBUsingIndexedPeaks_rbtn->isChecked());
state->setValue("IndexedPeaksTolerance_ledt", m_uiForm.IndexedPeaksTolerance_ledt->text());
state->setValue("LoadISAWUB_rbtn", m_uiForm.LoadISAWUB_rbtn->isChecked());
state->setValue("SelectUBFile_ledt", m_uiForm.SelectUBFile_ledt->text());
state->setValue("OptimizeGoniometerAngles_ckbx", m_uiForm.OptimizeGoniometerAngles_ckbx->isChecked());
Expand Down Expand Up @@ -2007,6 +2026,7 @@ void MantidEV::loadSettings( const std::string & filename )
restore( state, "MaxD_ledt", m_uiForm.MaxD_ledt );
restore( state, "FFTTolerance_ledt", m_uiForm.FFTTolerance_ledt );
restore( state, "FindUBUsingIndexedPeaks_rbtn", m_uiForm.FindUBUsingIndexedPeaks_rbtn );
restore( state, "IndexedPeaksTolerance_ledt", m_uiForm.IndexedPeaksTolerance_ledt );
restore( state, "LoadISAWUB_rbtn", m_uiForm.LoadISAWUB_rbtn );
restore( state, "SelectUBFile_ledt", m_uiForm.SelectUBFile_ledt );
restore( state, "OptimizeGoniometerAngles_ckbx", m_uiForm.OptimizeGoniometerAngles_ckbx );
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/MantidEVWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,14 @@ bool MantidEVWorker::findUBUsingFFT( const std::string & peaks_ws_name,
*
* @return true if FindUBusingIndexedPeaks completed successfully.
*/
bool MantidEVWorker::findUBUsingIndexedPeaks(const std::string & peaks_ws_name)
bool MantidEVWorker::findUBUsingIndexedPeaks(const std::string & peaks_ws_name, double tolerance )
{
if ( !isPeaksWorkspace( peaks_ws_name ) )
return false;

IAlgorithm_sptr alg = AlgorithmManager::Instance().create("FindUBUsingIndexedPeaks");
alg->setProperty("PeaksWorkspace",peaks_ws_name);
alg->setProperty("Tolerance",tolerance);

if ( alg->execute() )
return true;
Expand Down

0 comments on commit ed730ef

Please sign in to comment.