Skip to content

Commit

Permalink
refs #6279. Refactor PeakOverlayViewFactory hierachy.
Browse files Browse the repository at this point in the history
Add a new base class for common methods. Rename PeakOverlayFactory ->
PeakOverlaySphereFactory. Create new type of factory
PeakOverlayCrossFactory. PeakOverlayCrossFactory is not producing a new
product of a PeakOverlayCross yet. This is the next stage.
  • Loading branch information
OwenArnold committed Dec 11, 2012
1 parent 373691b commit cf27410
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 119 deletions.
8 changes: 6 additions & 2 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ set ( SRC_FILES
src/LineOverlay.cpp
src/LineViewer.cpp
src/PeakOverlaySphere.cpp
src/PeakOverlayFactory.cpp
src/PeakOverlaySphereFactory.cpp
src/PeakOverlayCrossFactory.cpp
src/PeakOverlayViewFactoryBase.cpp
src/PeakTransform.cpp
src/PeakTransformHKL.cpp
src/PeakTransformQSample.cpp
Expand Down Expand Up @@ -38,7 +40,9 @@ set ( INC_FILES
inc/MantidQtSliceViewer/PeakOverlaySphere.h
inc/MantidQtSliceViewer/PeakOverlayView.h
inc/MantidQtSliceViewer/PeakOverlayViewFactory.h
inc/MantidQtSliceViewer/PeakOverlayFactory.h
inc/MantidQtSliceViewer/PeakOverlayViewFactoryBase.h
inc/MantidQtSliceViewer/PeakOverlaySphereFactory.h
inc/MantidQtSliceViewer/PeakOverlayCrossFactory.h
inc/MantidQtSliceViewer/PeaksPresenter.h
inc/MantidQtSliceViewer/PeakTransformHKL.h
inc/MantidQtSliceViewer/PeakTransformQSample.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef MANTID_SLICEVIEWER_PEAKOVERLAYCROSS_FACTORY_H_
#define MANTID_SLICEVIEWER_PEAKOVERLAYCROSS_FACTORY_H_

#include "MantidQtSliceViewer/PeakOverlayViewFactoryBase.h"
#include <boost/shared_ptr.hpp>

namespace MantidQt
{
namespace SliceViewer
{

/** Concrete view factory. For creating instances of PeakOverlayCross widget.
@date 2012-08-24
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PeakOverlayCrossFactory : public PeakOverlayViewFactoryBase
{
public:
PeakOverlayCrossFactory(QwtPlot * plot, QWidget * parent, const size_t colourNumber=0);
virtual ~PeakOverlayCrossFactory();
boost::shared_ptr<PeakOverlayView> createView(const Mantid::Kernel::V3D& position) const;
virtual void setRadius(const double&)
{
// Do nothing.
}
};
}
}

#endif /*MANTID_SLICEVIEWER_PEAKOVERLAYCROSS_FACTORY_H_*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef MANTID_SLICEVIEWER_PEAKOVERLAYSPHERE_FACTORY_H_
#define MANTID_SLICEVIEWER_PEAKOVERLAYSPHERE_FACTORY_H_

#include "MantidQtSliceViewer/PeakOverlayViewFactoryBase.h"
#include <boost/shared_ptr.hpp>

namespace MantidQt
{
namespace SliceViewer
{

/** Concrete view factory. For creating instances of PeakOverlaySphere widget.
@date 2012-08-24
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PeakOverlaySphereFactory : public PeakOverlayViewFactoryBase
{
private:
double m_peakRadius;
public:
PeakOverlaySphereFactory(QwtPlot * plot, QWidget * parent, const size_t colourNumber=0);
virtual ~PeakOverlaySphereFactory();
boost::shared_ptr<PeakOverlayView> createView(const Mantid::Kernel::V3D& position) const;
virtual void setRadius(const double& peakRadius);
};
}
}

#endif /*MANTID_SLICEVIEWER_PEAKOVERLAYSPHERE_FACTORY_H_*/
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@

#ifndef MANTID_SLICEVIEWER_PEAKOVERLAY_FACTORY_H_
#define MANTID_SLICEVIEWER_PEAKOVERLAY_FACTORY_H_
#ifndef MANTID_SLICEVIEWER_PEAKOVERLAYVIEWFACTORYBASE_H_
#define MANTID_SLICEVIEWER_PEAKOVERLAYVIEWFACTORYBASE_H_

#include "DllOption.h"
#include "MantidQtSliceViewer/PeakOverlayViewFactory.h"
#include <QtGui/qwidget.h>
#include <qwt_plot.h>
#include <qcolor.h>
#include <boost/shared_ptr.hpp>

namespace Mantid
{
namespace API
{
/// Forward dec.
class IMDWorkspace;
}
}

namespace MantidQt
{
namespace SliceViewer
{

/** Concrete view factory. For creating instances of PeakOverlay widget.
/** Base class for Concrete view factories. Provides common functionality. This is abstract.
@date 2012-08-24
Expand All @@ -47,22 +36,19 @@ 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 PeakOverlayViewFactory
class DLLExport PeakOverlayViewFactoryBase : public PeakOverlayViewFactory
{
private:
protected:
QwtPlot * m_plot;
QWidget * m_parent;
double m_peakRadius;
QColor m_peakColour;
public:
PeakOverlayFactory(QwtPlot * plot, QWidget * parent, const size_t colourNumber=0);
virtual ~PeakOverlayFactory();
boost::shared_ptr<PeakOverlayView> createView(const Mantid::Kernel::V3D& position) const;
PeakOverlayViewFactoryBase(QwtPlot * plot, QWidget * parent, const size_t colourNumber=0);
virtual ~PeakOverlayViewFactoryBase();
virtual std::string getPlotXLabel() const;
virtual std::string getPlotYLabel() const;
virtual void setRadius(const double& peakRadius);
};
}
}

#endif /*MANTID_SLICEVIEWER_PEAKOVERLAY_FACTORY_H_*/
#endif /*MANTID_SLICEVIEWER_PEAKOVERLAYVIEWFACTORYBASE_H_*/
30 changes: 30 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayCrossFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "MantidQtSliceViewer/PeakOverlayCrossFactory.h"
#include "MantidQtSliceViewer/PeakOverlaySphere.h"
#include "MantidKernel/V3D.h"
#include "MantidAPI/IPeak.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/IMDHistoWorkspace.h"
#include <boost/make_shared.hpp>

using namespace Mantid::API;

namespace MantidQt
{
namespace SliceViewer
{

PeakOverlayCrossFactory::PeakOverlayCrossFactory(QwtPlot * plot, QWidget * parent, const size_t colourNumber) : PeakOverlayViewFactoryBase(plot, parent, colourNumber)
{
}

boost::shared_ptr<PeakOverlayView> PeakOverlayCrossFactory::createView(const Mantid::Kernel::V3D& position) const
{
return boost::make_shared<PeakOverlaySphere>(m_plot, m_parent, position, 0, this->m_peakColour);
}

PeakOverlayCrossFactory::~PeakOverlayCrossFactory()
{
}
}
}
92 changes: 0 additions & 92 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayFactory.cpp

This file was deleted.

34 changes: 34 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/PeakOverlaySphereFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "MantidQtSliceViewer/PeakOverlaySphereFactory.h"
#include "MantidQtSliceViewer/PeakOverlaySphere.h"
#include <boost/make_shared.hpp>

using namespace Mantid::API;

namespace MantidQt
{
namespace SliceViewer
{

PeakOverlaySphereFactory::PeakOverlaySphereFactory(QwtPlot * plot, QWidget * parent, const size_t colourNumber) : PeakOverlayViewFactoryBase(plot, parent, colourNumber)
{
}

boost::shared_ptr<PeakOverlayView> PeakOverlaySphereFactory::createView(const Mantid::Kernel::V3D& position) const
{
return boost::make_shared<PeakOverlaySphere>(m_plot, m_parent, position, this->m_peakRadius, this->m_peakColour);
}

PeakOverlaySphereFactory::~PeakOverlaySphereFactory()
{
}

/*
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 PeakOverlaySphereFactory::setRadius(const double& peakRadius)
{
m_peakRadius = peakRadius;
}
}
}

0 comments on commit cf27410

Please sign in to comment.