Skip to content
Snippets Groups Projects
SliceViewer.h 3.65 KiB
Newer Older
#ifndef SLICEVIEWER_H
#define SLICEVIEWER_H

#include "ColorBarWidget.h"
#include "MantidAPI/IMDIterator.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
#include "MantidQtAPI/MantidColorMap.h"
#include "MantidQtSliceViewer/LineOverlay.h"
#include <QtGui/qdialog.h>
#include <qwt_plot_spectrogram.h>
#include <qwt_plot.h>
Janik Zikovsky's avatar
Janik Zikovsky committed
#include <qwt_raster_data.h>
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(Mantid::API::IMDWorkspace_sptr ws);
  void zoomBy(double factor);
  void loadColorMap(QString filename = QString() );
  void changedShownDim(int index, int dim, int oldDim);
  void resetZoom();
  void showInfoAt(double, double);
  void colorRangeFullSlot();
  void colorRangeSliceSlot();
  void btnDoLineToggled(bool);
  void zoomInSlot();
  void zoomOutSlot();
  void loadColorMapSlot();
  void loadSettings();
  void saveSettings();
  void initMenus();

  void updateDisplay(bool resetAxes = false);
  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
  QHBoxLayout * m_spectLayout;

  /// Color bar indicating the color scale
  /// Vector of the widgets for slicing dimensions
  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;

  /// 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;
  /// 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
  /// Menus
  QMenu * m_menuColorOptions;
  QMenu * m_menuView;

  /// Cached double for infinity
  double m_inf;
} // namespace SliceViewer
} // namespace Mantid

#endif // SLICEVIEWER_H