#ifndef  __CUTCIRCLE_H_INCLUDE__
#define  __CUTCIRCLE_H_INCLUDE__
 

#include "cncobj.h"

#define CC_MAX_CP_CNT   3

// This class is exported from the CutCircle.dll
class CNCCLS_API CCutCircle : public CCncObj {

public:
	CCutCircle(void);
	virtual ~CCutCircle(void);
	
	virtual double GetMacLength();

	//@1 像素坐标
	RvPoint_f   GetCenter(/*float& x, float& y*/);
	void   SetCenter(float x, float y, BOOL bUpdateMap =FALSE );
	int     GetRadius(); 
	void   SetRadius(int val, BOOL bUpdateMap =FALSE );

	//virtual RvPoint GetCounterCamPos(int index);

	//end of @1
	
    //@2 机械坐标
//	virtual RvPoint_f64 GetStartMacPos() ; 
//	virtual RvPoint_f64 GetEndMacPos();
	virtual RvPoint_f64 GetReferMacPos();
	
	virtual int GetMacPosCount();
	virtual RvPoint_f64 GetMacPosAt(int index) ;
	virtual RvPoint_f64* GetMacPosArray() ;
	virtual void SetMacPosAt(int index, RvPoint_f64 pos) ;
	RvPoint_f64 GetMacCenter();
	double GetMacRadius();
	//end of @2 

	virtual RvPoint_f  GetCamPosAt(int index) ;
	virtual void     SetCamPosAt(int index, RvPoint_f pos);

	virtual void UpdateCamPos();
	virtual void UpdateMacPos();
	//virtual BOOL UpdateCamPos(double curMacX, double curMacY);
	//virtual BOOL UpdateMacPos(double curMacX, double curMacY);



private:
	//BOOL m_bDirFlag;    //lh0308

	void ResetExtender();
	void UpdateRect();
	 // BOOL UpdateCurve();

	void GetExtenderPoint(CDelegate* pDelegate,double &x, double &y ,int index);

	RV_HANDLE DrawCutter(CDelegate* pDelegate,    float radius, RV_HANDLE hStroke);
	
	RvPoint_f64  m_cps[CC_MAX_CP_CNT];

public:
	 
	//	RvPoint_f64 GetExtenderPoint(int nIndex);
	double CalcRadius(RvPoint_f64 pt, RvPoint_f64 center);

	 void Show(CDelegate* pDelegate, int mode,BOOL bForce);
	
	//图像坐标缩放和旋转
	virtual void Scale(double scale);
    virtual void Scale(double scaleX, double scaleY);
    virtual void Rotate(double cx, double cy, double angle);


private:
	 RV_HANDLE DrawCirclePath(HGDC dc,  double cx, double cy, double r, double offset, RV_HANDLE hStroke);

public:
	virtual void ShowExtender(CDelegate* pDelegate,CLeadMark* pMark);
	virtual void  ShowGrabber(CDelegate* pDelegate, CLeadMark* pMark);	
	virtual CUCObj* Clone( CUCObj* twin);
	virtual BOOL Serialize(HANDLE device, BOOL bIn );
	virtual void OnEndTrack(CDelegate* pDelegate,HGPD hCur,  GPoint point, int nHitTest);
	
	//	virtual void UpdateMacCoor(int hitPos, double x, double y);
	
	//private:
//	BOOL CalcArcCenter(RvPoint_f64&p1,RvPoint_f64&p2,RvPoint_f64&p3, RvPoint_f64* pCenter);

};

#endif


