Skip to content
Snippets Groups Projects
Commit aeeb9d05 authored by Dan Nixon's avatar Dan Nixon
Browse files

Merge pull request #531 from mantidproject/9505_Fitting_with_no_peaks

Fitting with no peaks
parents 7330325a 01f0cffc
No related merge requests found
...@@ -59,6 +59,7 @@ namespace CustomInterfaces ...@@ -59,6 +59,7 @@ namespace CustomInterfaces
void setParameter(const QString& funcIndex, const QString& paramName, double value); void setParameter(const QString& funcIndex, const QString& paramName, double value);
void setPeakPickerEnabled(bool enabled); void setPeakPickerEnabled(bool enabled);
void setPeakPicker(const IPeakFunction_const_sptr& peak); void setPeakPicker(const IPeakFunction_const_sptr& peak);
void displayError(const QString& message);
void help(); void help();
// -- End of IALCPeakFitting interface --------------------------------------------------------- // -- End of IALCPeakFitting interface ---------------------------------------------------------
......
...@@ -86,6 +86,12 @@ namespace CustomInterfaces ...@@ -86,6 +86,12 @@ namespace CustomInterfaces
/// @param peak :: A new peak to represent /// @param peak :: A new peak to represent
virtual void setPeakPicker(const IPeakFunction_const_sptr& peak) = 0; virtual void setPeakPicker(const IPeakFunction_const_sptr& peak) = 0;
/**
* Pops-up an error box
* @param message :: Error message to display
*/
virtual void displayError(const QString& message) = 0;
/// Opens the Mantid Wiki web page /// Opens the Mantid Wiki web page
virtual void help() = 0; virtual void help() = 0;
......
...@@ -31,7 +31,12 @@ namespace CustomInterfaces ...@@ -31,7 +31,12 @@ namespace CustomInterfaces
void ALCPeakFittingPresenter::fit() void ALCPeakFittingPresenter::fit()
{ {
m_model->fitPeaks(m_view->function("")); IFunction_const_sptr func = m_view->function("");
if ( func ) {
m_model->fitPeaks(func);
} else {
m_view->displayError("Couldn't fit an empty function");
}
} }
void ALCPeakFittingPresenter::onCurrentFunctionChanged() void ALCPeakFittingPresenter::onCurrentFunctionChanged()
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "MantidQtAPI/HelpWindow.h" #include "MantidQtAPI/HelpWindow.h"
#include <QMessageBox>
#include <qwt_symbol.h> #include <qwt_symbol.h>
namespace MantidQt namespace MantidQt
...@@ -109,6 +111,11 @@ void ALCPeakFittingView::help() ...@@ -109,6 +111,11 @@ void ALCPeakFittingView::help()
MantidQt::API::HelpWindow::showCustomInterface(NULL, QString("Muon_ALC")); MantidQt::API::HelpWindow::showCustomInterface(NULL, QString("Muon_ALC"));
} }
void ALCPeakFittingView::displayError(const QString& message)
{
QMessageBox::critical(m_widget, "Error", message);
}
} // namespace CustomInterfaces } // namespace CustomInterfaces
} // namespace Mantid } // namespace Mantid
...@@ -50,6 +50,7 @@ public: ...@@ -50,6 +50,7 @@ public:
MOCK_METHOD1(setPeakPicker, void(const IPeakFunction_const_sptr&)); MOCK_METHOD1(setPeakPicker, void(const IPeakFunction_const_sptr&));
MOCK_METHOD1(setFunction, void(const IFunction_const_sptr&)); MOCK_METHOD1(setFunction, void(const IFunction_const_sptr&));
MOCK_METHOD3(setParameter, void(const QString&, const QString&, double)); MOCK_METHOD3(setParameter, void(const QString&, const QString&, double));
MOCK_METHOD1(displayError, void(const QString&));
MOCK_METHOD0(help, void()); MOCK_METHOD0(help, void());
}; };
...@@ -127,6 +128,14 @@ public: ...@@ -127,6 +128,14 @@ public:
presenter.initialize(); presenter.initialize();
} }
void test_fitEmptyFunction()
{
ON_CALL(*m_view, function(QString(""))).WillByDefault(Return(IFunction_const_sptr()));
EXPECT_CALL(*m_view, displayError(QString("Couldn't fit an empty function"))).Times(1);
m_view->requestFit();
}
void test_fit() void test_fit()
{ {
IFunction_sptr peaks = createGaussian(1,2,3); IFunction_sptr peaks = createGaussian(1,2,3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment