MyManageGraphObj.h
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:4k
源码类别:

绘图程序

开发平台:

Visual C++

  1. #include "MyGraphObject.h"
  2. #include "MyDraw.h"
  3. #include "MyCommand.h"
  4. //被选择对象信息类
  5. class CSelectedObjectInfo: public CObject
  6. {
  7. public:
  8. int m_type;
  9. int m_index;
  10. public:
  11. CSelectedObjectInfo(int type, int index);
  12. };
  13. ///////////////////////////////////////////////////////////////////////////////////////////////
  14. class CManageGraphObject:public CObject
  15. {
  16. public:
  17. DECLARE_DYNCREATE(CManageGraphObject)
  18.     CManageGraphObject();
  19. void Serialize(CArchive& ar);
  20. ~CManageGraphObject();
  21. public:
  22. CDrawGrapObject m_DrawGrapObject;
  23. public:
  24.     SIZE     PageSize;       //图纸大小 
  25. float    Proportion;     //图形缩放比例
  26. private:
  27. CPoint   StartPoint;   //画直线、矩形、圆、圆弧时的起始点(画圆时,是圆的圆心) 
  28. CPoint   MidPoint;    //画圆弧时的中间点   
  29. CPoint   EndPoint;     //画直线、矩形、圆、圆弧时的结束点 
  30. CPoint   oldMidPoint;  //上一次画圆弧时的中间点 
  31. CPoint   oldEndPoint;  //上一次画直线、矩形、圆、圆弧时的结束点 
  32. private:
  33. COLORREF PenColor;
  34. int      LineStyle;
  35. public:
  36. void SetLineStyle(int style);
  37. void SetPenColor(COLORREF color);
  38. public:
  39. //对象类指针数组
  40. CObArray m_LineArray;
  41. CObArray m_RectArray;
  42. CObArray m_CircleArray;
  43. CObArray m_ArcArray;
  44.     
  45. //对象信息类指针数组
  46. CObArray m_LineInfoArray;
  47. CObArray m_RectInfoArray;
  48. CObArray m_CircleInfoArray;
  49. CObArray m_ArcInfoArray;
  50. //选中对象信息类指针数组
  51. CObArray m_SelObjInfoArray;
  52. public:
  53. void Initialize(int style, COLORREF color);
  54. private:
  55.     CCommandStack * pCommandStack; 
  56. public:
  57.     void GetCommandStack(CCommandStack* pStack);
  58. private:
  59. CClientDC* pDC;
  60. public:
  61. void GetDC(CClientDC* pClientDC);
  62. private:
  63. int LRepeatTimes;       //在当前绘图命令下鼠标左键点击次数
  64. int RRepeatTimes;       //在当前绘图命令下鼠标右键点击次数
  65. public:
  66. void OnLButtonDown(UINT ID, CPoint point);
  67. UINT OnRButtonDown(UINT ID, CPoint point);
  68. void OnMouseMove(UINT ID, CPoint point);
  69. void OnScroll(UINT ID);
  70. void OnRedo();
  71. void OnUndo();
  72. public:
  73. POINT   DrawingToLogic(FPOINT fpoint);        //将点的图纸坐标转换为逻辑坐标
  74. long    DrawingToLogic(float fdistance);      //将图纸距离转换为逻辑距离 
  75. FPOINT  LogicToDrawing(POINT point);          //将点的逻辑坐标转换为图纸坐标
  76. float   LogicToDrawing(long distance);        //将转换逻辑距离为图纸距离 
  77. public:
  78. void RedrawAllObject(CDC* pDC);
  79. void SelectObject(CDC* pDC, CPoint point);    //选取图形对象
  80. BOOL UnselectObject();                        //取消选取图形对象
  81. public:
  82. void RedrawLine(CDC* pDC);                 //重画所有的Line对象
  83. void SelectLine(CDC* pDC, CPoint point);
  84.     BOOL UnselectLine();
  85. void AddLine(POINT SPoint, POINT EPoint, int Style, COLORREF Color);  //增加直线对象
  86.     CMyLine* GetLine(int index);                  //获取指定序号的直线对象 
  87.     void DelAllLine();                            //删除所有的直线对象 
  88. public:
  89. void RedrawRect(CDC* pDC);  
  90. void SelectRect(CDC* pDC, CPoint point);
  91.     BOOL UnselectRect();
  92. void AddRect(POINT SPoint, POINT EPoint, int Style, COLORREF Color);
  93. CMyRect* GetRect(int index);
  94. void DelAllRect();
  95. public:
  96. void RedrawCircle(CDC* pDC);  
  97. void SelectCircle(CDC* pDC, CPoint point);
  98.     BOOL UnselectCircle();
  99. void AddCircle(POINT SPoint, POINT EPoint, int Style, COLORREF Color);
  100. CMyCircle* GetCircle(int index);
  101. void DelAllCircle();
  102. public:
  103. void RedrawArc(CDC* pDC);  
  104. void SelectArc(CDC* pDC, CPoint point);
  105.     BOOL UnselectArc();
  106. void AddArc(POINT SPoint, POINT MPoint, POINT EPoint, int Style, COLORREF Color);
  107. CMyArc* GetArc(int index);
  108. void DelAllArc();
  109. };