Skip to content

Commit

Permalink
refs #6271. Wire-up ZoomToPeak
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 11, 2013
1 parent 5ec1e92 commit 0e8454d
Show file tree
Hide file tree
Showing 20 changed files with 257 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ namespace MantidQt
void setBackgroundColour(const QColor){/*Do nothing*/}
void showBackgroundRadius(const bool show){/*Do nothing*/}
void setShown(const bool show){/*Do nothing*/}
virtual RectangleType getBoundingBox(const int peakIndex) const {return m_default->getBoundingBox(peakIndex);}


virtual std::string getTransformName() const;

/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace MantidQt
void setBackgroundColour(const QColor);
std::string getTransformName() const;
void setShown(const bool shown);
virtual RectangleType getBoundingBox(const int) const;
private:
/// Peak overlay views.
VecPeakOverlayView m_viewPeaks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace MantidQt
std::string getTransformName() const {return "";}
void showBackgroundRadius(const bool){/*Do nothing*/}
void setShown(const bool){/*Do nothing*/}
virtual RectangleType getBoundingBox(const int) const{return boost::make_tuple(Mantid::Kernel::V2D(), Mantid::Kernel::V2D());}
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <boost/shared_ptr.hpp>
#include "MantidKernel/System.h"
#include "MantidQtSliceViewer/PeakPalette.h"
#include "MantidQtSliceViewer/PeakOverlayView.h"
#include <set>

namespace Mantid
Expand All @@ -22,7 +23,6 @@ namespace SliceViewer
{
// Forward dec.
class PeakOverlayViewFactory;
class PeakOverlayView;
class PeakTransform;

// Alias
Expand All @@ -48,6 +48,7 @@ namespace SliceViewer
virtual std::string getTransformName() const = 0;
virtual void showBackgroundRadius(const bool shown) = 0;
virtual void setShown(const bool shown) = 0;
virtual RectangleType getBoundingBox(const int peakIndex) const = 0;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public slots:
void onBackgroundRadiusShown(Mantid::API::IPeaksWorkspace_const_sptr, bool);
void onRemoveWorkspace(Mantid::API::IPeaksWorkspace_const_sptr);
void onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool);
void onZoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, int peakIndex);
private:
boost::shared_ptr<ProxyCompositePeaksPresenter> m_presenter;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace SliceViewer
void backgroundRadiusShown(Mantid::API::IPeaksWorkspace_const_sptr, bool);
void removeWorkspace(Mantid::API::IPeaksWorkspace_const_sptr);
void hideInPlot(Mantid::API::IPeaksWorkspace_const_sptr, bool);
void zoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr, int);
private:
/// Populate the widget with model data.
void populate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>654</width>
<height>140</height>
<height>175</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -27,107 +27,109 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
<item>
<layout class="QHBoxLayout" name="infoLayout">
<item>
<widget class="QLabel" name="lblWSName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Workspace:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceName">
<property name="text">
<string>[Workspace]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblPeaksIntegrated">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Peaks Integrated:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceState">
<property name="text">
<string>[Integrated/UnIntegrated]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblCoordinates">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Coordinates:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceCoordinates">
<property name="text">
<string>[Viewing Coordinate System]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QFrame" name="infoFrame">
<layout class="QHBoxLayout" name="infoLayout">
<item>
<widget class="QLabel" name="lblWSName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Workspace:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceName">
<property name="text">
<string>[Workspace]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblPeaksIntegrated">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Peaks Integrated:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceState">
<property name="text">
<string>[Integrated/UnIntegrated]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblCoordinates">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Coordinates:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWorkspaceCoordinates">
<property name="text">
<string>[Viewing Coordinate System]</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="tableLayout">
Expand Down Expand Up @@ -167,18 +169,21 @@
</property>
<property name="minimumSize">
<size>
<width>60</width>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Remove entire peaks list from display</string>
</property>
<property name="text">
<string>Remove</string>
<string>Remove Peaks List</string>
</property>
</widget>
</item>
Expand All @@ -190,14 +195,23 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Hide/show all peaks from this list in the plot</string>
</property>
<property name="text">
<string>Hide in Plot</string>
<string>Hide Peaks List</string>
</property>
<property name="checkable">
<bool>true</bool>
Expand Down Expand Up @@ -226,6 +240,9 @@
<property name="text">
<string>Peak Color</string>
</property>
<property name="buddy">
<cstring>infoFrame</cstring>
</property>
</widget>
</item>
<item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace MantidQt
void remove(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS);
/// Hide these peaks in the plot.
void hideInPlot(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const bool hide);
/// zoom in on a peak.
void zoomToPeak(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const int peakIndex);

private:
/// Wrapped composite to delegate to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ namespace MantidQt

void CompositePeaksPresenter::zoomToPeak(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const int peakIndex)
{
//TODO
auto iterator = getPresenterIteratorFromWorkspace(peaksWS);
auto subjectPresenter = *iterator;
auto boundingBox = subjectPresenter->getBoundingBox(peakIndex);
m_zoomablePlottingWidget->zoomToRectangle(boundingBox.get<0>(), boundingBox.get<1>());
}
}
}
13 changes: 13 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/ConcretePeaksPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,18 @@ namespace SliceViewer
}
}

/**
@param peakIndex: index into contained peaks workspace.
@return the bounding box corresponding to the peakIndex.
*/
RectangleType ConcretePeaksPresenter::getBoundingBox(const int peakIndex) const
{
if(peakIndex < 0 || peakIndex > m_viewPeaks.size())
{
throw std::out_of_range("PeakIndex is out of range");
}
return this->m_viewPeaks[peakIndex]->getBoundingBox();
}

}
}
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/SliceViewer/src/PeakOverlayCross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace SliceViewer
*/
RectangleType PeakOverlayCross::getBoundingBox() const
{
throw std::runtime_error("Not implemented");
return m_physicalPeak.getBoundingBox();
}

} // namespace Mantid
Expand Down

0 comments on commit 0e8454d

Please sign in to comment.