MyDraw.h
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:4k
- #include "MyGraphObject.h"
- ///////////////////////////////////////////////////////////////////////////////////////////////
- class CMyObjectInfo: public CObject
- {
- public:
- BOOL m_del; //删除标记
- BOOL m_selected; //选中标记
- //int layer; //对象所在图层
- public:
- CMyObjectInfo(BOOL del, BOOL selected);
- };
- //被选择对象信息类
- class CMySelObjectInfo: public CObject
- {
- public:
- int m_type;
- int m_index;
- public:
- CMySelObjectInfo(int type, int index);
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //处理直线、矩形、圆等对象
- class CMyOperate : public CObject
- {
- protected:
- DECLARE_DYNCREATE(CMyOperate)
- public:
- SIZE size; //图纸大小
- CPoint StartPoint; //画直线、矩形、圆、圆弧时的起始点
- CPoint oldMidPoint; //上一次画圆弧时的中间点
- CPoint MidPoint; //画圆弧时的中间点
- CPoint oldEndPoint; //上一次画直线、矩形、圆、圆弧时的结束点
- CPoint EndPoint; //画直线、矩形、圆、圆弧时的结束点
- CPoint OriginPoint; //画圆弧时的圆心
- long Radius; //画圆、圆弧时的半径
- float Proportion; //图形缩放比例
- COLORREF ForeColor;
- int LineStyle;
- 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:
- CMyOperate();
-
- void RedrawAllObject(CDC* pDC);
- //选取图形对象
- void SelectObject(CDC* pDC, CPoint point);
- //取消选取图形对象
- BOOL UnselectObject();
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public:
- //处理直线
- //用异或擦除旧的直线,绘制新的直线(基于CDC, (0,0)点为窗口区的左上角)
- void DrawLineA(CDC* pDC);
-
- //直接绘制新的直线(基于CDC, (0,0)点为窗口区的左上角),用于屏幕滚动时
- void DrawLineB(CDC* pDC);
- //直接绘制新的直线(基于CDC, (0,0)点为窗口区的左上角),用于增加直线时
- void DrawLineC(CDC* pDC);
- //用异或擦除旧的直线(基于CDC, (0,0)点为窗口区的左上角)
- void CancelDrawLine(CDC* pDC);
- //重画所有的Line对象(基于CDC, (0,0)点为窗口的左上角)
- void RedrawLine(CDC* pDC);
- void SelectLine(CDC* pDC, CPoint point);
- BOOL UnselectLine();
- void DrawSelLine(CDC* pDC, CMyLine* pLine);
-
- void DelLine(CDC* pDC);
-
- void LightenLine();
- //增加直线对象
- void AddLine();
-
- //获取指定序号的直线对象
- CMyLine* GetLine(int index);
- //删除所有的直线对象
- void DelAllLine();
- //////////////////////////////////////////////////////////////////////////////////////////////
- public:
- //处理矩形
- void DrawRectA(CDC* pDC);
- void DrawRectB(CDC* pDC);
- void DrawRectC(CDC* pDC);
- void RedrawRect(CDC* pDC);
- void CancelDrawRect(CDC* pDC);
- void SelectRect(CDC* pDC, CPoint point);
- BOOL UnselectRect();
- void DrawSelRect(CDC* pDC, CMyRect* pRect);
- void AddRect();
- CMyRect* GetRect(int index);
- void DelAllRect();
- ////////////////////////////////////////////////////////////////////////////////////////////////
- public:
- //处理圆
- void DrawCircleA(CDC* pDC);
- void DrawCircleB(CDC* pDC);
- void DrawCircleC(CDC* pDC);
- void RedrawCircle(CDC* pDC);
- void CancelDrawCircle(CDC* pDC);
- void SelectCircle(CDC* pDC, CPoint point);
- BOOL UnselectCircle();
- void DrawSelCircle(CDC* pDC, CMyCircle* pCircle);
- void AddCircle();
- CMyCircle* GetCircle(int index);
- void DelAllCircle();
- ///////////////////////////////////////////////////////////////////////////////////////////////
- public:
- //处理圆弧
- void DrawArcA(CDC* pDC, int times);
- void DrawArcB(CDC* pDC, int times);
- void DrawArcC(CDC* pDC);
- void RedrawArc(CDC* pDC);
- void CancelDrawArc(CDC* pDC, int times);
- void SelectArc(CDC* pDC, CPoint point);
- BOOL UnselectArc();
- void DrawSelArc(CDC* pDC, CMyArc* pArc);
- void AddArc();
- CMyArc* GetArc(int index);
- void DelAllArc();
- ///////////////////////////////////////////////////////////////////////////////////////////////
- public:
- ~CMyOperate();
- void Serialize(CArchive& ar);
- };
- ////////////////////////////////////////////////////////////////////////////////////////////