//-----------------------------------------------------------------------------
#ifndef imageCanvasH
#define imageCanvasH imageCanvasH
//-----------------------------------------------------------------------------
#include <set>
#include <wx/bitmap.h>
#include <wx/brush.h>
#include <wx/colour.h>
#include "DrawingCanvas.h"

typedef std::set<AOI*> AOISet;

struct ImageCanvasImpl;

//-----------------------------------------------------------------------------
class ImageCanvas : public DrawingCanvas
//-----------------------------------------------------------------------------
{
	ImageCanvasImpl*	m_pImpl;
	AOISet				m_aoiSet;
	bool				m_boScaling;
	bool				m_boShowOverlayMessages;
	wxEvtHandler*		m_pAppEventHandler;
	int					m_pAppWinID;
	DECLARE_DYNAMIC_CLASS(ImageCanvas)
	DECLARE_EVENT_TABLE()
	void				OnDblClick( wxMouseEvent& );
public:
	ImageCanvas() {}
	ImageCanvas( wxWindow* pApp, wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
				 long style = wxSUNKEN_BORDER, const wxString& name = wxT("ImageCanvas"), bool boActive = true );
	~ImageCanvas();
	void				OnPaint( wxPaintEvent & );
	bool				IsScaled( void ) const { return m_boScaling; }
	bool				OverlayMessagesActive( void ) const { return m_boShowOverlayMessages; }
	AOI*				RegisterAOI( const wxRect&, const wxColour&, const wxString& );
	bool				RemoveAOI( AOI* pAOI );
	//-----------------------------------------------------------------------------
	enum TSaveResult
	//-----------------------------------------------------------------------------
	{
		srOK,
		srNoImage,
		srFailedToSave
	};
	TSaveResult			SaveCurrentImageAsBitmap( const wxString& filenameAndPath ) const;
	bool				SetAOI( AOI* pAOI, int x, int y, int w, int h );
	bool				SetImage( const mvIMPACT::acquire::ImageBuffer* pIB );
	void				SetScaling( bool boOn );
	void				SetPerformanceWarningOutput( bool boOn );
};

//-----------------------------------------------------------------------------
inline void ImageCanvas::SetScaling( bool boOn )
//-----------------------------------------------------------------------------
{
	if( m_boScaling != boOn )
	{
		m_boScaling = boOn;
		Refresh( true );
	}
}

//-----------------------------------------------------------------------------
inline void ImageCanvas::SetPerformanceWarningOutput( bool boOn )
//-----------------------------------------------------------------------------
{
	if( m_boShowOverlayMessages != boOn )
	{
		m_boShowOverlayMessages = boOn;
		Refresh( true );
	}
}

#endif // imageCanvasH
