//-----------------------------------------------------------------------------
#ifndef histogramCanvasH
#define histogramCanvasH histogramCanvasH
//-----------------------------------------------------------------------------
#include <wx/dcclient.h>
#include "DrawingCanvas.h"

//-----------------------------------------------------------------------------
class HistogramCanvas : public ImageAnalysisPlotCanvas
//-----------------------------------------------------------------------------
{
	int					m_DrawStepWidth;
protected:
	int**				m_ppHistogramBuffer;
	PlotPoint*			m_pHistogramMax;
	double*				m_pHistogramAverage;
	double*				m_pStandardDeviation;
	bool				m_boHandleStandardDeviation;
	PlotPoint			m_CurrentMax;
	void				CalculateMaxValue( void );
	void				DeallocateHistogramBuffer( void );
	void				PrepareHistogramBuffer( bool boImageFormatChanged, int channelCount, mvIMPACT::acquire::TImageBufferPixelFormat pixelFormat );
	void				DrawHistogramLine( wxPaintDC& dc, int h, double scaleX, double scaleY, TPlane plane );
	DECLARE_EVENT_TABLE()
public:
	explicit			HistogramCanvas() {}
	explicit			HistogramCanvas( wxWindow* parent, const wxString& configName, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
							const wxSize& size = wxDefaultSize, long style = wxSUNKEN_BORDER,
							const wxString& name = wxT("Histogram"), bool boActive = false, bool boHandleStandardDeviation = false );
					   ~HistogramCanvas();
	void				OnPaint( wxPaintEvent & );
	virtual bool		HasPercentageWindow( void ) const { return true; }
	virtual bool		HasStepWidthParameter( void ) const { return true; }
	void				SetDrawStepWidth( int value );
	static int			GetDrawStepWidthMax( void ) { return 8; }
	virtual wxString	GetGridValue( int row, int col ) const;
};

//-----------------------------------------------------------------------------
class PixelHistogramCanvas : public HistogramCanvas
//-----------------------------------------------------------------------------
{
	DECLARE_DYNAMIC_CLASS(PixelHistogramCanvas)
public:
	explicit		PixelHistogramCanvas() {}
	explicit		PixelHistogramCanvas( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
						const wxSize& size = wxDefaultSize, long style = wxSUNKEN_BORDER,
						const wxString& name = wxT("Pixel Histogram"), bool boActive = false );
	virtual void	RefreshData( const RequestData& data, int x = -1, int y = -1, int w = -1, int h = -1, bool boForceRefresh = false );
};

//-----------------------------------------------------------------------------
class NoiseHistogramCanvas : public HistogramCanvas
//-----------------------------------------------------------------------------
{
	DECLARE_DYNAMIC_CLASS(NoiseHistogramCanvas)
public:
	explicit		NoiseHistogramCanvas() {}
	explicit		NoiseHistogramCanvas( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
						const wxSize& size = wxDefaultSize, long style = wxSUNKEN_BORDER,
						const wxString& name = wxT("Noise Histogram"), bool boActive = false );
	virtual void	RefreshData( const RequestData& data, int x = -1, int y = -1, int w = -1, int h = -1, bool boForceRefresh = false );
};

#endif // histogramCanvasH
