Skip to content

Commit

Permalink
Refs #4504: LineViewer choice of what to plot as X axis
Browse files Browse the repository at this point in the history
Either the X of the original workspace, or the Y, or the distance in XY, or auto choose (default).
  • Loading branch information
Janik Zikovsky committed Jan 13, 2012
1 parent 3896495 commit a5cc789
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def test_showLine(self):
svw.setSlicePoint(2,6.0)
liner = svw.showLine([1,1], [7,9], width=0.88, num_bins=200)
self.assertTrue( not (liner is None), "Returns a LineViewer proxy object")
# Plot the X units
liner.setPlotAxis(2);
liner.apply()
# Check that the values are there
self.assertEqual(liner.getNumBins(), 200)
# Length of 10 with 200 bins = 0.05 width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QtGui/QWidget>
#include <qwt_plot_curve.h>
#include <qwt_plot.h>
#include <qwt_painter.h>

namespace MantidQt
{
Expand All @@ -19,6 +20,21 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER LineViewer : public QWidget
Q_OBJECT

public:
/** Enumeration of the ways to plot the X axis of the
* line plot.
*/
enum PlotAxisChoice
{
/// Automatically pick X or Y depending on the angle
PlotAuto = 0,
/// Plot the X axis, in the coords of the original workspace
PlotX = 1,
/// Plot the Y axis, in the coords of the original workspace
PlotY = 2,
/// Plot the distance in the XY plane, relative to the start of the line
PlotDistance = 3
};

LineViewer(QWidget *parent = 0);
~LineViewer();

Expand All @@ -30,6 +46,7 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER LineViewer : public QWidget
void setPlanarWidth(double width);
void setNumBins(int numBins);
void setFixedBinWidthMode(bool fixedWidth, double binWidth);
void setPlotAxis(LineViewer::PlotAxisChoice choice);

void showPreview();
void showFull();
Expand All @@ -40,13 +57,16 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER LineViewer : public QWidget
bool getFixedBinWidthMode() const;
int getNumBins() const;
double getBinWidth() const;
LineViewer::PlotAxisChoice getPlotAxis() const;

// For python
void setStartXY(double x, double y);
void setEndXY(double x, double y);
void setWidth(double width);
void setWidth(int dim, double width);
void setWidth(const QString & dim, double width);
QPointF getStartXY() const;
QPointF getEndXY() const;

private:
void createDimensionWidgets();
Expand All @@ -56,6 +76,8 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER LineViewer : public QWidget
void readTextboxes();
void calculateCurve(Mantid::API::IMDWorkspace_sptr ws, Mantid::Kernel::VMD start, Mantid::Kernel::VMD end,
size_t minNumPoints, QwtPlotCurve * curve);
void choosePlotAxis();
void setPlotAxisLabels();

public slots:
void startEndTextEdited();
Expand All @@ -67,6 +89,7 @@ public slots:
void setFreeDimensions(size_t dimX, size_t dimY);
void on_radNumBins_toggled();
void textBinWidth_changed();
void radPlot_changed();

signals:
/// Signal emitted when the planar width changes
Expand Down Expand Up @@ -142,6 +165,12 @@ public slots:
/// ACTUAL bin width, whether in fixed or not-fixed bin width mode
double m_binWidth;

/// Choice of which X axis to plot.
PlotAxisChoice m_plotAxis;

/// Current choice, in the case of auto-determined
PlotAxisChoice m_currentPlotAxis;

};

} //namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,104 @@ from the length of the line being drawn</string>
</item>
</layout>
</widget>
<widget class="QFrame" name="frmPlot">
<widget class="QFrame" name="frmBottom">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="frmPlot">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Plot X axis:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radPlotAuto">
<property name="toolTip">
<string>Automatically choose between plotting X or Y depending on the angle of the line</string>
</property>
<property name="text">
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radPlotX">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Use the workspace's viewed X coordinate as the X axis of the plot</string>
</property>
<property name="text">
<string>X ()</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radPlotY">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Use the workspace's viewed Y coordinate as the X axis of the plot</string>
</property>
<property name="text">
<string>Y ()</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radPlotDistance">
<property name="toolTip">
<string>Use the distance from the start of the line as the X axis of the plot</string>
</property>
<property name="text">
<string>Distance</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>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
Expand Down

0 comments on commit a5cc789

Please sign in to comment.