当前位置: 首页>>代码示例>>C++>>正文


C++ IAlgorithm_sptr::addObserver方法代码示例

本文整理汇总了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;
    }
开发者ID:mkoennecke,项目名称:mantid,代码行数:41,代码来源:MDEWEventNexusLoadingPresenter.cpp

示例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;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:51,代码来源:SQWLoadingPresenter.cpp

示例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");
}
开发者ID:mantidproject,项目名称:mantid,代码行数:20,代码来源:MDHWNexusLoadingPresenter.cpp


注:本文中的IAlgorithm_sptr::addObserver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。