FractalView.h
上传用户:dxkjfz
上传日期:2021-06-06
资源大小:1930k
文件大小:3k
源码类别:

分形几何

开发平台:

Visual C++

  1. // FractalView.h : interface of the CFractalView class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_FRACTALVIEW_H__936474E6_41E8_4F92_A03D_AE280DDC51F4__INCLUDED_)
  5. #define AFX_FRACTALVIEW_H__936474E6_41E8_4F92_A03D_AE280DDC51F4__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CFractalView : public CView
  10. {
  11. public: //class defination
  12. /* 分行树 */
  13. class FractalTree{
  14. public:
  15. //定时器间隔,单位毫秒
  16. int m_Interval;
  17. //记录定时器是否在工作
  18. BOOL m_bRunning;
  19. };
  20. /* Sierpinski三角形 */
  21. class Sierpinski{
  22. public:
  23. int m_Interval;
  24. BOOL m_bRunning;
  25. };
  26. /* 万花筒 */
  27. class Flower{
  28. public:
  29. int m_Interval;
  30. BOOL m_bRunning;
  31. };
  32. /* 王冠 */
  33. class Crown{
  34. public:
  35. int m_Interval;
  36. BOOL m_bRunning;
  37. float m_C;
  38. COLORREF m_pColor;
  39. double cx,cy;
  40. double x,y;
  41. double wx,wy;
  42. double theta;
  43. int i;
  44. float rnd;
  45. int m,n;
  46. double r;
  47. BOOL stop;
  48. CDC memdc;
  49. BOOL ondraw;
  50. float cxspeed;
  51. float cyspeed;
  52. float cxmin;
  53. float cxmax;
  54. float cymin;
  55. float cymax;
  56. int cxdirect;
  57. int cydirect;
  58. int count;
  59. int cnt;
  60. };
  61. protected: // create from serialization only
  62. CFractalView();
  63. DECLARE_DYNCREATE(CFractalView)
  64. // Attributes
  65. public:
  66. CFractalDoc* GetDocument();
  67. // Operations
  68. public:
  69. // Overrides
  70. // ClassWizard generated virtual function overrides
  71. //{{AFX_VIRTUAL(CFractalView)
  72. public:
  73. virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  74. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  75. protected:
  76. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  77. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  78. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  79. //}}AFX_VIRTUAL
  80. // Implementation
  81. public:
  82. virtual ~CFractalView();
  83. #ifdef _DEBUG
  84. virtual void AssertValid() const;
  85. virtual void Dump(CDumpContext& dc) const;
  86. #endif
  87. protected:
  88. FractalTree tree;
  89. Sierpinski sier;
  90. Flower flower;
  91. Crown crown;
  92. BOOL m_dir;
  93. /************************************************************************/
  94. //画笔
  95. CPen m_Pen;
  96. //前景颜色
  97. COLORREF m_fgColor;
  98. //背景颜色
  99. COLORREF m_bgColor;
  100. //物理画布
  101. CDC m_DC;
  102. //内存位图
  103. CBitmap m_Bitmap;
  104. //内存画布
  105. CDC m_MemDC;
  106. //窗口客户区大小
  107. CRect m_Rect;
  108. /************************************************************************/
  109. HICON m_hIcon;
  110. //绘制树叶
  111. void drawLeaf(double x, double y, double L, double a,float B,float C);
  112. //Sierpinski
  113. void sier_ifs(CDC *pDC, float k);
  114. //万花筒
  115. void flower_ifs(CDC *pDC, float k);
  116. //王冠
  117. void drawCrown();
  118. // Generated message map functions
  119. protected:
  120. //{{AFX_MSG(CFractalView)
  121. afx_msg void OnDrawtree();
  122. afx_msg void OnTimer(UINT nIDEvent);
  123. afx_msg void OnDrawstop();
  124. afx_msg void OnDrawsierpinski();
  125. afx_msg void OnDrawflower();
  126. afx_msg void OnDrawcrown();
  127. afx_msg void OnDrawnew();
  128. //}}AFX_MSG
  129. DECLARE_MESSAGE_MAP()
  130. };
  131. #ifndef _DEBUG  // debug version in FractalView.cpp
  132. inline CFractalDoc* CFractalView::GetDocument()
  133.    { return (CFractalDoc*)m_pDocument; }
  134. #endif
  135. /////////////////////////////////////////////////////////////////////////////
  136. //{{AFX_INSERT_LOCATION}}
  137. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  138. #endif // !defined(AFX_FRACTALVIEW_H__936474E6_41E8_4F92_A03D_AE280DDC51F4__INCLUDED_)