DrawSysView.h
Upload User: taoguanmin
Upload Date: 2007-05-11
Package Size: 180k
Code Size: 5k
Category:

2D Graphic

Development Platform:

Visual C++

  1. // DrawSysView.h : interface of the CDrawSysView class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_)
  5. #define AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_
  6. #pragma warning(disable:4786)//禁止waring号为4786的warning消息
  7. #if _MSC_VER > 1000
  8. #pragma once
  9. #endif // _MSC_VER > 1000
  10. #include "SetDlg.h"
  11. #include "stdlib.h"
  12. #include "math.h"
  13. #include <list>
  14. #include <vector>
  15. enum DRAWSORT{DsNull,DsLine,DsCircle,DsManyBd,DsCutLine,DsBezier,DsStroke,DsText};//画图类型
  16. //直线
  17. struct LINE
  18. {
  19. POINT pStart;
  20. POINT pEnd;
  21. bool operator==(LINE l)
  22. {
  23. if(l.pStart.x==pStart.x && l.pStart.y==pStart.y && l.pEnd.x==pEnd.x && l.pEnd.y==pEnd.y)
  24. return 1;
  25. return 0;
  26. };
  27. };
  28. //圆
  29. struct CIRCLE
  30. {
  31. POINT pMid;//圆心
  32. int r;     //半径
  33. };
  34. //文本
  35. struct TEXT
  36. {
  37. CString str;
  38. POINT p;
  39. };
  40. using namespace std;
  41. typedef vector<POINT> BEZIER;//Bezier曲线
  42. class CDrawSysView : public CView
  43. {
  44. protected: // create from serialization only
  45. CDrawSysView();
  46. DECLARE_DYNCREATE(CDrawSysView)
  47. // Attributes
  48. public:
  49. CDrawSysDoc* GetDocument();
  50. // Operations
  51. public:
  52. // Overrides
  53. // ClassWizard generated virtual function overrides
  54. //{{AFX_VIRTUAL(CDrawSysView)
  55. public:
  56. virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  57. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  58. protected:
  59. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  60. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  61. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  62. //}}AFX_VIRTUAL
  63. // Implementation
  64. public:
  65. void Circle(long pcx,long pcy,int r,CDC *pDC);
  66. virtual ~CDrawSysView();
  67. #ifdef _DEBUG
  68. virtual void AssertValid() const;
  69. virtual void Dump(CDumpContext& dc) const;
  70. #endif
  71. protected:
  72. void Line_DDA(POINT p1,POINT p2,CDC *pDC);
  73. void Line_Bresenham(POINT p1,POINT p2,CDC *pDC);
  74. void Line(POINT p1,POINT p2,CDC *pDC);
  75. void Line(LINE l,CDC *pDC);
  76. void Line(long p1x,long p1y,long p2x,long p2y,CDC *pDC);
  77. void Circle(POINT pc,int r,CDC *pDC);
  78. void Circle(CIRCLE c,CDC *pDC);
  79. int GetDist(POINT p1,POINT p2);
  80. void CutLine(RECT rect,POINT& p1,POINT& p2);//剪切直线
  81. void CutLine(RECT rect,LINE& l);
  82. void Bezier(vector<POINT> vectorPoint,CDC *pDC);
  83. void Draw3DText(CString str,CRect rectText,int nHeight,int nWidth,int nWeight,BYTE bItalic,LPCTSTR lpszFacename,CDC *pDC);
  84. protected:
  85. DRAWSORT m_dsDrawSort; //画图类型
  86. DRAWLINESORT m_dlsDrawLSort;//画直线的方式
  87. POINT m_startPoint;//前点
  88. POINT m_endPoint;  //后点
  89. POINT m_spManyBd;  //多边形的第一个点
  90. bool m_bIsMouseDown;//鼠标是否在移动
  91. bool m_bIsFirstDone;//多边形的第一条边是否画完
  92. bool m_bIsDel;
  93. int m_iPenWidth;  //画笔宽度
  94. long m_lPenColor; //画笔颜色
  95. long m_lBkColor;  //背景颜色
  96. long m_lFillColor;//填充颜色
  97. list<LINE> m_listAllLine;  //当前所有的直线
  98. list<CIRCLE> m_listAllCircle;//当前所有的圆
  99. list<BEZIER> m_listBezier;   //当前所有的贝塞尔曲线
  100. vector<TEXT> m_vectorText;   //当前所有文本
  101. BEZIER m_vectorCurBezier;//当前的贝塞尔曲线
  102. //光标
  103. HCURSOR m_hDLCursor;//直线
  104. HCURSOR m_hDCCursor;//圆
  105. HCURSOR m_hCLCursor;//剪切
  106. HCURSOR m_hDBCursor;//贝塞尔曲线
  107. HCURSOR m_hDTCursor;//文本
  108. HCURSOR m_hDSCursor;//随手画
  109. CSetDlg m_SetDlg;
  110. CStatusBar* m_pwndStatusBar;
  111. CEdit m_edtTextIn;
  112. // Generated message map functions
  113. protected:
  114. //{{AFX_MSG(CDrawSysView)
  115. afx_msg void OnLine();
  116. afx_msg void OnCircle();
  117. afx_msg void OnUpdateLine(CCmdUI* pCmdUI);
  118. afx_msg void OnUpdateCircle(CCmdUI* pCmdUI);
  119. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  120. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  121. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  122. afx_msg void OnDda();
  123. afx_msg void OnBresenham();
  124. afx_msg void OnSet();
  125. afx_msg void OnManybd();
  126. afx_msg void OnUpdateManybd(CCmdUI* pCmdUI);
  127. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  128. afx_msg void OnCut();
  129. afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
  130. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  131. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  132. afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  133. afx_msg void OnBezier();
  134. afx_msg void OnUpdateBezier(CCmdUI* pCmdUI);
  135. afx_msg void OnText();
  136. afx_msg void OnClear();
  137. afx_msg void OnStroke();
  138. afx_msg void OnUpdateStroke(CCmdUI* pCmdUI);
  139. afx_msg void OnUpdateText(CCmdUI* pCmdUI);
  140. afx_msg void OnTest();
  141. afx_msg void OnRandline();
  142. afx_msg void OnRefresh();
  143. //}}AFX_MSG
  144. DECLARE_MESSAGE_MAP()
  145. };
  146. #ifndef _DEBUG  // debug version in DrawSysView.cpp
  147. inline CDrawSysDoc* CDrawSysView::GetDocument()
  148.    { return (CDrawSysDoc*)m_pDocument; }
  149. #endif
  150. /////////////////////////////////////////////////////////////////////////////
  151. //{{AFX_INSERT_LOCATION}}
  152. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  153. #endif // !defined(AFX_DRAWSYSVIEW_H__425C0345_B72D_45B7_9628_01D8E32F4E09__INCLUDED_)