Skip to content

Commit

Permalink
refs #5167. Refactor to simplify.
Browse files Browse the repository at this point in the history
Remove PeakOverlayFactoryBase class. Most of the logic had already been stripped out of this type. Also added a test for the NullPeaksPresenter since object of this type should be neutral in existance, yielding no noticable affect on the system whatsoever.
  • Loading branch information
OwenArnold committed Nov 29, 2012
1 parent a7866b4 commit 49acde5
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 249 deletions.
4 changes: 1 addition & 3 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set ( SRC_FILES
src/LineViewer.cpp
src/PeakOverlay.cpp
src/PeakOverlayFactory.cpp
src/PeakOverlayFactoryBase.cpp
src/PeakTransform.cpp
src/QScienceSpinBox.cpp
src/QwtRasterDataMD.cpp
Expand All @@ -33,7 +32,6 @@ set ( INC_FILES
inc/MantidQtSliceViewer/PeakOverlayView.h
inc/MantidQtSliceViewer/PeakOverlayViewFactory.h
inc/MantidQtSliceViewer/PeakOverlayFactory.h
inc/MantidQtSliceViewer/PeakOverlayFactoryBase.h
inc/MantidQtSliceViewer/PeaksPresenter.h
inc/MantidQtSliceViewer/PeakTransform.h
inc/MantidQtSliceViewer/QScienceSpinBox.h
Expand Down Expand Up @@ -71,8 +69,8 @@ set ( UI_FILES

set ( TEST_FILES
test/ConcretePeaksPresenterTest.h
test/PeakOverlayFactoryBaseTest.h
test/PeakTransformTest.h
test/NullPeaksPresenterTest.h
)

# Python unit tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define MANTID_SLICEVIEWER_PEAKOVERLAY_FACTORY_H_

#include "DllOption.h"
#include "MantidQtSliceViewer/PeakOverlayFactoryBase.h"
#include "MantidQtSliceViewer/PeakOverlayViewFactory.h"
#include <QtGui/qwidget.h>
#include <qwt_plot.h>
#include <boost/shared_ptr.hpp>
Expand Down Expand Up @@ -46,18 +46,21 @@ namespace MantidQt
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PeakOverlayFactory : public PeakOverlayFactoryBase
class DLLExport PeakOverlayFactory : public PeakOverlayViewFactory
{
private:
QwtPlot * m_plot;
QWidget * m_parent;
double m_peakRadius;
boost::shared_ptr<PeakOverlayView> createViewAtPoint(const Mantid::Kernel::V3D& position, const double& radius) const;

public:
PeakOverlayFactory(QwtPlot * plot, QWidget * parent);
virtual ~PeakOverlayFactory();
virtual boost::shared_ptr<PeakOverlayView> createViewAtPoint(const Mantid::Kernel::V3D& position, const double& radius) const;
boost::shared_ptr<PeakOverlayView> createView(const Mantid::Kernel::V3D& position) const;
virtual std::string getPlotXLabel() const;
virtual std::string getPlotYLabel() const;
virtual void setRadius(const double& peakRadius);
};
}
}
Expand Down

This file was deleted.

16 changes: 15 additions & 1 deletion Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ namespace MantidQt
namespace SliceViewer
{

PeakOverlayFactory::PeakOverlayFactory(QwtPlot * plot, QWidget * parent) : PeakOverlayFactoryBase(), m_plot(plot), m_parent(parent)
PeakOverlayFactory::PeakOverlayFactory(QwtPlot * plot, QWidget * parent) : PeakOverlayViewFactory(), m_plot(plot), m_parent(parent)
{
if(!plot)
throw std::invalid_argument("PeakOverlayFactory plot is null");
if(!parent)
throw std::invalid_argument("PeakOverlayFactory parent widget is null");
}

boost::shared_ptr<PeakOverlayView> PeakOverlayFactory::createView(const Mantid::Kernel::V3D& position) const
{
return this->createViewAtPoint(position, m_peakRadius);
}

boost::shared_ptr<PeakOverlayView> PeakOverlayFactory::createViewAtPoint(const Mantid::Kernel::V3D& position, const double& radius) const
{
return boost::make_shared<PeakOverlay>(m_plot, m_parent, position, radius);
Expand All @@ -42,5 +47,14 @@ namespace MantidQt
PeakOverlayFactory::~PeakOverlayFactory()
{
}

/*
Setter for the actual peak radius. The radius used for drawing will depend on the plane instesection.
@param peakRadius : Global value for the peak radius to apply to all peaks manufactured through this factory.
*/
void PeakOverlayFactory::setRadius(const double& peakRadius)
{
m_peakRadius = peakRadius;
}
}
}
34 changes: 0 additions & 34 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayFactoryBase.cpp

This file was deleted.

54 changes: 54 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/test/NullPeaksPresenterTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef SLICE_VIEWER_NULLPEAKSPRESENTER_TEST_H_
#define SLICE_VIEWER_NULLPEAKSPRESENTER_TEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidQtSliceViewer/NullPeaksPresenter.h"

using namespace MantidQt::SliceViewer;
using namespace Mantid;

class NullPeaksPresenterTest : public CxxTest::TestSuite
{

public:

void test_construction()
{
TS_ASSERT_THROWS_NOTHING(NullPeaksPresenter p());
}

void test_is_peaks_presenter()
{
NullPeaksPresenter presenter;
PeaksPresenter& base = presenter; // compile-time test for the is-a relationship
}

/* Test individual methods on the interface */

void test_update_does_nothing()
{
NullPeaksPresenter presenter;
TS_ASSERT_THROWS_NOTHING(presenter.update());
}

void test_updateWithSlicePoint_does_nothing()
{
NullPeaksPresenter presenter;
TS_ASSERT_THROWS_NOTHING(presenter.updateWithSlicePoint(0));
}

void test_changeShownDim_does_nothing()
{
NullPeaksPresenter presenter;
TS_ASSERT_THROWS_NOTHING(presenter.changeShownDim());
}

void test_isLabelOfFreeAxis_always_returns_false()
{
NullPeaksPresenter presenter;
TS_ASSERT(!presenter.isLabelOfFreeAxis(""));
}

};

#endif
171 changes: 0 additions & 171 deletions Code/Mantid/MantidQt/SliceViewer/test/PeakOverlayFactoryBaseTest.h

This file was deleted.

0 comments on commit 49acde5

Please sign in to comment.