/******************************************************************************\
* "$RCSfile: CDlgPreviewSettings.hpp,v $"                                      *
********************************************************************************
* Information by CVS or VSS:                                                   *
*     Last check in on: $Date: 2011-10-24 07:57:07 $                           *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.12 $                                      *
\******************************************************************************/
/*! \file CDlgPreviewSettings.hpp
*	\brief Header CDlgPreviewSettings Class
*******************************************************************************/

/******************************************************************************/
/*! @brief Dialog class for changing zoom factor or ROI.

	CDlgPreviewSettings is non-modal.\n
	A down scaled live image is displayed inside the dialog area. The ROI is
	marked with a rectangle. By clicking inside, the user can change the
	position of the ROI. The user can zoom in and out.
	@image html CDlgPreviewSettings.png Preview settings: Standard
	@image html CDlgPreviewSettings2.png Preview settings: ROI controls enabled
*******************************************************************************/
class CDlgPreviewSettings: public CDlg
{
protected:
	//! @brief Dialog identifier of previews settings dialog.
	//!
	//! They are reused as array index together with the INDEX() and ICON() macros.
	enum eDlgPreview_ID
	{
		// 0x100 <= ICON <= 0x1FF
		ID_UP = 0x100,			//!< Up button
		ID_DOWN,				//!< Down button
		ID_LEFT,				//!< Left button
		ID_RIGHT,				//!< Right button
		ID_ZOOMUP,				//!< Zoom in button
		ID_ZOOMDOWN,			//!< Zoom out button
		ID_OK_S,				//!< OK button
		ID_INFO_S,				//!< Info button
		ID_ROI_TL,				//!< ROI Top Left Corner
		ID_ROI_BR,				//!< ROI Bottom Right Corner
		ID_ROI_CENTER,			//!< ROI Center
		ID_XXX,

		ID_ROI_TL_ITEM = 0x200, //!< ROI Top Left corner item
		ID_ROI_BR_ITEM,			//!< ROI Bottom Right corner item
		ID_ROI_CENTER_ITEM,		//!< ROI Center item

		ID_ROI_STRX = 0x400,	//!< String ROI X-Position
		ID_ROI_STRY,			//!< String ROI Y-Position
		ID_ROI_STRW,			//!< String ROI width
		ID_ROI_STRH,			//!< String ROI height
		ID_ROI_NAME,			//!< Name of ROI
		ID_ROI_X,				//!< ROI X-Position
		ID_ROI_Y,				//!< ROI Y-Position
		ID_ROI_W,				//!< ROI width
		ID_ROI_H				//!< ROI height
	};

private:
	CDlgPreviewSettings(int x, int y, int Width, int Height);
	~CDlgPreviewSettings();
	static CDlgPreviewSettings *m_pThis;

public:
	static CDlgPreviewSettings *CreateInstance(int x, int y, int Width, int Height);
	//! Gets CDlgPreviewSettings instance.
	static CDlgPreviewSettings *GetInstance() { return m_pThis; }
	static void DisposeInstance();

	int OnUserIO(int nKey);
	void DynamicRedraw();
	void Prepare();
	void UpdateScaleFactors();
	void UpdateROIValues();

	//! Sets region of interest.
	void SetROI(CRegion *pReg)
		{ m_pROI = pReg; m_bForceRedrawEx = true;}
	//! Frees region of interest.
	void FreeROI()
		{ m_pROI = NULL; m_bForceRedrawEx = true;}
	//! Enables cursor in preview window.
	void SetCursor(POINT *pCursor)
		{ m_pCursor = pCursor; m_bForceRedrawEx = true; }
	//! Disables cursor in preview window.
	void FreeCursor()
		{ m_pCursor = NULL;  m_bForceRedrawEx = true;}
	//! Sets preview image offset.
	void SetPVImageOffset(int x, int y)
		{ m_PVImageOffsetX = x; m_PVImageOffsetY = y;}

protected:
	void EnableROI_Items();

	int		m_OVImagePosX;	//!< X-Position of overview image
	int		m_OVImagePosY;	//!< Y-Position of overview image
	CIMAGE	m_OVImage;		//!< Overview image (Color)
	YIMAGE	m_YOVImage;		//!< Overview image (Gray)
	double	m_OVScaleX;		//!< X-Direction scale factor
	double	m_OVScaleY;		//!< Y-Direction scale factor

	int		m_OVRectPosX;	//!< X-Position of previewed area rectangle in overview image
	int		m_OVRectPosY;	//!< Y-Position of previewed area rectangle in overview image
	int		m_OVRectWidth;	//!< Width of previewed area rectangle in overview image
	int		m_OVRectHeight;	//!< Height of previewed area rectangle in overview image

	int		m_OVROIRectPosX;	//!< X-Position of ROI rectangle in overview image
	int		m_OVROIRectPosY;	//!< Y-Position of ROI rectangle in overview image
	int		m_OVROIRectWidth;	//!< Width of ROI rectangle in overview image
	int		m_OVROIRectHeight;	//!< Height of ROI rectangle in overview image
	int		m_bForceRedrawEx;
	int		m_OVCursorPosX;
	int		m_OVCursorPosY;
	int		m_PVImageOffsetX;
	int		m_PVImageOffsetY;
	int		m_ROIXPos;			//!< X-Position of ROI
	int		m_ROIYPos;			//!< Y-Position of ROI
	int		m_ROIWidth;			//!< Width of ROI
	int		m_ROIHeight;		//!< Height of ROI

	CRegion	*m_pROI;			//!< Region Of Interest
	char	m_StrXPos[8];		//!< String to display X-position of previewed area
	char	m_StrYPos[8];		//!< String to display Y-position of previewed area
	char	m_StrWidth[8];		//!< String to display width of previewed area
	char	m_StrHeight[8];		//!< String to display height of previewed area
	char	m_StrROIName[32];	//!< String to display height of ROI
	char	m_ZoomText[20];		//!< Text the current zoom factor is written to
	POINT	*m_pCursor;
};

/******************************************************************************/
