#ifndef __qSlicerScalarVolumeDisplayWidget_h
#define __qSlicerScalarVolumeDisplayWidget_h

// Qt includes
#include <QWidget>

// CTK includes
#include <ctkVTKObject.h>

// Slicer includes
#include <qSlicerWidget.h>
#include "vtkImageMapToWindowLevelAddon.h"

#include "qSlicerVolumesModuleWidgetsExport.h"

class vtkMRMLNode;
class vtkMRMLScalarVolumeDisplayNode;
class vtkMRMLScalarVolumeNode;
class qSlicerScalarVolumeDisplayWidgetPrivate;

class Q_SLICER_QTMODULES_VOLUMES_WIDGETS_EXPORT qSlicerScalarVolumeDisplayWidget : public qSlicerWidget
{
  Q_OBJECT
  QVTK_OBJECT
  Q_PROPERTY(bool enableColorTableComboBox READ isColorTableComboBoxEnabled WRITE setColorTableComboBoxEnabled)
  Q_PROPERTY(bool enableMRMLWindowLevelWidget READ isMRMLWindowLevelWidgetEnabled WRITE setMRMLWindowLevelWidgetEnabled)

public:
  /// Constructors
  typedef qSlicerWidget Superclass;
  explicit qSlicerScalarVolumeDisplayWidget(QWidget* parent);
  ~qSlicerScalarVolumeDisplayWidget() override;

  Q_INVOKABLE vtkMRMLScalarVolumeNode* volumeNode() const;
  Q_INVOKABLE vtkMRMLScalarVolumeDisplayNode* volumeDisplayNode() const;

  bool isColorTableComboBoxEnabled() const;
  void setColorTableComboBoxEnabled(bool);

  bool isMRMLWindowLevelWidgetEnabled() const;
  void setMRMLWindowLevelWidgetEnabled(bool);

  /// Get the option for how to map scalar values within the current window
  /// \sa scalarMappingMethod, setScalarMappingMethod()
  vtkImageMapToWindowLevelAddon::WindowMappingMode scalarMappingMethod();

public slots:
  ///
  /// Set the MRML node of interest
  void setMRMLVolumeNode(vtkMRMLNode* node);
  void setMRMLVolumeNode(vtkMRMLScalarVolumeNode* node);

  void setInterpolate(bool interpolate);
  void setInvert(bool invert);
  void setColorNode(vtkMRMLNode* node);
  void setPreset(const QString& presetName);

  /// Set the option for how to map scalar values within the current window
  /// \sa scalarMappingMethod
  void setScalarMappingMethod(int mappingMethod);

protected slots:
  void updateWidgetFromMRML();
  void updateHistogram();
  void onPresetButtonClicked();
  void onHistogramSectionExpanded(bool);

protected:
  void showEvent(QShowEvent* event) override;

protected:
  QScopedPointer<qSlicerScalarVolumeDisplayWidgetPrivate> d_ptr;

private:
  Q_DECLARE_PRIVATE(qSlicerScalarVolumeDisplayWidget);
  Q_DISABLE_COPY(qSlicerScalarVolumeDisplayWidget);
};

#endif
