コード例 #1
0
ファイル: LineViewer.cpp プロジェクト: trnielsen/mantid
/** Calculate and show the full (integrated) line, using the latest
 * integrated workspace. The apply() method must have been called
 * before calling this. */
void LineViewer::showFull()
{
  if (!m_sliceWS) return;
  MatrixWorkspace_const_sptr sliceMatrix = boost::dynamic_pointer_cast<const MatrixWorkspace>(m_sliceWS);
  if (sliceMatrix)
  {
    MantidQwtMatrixWorkspaceData curveData(sliceMatrix, 0, false /*not logScale*/);
    m_fullCurve->setData(curveData);
    Unit_const_sptr unit = sliceMatrix->getAxis(0)->unit();
    std::string title = unit->caption() + " (" + unit->label() + ")";
    m_plot->setAxisTitle( QwtPlot::xBottom, QString::fromStdString(title));;
    title = sliceMatrix->YUnit() + " (" + sliceMatrix->YUnitLabel() + ")";
    m_plot->setAxisTitle( QwtPlot::yLeft, QString::fromStdString(title));;
  }
  else
  {
    MantidQwtIMDWorkspaceData curveData(m_sliceWS, false,
        VMD(), VMD(), m_lineOptions->getNormalization());
    curveData.setPreviewMode(false);
    curveData.setPlotAxisChoice(m_lineOptions->getPlotAxis());
    m_fullCurve->setData(curveData);
    m_plot->setAxisTitle( QwtPlot::xBottom, QString::fromStdString( curveData.getXAxisLabel() ));;
    m_plot->setAxisTitle( QwtPlot::yLeft, QString::fromStdString( curveData.getYAxisLabel() ));;
  }

  if (m_previewCurve->isVisible())
  {
    m_previewCurve->setVisible(false);
    m_previewCurve->detach();
    m_fullCurve->attach(m_plot);
  }
  m_fullCurve->setVisible(true);
  m_plot->replot();
  m_plot->setTitle("Integrated Line Plot");
}
コード例 #2
0
ファイル: MergeRuns.cpp プロジェクト: mducle/mantid
/**
Test a workspace for compatibility with others on the basis of the arguments
provided.
@param ws : Workspace to test
@param xUnitID : Unit id for the x axis
@param YUnit : Y Unit
@param dist : flag indicating that the workspace should be a distribution
@param instrument : name of the instrument
@throws an invalid argument if a full match is not acheived.
*/
void MergeRuns::testCompatibility(MatrixWorkspace_const_sptr ws,
                                  const std::string &xUnitID,
                                  const std::string &YUnit, const bool dist,
                                  const std::string instrument) const {
    std::string errors;
    if (ws->getAxis(0)->unit()->unitID() != xUnitID)
        errors += "different X units; ";
    if (ws->YUnit() != YUnit)
        errors += "different Y units; ";
    if (ws->isDistribution() != dist)
        errors += "not all distribution or all histogram type; ";
    if (ws->getInstrument()->getName() != instrument)
        errors += "different instrument names; ";
    if (errors.length() > 0) {
        g_log.error("Input workspaces are not compatible: " + errors);
        throw std::invalid_argument("Input workspaces are not compatible: " +
                                    errors);
    }
}