Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef HISTOGRAM_H
Toshihiro Shimizu 890ddd
#define HISTOGRAM_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "traster.h"
Toshihiro Shimizu 890ddd
#include "ttoonzimage.h"
Toshihiro Shimizu 890ddd
#include "tpalette.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
#include <qstackedwidget></qstackedwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QStackedWidget;
Toshihiro Shimizu 890ddd
class QString;
Toshihiro Shimizu 890ddd
class QComboBox;
Toshihiro Shimizu 890ddd
class QColor;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// HistogramGraph
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI HistogramGraph final : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QColor m_color;
Shinya Kitaoka 120a6e
  /*! Height of graph, without margin.*/
Shinya Kitaoka 120a6e
  int m_height;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QVector<int> m_values, m_viewValues, m_logViewValues;</int>
Shinya Kitaoka 120a6e
  bool m_logScale;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static const int drawMargin;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  HistogramGraph(QWidget *parent = 0, QColor m_color = QColor());
Shinya Kitaoka 120a6e
  ~HistogramGraph();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setAlphaMask(int value);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setHeight(int height) { m_height = height; }
Shinya Kitaoka 120a6e
  int getHeight() { return m_height; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setValues(const int values[]);
Shinya Kitaoka 120a6e
  const QVector<int> &values() const { return m_values; }</int>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLogScale(bool onOff) { m_logScale = onOff; }
Shinya Kitaoka 120a6e
  bool logScale() const { return m_logScale; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void draw(QPainter *painter, QPoint translation = QPoint(0, 0));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  void paintEvent(QPaintEvent *pe) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ChannelBar
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI ChannelBar final : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QColor m_color;
Shinya Kitaoka 120a6e
  int m_colorBarLength;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isHorizontal;
Shinya Kitaoka 120a6e
  bool m_drawNumbers;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ChannelBar(QWidget *parent = 0, QColor m_color = QColor(),
Shinya Kitaoka 120a6e
             bool isHorizontal = true);
Shinya Kitaoka 120a6e
  ~ChannelBar();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QColor getColor() const { return m_color; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setDrawNumbers(bool onOff);
Shinya Kitaoka 120a6e
  bool drawNumbers() const { return m_drawNumbers; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void draw(QPainter *painter, QPoint translation = QPoint(0, 0));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  void paintEvent(QPaintEvent *event) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// HistogramView
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI HistogramView final : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  HistogramGraph *m_histogramGraph;
Shinya Kitaoka 120a6e
  ChannelBar *m_colorBar;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QWidget *m_drawnWidget;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  HistogramView(QWidget *parent = 0, QColor color = Qt::black);
Shinya Kitaoka 120a6e
  ~HistogramView();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const HistogramGraph *histogramGraph() const { return m_histogramGraph; }
Shinya Kitaoka 120a6e
  HistogramGraph *histogramGraph() { return m_histogramGraph; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const ChannelBar *channelBar() const { return m_colorBar; }
Shinya Kitaoka 120a6e
  ChannelBar *channelBar() { return m_colorBar; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QColor getChannelBarColor() const { return m_colorBar->getColor(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Deve essere fatto prima di chiamare setValues()
Shinya Kitaoka 120a6e
  void setGraphHeight(int height) { m_histogramGraph->setHeight(height); }
Shinya Kitaoka 120a6e
  void setGraphAlphaMask(int value) { m_histogramGraph->setAlphaMask(value); }
Shinya Kitaoka 120a6e
  void setDrawnWidget(QWidget *widget);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setValues(const int values[]);
Shinya Kitaoka 120a6e
  const QVector<int> &values() const { return m_histogramGraph->values(); }</int>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void draw(QPainter *painter, QPoint translation = QPoint(0, 0));
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// Histograms
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI Histograms final : public QStackedWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterP m_raster;
Shinya Kitaoka 120a6e
  TPaletteP m_palette;  // Necessario per le tlv
Shinya Kitaoka 120a6e
  int m_channelValue[6][256];
Shinya Kitaoka 120a6e
  int m_channelsCount;
Shinya Kitaoka 120a6e
  bool m_computeAlsoRGBA;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Histograms(QWidget *parent = 0, bool rgba = false);
Shinya Kitaoka 120a6e
  ~Histograms();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterP getRaster() const { return m_raster; }
Shinya Kitaoka 120a6e
  void setRaster(const TRasterP &raster, const TPaletteP &palette = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  HistogramView *getHistogramView(int indexType) const;
Shinya Kitaoka 120a6e
  int channelsCount() const { return m_channelsCount; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  void computeChannelsValue();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// Histogram
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI Histogram final : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QComboBox *m_channelsListBox;
Shinya Kitaoka 120a6e
  Histograms *m_histograms;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Histogram(QWidget *parent = 0);
Shinya Kitaoka 120a6e
  ~Histogram() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Histograms *getHistograms() const { return m_histograms; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterP getRaster() const { return m_histograms->getRaster(); }
Shinya Kitaoka 120a6e
  void setRaster(const TRasterP &raster, const TPaletteP &palette = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLogScale(bool onOff);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  void updateChannelsList();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // HISTOGRAM_H