Esempio n. 1
0
/**
 * Check if the rebin and unbin buttons should be visible
 * Note that for a rebin button to be visible there may be no
 * MDHisto workspaces present, yet  MDHisto workspaces which result from
 * rebinning within the VSI are allowed.
 */
void StandardView::setRebinAndUnbinButtons() {
  unsigned int numberOfInternallyRebinnedWorkspaces = 0;
  unsigned int numberOfTrueMDHistoWorkspaces = 0;
  unsigned int numberOfPeakWorkspaces = 0;

  pqServer *server = pqActiveObjects::instance().activeServer();
  pqServerManagerModel *smModel =
      pqApplicationCore::instance()->getServerManagerModel();
  const QList<pqPipelineSource *> sources =
      smModel->findItems<pqPipelineSource *>(server);

  foreach (pqPipelineSource *source, sources) {
    if (isInternallyRebinnedWorkspace(source)) {
      ++numberOfInternallyRebinnedWorkspaces;
    } else if (isMDHistoWorkspace(source)) {
      ++numberOfTrueMDHistoWorkspaces;
    } else if (isPeaksWorkspace(source)) {
      ++numberOfPeakWorkspaces;
    }
  }

  // If there are any true MDHisto workspaces then the rebin button should be
  // disabled
  bool allowRebinning =
      numberOfTrueMDHistoWorkspaces > 0 || numberOfPeakWorkspaces > 0;
  this->allowRebinningOptions(allowRebinning);

  // If there are no internally rebinned workspaces the button should be
  // disabled.
  allowUnbinOption(numberOfInternallyRebinnedWorkspaces > 0);
}
Esempio n. 2
0
/**
  * Listen for a change of the active source in order to check if the
  * active source is an MDEventSource for which we allow rebinning.
  */
void StandardView::activeSourceChangeListener(pqPipelineSource* source)
{
  // If there is no active source, then we do not allow rebinning
  if (!source)
  {
    this->allowRebinningOptions(false);
    this->m_unbinAction->setEnabled(false);
    return;
  }

  // If it is a filter work your way down
  pqPipelineSource* localSource = source;
  pqPipelineFilter* filter = qobject_cast<pqPipelineFilter*>(localSource);

  while(filter)
  {
    localSource = filter->getInput(0);
    filter = qobject_cast<pqPipelineFilter*>(localSource);
  }

  // Important to first check for an internally rebinned source, then for MDEvent source, 
  // since the internally rebinned source may be an MDEventSource.
  std::string workspaceType(localSource->getProxy()->GetXMLName());

  // Check if the source is associated with a workspace which was internally rebinned by the VSI.
  // In this case the user can further rebin or unbin the source.
  if (isInternallyRebinnedWorkspace(localSource))
  {
    this->allowRebinningOptions(true);
    this->allowUnbinOption(true);
  }
  // Check if we are dealing with a MDEvent workspace. In this case we allow rebinning, but 
  // unbinning will not make a lot of sense.
  else if (workspaceType.find("MDEW Source") != std::string::npos)
  {
    this->allowRebinningOptions(true);
    this->allowUnbinOption(false);
  }
  // Otherwise we must be dealing with either a MDHIsto or PeaksWorkspace
  // which cannot be neither rebinned nor unbinned.
  else
  {
    this->allowRebinningOptions(false);
    this->allowUnbinOption(false);
  }
}