Newer
Older
}
return yPositiveMin;
}
/**
* Set up the appropriate scale engine.
* Uses the isLogScaled method to work out which scale engine to make.
* @param curveData : Curve Data to read.
*/
void LineViewer::setupScaleEngine(MantidQwtWorkspaceData& curveData)
{
QwtScaleEngine* engine = NULL;
auto from = curveData.getYMin();
auto to = curveData.getYMax();
if (m_lineOptions->isLogScaledY())
{
engine = new QwtLog10ScaleEngine();
curveData.saveLowestPositiveValue(from);
}
else
{
engine = new QwtLinearScaleEngine();
}
m_plot->setAxisScaleEngine(QwtPlot::yLeft, engine);
m_plot->setAxisScale(QwtPlot::yLeft, from, to);
//-----------------------------------------------------------------------------
/** Calculate and show the preview (non-integrated) line,
* using the current parameters. */
void LineViewer::showPreview()
{
MantidQwtIMDWorkspaceData curveData(m_ws, isLogScaledY(),
m_start, m_end, m_lineOptions->getNormalization());
curveData.setPreviewMode(true);
curveData.setPlotAxisChoice(m_lineOptions->getPlotAxis());
m_previewCurve->setData(curveData);
if (m_fullCurve->isVisible())
{
m_fullCurve->setVisible(false);
m_fullCurve->detach();
m_previewCurve->attach(m_plot);
}
setupScaleEngine(curveData);
m_previewCurve->setVisible(true);
m_plot->replot();
m_plot->setTitle("Preview Plot");
m_plot->setAxisTitle( QwtPlot::xBottom, curveData.getXAxisLabel() );
m_plot->setAxisTitle( QwtPlot::yLeft, curveData.getYAxisLabel() );
/**
Gets the dimension index corresponding to the lineviewers preview plot x axis.
@return the index.
*/
int LineViewer::getXAxisDimensionIndex() const
{
MantidQwtIMDWorkspaceData curveData(m_ws, isLogScaledY(),
m_start, m_end, m_lineOptions->getNormalization());
curveData.setPreviewMode(true);
curveData.setPlotAxisChoice(m_lineOptions->getPlotAxis());
return curveData.currentPlotXAxis();
}
/**
* Getter for the log scaled status.
* @return True if and only if the y-axis is log scaled.
*/
bool LineViewer::isLogScaledY() const
{
return m_lineOptions->isLogScaledY();
}
//-----------------------------------------------------------------------------
/** 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_sptr sliceMatrix = boost::dynamic_pointer_cast<MatrixWorkspace>(m_sliceWS);
if (sliceMatrix)
{
const bool distribution(false);
QwtWorkspaceSpectrumData curveData(*sliceMatrix, 0, isLogScaledY(), distribution);
m_fullCurve->setData(curveData);
m_plot->setAxisTitle( QwtPlot::xBottom, curveData.getXAxisLabel() );
m_plot->setAxisTitle( QwtPlot::yLeft, curveData.getYAxisLabel() );
MantidQwtIMDWorkspaceData curveData(m_sliceWS, isLogScaledY(),
VMD(), VMD(), m_lineOptions->getNormalization());
curveData.setPreviewMode(false);
curveData.setPlotAxisChoice(m_lineOptions->getPlotAxis());
m_fullCurve->setData(curveData);
m_plot->setAxisTitle( QwtPlot::xBottom, curveData.getXAxisLabel() );
m_plot->setAxisTitle( QwtPlot::yLeft, 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");
//-----------------------------------------------------------------------------
/** Slot called when the options of the plot display change (normalization
* or plot axis.
* Refreshes the preview or full plot, whichever is visible.
*/
void LineViewer::refreshPlot()
{
if (m_previewCurve->isVisible())
showPreview();
else
showFull();
}
/**
* Handler for the log10 toggle axis event.
*/
void LineViewer::onToggleLogYAxis()
{