コード例 #1
0
ファイル: InputHistory.cpp プロジェクト: jkrueger1/mantid
/**
     Upadates the non-default algorithm properties in the history.
     @param alg :: Pointer to the algorthm
*/
void InputHistoryImpl::updateAlgorithm(Mantid::API::IAlgorithm_sptr alg)
{
    const std::vector< Property* >& props = alg->getProperties();
    QList< PropertyData > prop_hist_list;
    for(std::vector< Property* >::const_iterator prop=props.begin();prop!=props.end();++prop)
    if (!(*prop)->isDefault())
    {
        PropertyData prop_hist(QString::fromStdString((*prop)->name()),QString::fromStdString((*prop)->value()));
        prop_hist_list.push_back(prop_hist);
    }
    else
    {
        PropertyData prop_hist(QString::fromStdString((*prop)->name()),"");
        prop_hist_list.push_back(prop_hist);
    }
    m_history[QString::fromStdString(alg->name())] = prop_hist_list;
}
コード例 #2
0
ファイル: AlgorithmDialog.cpp プロジェクト: DanNixon/mantid
/**
 * Set the algorithm pointer
 * @param alg :: A pointer to the algorithm
 */
void AlgorithmDialog::setAlgorithm(Mantid::API::IAlgorithm_sptr alg) {
  m_algorithm = alg;
  m_algName = QString::fromStdString(alg->name());
  m_algProperties.clear();
  m_tied_properties.clear();
  std::vector<Mantid::Kernel::Property *>::const_iterator iend =
      alg->getProperties().end();
  for (std::vector<Mantid::Kernel::Property *>::const_iterator itr =
           alg->getProperties().begin();
       itr != iend; ++itr) {
    Mantid::Kernel::Property *p = *itr;
    if (dynamic_cast<Mantid::API::IWorkspaceProperty *>(p) ||
        p->direction() != Mantid::Kernel::Direction::Output) {
      m_algProperties.append(QString::fromStdString(p->name()));
    }
  }

  m_validators.clear();
  m_noValidation.clear();
}
コード例 #3
0
ファイル: AlgorithmDialog.cpp プロジェクト: DanNixon/mantid
/**
 * Execute the underlying algorithm
 */
void AlgorithmDialog::executeAlgorithmAsync() {
  Mantid::API::IAlgorithm_sptr algToExec = m_algorithm;
  // Clear any previous trackers so we know what state we are in
  this->stopObserving(algToExec);

  try {
    // Add any custom AlgorithmObservers to the algorithm
    for (auto it = m_observers.begin(); it != m_observers.end(); ++it) {
      (*it)->observeAll(algToExec);
    }

    // Only need to observe finish events if we are staying open
    if (m_keepOpenCheckBox && m_keepOpenCheckBox->isChecked()) {
      this->observeFinish(algToExec);
      this->observeError(algToExec);
      m_statusTracked = true;
      // Disable close button for a short period. If it is clicked to soon then
      // Mantid crashes - https://github.com/mantidproject/mantid/issues/13836
      if (m_exitButton) {
        m_exitButton->setEnabled(false);
        m_btnTimer.setInterval(1000);
        connect(&m_btnTimer, SIGNAL(timeout()), this, SLOT(enableExitButton()));
      } else {
        m_statusTracked = false;
      }
    }
    algToExec->executeAsync();
    m_btnTimer.start();

    if (m_okButton) {
      m_okButton->setEnabled(false);
    }
  } catch (Poco::NoThreadAvailableException &) {
    g_log.error() << "No thread was available to run the " << algToExec->name()
                  << " algorithm in the background.\n";
  }
}