Skip to content

Commit

Permalink
refs #4328. Start handling goniometer settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 4, 2012
1 parent 158f3f6 commit 444b746
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace MantidQt

void createMDWorkspaceClicked();

void setGoniometerClicked();

private:
Ui::CreateMDWorkspace m_uiForm;
WorkspaceMementoCollection m_data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MANTID_CUSTOMINTERFACES_MEMENTO_H_

#include "MantidKernel/System.h"
#include "MantidKernel/Matrix.h"
#include "MantidAPI/MatrixWorkspace.h"
#include <string>
#include <vector>
Expand Down Expand Up @@ -77,6 +78,10 @@ namespace MantidQt
void setUB(const double& ub00, const double& ub01, const double& ub02, const double& ub10, const double& ub11, const double& ub12, const double& ub20, const double& ub21, const double& ub22);
/// Getter for a ub matrix.
std::vector<double> getUB() const;
/// Sets the goniometer matrix
void setGoniometer(const Mantid::Kernel::DblMatrix& matrix);
/// Getter for the goniometer matrix
Mantid::Kernel::DblMatrix getGoniometer() const;
/// Destructor
virtual ~WorkspaceMemento(){};
/// Common implementation for generating status
Expand All @@ -87,9 +92,12 @@ namespace MantidQt
/// Extract a friendly status.
std::string interpretStatus(const Status arg) const;

//Vector of elements describing a UB matrix.
// Vector of elements describing a UB matrix.
std::vector<double> m_ub;

// Goniometer matrix
Mantid::Kernel::DblMatrix m_goniometer;

};

/// WorkspaceMemento shared_ptr
Expand Down
35 changes: 34 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace CustomInterfaces
{

//Add this class to the list of specialised dialogs in this namespace
DECLARE_SUBWINDOW(CreateMDWorkspace); //TODO: Enable this to use it via mantid plot. Not ready for this yet!
//DECLARE_SUBWINDOW(CreateMDWorkspace); //TODO: Enable this to use it via mantid plot. Not ready for this yet!

/**
Helper type to perform comparisons between WorkspaceMementos
Expand Down Expand Up @@ -98,6 +98,7 @@ void CreateMDWorkspace::initLayout()
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 @@ -299,6 +300,38 @@ void CreateMDWorkspace::addFileClicked()
}
}

/**
Handler for setting the goniometer.
*/
void CreateMDWorkspace::setGoniometerClicked()
{
try
{
WorkspaceMemento_sptr memento = getFirstSelected();
Mantid::API::MatrixWorkspace_sptr ws = memento->fetchIt();
QString id = QString(memento->getId().c_str());

QString pyInput =
"from mantidsimple import *\n"
"import sys\n"
"try:\n"
" wsName='%1'\n"
" SetGoniometer(Workspace=wsName)\n"
" print 'SUCCESS'\n"
"except:\n"
" print 'FAIL'\n";

pyInput = pyInput.arg(id);
QString pyOutput = runPythonCode(pyInput).trimmed();

}
catch(std::invalid_argument& ex)
{
runConfirmation(ex.what());
}
}


/*
Remove any selected workspace mementos
*/
Expand Down
18 changes: 18 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/WorkspaceMemento.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ namespace MantidQt
m_ub[8] = ub22;
}

/**
Setter for the goniometer matrix
@param goniometer matrix.
*/
void WorkspaceMemento::setGoniometer(const Mantid::Kernel::DblMatrix& matrix)
{
m_goniometer = matrix;
}

/**
Getter for the goniometer matrix
@return goniometer matrix
*/
Mantid::Kernel::DblMatrix WorkspaceMemento::getGoniometer() const
{
return m_goniometer;
}

/*
Getter for the ubmatrix
@return vector of elements. indexed by row then by column. i.e. First 3 entries are from the first row and span all columns.
Expand Down

0 comments on commit 444b746

Please sign in to comment.