//-----------------------------------------------------------------------------
#ifndef PlotCanvasInfoH
#define PlotCanvasInfoH PlotCanvasInfoH
//-----------------------------------------------------------------------------
#include "DevData.h"
#include "PlotCanvas.h"
#include <deque>

//-----------------------------------------------------------------------------
class PlotCanvasInfo : public PlotCanvas
//-----------------------------------------------------------------------------
{
public:
	//-----------------------------------------------------------------------------
	enum TPlotSelection
	//-----------------------------------------------------------------------------
	{
		psFIRST,
		psTimestampDifference = psFIRST,
		psExposureTime_us,
		psFrameIDDifference,
		psFrameID,
		psGain_mdB,
		psLineCounter,
		psLAST
	};
	explicit				PlotCanvasInfo() {}
	explicit				PlotCanvasInfo( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
								const wxSize& size = wxDefaultSize, long style = wxSUNKEN_BORDER,
								const wxString& name = wxT("info plot"), bool boActive = false );
						   ~PlotCanvasInfo();
	const wxString&			GetPlotSelectionName( TPlotSelection plotSelection ) const { return m_PlotNames[plotSelection]; }
	TPlotSelection			GetPlotSelection( void ) const { return m_SelectedPlot; }
	void					SetPlotSelection( TPlotSelection plotSelection );
	void					SetHistoryDepth( unsigned int historyDepth );
	unsigned int			GetHistoryDepth( void ) const { return m_HistoryDepth; }
	void					SetupPlotIdentifiers( const std::vector<std::pair<std::string, int> >& plotIdentifiers );
	virtual void			RefreshData( const RequestInfoData& infoData, bool boForceRefresh = false );
protected:
	virtual double			GetScaleX( wxCoord w ) const;
	virtual double			GetScaleY( wxCoord h ) const;
	virtual unsigned int	GetXMarkerParameters( unsigned int& from, unsigned int& to ) const;
	virtual void			OnPaintCustom( wxPaintDC& dc );
private:
	TPlotSelection			m_SelectedPlot;
	unsigned int			m_HistoryDepth;
	std::deque<int64_type>** m_ppPlotValues;
	std::vector<int64_type>	m_CurrentMaxPlotValues;
	std::vector<int64_type>	m_CurrentMinPlotValues;
	std::vector<int64_type>	m_CurrentPlotValues;
	enum { COLOUR_COUNT = 4 };
	wxColour				m_pens[COLOUR_COUNT];
	typedef std::map<int, int> PlotHashTable;
	PlotHashTable			m_PlotHashTable;
	std::vector<wxString>	m_PlotIdentifiers;
	size_t					m_PlotCount;
	int64_type				m_CurrentMaxPlotValue;
	int64_type				m_CurrentMinPlotValue;
	wxString				m_PlotNames[psLAST];

	void					AllocateDataBuffer( unsigned int plotCount );
	void					DeallocateDataBuffer( void );
	bool					MustUpdate( bool boForceRefresh );
	bool					RefreshPlotData( void );
};

#endif // PlotCanvasInfoH
