Skip to content

Commit

Permalink
refs #4328 Work on Raw file processing with OrientedLattices.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 3, 2012
1 parent 7a29ed2 commit 956f6a6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace MantidQt

void findUBMatrixClicked();

void createMDWorkspaceClicked();

private:
Ui::CreateMDWorkspace m_uiForm;
WorkspaceMementoCollection m_data;
Expand Down
22 changes: 18 additions & 4 deletions Code/Mantid/MantidQt/CustomInterfaces/src/CreateMDWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 All @@ -64,7 +64,7 @@ namespace CustomInterfaces
{
std::vector<std::string> strs;
std::string id = m_benchmark->getId();
boost::split(strs, id, boost::is_any_of("/"));
boost::split(strs, id, boost::is_any_of("/,\\"));

std::stringstream streamPattern;
streamPattern << "(" << strs.back() << ")$";
Expand Down Expand Up @@ -96,6 +96,7 @@ 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()));
//Set MVC Model
m_uiForm.tableView->setModel(m_model);
}
Expand Down Expand Up @@ -135,6 +136,7 @@ void CreateMDWorkspace::setUBMatrixClicked()
if ( pyOutput == "1" )
{
memento->setReport(WorkspaceMemento::Ready);
memento->cleanUp();
m_model->update();
}
}
Expand Down Expand Up @@ -189,8 +191,15 @@ void CreateMDWorkspace::addFileClicked()
std::string name = fileName.toStdString();
if(!name.empty())
{
WorkspaceMemento_sptr candidate(new WorkspaceOnDisk(name));
addUniqueMemento(candidate);
try
{
WorkspaceMemento_sptr candidate(new WorkspaceOnDisk(name));
addUniqueMemento(candidate);
}
catch(std::invalid_argument& arg)
{
this->runConfirmation(arg.what());
}
}
}

Expand Down Expand Up @@ -241,6 +250,11 @@ int CreateMDWorkspace::runConfirmation(const std::string& message)
return msgBox.exec();
}

void CreateMDWorkspace::createMDWorkspaceClicked()
{
//Launch dialog
}


/// Destructor
CreateMDWorkspace::~CreateMDWorkspace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace MantidQt
}



/**
Getter for the id of the workspace
@return the id of the workspace
Expand Down
16 changes: 13 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/WorkspaceOnDisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ namespace MantidQt
std::string msg = "WorkspaceOnDisk:: Unknown File extension on: " + fileName;
throw std::invalid_argument(msg);
}

if(!checkStillThere())
{
throw std::runtime_error("WorkspaceOnDisk:: File doesn't exist");
}

std::vector<std::string> strs;
boost::split(strs, m_fileName, boost::is_any_of("/"));
boost::split(strs, m_fileName, boost::is_any_of("/,\\"));
m_adsID = strs.back();
m_adsID = m_adsID.substr(0, m_adsID.find('.'));

//Generate an initial report.
Mantid::API::MatrixWorkspace_sptr ws = fetchIt();
Expand Down Expand Up @@ -81,11 +83,19 @@ namespace MantidQt

IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("LoadRaw");
alg->initialize();
alg->setRethrows(true);
alg->setProperty("Filename", m_fileName);
alg->setProperty("OutputWorkspace", "_temp");
alg->setPropertyValue("OutputWorkspace", m_adsID);
alg->execute();

return boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve("_temp"));
Mantid::API::Workspace_sptr ws = AnalysisDataService::Instance().retrieve(m_adsID);

Mantid::API::WorkspaceGroup_sptr gws = boost::dynamic_pointer_cast<WorkspaceGroup>(ws);
if(gws != NULL)
{
throw std::invalid_argument("This raw file corresponds to a WorkspaceGroup. Cannot process groups like this. Import via MantidPlot instead.");
}
return boost::dynamic_pointer_cast<MatrixWorkspace>(ws);
}

/**
Expand Down

0 comments on commit 956f6a6

Please sign in to comment.