#pragma once

 


#include "EasyTrace.h"
#include <sst\realview.h>
#include <ocv\RobotSpaceMapE1.h>
 

#define MAX_VERTEX_COUNT   128


#define   WM_UC_SUB_POPMENU       (WM_USER + 1502)
#define   WM_UC_SUB_REFRASH       (WM_USER + 1503)
#define	  WM_MV_SIGHT_LMC_DOWN    (WM_USER + 1505)  //鼠标左键下+ ctrl
#define	  WM_MV_SIGHT_LMC_UP      (WM_USER + 1506)  //鼠标左键上 + ctrl
#define   WM_MV_SIGHT_MOUSE_MOVE  (WM_USER + 1507)
#define   WM_MV_SIGHT_DBLCLK      (WM_USER + 1509)   
#define   WM_UC_CTRLPOINT_HIT     (WM_USER + 1501)  
#define   WM_UC_CTRLPOINT_UNHIT   (WM_USER + 1508)

//全局视场编辑消息
#define   WM_UC_OBJ_ADD          (WM_USER + 1510)
#define   WM_UC_OBJ_DEL          (WM_USER + 1511)
#define   WM_UC_OBJ_MOD          (WM_USER + 1512)

//局部视场（移动相机）
#define   WM_UC_POLYLINE_FINISH   (WM_USER + 1521)
#define   WM_MV_SIGHT_EDIT_CTRLPT (WM_USER + 1522)  //增加或修改控制点
#define   WM_MV_SIGHT_STEPMOVE    (WM_USER + 1523)  //寸动

 

#define OA_DEF_CAM_WIDTH      1280
#define OA_DEF_CAM_HEIGHT     1024

#define OA_DRILL_SIZE         34


class CNCCLS_API  CElemView :	public CRealView
{
public:
	CElemView(void);
	virtual ~CElemView(void);

	enum {
		VT_DEFAULT =0,
		VT_FILLWIN  ,
		VT_ZOOMIN   ,
		VT_ZOOMOUT  ,
	};

	//ADDIN TYPE
	//需与EasyTrace定义一致
	enum ADD_TYPE
	{
		AT_UNK  = -1,
		AT_PICK = 0,
		AT_POINT ,
		AT_LINE, 
		AT_ARC, 
		AT_CIRCLE,
		AT_SHAPE_L,
		AT_SHAPE_U,
		AT_POLYLINE, 
	};

	virtual BOOL Create(HWND hParentWnd, const char* strWindowName , int sightWidth , int sightHeight , GRect& rect);
	virtual void Destroy();

	virtual void SetAddinType(int type, BOOL bRefresh=TRUE);
	int  GetAddinType(){ return m_nAddinType; };

	//void FeedFrameEx(const RvImage image);
	BOOL IsAdding(){return m_bAdding;};

	//void  SetTraceColor(GRgb color);
	//void  SetTraceSize(int value);
 
	void SetFocusVisible(BOOL flag, BOOL bRefresh);
	BOOL IsFocusVisible();
	void SetFocusSize(int min, int max, int steps,  BOOL bRefresh);
	void BeatFocus( BOOL bRefresh);
	void SetFocusPos(int x, int y, BOOL bRefresh);



	void  SetTraceWidth(int value); 


	void SetViewModeE1(int mode);
	int  GetViewModeE1();

	CEasyTrace* GetTrace(){ return &m_traceMark; };
	CMark* GetFocusMark() { return &m_focusMark;}

public:
	HWND  m_hNotifyWnd;

public: 
	virtual BOOL MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam , LRESULT* pResult);
	virtual BOOL EventProc(RV_HANDLE hObj, UINT uEvent, WPARAM wParam, LPARAM lParam);

	virtual void Refresh(REFRESH_TYPE type);
protected:
	BOOL HandleDrawingMsg( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam , LRESULT* pResult);
	BOOL HandleNavigateMsg( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam , LRESULT* pResult);

	BOOL  TryTrace(int x, int y);

	void DrawTrace(HGDC dc, BOOL bForce);
	void DrawFocus(HGDC dc, BOOL bForce);

	BOOL AddElem(int type);
    BOOL AddPolyline();

protected:
	CEasyTrace m_traceMark;
	 
	int        m_nAddinType;
	POINT      m_prevMousePos;

	int m_nScaleIndex;

	CMark      m_focusMark;  //焦点标志
	int        m_nMinFocusSize;
	int        m_nMaxFocusSize;
	int        m_nCurFocusSize;
	int        m_nFocusSteps ;  //从最小变化到最大的次数
	BOOL       m_bFocusVisible ;

	BOOL      m_bAdding;
	int       m_nVertexIndex;
	RvPoint_f m_vertex[MAX_VERTEX_COUNT];



};

