コード例 #1
0
ファイル: MantidMatrix.cpp プロジェクト: mducle/mantid
void MantidMatrix::setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start,
                         int end) {
  if (!ws) {
    QMessageBox::critical(0, "WorkspaceMatrixModel error",
                          "2D workspace expected.");
    m_rows = 0;
    m_cols = 0;
    m_startRow = 0;
    m_endRow = 0;
    return;
  }

  m_workspace = ws;
  m_workspaceTotalHist = static_cast<int>(ws->getNumberHistograms());
  m_startRow = (start < 0 || start >= m_workspaceTotalHist) ? 0 : start;
  m_endRow = (end < 0 || end >= m_workspaceTotalHist || end < start)
                 ? m_workspaceTotalHist - 1
                 : end;
  m_rows = m_endRow - m_startRow + 1;
  m_cols = static_cast<int>(ws->blocksize());
  if (ws->isHistogramData())
    m_histogram = true;
  connect(this, SIGNAL(needsUpdating()), this, SLOT(repaintAll()));

  m_bk_color = QColor(128, 255, 255);
  m_matrix_icon = getQPixmap("mantid_matrix_xpm");
  m_column_width = 100;
}
コード例 #2
0
ファイル: IDATab.cpp プロジェクト: trnielsen/mantid
  /**
   * Creates and returns a "mini plot", from the given QwtPlot and QwtPlotCurve objects, as well as the given workspace
   * and workspace index.
   *
   * @param plot      :: the QwtPlot object
   * @param curve     :: the QwtPlotCurve object
   * @param workspace :: the workspace to use
   * @param wsIndex   :: the workspace index
   *
   * @returns the resulting QwtPlotCurve object
   */
  QwtPlotCurve* IDATab::plotMiniplot(QwtPlot* plot, QwtPlotCurve* curve, const std::string & workspace, size_t wsIndex)
  {
    if ( curve != NULL )
    {
      curve->attach(0);
      delete curve;
      curve = 0;
    }

    Mantid::API::MatrixWorkspace_const_sptr ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(Mantid::API::AnalysisDataService::Instance().retrieve(workspace));

    size_t nhist = ws->getNumberHistograms();
    if ( wsIndex >= nhist )
    {
      showInformationBox("Error: Workspace index out of range.");
      return NULL;
    }

    using Mantid::MantidVec;
    const MantidVec & dataX = ws->readX(wsIndex);
    const MantidVec & dataY = ws->readY(wsIndex);

    curve = new QwtPlotCurve();
    curve->setData(&dataX[0], &dataY[0], static_cast<int>(ws->blocksize()));
    curve->attach(plot);

    plot->replot();

    return curve;
  }
コード例 #3
0
ファイル: InstrumentActor.cpp プロジェクト: stothe2/mantid
/**
 * Sum counts in detectors for purposes of rough plotting against the units on the x-axis.
 * Checks (approximately) if the workspace is ragged or not and uses the appropriate summation
 * method.
 *
 * @param dets :: A list of detector IDs to sum.
 * @param x :: (output) Time of flight values (or whatever values the x axis has) to plot against.
 * @param y :: (output) The sums of the counts for each bin.
 * @param size :: (optional input) Size of the output vectors. If not given it will be determined automatically.
 */
void InstrumentActor::sumDetectors(QList<int> &dets, std::vector<double> &x, std::vector<double> &y, size_t size) const
{
    Mantid::API::MatrixWorkspace_const_sptr ws = getWorkspace();
    if ( size > ws->blocksize() || size == 0 )
    {
        size = ws->blocksize();
    }

    if ( m_ragged )
    {
        // could be slower than uniform
        sumDetectorsRagged( dets, x, y, size );
    }
    else
    {
        // should be faster than ragged
        sumDetectorsUniform( dets, x, y );
    }
}