Skip to content

Commit

Permalink
RE 6901 MantidEV usability
Browse files Browse the repository at this point in the history
Added controls on the first form to allow the user to restrict the
range of Q values, and choose whether or not to do the Lorentz
correction when converting to MD.  This will be necessary for
large molecule/protein crystallography.

refs #6901
  • Loading branch information
DennisMikkelson committed Apr 25, 2013
1 parent 4fcf217 commit 0649a3e
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class RunLoadAndConvertToMD : public QRunnable
RunLoadAndConvertToMD( MantidEVWorker * worker,
const std::string & file_name,
const std::string & ev_ws_name,
const std::string & md_ws_name );
const std::string & md_ws_name,
double maxQ,
bool do_lorentz_corr );

/// Calls worker->loadAndConvertToMD from a separate thread
void run();
Expand All @@ -49,6 +51,8 @@ class RunLoadAndConvertToMD : public QRunnable
std::string file_name;
std::string ev_ws_name;
std::string md_ws_name;
double maxQ;
bool do_lorentz_corr;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<item>
<widget class="QTabWidget" name="MantidEV_tabwidg">
<property name="currentIndex">
<number>5</number>
<number>0</number>
</property>
<widget class="QWidget" name="SelectData">
<attribute name="title">
Expand Down Expand Up @@ -117,19 +117,19 @@
<rect>
<x>40</x>
<y>150</y>
<width>331</width>
<width>451</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string> Load From Event File</string>
<string> Load From Event File and Map to MD</string>
</property>
</widget>
<widget class="QRadioButton" name="UseExistingWorkspaces_rbtn">
<property name="geometry">
<rect>
<x>40</x>
<y>250</y>
<y>380</y>
<width>441</width>
<height>23</height>
</rect>
Expand All @@ -141,7 +141,7 @@
<widget class="QLabel" name="EventFileName_lbl">
<property name="geometry">
<rect>
<x>60</x>
<x>70</x>
<y>190</y>
<width>101</width>
<height>31</height>
Expand Down Expand Up @@ -174,6 +174,42 @@
<string>Browse</string>
</property>
</widget>
<widget class="QLabel" name="MaxMagQ_lbl">
<property name="geometry">
<rect>
<x>70</x>
<y>260</y>
<width>221</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Max |Q| to Map to MD</string>
</property>
</widget>
<widget class="QLineEdit" name="MaxMagQ_ledt">
<property name="geometry">
<rect>
<x>290</x>
<y>250</y>
<width>101</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="LorentzCorrection_ckbx">
<property name="geometry">
<rect>
<x>70</x>
<y>310</y>
<width>271</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Apply Lorentz Correction</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="FindPeaks">
<attribute name="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class DLLExport MantidEVWorker
/// Load and event file and convert to MD workspace
bool loadAndConvertToMD( const std::string & file_name,
const std::string & ev_ws_name,
const std::string & md_ws_name );
const std::string & md_ws_name,
double maxQ,
bool do_lorentz_corr );

/// Find peaks in MD workspace and set peaks into peaks workspace
bool findPeaks( const std::string & md_ws_name,
Expand Down
54 changes: 47 additions & 7 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MantidEV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ using namespace Mantid::API;
RunLoadAndConvertToMD::RunLoadAndConvertToMD( MantidEVWorker * worker,
const std::string & file_name,
const std::string & ev_ws_name,
const std::string & md_ws_name )
const std::string & md_ws_name,
double maxQ,
bool do_lorentz_corr )
{
this->worker = worker;
this->file_name = file_name;
this->ev_ws_name = ev_ws_name;
this->md_ws_name = md_ws_name;
this->worker = worker;
this->file_name = file_name;
this->ev_ws_name = ev_ws_name;
this->md_ws_name = md_ws_name;
this->maxQ = maxQ;
this->do_lorentz_corr = do_lorentz_corr;
}

void RunLoadAndConvertToMD::run()
{
worker->loadAndConvertToMD( file_name, ev_ws_name, md_ws_name );
worker->loadAndConvertToMD( file_name, ev_ws_name, md_ws_name, maxQ, do_lorentz_corr );
}


Expand All @@ -62,6 +66,10 @@ RunFindPeaks::RunFindPeaks( MantidEVWorker * worker,
this->min_intensity = min_intensity;
}


/**
* Class to call findPeaks in a separate thread.
*/
void RunFindPeaks::run()
{
worker->findPeaks( md_ws_name, peaks_ws_name,
Expand Down Expand Up @@ -89,6 +97,10 @@ RunSphereIntegrate::RunSphereIntegrate( MantidEVWorker * worker,
this->integrate_edge = integrate_edge;
}


/**
* Class to call sphereIntegrate in a separate thread.
*/
void RunSphereIntegrate::run()
{
worker->sphereIntegrate( peaks_ws_name, event_ws_name,
Expand All @@ -115,6 +127,10 @@ RunFitIntegrate::RunFitIntegrate( MantidEVWorker * worker,
this->use_ikeda_carpenter = use_ikeda_carpenter;
}


/**
* Class to call fitIntegrate in a separate thread.
*/
void RunFitIntegrate::run()
{
worker->fitIntegrate( peaks_ws_name, event_ws_name,
Expand Down Expand Up @@ -144,6 +160,10 @@ RunEllipsoidIntegrate::RunEllipsoidIntegrate( MantidEVWorker * worker,
this->outer_size = outer_size;
}


/**
* Class to call ellipsoidIntegrate in a separate thread.
*/
void RunEllipsoidIntegrate::run()
{
worker->ellipsoidIntegrate( peaks_ws_name, event_ws_name,
Expand Down Expand Up @@ -299,6 +319,7 @@ void MantidEV::initLayout()
this, SLOT( setEnabledEllipseSizeOptions_slot() ) );

// Add validators to all QLineEdit objects that require numeric values
m_uiForm.MaxMagQ_ledt->setValidator( new QDoubleValidator(m_uiForm.MaxMagQ_ledt));
m_uiForm.MaxABC_ledt->setValidator( new QDoubleValidator(m_uiForm.MaxABC_ledt));
m_uiForm.NumToFind_ledt->setValidator( new QDoubleValidator(m_uiForm.NumToFind_ledt));
m_uiForm.MinIntensity_ledt->setValidator( new QDoubleValidator(m_uiForm.MinIntensity_ledt));
Expand Down Expand Up @@ -338,6 +359,8 @@ void MantidEV::setDefaultState_slot()
m_uiForm.MDworkspace_ledt->setText("");
m_uiForm.LoadEventFile_rbtn->setChecked(true);
m_uiForm.EventFileName_ledt->setText("");
m_uiForm.MaxMagQ_ledt->setText("25");
m_uiForm.LorentzCorrection_ckbx->setChecked(true);
m_uiForm.UseExistingWorkspaces_rbtn->setChecked(false);
setEnabledLoadEventFileParams_slot(true);
last_event_file.clear();
Expand Down Expand Up @@ -454,8 +477,18 @@ void MantidEV::selectWorkspace_slot()
return;
}

double maxQ;
getDouble( m_uiForm.MaxMagQ_ledt, maxQ );
if ( maxQ <= 0 )
{
errorMessage("Max |Q| to Map to MD MUST BE POSITIVE.");
return;
}

RunLoadAndConvertToMD* runner = new RunLoadAndConvertToMD(worker,file_name,
ev_ws_name, md_ws_name );
ev_ws_name, md_ws_name,
maxQ,
m_uiForm.LorentzCorrection_ckbx->isChecked() );
bool running = m_thread_pool->tryStart( runner );
if ( !running )
errorMessage( "Failed to start Load and ConvertToMD thread...previous operation not complete" );
Expand Down Expand Up @@ -1282,6 +1315,9 @@ void MantidEV::setEnabledLoadEventFileParams_slot( bool on )
m_uiForm.EventFileName_lbl->setEnabled( on );
m_uiForm.EventFileName_ledt->setEnabled( on );
m_uiForm.SelectEventFile_btn->setEnabled( on );
m_uiForm.MaxMagQ_lbl->setEnabled( on );
m_uiForm.MaxMagQ_ledt->setEnabled( on );
m_uiForm.LorentzCorrection_ckbx->setEnabled( on );
}


Expand Down Expand Up @@ -1635,6 +1671,8 @@ void MantidEV::saveSettings( const std::string & filename )
state->setValue("MDworkspace_ledt", m_uiForm.MDworkspace_ledt->text());
state->setValue("LoadEventFile_rbtn", m_uiForm.LoadEventFile_rbtn->isChecked());
state->setValue("EventFileName_ledt", m_uiForm.EventFileName_ledt->text());
state->setValue("MaxMagQ_ledt", m_uiForm.MaxMagQ_ledt->text());
state->setValue("LorentzCorrection_ckbx", m_uiForm.LorentzCorrection_ckbx->isChecked());
state->setValue("UseExistingWorkspaces_rbtn", m_uiForm.UseExistingWorkspaces_rbtn->isChecked());

// Save Tab 2, Find Peaks
Expand Down Expand Up @@ -1728,6 +1766,8 @@ void MantidEV::loadSettings( const std::string & filename )
restore( state, "MDworkspace_ledt", m_uiForm.MDworkspace_ledt );
restore( state, "LoadEventFile_rbtn", m_uiForm.LoadEventFile_rbtn );
restore( state, "EventFileName_ledt", m_uiForm.EventFileName_ledt );
restore( state, "MaxMagQ_ledt", m_uiForm.MaxMagQ_ledt );
restore( state, "LorentzCorrection_ckbx", m_uiForm.LorentzCorrection_ckbx );
restore( state, "UseExistingWorkspaces_rbtn", m_uiForm.UseExistingWorkspaces_rbtn );

// Load Tab 2, Find Peaks
Expand Down
29 changes: 22 additions & 7 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MantidEVWorker.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <sstream>

#include "MantidQtCustomInterfaces/MantidEVWorker.h"
#include "MantidAPI/AnalysisDataService.h"
Expand Down Expand Up @@ -133,16 +134,24 @@ bool MantidEVWorker::isEventWorkspace( const std::string & event_ws_name )
* Load the specified NeXus event file into the specified EventWorkspace
* and convert it to the specified MD workspace.
*
* @param file_name Name of the NeXus file to load
* @param ev_ws_name Name of the event workspace to create
* @param md_ws_name Name of the MD workspace to create
* @param file_name Name of the NeXus file to load
* @param ev_ws_name Name of the event workspace to create
* @param md_ws_name Name of the MD workspace to create
* @param maxQ The largest absolute value of any component
* of Q to include. When ConvertToMD is called,
* MinValues = -maxQ,-maxQ,-maxQ and
* MaxValues = maxQ, maxQ, maxQ
* @param do_lorentz_corr Set true to do the Lorentz correction when
* converting to reciprocal space.
*
* @return true if the file was loaded and MD workspace was
* successfully created.
*/
bool MantidEVWorker::loadAndConvertToMD( const std::string & file_name,
const std::string & ev_ws_name,
const std::string & md_ws_name )
const std::string & md_ws_name,
double maxQ,
bool do_lorentz_corr )
{
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("Load");
alg->setProperty("Filename",file_name);
Expand All @@ -153,16 +162,22 @@ bool MantidEVWorker::loadAndConvertToMD( const std::string & file_name,
if ( !alg->execute() )
return false;

std::ostringstream min_str;
min_str << "-" << maxQ << ",-" << maxQ << ",-" << maxQ;

std::ostringstream max_str;
max_str << maxQ << "," << maxQ << "," << maxQ;

alg = AlgorithmManager::Instance().create("ConvertToMD");
alg->setProperty("InputWorkspace",ev_ws_name);
alg->setProperty("OutputWorkspace",md_ws_name);
alg->setProperty("OverwriteExisting",true);
alg->setProperty("QDimensions","Q3D");
alg->setProperty("dEAnalysisMode","Elastic");
alg->setProperty("QConversionScales","Q in A^-1");
alg->setProperty("LorentzCorrection",true);
alg->setProperty("MinValues","-35,-35,-35");
alg->setProperty("MaxValues","35,35,35");
alg->setProperty("LorentzCorrection",do_lorentz_corr);
alg->setProperty("MinValues",min_str.str());
alg->setProperty("MaxValues",max_str.str());
alg->setProperty("SplitInto","2");
alg->setProperty("SplitThreshold","50");
alg->setProperty("MaxRecursionDepth","13");
Expand Down

0 comments on commit 0649a3e

Please sign in to comment.