#pragma once

#include "cncobj.h"


#define CSL_VERTEX_COUNT  3

class CNCCLS_API CCutShapeL :	public CCncObj
{
public:
	CCutShapeL(void);
	virtual ~CCutShapeL(void);
	 
    //@1相机坐标
	void   SetVertexPos(int index, RvPoint_f  pos/*, BOOL bUpdateMap*/);
	RvPoint_f  GetVertexPos(int index);
	//virtual RvPoint GetCounterCamPos(int index);
	//end of @1

	//@2机械坐标
	virtual double GetMacLength();
//	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) ;
	//end of @2

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

	virtual void UpdateCamPos();
	virtual void UpdateMacPos();
	 

public:
	virtual void Show(CDelegate* pDelegate, int mode,BOOL bForce);

	//virtual void Move(double xOffset, double yOffset);

	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 Move(double dx, double dy) ;
	virtual void Scale(double scale);
    virtual void Scale(double scaleX, double scaleY);
    virtual void Rotate(double cx, double cy, double angle);


	//for delegate use only
public:
	virtual int    HitTest(CDelegate* pDelegate,GPoint point) ; 
	//virtual GRect  GetGrabberRect(BOOL bActualSize) ;
	
	virtual GRect  GetExtenderRect(CDelegate* pDelegate,int index, RvSize size) ;
	virtual GRect  GetCurRect() ;
	 
	virtual void ShowSketch(CDelegate* pDelegate, CSketchMark* pMark,  HGPD hGpd,  int grabType, GPoint grabPos)  ;

	virtual BOOL OnPositionChange( HGPD hOri, HGPD hCur, HGPD hNew, GPoint grabPos, RvOffset &offset) ;
	virtual BOOL OnExtenderChange( HGPD hCur, HGPD hNew, int index, GPoint &curPos) ;
	   
	virtual void OnEndTrack(CDelegate* pDelegate,HGPD hCur,  GPoint point, int nHitTest) ;

	virtual void DestroyGraphicDescriptor(HGPD hGpd)  ;
	virtual HGPD CreateGraphicDescriptor(CDelegate* pDelegate) ;
	virtual void CopyGraphicDescriptor(const HGPD src, HGPD dest);

	
protected:
	void UpdateMachRect(void);

	RV_HANDLE DrawCutter(CDelegate* pDelegate, float radius, RV_HANDLE hStroke);

	double CalcAngle(double x0, double y0, double x1, double y1 );

	RV_HANDLE DrawShapeLPath(HGDC dc,  const GPoint* pVertArr, int nVertCount, double offset, RV_HANDLE hStroke);

	void UpdateRect();
private:
	typedef struct _cut_shape_l_graphic_descriptor{

		GPoint p0,p1,p2;   

	}GdCutShapeL;

	RvPoint_f   m_vertexes[CSL_VERTEX_COUNT];
	RvPoint_f64 m_cps[CSL_VERTEX_COUNT];
 

};

