Skip to content

Commit

Permalink
Re #12398 Display errors in PeakFitting step
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelalvarezbanos committed Jun 15, 2015
1 parent 572cdf7 commit 6343dc6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
Expand Up @@ -12,6 +12,14 @@
#include <QWidget>
#include <qwt_plot_curve.h>

namespace MantidQt
{
namespace MantidWidgets
{
class ErrorCurve;
}
}

namespace MantidQt
{
namespace CustomInterfaces
Expand Down Expand Up @@ -43,6 +51,7 @@ namespace CustomInterfaces
{
public:
ALCPeakFittingView(QWidget* widget);
~ALCPeakFittingView();

// -- IALCPeakFitting interface ----------------------------------------------------------------

Expand All @@ -53,7 +62,7 @@ namespace CustomInterfaces
public slots:

void initialize();
void setDataCurve(const QwtData& data);
void setDataCurve(const QwtData &data, const std::vector<double> &errors);
void setFittedCurve(const QwtData& data);
void setFunction(const IFunction_const_sptr& newFunction);
void setParameter(const QString& funcIndex, const QString& paramName, double value);
Expand All @@ -74,6 +83,9 @@ namespace CustomInterfaces
/// Plot curves
QwtPlotCurve *m_dataCurve, *m_fittedCurve;

/// Error curves
MantidQt::MantidWidgets::ErrorCurve *m_dataErrorCurve;

/// Peak picker tool - only one on the plot at any given moment
MantidWidgets::PeakPicker* m_peakPicker;
};
Expand Down
Expand Up @@ -62,7 +62,8 @@ namespace CustomInterfaces

/// Update the data curve displayed
/// @param data :: New curve data
virtual void setDataCurve(const QwtData& data) = 0;
virtual void setDataCurve(const QwtData &data,
const std::vector<double> &errors) = 0;

/// Update the fitted curve displayed
/// @param data :: New curve data
Expand Down
Expand Up @@ -108,7 +108,8 @@ namespace CustomInterfaces

void ALCPeakFittingPresenter::onDataChanged()
{
m_view->setDataCurve(*(ALCHelper::curveDataFromWs(m_model->data(), 0)));
m_view->setDataCurve(*(ALCHelper::curveDataFromWs(m_model->data(), 0)),
ALCHelper::curveErrorsFromWs(m_model->data(), 0));
}

} // namespace CustomInterfaces
Expand Down
@@ -1,6 +1,7 @@
#include "MantidQtCustomInterfaces/Muon/ALCPeakFittingView.h"

#include "MantidQtAPI/HelpWindow.h"
#include "MantidQtMantidWidgets/ErrorCurve.h"

#include <QMessageBox>

Expand All @@ -13,9 +14,19 @@ namespace CustomInterfaces

ALCPeakFittingView::ALCPeakFittingView(QWidget* widget)
: m_widget(widget), m_ui(), m_dataCurve(new QwtPlotCurve()), m_fittedCurve(new QwtPlotCurve()),
m_peakPicker(NULL)
m_dataErrorCurve(NULL), m_peakPicker(NULL)
{}

ALCPeakFittingView::~ALCPeakFittingView()
{
m_dataCurve->detach();
delete m_dataCurve;
if (m_dataErrorCurve) {
m_dataErrorCurve->detach();
delete m_dataErrorCurve;
}
}

IFunction_const_sptr ALCPeakFittingView::function(QString index) const
{
return m_ui.peaks->getFunctionByIndex(index);
Expand Down Expand Up @@ -62,9 +73,22 @@ void ALCPeakFittingView::initialize()
connect(m_ui.help, SIGNAL(clicked()), this, SLOT(help()));
}

void ALCPeakFittingView::setDataCurve(const QwtData& data)
{
void ALCPeakFittingView::setDataCurve(const QwtData &data,
const std::vector<double> &errors) {

// Set data
m_dataCurve->setData(data);

// Set errors
if (m_dataErrorCurve) {
m_dataErrorCurve->detach();
delete m_dataErrorCurve;
}
m_dataErrorCurve =
new MantidQt::MantidWidgets::ErrorCurve(m_dataCurve, errors);
m_dataErrorCurve->attach(m_ui.plot);

// Replot
m_ui.plot->replot();
}

Expand Down

0 comments on commit 6343dc6

Please sign in to comment.