Skip to content

Commit

Permalink
refs #4328 #3641. Add custom dialog and fix bug.
Browse files Browse the repository at this point in the history
 Custom dialog enables users to enter parameters for ConvertToMDEvents once.
  • Loading branch information
OwenArnold committed Jan 6, 2012
1 parent c54fb8d commit 9708cb2
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set ( SRC_FILES
src/ConvertToEnergy.cpp
src/CreateMDWorkspace.cpp
src/CreateMDWorkspaceAlgDialog.cpp
src/EventNexusFileMemento.cpp
src/Homer.cpp
src/IO_MuonGrouping.cpp
Expand Down Expand Up @@ -29,6 +30,7 @@ set ( INC_FILES
inc/MantidQtCustomInterfaces/Background.h
inc/MantidQtCustomInterfaces/ConvertToEnergy.h
inc/MantidQtCustomInterfaces/CreateMDWorkspace.h
inc/MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h
inc/MantidQtCustomInterfaces/EventNexusFileMemento.h
inc/MantidQtCustomInterfaces/Homer.h
inc/MantidQtCustomInterfaces/IO_MuonGrouping.h
Expand Down Expand Up @@ -57,6 +59,7 @@ set ( SRC_UNITY_IGNORE_FILES )
set ( MOC_FILES inc/MantidQtCustomInterfaces/Background.h
inc/MantidQtCustomInterfaces/ConvertToEnergy.h
inc/MantidQtCustomInterfaces/CreateMDWorkspace.h
inc/MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h
inc/MantidQtCustomInterfaces/Homer.h
inc/MantidQtCustomInterfaces/Indirect.h
inc/MantidQtCustomInterfaces/IndirectDataAnalysis.h
Expand All @@ -73,6 +76,7 @@ set ( MOC_FILES inc/MantidQtCustomInterfaces/Background.h

set ( UI_FILES inc/MantidQtCustomInterfaces/ConvertToEnergy.ui
inc/MantidQtCustomInterfaces/CreateMDWorkspace.ui
inc/MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.ui
inc/MantidQtCustomInterfaces/IndirectDataAnalysis.ui
inc/MantidQtCustomInterfaces/IndirectDiffractionReduction.ui
inc/MantidQtCustomInterfaces/MuonAnalysis.ui
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef MANTIDQTCUSTOMINTERFACES_CREATEMDWORKSPACE_ALG_DIALOG_H_
#define MANTIDQTCUSTOMINTERFACES_CREATEMDWORKSPACE_ALG_DIALOG_H_

#include <QDialog>
#include "ui_CreateMDWorkspaceAlgDialog.h"

/// Code-behind for CreateMDWorkspaceAlgDialog.
class CreateMDWorkspaceAlgDialog : public QDialog
{
Q_OBJECT

public:

CreateMDWorkspaceAlgDialog();
virtual ~CreateMDWorkspaceAlgDialog();

QString getQDimension() const;
QString getAnalysisMode() const;
QString getOtherDimensions() const;
QString getMaxExtents() const;
QString getMinExtents() const;
bool getPreprocessedEvents() const;



private:

Ui::CreateMDWorkspaceAlgDialog m_uiForm;

};


#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateMDWorkspaceAlgDialog</class>
<widget class="QDialog" name="CreateMDWorkspaceAlgDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>456</width>
<height>205</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>You can to transfer source workspace dimensions into target worskpace directly (NoQ) or transform into mod(Q) (1 dimension) or QxQyQz (3 dimensions) in Q space</string>
</property>
<property name="text">
<string>Q Dimensions</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combo_q_dimensions"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>You can analyze neutron energy transfer in direct, indirect or elastic mode. The analysis mode has to correspond to experimenal set up.</string>
</property>
<property name="text">
<string>dE Analysis Mode</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="combo_analysis_mode"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>List(comma separated) of additional to Q (orthogonal) dimensions in the target workspace.</string>
</property>
<property name="text">
<string>Other Dimensions</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="txt_other_dimensions"/>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="ck_use_preprocessed_detectors">
<property name="text">
<string>Use Pre-processed detectors</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>An array of size:

a) 1+N_OtherDimensions if the first dimension (QDimensions property) is equal to |Q| or

b) 3+N_OtherDimensions if the first (3) dimensions (QDimensions property) equal QxQyQz or

c) (1 or 2)+N_OtherDimesnions if QDimesnins property is empty.

In case c) the target workspace dimensions are defined by the units of the input workspace axis


This array contains minimal values for all dimensions.

Momentum values expected to be in [A^-1] and energy transfer (if any) expressed in [meV]

All other values are in uints they are in their log files

Values lower than the specified one will be ignored

If a minimal target workspace range is higher than the one specified here, the target workspace range will be used instead
</string>
</property>
<property name="text">
<string>Min Values</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="txt_min_values">
<property name="toolTip">
<string>An array of the same size and the same units as MinValues array
Values higher then the specified by this array will be ignored
If a maximal target workspace range is lower, then one of specified here, the target workspace range will be used instead.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Max Values</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txt_max_values"/>
</item>
<item row="7" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Settings made here will be applied to every converted workspace.</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CreateMDWorkspaceAlgDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CreateMDWorkspaceAlgDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
27 changes: 25 additions & 2 deletions Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "MantidQtCustomInterfaces/RawFileMemento.h"
#include "MantidQtCustomInterfaces/EventNexusFileMemento.h"
#include "MantidQtCustomInterfaces/WorkspaceMemento.h"
#include "MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h"

#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/AnalysisDataService.h"
Expand Down Expand Up @@ -101,7 +102,6 @@ void CreateMDWorkspace::initLayout()
connect(m_uiForm.btn_remove_workspace, SIGNAL(clicked()), this, SLOT(removeSelectedClicked()));
connect(m_uiForm.btn_set_ub_matrix, SIGNAL(clicked()), this, SLOT(setUBMatrixClicked()));
connect(m_uiForm.btn_find_ub_matrix, SIGNAL(clicked()), this, SLOT(findUBMatrixClicked()));
connect(m_uiForm.btn_create, SIGNAL(clicked()), this, SLOT(createMDWorkspaceClicked()));
connect(m_uiForm.btn_set_goniometer, SIGNAL(clicked()), this, SLOT(setGoniometerClicked()));
//Set MVC Model
m_uiForm.tableView->setModel(m_model);
Expand Down Expand Up @@ -416,13 +416,36 @@ void CreateMDWorkspace::createMDWorkspaceClicked()
//Launch dialog

//1) Run a top-level dialog similar to ConvertToMDEvents. Extract all required arguments.
CreateMDWorkspaceAlgDialog algDlg;
algDlg.setModal(true);
int result = algDlg.exec();
if(result != QDialog::Accepted)
{
return;
}

QString qDimension = algDlg.getQDimension();
QString maxExtents = algDlg.getMaxExtents();
QString minExtents = algDlg.getMinExtents();
QString analysisMode = algDlg.getAnalysisMode();
QString otherDimensions = algDlg.getOtherDimensions();
bool preProcessedEvents = algDlg.getPreprocessedEvents();

//2) Run ConvertToMDEvents on each workspace.
for(WorkspaceMementoCollection::size_type i = 0; i < m_data.size(); i++)
{
//Workspace_sptr ws = m_data[i]->applyActions();
WorkspaceMemento_sptr currentMemento = m_data[i];
Workspace_sptr ws = currentMemento->applyActions();

//
//QString command = ""
// "";

//ConvertToMDEvents
//SaveMD


currentMemento->cleanUp();
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h"
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>

CreateMDWorkspaceAlgDialog::CreateMDWorkspaceAlgDialog()
{
m_uiForm.setupUi(this);

connect(m_uiForm.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_uiForm.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

m_uiForm.combo_q_dimensions->addItem("|Q|");
m_uiForm.combo_q_dimensions->addItem("QxQyQz");

m_uiForm.combo_analysis_mode->addItem("Direct");
m_uiForm.combo_analysis_mode->addItem("Indirect");
m_uiForm.combo_analysis_mode->addItem("InElastic");

this->setWindowTitle("Set MDWorkspace Creation Parameters");
}

QString CreateMDWorkspaceAlgDialog::getQDimension() const
{
return m_uiForm.combo_q_dimensions->currentText();
}

QString CreateMDWorkspaceAlgDialog::getAnalysisMode() const
{
return m_uiForm.combo_analysis_mode->currentText();
}

QString CreateMDWorkspaceAlgDialog::getOtherDimensions() const
{
return m_uiForm.txt_other_dimensions->text();
}

QString CreateMDWorkspaceAlgDialog::getMaxExtents() const
{
return m_uiForm.txt_max_values->text();
}

QString CreateMDWorkspaceAlgDialog::getMinExtents() const
{
return m_uiForm.txt_min_values->text();
}

bool CreateMDWorkspaceAlgDialog::getPreprocessedEvents() const
{
return m_uiForm.ck_use_preprocessed_detectors->isChecked();
}

CreateMDWorkspaceAlgDialog::~CreateMDWorkspaceAlgDialog()
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ namespace MantidQt
{
Mantid::API::Workspace_sptr ws = fetchIt();

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SetUB");
alg->initialize();
alg->setRethrows(true);
alg->setPropertyValue("Workspace", this->m_adsID);
alg->setProperty("UB", m_ub);
alg->execute();

if(m_ub.size() == 9)
{
Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SetUB");
alg->initialize();
alg->setRethrows(true);
alg->setPropertyValue("Workspace", this->m_adsID);
alg->setProperty("UB", m_ub);
alg->execute();
}
return AnalysisDataService::Instance().retrieve(m_adsID);
}

Expand Down
16 changes: 9 additions & 7 deletions Code/Mantid/MantidQt/CustomInterfaces/src/RawFileMemento.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ namespace MantidQt
{
Mantid::API::Workspace_sptr ws = fetchIt();

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SetUB");
alg->initialize();
alg->setRethrows(true);
alg->setPropertyValue("Workspace", this->m_adsID);
alg->setProperty("UB", m_ub);
alg->execute();

if(m_ub.size() == 9)
{
Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SetUB");
alg->initialize();
alg->setRethrows(true);
alg->setPropertyValue("Workspace", this->m_adsID);
alg->setProperty("UB", m_ub);
alg->execute();
}
return AnalysisDataService::Instance().retrieve(m_adsID);
}

Expand Down

0 comments on commit 9708cb2

Please sign in to comment.