Skip to content

Commit

Permalink
refs #5929. Refactoring done.
Browse files Browse the repository at this point in the history
Should have got rid of all all offending algorithm instances
  • Loading branch information
OwenArnold committed Oct 10, 2012
1 parent 8342d9d commit db58f42
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 40 deletions.
18 changes: 9 additions & 9 deletions Code/Mantid/Vates/VatesAPI/src/EventNexusLoadingPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "MantidNexusCPP/NeXusFile.hpp"
#include "MantidNexusCPP/NeXusException.hpp"
#include "MantidMDEvents/OneStepMDEW.h"
#include "MantidAPI/AlgorithmManager.h"

#include <vtkUnstructuredGrid.h>

Expand Down Expand Up @@ -99,14 +99,14 @@ namespace Mantid
Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(loadingProgressUpdate, &ProgressAction::handler);
AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");

Mantid::MDEvents::OneStepMDEW alg;
alg.initialize();
alg.setRethrows(true);
alg.setPropertyValue("Filename", this->m_filename);
alg.setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg.addObserver(observer);
alg.execute();
alg.removeObserver(observer);
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("OneStepMDEW");
alg->initialize();
alg->setRethrows(true);
alg->setPropertyValue("Filename", this->m_filename);
alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
}

Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Expand Down
33 changes: 18 additions & 15 deletions Code/Mantid/Vates/VatesAPI/src/MDEWEventNexusLoadingPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "MantidNexusCPP/NeXusFile.hpp"
#include "MantidNexusCPP/NeXusException.hpp"
#include "MantidMDEvents/LoadMD.h"
#include "MantidAPI/AlgorithmManager.h"

#include <vtkUnstructuredGrid.h>

Expand Down Expand Up @@ -77,13 +77,15 @@ namespace Mantid
Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(loadingProgressUpdate, &ProgressAction::handler);
AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");

Mantid::MDEvents::LoadMD alg;
alg.initialize();
alg.setPropertyValue("Filename", this->m_filename);
alg.setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg.setProperty("FileBackEnd", !this->m_view->getLoadInMemory()); //Load from file by default.
alg.setPropertyValue("Memory", "0");
alg.execute();
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadMD");
alg->initialize();
alg->setPropertyValue("Filename", this->m_filename);
alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg->setProperty("FileBackEnd", !this->m_view->getLoadInMemory()); //Load from file by default.
alg->setPropertyValue("Memory", "0");
alg->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
}

Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Expand All @@ -110,13 +112,14 @@ namespace Mantid
using namespace Mantid::API;
AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");

Mantid::MDEvents::LoadMD alg;
alg.initialize();
alg.setPropertyValue("Filename", this->m_filename);
alg.setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg.setProperty("MetadataOnly", true); //Don't load the events.
alg.setProperty("FileBackEnd", true); //Only require metadata, so do it in memory.
alg.execute();
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadMD");

alg->initialize();
alg->setPropertyValue("Filename", this->m_filename);
alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg->setProperty("MetadataOnly", true); //Don't load the events.
alg->setProperty("FileBackEnd", true); //Only require metadata, so do it in memory.
alg->execute();

Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
IMDEventWorkspace_sptr eventWs = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(result);
Expand Down
31 changes: 15 additions & 16 deletions Code/Mantid/Vates/VatesAPI/src/SQWLoadingPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "MantidVatesAPI/ProgressAction.h"
#include "MantidVatesAPI/vtkDataSetFactory.h"

#include "MantidMDEvents/LoadSQW.h"
#include "MantidAPI/AlgorithmManager.h"
#include <boost/regex.hpp>

namespace Mantid
Expand Down Expand Up @@ -58,22 +58,21 @@ namespace Mantid
Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(loadingProgressUpdate, &ProgressAction::handler);
AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");


IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadSQW");

Mantid::MDEvents::LoadSQW alg;
alg.initialize();
alg.setPropertyValue("Filename", this->m_filename);
alg.setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg->initialize();
alg->setPropertyValue("Filename", this->m_filename);
alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
//Default is not to load into memory and when this is the case, generate a nxs backend for output.
if(!this->m_view->getLoadInMemory())
{
size_t pos = this->m_filename.find(".");
std::string backEndFile = this->m_filename.substr(0, pos) + ".nxs";
alg.setPropertyValue("OutputFilename", backEndFile);
alg->setPropertyValue("OutputFilename", backEndFile);
}
alg.addObserver(observer);
alg.execute();
alg.removeObserver(observer);
alg->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
}

Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Expand Down Expand Up @@ -146,12 +145,12 @@ namespace Mantid

AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");

Mantid::MDEvents::LoadSQW alg;
alg.initialize();
alg.setPropertyValue("Filename", this->m_filename);
alg.setProperty("MetadataOnly", true); //Don't load the events.
alg.setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg.execute();
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadSQW");
alg->initialize();
alg->setPropertyValue("Filename", this->m_filename);
alg->setProperty("MetadataOnly", true); //Don't load the events.
alg->setPropertyValue("OutputWorkspace", "MD_EVENT_WS_ID");
alg->execute();

Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Mantid::API::IMDEventWorkspace_sptr eventWs = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(result);
Expand Down

0 comments on commit db58f42

Please sign in to comment.