Toshihiro Shimizu 890ddd
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
Toshihiro Shimizu 890ddd
#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
Toshihiro Shimizu 890ddd
class DVAPI HistogramGraph : public QWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QColor m_color;
Toshihiro Shimizu 890ddd
	/*! Height of graph, without margin.*/
Toshihiro Shimizu 890ddd
	int m_height;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QVector<int> m_values, m_viewValues, m_logViewValues;</int>
Toshihiro Shimizu 890ddd
	bool m_logScale;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static const int drawMargin;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	HistogramGraph(QWidget *parent = 0, QColor m_color = QColor());
Toshihiro Shimizu 890ddd
	~HistogramGraph();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setAlphaMask(int value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setHeight(int height) { m_height = height; }
Toshihiro Shimizu 890ddd
	int getHeight() { return m_height; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setValues(const int values[]);
Toshihiro Shimizu 890ddd
	const QVector<int> &values() const { return m_values; }</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setLogScale(bool onOff) { m_logScale = onOff; }
Toshihiro Shimizu 890ddd
	bool logScale() const { return m_logScale; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw(QPainter *painter, QPoint translation = QPoint(0, 0));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void paintEvent(QPaintEvent *pe);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ChannelBar
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI ChannelBar : public QWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QColor m_color;
Toshihiro Shimizu 890ddd
	int m_colorBarLength;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_isHorizontal;
Toshihiro Shimizu 890ddd
	bool m_drawNumbers;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ChannelBar(QWidget *parent = 0, QColor m_color = QColor(),
Toshihiro Shimizu 890ddd
			   bool isHorizontal = true);
Toshihiro Shimizu 890ddd
	~ChannelBar();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QColor getColor() const { return m_color; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setDrawNumbers(bool onOff);
Toshihiro Shimizu 890ddd
	bool drawNumbers() const { return m_drawNumbers; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void draw(QPainter *painter, QPoint translation = QPoint(0, 0));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void paintEvent(QPaintEvent *event);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// HistogramView
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI HistogramView : public QWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	HistogramGraph *m_histogramGraph;
Toshihiro Shimizu 890ddd
	ChannelBar *m_colorBar;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QWidget *m_drawnWidget;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	HistogramView(QWidget *parent = 0, QColor color = Qt::black);
Toshihiro Shimizu 890ddd
	~HistogramView();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const HistogramGraph *histogramGraph() const { return m_histogramGraph; }
Toshihiro Shimizu 890ddd
	HistogramGraph *histogramGraph() { return m_histogramGraph; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const ChannelBar *channelBar() const { return m_colorBar; }
Toshihiro Shimizu 890ddd
	ChannelBar *channelBar() { return m_colorBar; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QColor getChannelBarColor() const { return m_colorBar->getColor(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//Deve essere fatto prima di chiamare setValues()
Toshihiro Shimizu 890ddd
	void setGraphHeight(int height) { m_histogramGraph->setHeight(height); }
Toshihiro Shimizu 890ddd
	void setGraphAlphaMask(int value) { m_histogramGraph->setAlphaMask(value); }
Toshihiro Shimizu 890ddd
	void setDrawnWidget(QWidget *widget);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setValues(const int values[]);
Toshihiro Shimizu 890ddd
	const QVector<int> &values() const { return m_histogramGraph->values(); }</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	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
Toshihiro Shimizu 890ddd
class DVAPI Histograms : public QStackedWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP m_raster;
Toshihiro Shimizu 890ddd
	TPaletteP m_palette; //Necessario per le tlv
Toshihiro Shimizu 890ddd
	int m_channelValue[6][256];
Toshihiro Shimizu 890ddd
	int m_channelsCount;
Toshihiro Shimizu 890ddd
	bool m_computeAlsoRGBA;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Histograms(QWidget *parent = 0, bool rgba = false);
Toshihiro Shimizu 890ddd
	~Histograms();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP getRaster() const { return m_raster; }
Toshihiro Shimizu 890ddd
	void setRaster(const TRasterP &raster, const TPaletteP &palette = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	HistogramView *getHistogramView(int indexType) const;
Toshihiro Shimizu 890ddd
	int channelsCount() const { return m_channelsCount; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void computeChannelsValue();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// Histogram
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI Histogram : public QWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QComboBox *m_channelsListBox;
Toshihiro Shimizu 890ddd
	Histograms *m_histograms;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Histogram(QWidget *parent = 0);
Toshihiro Shimizu 890ddd
	~Histogram() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Histograms *getHistograms() const { return m_histograms; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP getRaster() const { return m_histograms->getRaster(); }
Toshihiro Shimizu 890ddd
	void setRaster(const TRasterP &raster, const TPaletteP &palette = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setLogScale(bool onOff);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	void updateChannelsList();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // HISTOGRAM_H