Newer
Older
#ifndef SLICEVIEWER_H
#define SLICEVIEWER_H
#include "DimensionSliceWidget.h"
Janik Zikovsky
committed
#include "DllOption.h"
#include "MantidAPI/IMDWorkspace.h"
Janik Zikovsky
committed
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
#include "MantidKernel/VMD.h"
#include "MantidQtAPI/MantidColorMap.h"
#include "MantidQtAPI/SyncedCheckboxes.h"
#include "MantidQtSliceViewer/LineOverlay.h"
#include "QwtRasterDataMD.h"
#include "ui_SliceViewer.h"
Janik Zikovsky
committed
#include <QtCore/QtCore>
#include <QtGui/qdialog.h>
#include <QtGui/QWidget>
Janik Zikovsky
committed
#include <qwt_color_map.h>
#include <qwt_plot_spectrogram.h>
#include <qwt_plot.h>
Janik Zikovsky
committed
#include <qwt_scale_widget.h>
#include <vector>
Janik Zikovsky
committed
namespace MantidQt
{
namespace SliceViewer
{
/** GUI for viewing a 2D slice out of a multi-dimensional workspace.
* You can select which dimension to plot as X,Y, and the cut point
* along the other dimension(s).
*
*/
class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewer : public QWidget
SliceViewer(QWidget *parent = 0);
~SliceViewer();
void setWorkspace(const QString & wsName);
void setWorkspace(Mantid::API::IMDWorkspace_sptr ws);
Janik Zikovsky
committed
void showControls(bool visible);
void zoomBy(double factor);
void loadColorMap(QString filename = QString() );
LineOverlay * getLineOverlay() { return m_lineOverlay; }
Mantid::Kernel::VMD getSlicePoint() const { return m_slicePoint; }
int getDimX() const;
int getDimY() const;
void setXYDim(int indexX, int indexY);
void setXYDim(const QString & dimX, const QString & dimY);
void setSlicePoint(int dim, double value);
void setSlicePoint(const QString & dim, double value);
double getSlicePoint(int dim) const;
double getSlicePoint(const QString & dim) const;
void setColorScaleMin(double min);
void setColorScaleMax(double max);
void setColorScaleLog(bool log);
void setColorScale(double min, double max, bool log);
double getColorScaleMin() const;
double getColorScaleMax() const;
bool getColorScaleLog() const;
void setXYLimits(double xleft, double xright, double ybottom, double ytop);
QwtDoubleInterval getXLimits() const;
QwtDoubleInterval getYLimits() const;
void setXYCenter(double x, double y);
signals:
/// Signal emitted when the X/Y index of the shown dimensions is changed
void changedShownDim(size_t dimX, size_t dimY);
/// Signal emitted when the slice point moves
void changedSlicePoint(Mantid::Kernel::VMD slicePoint);
/// Signal emitted when the LineViewer should be shown/hidden.
void showLineViewer(bool);
public slots:
void changedShownDim(int index, int dim, int oldDim);
Janik Zikovsky
committed
void resetZoom();
Janik Zikovsky
committed
void showInfoAt(double, double);
void colorRangeChanged();
void zoomInSlot();
void zoomOutSlot();
Janik Zikovsky
committed
void updateDisplaySlot(int index, double value);
void helpSliceViewer();
void helpLineViewer();
void setColorScaleAutoFull();
void setColorScaleAutoSlice();
// Slots that will be automatically connected via QMetaObject.connectSlotsByName
void on_btnClearLine_clicked();
// Synced checkboxes
void LineMode_toggled(bool);
void SnapToGrid_toggled(bool);
void loadSettings();
void saveSettings();
Janik Zikovsky
committed
void initZoomer();
void updateDisplay(bool resetAxes = false);
void updateDimensionSliceWidgets();
void resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr dim);
QwtDoubleInterval getRange(Mantid::API::IMDIterator * it);
void findRangeFull();
void findRangeSlice();
// -------------------------- Widgets ----------------------------
/// Auto-generated UI controls.
Ui::SliceViewerClass ui;
/// Main plot object
QwtPlot * m_plot;
/// Spectrogram plot
QwtPlotSpectrogram * m_spect;
/// Layout containing the spectrogram
Janik Zikovsky
committed
QHBoxLayout * m_spectLayout;
/// Color bar indicating the color scale
ColorBarWidget * m_colorBar;
/// Vector of the widgets for slicing dimensions
Janik Zikovsky
committed
std::vector<DimensionSliceWidget *> m_dimWidgets;
/// The LineOverlay widget for drawing line cross-sections (hidden at startup)
LineOverlay * m_lineOverlay;
// -------------------------- Data Members ----------------------------
/// Workspace being shown
Mantid::API::IMDWorkspace_sptr m_ws;
/// Set to true once the first workspace has been loaded in it
bool m_firstWorkspaceOpen;
/// File of the last loaded color map.
QString m_currentColorMapFile;
Janik Zikovsky
committed
/// Vector of the dimensions to show.
std::vector<Mantid::Geometry::MDHistoDimension_sptr> m_dimensions;
/// Data presenter
QwtRasterDataMD * m_data;
/// The X and Y dimensions being plotted
Mantid::Geometry::IMDDimension_const_sptr m_X;
Mantid::Geometry::IMDDimension_const_sptr m_Y;
Janik Zikovsky
committed
size_t m_dimX;
size_t m_dimY;
/// The point of slicing in the other dimensions
Mantid::Kernel::VMD m_slicePoint;
Janik Zikovsky
committed
/// The range of values to fit in the color map.
QwtDoubleInterval m_colorRange;
/// The calculated range of values in the FULL data set
QwtDoubleInterval m_colorRangeFull;
/// The calculated range of values ONLY in the currently viewed part of the slice
QwtDoubleInterval m_colorRangeSlice;
/// Use the log of the value for the color scale
bool m_logColor;
QMenu *m_menuColorOptions, *m_menuView, *m_menuHelp, *m_menuLine;
/// Synced menu/buttons
MantidQt::API::SyncedCheckboxes *m_syncLineMode, *m_syncSnapToGrid;
/// Cached double for infinity
double m_inf;
} // namespace SliceViewer
} // namespace Mantid