Skip to content

Commit

Permalink
refs #6271. Physical Peak bounding box calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 9, 2013
1 parent f4d4b02 commit 7fb968c
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 109 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/MantidQt/SliceViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ set ( INC_FILES
inc/MantidQtSliceViewer/SliceViewerWindow.h
inc/MantidQtSliceViewer/SnapToGridDialog.h
inc/MantidQtSliceViewer/XYLimitsDialog.h
inc/MantidQtSliceViewer/ZoomablePeaksView.h
)

set ( MOC_FILES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MantidQtSliceViewer/PeaksPresenter.h"
#include "MantidQtSliceViewer/NullPeaksPresenter.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include "MantidQtSliceViewer/ZoomablePeaksView.h"
#include <vector>
#include <stdexcept>
#include <boost/shared_ptr.hpp>
Expand Down Expand Up @@ -35,7 +36,7 @@ namespace MantidQt
virtual std::string getTransformName() const;

/// Constructor
CompositePeaksPresenter(PeaksPresenter_sptr defaultPresenter = PeaksPresenter_sptr(new NullPeaksPresenter));
CompositePeaksPresenter(ZoomablePeaksView* const zoomablePlottingWidget, PeaksPresenter_sptr defaultPresenter = PeaksPresenter_sptr(new NullPeaksPresenter));
/// Destructor
~CompositePeaksPresenter();
/// Add a peaks presenter onto the composite.
Expand All @@ -59,7 +60,9 @@ namespace MantidQt
/// Remove the workspace and corresponding presenter.
void remove(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS);
/// Hide these peaks in the plot.
void CompositePeaksPresenter::setShown(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const bool shown);
void setShown(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const bool shown);
/// zoom in on a peak.
void zoomToPeak(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const int peakIndex);
private:
/// Alias for container of subjects type.
typedef std::vector<PeaksPresenter_sptr> SubjectContainer;
Expand All @@ -75,6 +78,8 @@ namespace MantidQt
SubjectContainer::const_iterator getPresenterIteratorFromWorkspace(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const;
/// Colour pallette.
PeakPalette m_palette;
/// Zoomable peaks view.
ZoomablePeaksView* const m_zoomablePlottingWidget;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace SliceViewer
virtual void changeForegroundColour(const QColor);
/// Change background colour
virtual void changeBackgroundColour(const QColor);
/// Get a bounding box for this peak.
virtual RectangleType getBoundingBox() const;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ namespace SliceViewer
virtual void changeBackgroundColour(const QColor);
/// Show the background radius
virtual void showBackgroundRadius(const bool show);
/// Get a bounding box for this peak.
virtual RectangleType getBoundingBox() const;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
#define MANTID_SLICEVIEWER_PEAKOVERLAY_VIEW_H_

#include "MantidKernel/System.h"
#include "MantidKernel/V2D.h"
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include <QPointF>
#include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp>

namespace MantidQt
{
namespace SliceViewer
{

typedef boost::tuple<Mantid::Kernel::V2D, Mantid::Kernel::V2D> RectangleType;

/** Abstract view in MVP model representing a PeakOverlay.
@date 2012-08-24
Expand Down Expand Up @@ -55,6 +59,8 @@ namespace MantidQt
virtual void changeBackgroundColour(const QColor) = 0;
/// Show the background radius
virtual void showBackgroundRadius(const bool){}
/// Get a bounding box around the peak in windows coordinates.
virtual RectangleType getBoundingBox() const = 0;
/// Destructor
virtual ~PeakOverlayView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,84 +218,80 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Peak Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPeakColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Peak Background Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBackgroundColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Peak Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPeakColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Peak Background Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBackgroundColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "MantidKernel/V3D.h"
#include "MantidKernel/ClassMacros.h"
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/PeakOverlayView.h"

namespace MantidQt
{
Expand Down Expand Up @@ -44,6 +45,11 @@ namespace MantidQt
{
return (m_opacityAtDistance != m_opacityMin);
}
/// Get the bounding box.
RectangleType getBoundingBox() const;
/// Get the bounding box in windows coordinates.
RectangleType getBoundingBox(const double& windowHeight, const double& windowWidth, const double& viewWidth, const double& viewHeight) const;

private:
/// Original origin x=h, y=k, z=l
const Mantid::Kernel::V3D m_originalOrigin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "MantidKernel/V3D.h"
#include "MantidKernel/ClassMacros.h"
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/PeakOverlayView.h"
#include <boost/optional.hpp>

namespace MantidQt
Expand Down Expand Up @@ -78,6 +79,12 @@ namespace MantidQt
/// Setter to command whether the background radius should also be shown.
void showBackgroundRadius(const bool show);

/// Get the bounding box in natural coordinates.
RectangleType getBoundingBox() const;

/// Get the bounding box in windows coordinates.
RectangleType getBoundingBox(const double& windowHeight, const double& windowWidth, const double& viewWidth, const double& viewHeight) const;

private:
/// Original origin x=h, y=k, z=l
const Mantid::Kernel::V3D m_originalOrigin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "MantidQtSliceViewer/LineOverlay.h"
#include "MantidQtSliceViewer/PeakTransformSelector.h"
#include "MantidQtSliceViewer/PeaksPresenter.h"
#include "MantidQtSliceViewer/ZoomablePeaksView.h"
#include "QwtRasterDataMD.h"
#include "ui_SliceViewer.h"
#include <QtCore/QtCore>
Expand Down Expand Up @@ -43,7 +44,7 @@ class ProxyCompositePeaksPresenter;
* along the other dimension(s).
*
*/
class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget
class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget, public ZoomablePeaksView
{
friend class SliceViewerWindow;

Expand Down Expand Up @@ -99,6 +100,9 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget
/// Methods relating to peaks overlays.
boost::shared_ptr<ProxyCompositePeaksPresenter> getPeaksPresenter() const;

/// Methods from implementation of ZoomablePeaksView.
virtual void zoomToRectangle(Mantid::Kernel::V2D& lowerLeft, Mantid::Kernel::V2D& upperRight);

signals:
/// Signal emitted when the X/Y index of the shown dimensions is changed
void changedShownDim(size_t dimX, size_t dimY);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#ifndef MANTID_SLICEVIEWER_ZOOMABLE_PEAKS_VIEW_H_
#define MANTID_SLICEVIEWER_ZOOMABLE_PEAKS_VIEW_H_

#include "MantidKernel/System.h"
#include "MantidKernel/V2D.h"

namespace MantidQt
{
namespace SliceViewer
{

/** Abstract view in Representing a view that can be zoomed in upon.
@date 2013-01-08
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 ZoomablePeaksView
{
public:
/// Zoom to a peak position provided by a boundary rectangle in the windows coordinate system.
virtual void zoomToRectangle(Mantid::Kernel::V2D& lowerLeft, Mantid::Kernel::V2D& upperRight) = 0;
/// Destructor
virtual ~ZoomablePeaksView(){ }
};

/**
@class ZoomableAdapter
Templated adapter to zoom to peak. Alows objects from outside this type hierachy to be made to work seamlessly with it.
*/
template <class Adaptee>
class DLLExport ZoomableAdapter : public ZoomablePeaksView
{
private:
Adaptee * const _adaptee;
ZoomableAdapter& operator=(const ZoomableAdapter& other);
ZoomableAdapter(const ZoomableAdapter& other);
public:
ZoomableAdapter(Adaptee* const adaptee) : _adaptee(adaptee)
{
}

void zoomToRectangle(Mantid::Kernel::V2D& lowerLeft, Mantid::Kernel::V2D& upperRight)
{
_adaptee.zoomToRectange(lowerLeft, upperRight);
}
virtual ~ZoomableAdapter(){ }
};
}
}

#endif /* MANTID_SLICEVIEWER_PEAKOVERLAY_VIEW_H_ */

0 comments on commit 7fb968c

Please sign in to comment.