예제 #1
0
/**
 * Get the viewable peaks. Essentially copied from the slice viewer.
 * @returns A vector indicating which of the peaks are viewable.
 */
std::vector<bool> ConcretePeaksPresenterVsi::getViewablePeaks() const {
  // Need to apply a transform.
  // Don't bother to find peaks in the region if there are no peaks to find.
  Mantid::API::ITableWorkspace_sptr outTable;

  if (this->m_peaksWorkspace->getNumberPeaks() >= 1) {
    double effectiveRadius = 1e-2;
    std::string viewable = m_viewableRegion->toExtentsAsString();
    Mantid::API::IPeaksWorkspace_sptr peaksWS = m_peaksWorkspace;

    Mantid::API::IAlgorithm_sptr alg =
        Mantid::API::AlgorithmManager::Instance().create("PeaksInRegion");
    alg->setChild(true);
    alg->setRethrows(true);
    alg->initialize();
    alg->setProperty("InputWorkspace", peaksWS);
    alg->setProperty("OutputWorkspace", peaksWS->name() + "_peaks_in_region");
    alg->setProperty("Extents", viewable);
    alg->setProperty("CheckPeakExtents", true);
    alg->setProperty("PeakRadius", effectiveRadius);
    alg->setPropertyValue("CoordinateFrame", m_frame);
    alg->execute();
    outTable = alg->getProperty("OutputWorkspace");
    std::vector<bool> viewablePeaks(outTable->rowCount());
    for (size_t i = 0; i < outTable->rowCount(); ++i) {
      viewablePeaks[i] = outTable->cell<Mantid::API::Boolean>(i, 1);
    }
    m_viewablePeaks = viewablePeaks;
  } else {
    // No peaks will be viewable
    m_viewablePeaks = std::vector<bool>();
  }

  return m_viewablePeaks;
}
예제 #2
0
    /**This method updates the search result to search tree
     *@param ws_sptr :: workspace shared pointer
     *@param tablewidget :: pointer to table widget
     */
    void ICatUtils::updatesearchResults(Mantid::API::ITableWorkspace_sptr& ws_sptr,QTableWidget* tablewidget )
    {
      if(!ws_sptr || ws_sptr->rowCount()==0)
      {
        return ;
      }

      //now set alternating color flag
      tablewidget->setAlternatingRowColors(true);
      //stylesheet for alternating background color
      tablewidget->setStyleSheet("alternate-background-color: rgb(216, 225, 255)");
      //disable  sorting as per QT documentation.otherwise  setitem will give undesired results
      tablewidget->setSortingEnabled(false);

      tablewidget->verticalHeader()->setVisible(false);
      tablewidget->setRowCount(static_cast<int>(ws_sptr->rowCount()));
      tablewidget->setColumnCount(static_cast<int>(ws_sptr->columnCount()));

      for (size_t i=0;i<ws_sptr->rowCount();++i)
      {
        //setting the row height of tableWidget
        tablewidget->setRowHeight(static_cast<int>(i),20);
      }

      QStringList qlabelList;
      for(size_t i=0;i<ws_sptr->columnCount();i++)
      {
        Column_sptr col_sptr = ws_sptr->getColumn(i);
        //get the column name to display as the header of table widget
        QString colTitle = QString::fromStdString(col_sptr->name());
        qlabelList.push_back(colTitle);

        for(size_t j=0;j<ws_sptr->rowCount();++j)
        {
          std::ostringstream ostr;
          col_sptr->print(j,ostr);

          QTableWidgetItem *newItem  = new QTableWidgetItem(QString::fromStdString(ostr.str()));
          newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
          tablewidget->setItem(static_cast<int>(j),static_cast<int>(i), newItem);
          newItem->setToolTip(QString::fromStdString(ostr.str()));
        }
      }
      QFont font;
      font.setBold(true);
      //setting table widget header labels from table workspace
      tablewidget->setHorizontalHeaderLabels(qlabelList);
      for (int i=0;i<tablewidget->columnCount();++i)
      {
        tablewidget->horizontalHeaderItem(i)->setFont(font);
        tablewidget->horizontalHeaderItem(i)->setTextAlignment(Qt::AlignLeft);
      }
      //sorting by title
      tablewidget->sortByColumn(2,Qt::AscendingOrder);
      //enable sorting
      tablewidget->setSortingEnabled(true);
      tablewidget->resizeColumnsToContents();
    }
예제 #3
0
 /// for displaying the investigatiosn count
 void ICatUtils::updateSearchLabel(const Mantid::API::ITableWorkspace_sptr& ws_sptr,QLabel* label)
 {
   std::stringstream rowcount;
   QString results("Search Results : ");
   if(!ws_sptr)
   {
     results+="No investigations to display as an error occured";
   }
   else{
     rowcount<<ws_sptr->rowCount();
     results+=QString::fromStdString(rowcount.str()) + " Investigations Found";
   }
   setLabelText(label,results);
 }