MyManageGraphObj.h
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:6k
- #include "MyGraphObject.h"
- #include "MyDraw.h"
- #include "MyCommand.h"
- #include "MyFileLayer.h"
- //被选择对象信息类
- class CSelectedObjectInfo: public CObject
- {
- public:
- int m_type;
- int m_index;
- CRect m_range;
- public:
- CSelectedObjectInfo(int type, int index);
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////
- class CManageGraphObject:public CObject
- {
- public:
- DECLARE_DYNCREATE(CManageGraphObject)
- CManageGraphObject();
- void Serialize(CArchive& ar);
- ~CManageGraphObject();
- public:
- CDrawGrapObject m_DrawGrapObject;
- public:
- float Proportion; //图形缩放比例
-
- private:
- CPoint StartPoint; //画直线、矩形、圆、圆弧时的起始点(画圆时,是圆的圆心)
- CPoint MidPoint; //画圆弧时的中间点
- CPoint EndPoint; //画直线、矩形、圆、圆弧时的结束点
- CPoint oldMidPoint; //上一次画圆弧时的中间点
- CPoint oldEndPoint; //上一次画直线、矩形、圆、圆弧时的结束点
- private:
- COLORREF PenColor; //画笔颜色
- int LineStyle; //画笔线形
- private:
- SIZE LogicViewSize; //逻辑视区的尺寸,等于图纸大小加额外尺寸
- public:
- void SetLogicViewSize(SIZE size); //获取逻辑区的尺寸
- void SetLineStyle(int style); //获取画笔线形
- void SetPenColor(COLORREF color); //获取画笔颜色
- public:
- //对象类指针数组
- CObArray m_LineArray;
- CObArray m_RectArray;
- CObArray m_CircleArray;
- CObArray m_ArcArray;
-
- //对象信息类指针数组
- CObArray m_LineInfoArray;
- CObArray m_RectInfoArray;
- CObArray m_CircleInfoArray;
- CObArray m_ArcInfoArray;
- //被选中对象信息类指针数组
- CObArray m_SelObjInfoArray;
-
- public:
- void Initialize(SIZE size, int style, COLORREF color); //初始化内部参数
- private:
- CCommandStack * pCommandStack; //命令类指针
- public:
- void GetCommandStack(CCommandStack* pStack); //获取命令类指针
- private:
- CManageFileLayer* pManageLayer; //命令类指针
- public:
- void GetManageFileLayer(CManageFileLayer* pManage); //获取命令类指针
- private:
- CString CurrentLayerName;
- public:
- void SetCurrentLayerName(CString layername); //图层管理类指针
- private:
- CDC* pDC; //图形设备指针
- CView* pView; //视指针
- public:
- void GetDC(CDC* pClientDC); //获取图形设备指针
- void GetView(CView* view); //获取视指针
- private:
- int LRepeatTimes; //在当前绘图命令下鼠标左键点击次数
- int RRepeatTimes; //在当前绘图命令下鼠标右键点击次数
- public:
- void OnLButtonDown(UINT ID, CPoint point);
- UINT OnRButtonDown(UINT ID, CPoint point);
- void OnMouseMove(UINT ID, CPoint point);
- void OnScroll(UINT ID);
- void OnRedo();
- void OnUndo();
- public:
- UINT OnDrawLine(UINT msg, CPoint point);
- UINT OnDrawRect(UINT msg, CPoint point);
- UINT OnDrawCircle(UINT msg, CPoint point);
- UINT OnDrawArc(UINT msg, CPoint point);
- public:
- UINT OnModifyDelete(UINT msg = NULL, CPoint point = NULL);
- public:
- POINT DrawingToLogic(FPOINT fpoint); //将点的图纸坐标转换为逻辑坐标
- long DrawingToLogic(float fdistance); //将图纸距离转换为逻辑距离
- FPOINT LogicToDrawing(POINT point); //将点的逻辑坐标转换为图纸坐标
- float LogicToDrawing(long distance); //将转换逻辑距离为图纸距离
- private:
- CRect LogicClientRect; //窗口占有的逻辑区
- public:
- CRect GetLogicClientRect(); //获取窗口占有的逻辑区
- BOOL IsInLogicClientRect(CRect rect); //图形对象是否在窗口占有的逻辑区内,rect
- //是图形对象所占有的逻辑区
-
- private:
- CRect EffectRect; //发生变化的逻辑区
- public:
- void SetEffectRect(CRect rect); //设置发生变化的逻辑区
- public:
- //获取需要重画的逻辑区域,参数effectRect是发生变化的逻辑区
- //参数clientRect是窗口占有的逻辑区
- CRect GetRedrawRect(CRect effectRect, CRect clientRect);
- //判断图形对象是否需要重画
- BOOL IsRedraw(CRect redrawRect, CRect objRect);
-
- public:
- void GetObjectRange(); //获取所有图形对象所占据的逻辑区
- void RedrawAllObject(CDC* pDC); //重画所有图形对象
- void SelectObject(CDC* pDC, CPoint point); //选取图形对象
- BOOL UnselectObject(); //取消选取图形对象
- public:
- void RedrawLine(CDC* pDC); //重画所有的Line对象
- void SelectLine(CDC* pDC, CPoint point); //选取直线对象
- BOOL UnselectLine();
- void AddLine(POINT SPoint, POINT EPoint, int Style, COLORREF Color); //增加直线对象
- CMyLine* GetLine(int index); //获取指定序号的直线对象
- void DelLine(int index); //删除指定序号的直线对象
- void DelAllLine(); //删除所有的直线对象
- CRect GetLineRange(long ExtraRange, CMyLine* pLine); //获取直线对象所占据的逻辑区
- public:
- void RedrawRect(CDC* pDC);
- void SelectRect(CDC* pDC, CPoint point);
- BOOL UnselectRect();
- void AddRect(POINT SPoint, POINT EPoint, int Style, COLORREF Color);
- CMyRect* GetRect(int index);
- void DelRect(int index);
- void DelAllRect();
- CRect GetRectRange(long ExtraRange, CMyRect* pRect);
- public:
- void RedrawCircle(CDC* pDC);
- void SelectCircle(CDC* pDC, CPoint point);
- BOOL UnselectCircle();
- void AddCircle(POINT SPoint, POINT EPoint, int Style, COLORREF Color);
- CMyCircle* GetCircle(int index);
- void DelCircle(int index);
- void DelAllCircle();
- CRect GetCircleRange(long ExtraRange, CMyCircle* pCircle);
- public:
- void RedrawArc(CDC* pDC);
- void SelectArc(CDC* pDC, CPoint point);
- BOOL UnselectArc();
- void AddArc(POINT SPoint, POINT MPoint, POINT EPoint, int Style, COLORREF Color);
- CMyArc* GetArc(int index);
- void DelArc(int index);
- void DelAllArc();
- CRect GetArcRange(long ExtraRange, CMyArc* pArc);
- };