本文整理汇总了C++中IAlgorithm_sptr::addObserver方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::addObserver方法的具体用法?C++ IAlgorithm_sptr::addObserver怎么用?C++ IAlgorithm_sptr::addObserver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::addObserver方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
/*
Executes the underlying algorithm to create the MVP model.
@param factory : visualisation factory to use.
@param loadingProgressUpdate : Handler for GUI updates while algorithm progresses.
@param drawingProgressUpdate : Handler for GUI updates while vtkDataSetFactory::create occurs.
*/
vtkDataSet* MDEWEventNexusLoadingPresenter::execute(vtkDataSetFactory* factory, ProgressAction& loadingProgressUpdate, ProgressAction& drawingProgressUpdate)
{
using namespace Mantid::API;
using namespace Mantid::Geometry;
if(this->shouldLoad())
{
Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification> observer(loadingProgressUpdate, &ProgressAction::handler);
AnalysisDataService::Instance().remove("MD_EVENT_WS_ID");
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->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
}
Workspace_sptr result=AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Mantid::API::IMDEventWorkspace_sptr eventWs = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(result);
factory->setRecursionDepth(this->m_view->getRecursionDepth());
//Create visualisation in one-shot.
vtkDataSet* visualDataSet = factory->oneStepCreate(eventWs, drawingProgressUpdate);
/*extractMetaData needs to be re-run here because the first execution of this from ::executeLoadMetadata will not have ensured that all dimensions
have proper range extents set.
*/
this->extractMetadata(eventWs);
this->appendMetadata(visualDataSet, eventWs->getName());
return visualDataSet;
}
示例2: observer
/*
Executes the underlying algorithm to create the MVP model.
@param factory : visualisation factory to use.
@param loadingProgressUpdate : Handler for GUI updates while algorithm
progresses.
@param drawingProgressUpdate : Handler for GUI updates while
vtkDataSetFactory::create occurs.
*/
vtkSmartPointer<vtkDataSet>
SQWLoadingPresenter::execute(vtkDataSetFactory *factory,
ProgressAction &loadingProgressUpdate,
ProgressAction &drawingProgressUpdate) {
using namespace Mantid::API;
using namespace Mantid::Geometry;
if (this->shouldLoad()) {
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");
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->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
}
Workspace_sptr result =
AnalysisDataService::Instance().retrieve("MD_EVENT_WS_ID");
Mantid::API::IMDEventWorkspace_sptr eventWs =
boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(result);
factory->setRecursionDepth(this->m_view->getRecursionDepth());
auto visualDataSet = factory->oneStepCreate(eventWs, drawingProgressUpdate);
this->appendMetadata(visualDataSet, eventWs->getName());
return visualDataSet;
}
示例3: loadWorkspace
void MDHWNexusLoadingPresenter::loadWorkspace(
ProgressAction &loadingProgressUpdate) {
using namespace Mantid::API;
Poco::NObserver<ProgressAction, Mantid::API::Algorithm::ProgressNotification>
observer(loadingProgressUpdate, &ProgressAction::handler);
AnalysisDataService::Instance().remove("MD_HISTO_WS_ID");
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("LoadMD");
alg->initialize();
alg->setPropertyValue("Filename", this->m_filename);
alg->setPropertyValue("OutputWorkspace", "MD_HISTO_WS_ID");
alg->setProperty(
"FileBackEnd",
!this->m_view->getLoadInMemory()); // Load from file by default.
alg->addObserver(observer);
alg->execute();
alg->removeObserver(observer);
m_histoWs = AnalysisDataService::Instance()
.retrieveWS<Mantid::API::IMDHistoWorkspace>("MD_HISTO_WS_ID");
}