MyDraw.h
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:4k
- #include "MyGraphObject.h"
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //被选择对象信息类
- class CSelectedObjectInfo: public CObject
- {
- public:
- int m_type;
- int m_index;
- public:
- CSelectedObjectInfo(int type, int index);
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //处理直线、矩形、圆等对象
- class COperateObject : public CObject
- {
- protected:
- DECLARE_DYNCREATE(COperateObject)
- public:
- COLORREF PenColor; //
- int LineStyle; //
- public:
- BOOL ScrollFlag; //屏幕滚动标志
- SIZE PageSize; //图纸大小
- CPoint StartPoint; //画直线、矩形、圆、圆弧时的起始点
- CPoint oldMidPoint; //上一次画圆弧时的中间点
- CPoint MidPoint; //画圆弧时的中间点
- CPoint oldEndPoint; //上一次画直线、矩形、圆、圆弧时的结束点
- CPoint EndPoint; //画直线、矩形、圆、圆弧时的结束点
- CPoint OriginPoint; //画圆弧时的圆心
- long Radius; //画圆、圆弧时的半径
- float Proportion; //图形缩放比例
-
- 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:
- COperateObject();
- public:
- void Intialize(COLORREF pcolor, int pstyle);
- void SetPageSize(SIZE size);
- 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 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 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 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);
- 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:
- ~COperateObject();
- void Serialize(CArchive& ar);
- };
- ////////////////////////////////////////////////////////////////////////////////////////////