DataShow.h
上传用户:shdibao
上传日期:2022-07-20
资源大小:3385k
文件大小:7k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /************************************************************************/
  2. /* /* 数据显示类:
  3.    作者:南京航空航天大学能源与动力学院 庄三少
  4.                                    2009年1月11日  
  5.    Email:viualsan@yahoo.cn
  6.      tel:13512524413 
  7.  友情发布:http://www.codefans.net
  8.    说明:
  9.       本类无任何限制,可自由改动传播。只需附上该段说明。                                                                   */
  10. /************************************************************************/
  11. #if !defined(AFX_DATASHOW_H__50A0E545_1AFF_4752_9317_5ACBACA5073D__INCLUDED_)
  12. #define AFX_DATASHOW_H__50A0E545_1AFF_4752_9317_5ACBACA5073D__INCLUDED_
  13. #define   IDC_SAVE_BMP   1
  14. #define   IDC_SAVE_DATA   2
  15. #define   IDC_SET_DATA_COLOR 3
  16. #define   IDC_SET_AXIS_COLOR 4
  17. #define   IDC_SET_XYLEBAL_COLOR 5
  18. #define   IDC_SET_TITLE_COLOR 6
  19. #define   IDC_SET_CROSSLINE_COLOR 7
  20. #define   IDC_SET_GRID_COLOR 8
  21. #define   IDC_SET_BK_COLOR 9
  22. #define   IDC_SET_FACE_COLOR 10
  23. #define   IDC_DATA_INPUT 11
  24. #define   IDC_SET_GRID_ON_OFF 12
  25. #define   IDC_SET_NOTE_ON_OFF 13
  26. #define   IDC_SET_LINESTYLE 14
  27. #define   IDC_SET_NOTE_COLOR 15
  28. #define   IDB_BOTTON_1 101
  29. #define   IDB_SET_TIME_SHOW  16
  30. #define   IDB_SET_TIME_TEXT_COLOR 17
  31. #define   IDC_BUTTON_CANNAL  18
  32. //#define   IDC_ABOUT 8
  33. #if _MSC_VER > 1000
  34. #pragma once
  35. #endif // _MSC_VER > 1000
  36. // DataShow.h : header file
  37. // Download by http://www.codefans.net
  38. // Download by http://www.codefans.net
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDataShow window
  41. struct  pdc
  42. {
  43. CBrush new_brush,*old_brush;
  44. CPen new_pen,*old_pen;
  45. COLORREF c;
  46. };
  47. class CDataShow : public CStatic
  48. {
  49. // Construction
  50. public:
  51. CDataShow();
  52. // Attributes
  53. public:
  54. // Operations
  55. public:
  56. // Overrides
  57. // ClassWizard generated virtual function overrides
  58. //{{AFX_VIRTUAL(CDataShow)
  59. //}}AFX_VIRTUAL
  60. // Implementation
  61. public:
  62. void SetTimeShow(bool IsShow);
  63. void SetTimeTextColor(COLORREF C);
  64. CString GetTimeFormat();
  65. void SetNoteColor(COLORREF C);
  66. void SetNoteWordOn(bool IsOn);
  67. void SetNoteText(CString note);
  68. void Draw_NoteWord(CDC *pDC);
  69. void TextControl(CDC *pDC);
  70. void Draw_Text(CDC*pDC,CString str);
  71. void EnlargeSelectLarge();
  72. void SetSelectRectColor(COLORREF C);
  73. void Draw_SelectArea(CDC*pDC);
  74. void Move(CPoint p);
  75. void Init();
  76. ///////////////////////////颜色设置
  77. void SetTitleColor(COLORREF C);//设置标题颜色
  78. void SetCrossColor(COLORREF C);//设置十字线颜色
  79. void SetTextColor(COLORREF C);//设置文字颜色
  80. void SetDataColor(COLORREF C);//设置曲线颜色
  81. void SetChildRectColor(COLORREF C);//设置数据窗口颜色
  82. void SetFrameColor(COLORREF C);//设置背景框颜色
  83. int SetDrawLineStyle(int style,int lineWide);//设置数据绘制样式,style为线形,其值为0到6,linewide为线宽,其值为0到20.
  84. void SetXYLebalColor(COLORREF C);//设置x,y坐标文颜色。
  85. void SetAxisColor(COLORREF C);//设置坐标轴颜色
  86. //////////////////////////
  87. void SetGridDensity(int density);//设置网格密度,其值大于0
  88. void Grid(CString IsOn);//控制网格开关,grid:on,off.
  89. void SetGridColor(COLORREF C);//设置网格颜色
  90. //////////////////////////
  91. void SetAxisRange(double start,double ed,CString name);//坐标轴范围设置,用于确定最大最小坐标刻度,name:x,y分别表示设置x轴和y轴。
  92. void SetData(double *x,double *y,int n);//设置显示数据,n为数据的大小。
  93. void SetMaxCapturePicture(int max_p);//暂时不可用
  94. void CaptureSaveBMP(CString filename);//保存当前图像
  95. void SaveData();//保存数据,调用时自动弹出保存对话框
  96. void LoadData();//载入数据,调用时自动弹出对话框
  97. bool SaveBmp(); //保存当前图片,调用时自动弹出对话框
  98. void SaveData(double second,bool stop);//连续保存数据,second为间隔秒数,stop控制是否停止,stop为true时停止。
  99. void SaveBmp(double second,bool stop);//连续图像,second为间隔秒数,stop控制是否停止,stop为true时停止。
  100. void SetText(CString str,CString name="x");//设置坐标轴及标题文字,name为x,y,title时相应设置其值。
  101. virtual ~CDataShow();
  102. // Generated message map functions
  103. protected:
  104. //{{AFX_MSG(CDataShow)
  105. afx_msg void OnTimer(UINT nIDEvent);
  106. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  107. afx_msg void OnPaint();
  108. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  109. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  110. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  111. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  112. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  113. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  114. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  115. afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  116. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  117. afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  118. afx_msg void OnSaveBmp();
  119. afx_msg void OnSaveData();
  120. afx_msg void OnSetDataColor();
  121.     afx_msg void OnSetAxisColor();
  122. afx_msg void OnSetXYlebalColor();
  123. afx_msg void OnSetGridColor();
  124. afx_msg void OnSetBKColor();
  125. afx_msg void OnSetTitleColor();
  126. afx_msg void OnSetCrossLineColor();
  127. afx_msg void OnSetFaceColor();
  128. afx_msg void OnSetDataInput();
  129. afx_msg void OnSetGridOnOff();
  130.     afx_msg void OnSetNoteOnOff();
  131.     afx_msg void OnSetNoteColor();
  132. afx_msg void OnSetTimeShow();
  133.     afx_msg void OnSetTimeColor();
  134. //}}AFX_MSG
  135. DECLARE_MESSAGE_MAP()
  136. private:
  137. void SetNotePoint();
  138. void SetColor(CString name);
  139. void Enlarge(CPoint p);
  140. void DataChange(CString name);//数据转换,用于输入数据的显示name可为:in(显示),out(输出)
  141. void SaveDateAuto();
  142. void SaveBmpWithTheOfTime();
  143. void Draw_SelectRect(CDC *pdc);
  144. void SetAxisChange();
  145. void Draw_Grid(CDC *pDC);
  146. double GetDistance(CPoint p,double x,double y);
  147. void Draw_childRect(CDC *dc);
  148. void Draw_frameRect(CDC *dc);
  149. double GetAxisPosition(int n,CString name);//获得坐标刻度值
  150. void Draw_Data(CDC*pDC);
  151. void Draw_Axis_xyLebal(CDC *pdc);
  152. bool IsDataOut(double x,double y);
  153. void Draw_CrossLine(CDC*pDC);
  154. void SetTitlePosition();
  155. void Draw_Axis(CDC*pDC);
  156. void Draw_Title(CDC *pdc);
  157. void Draw_MousePoint(CDC *pdc);
  158. int GetNearPoint();
  159. void SetDataRect();
  160. void SetNearMousePoint();
  161. int m_max_CapturePictre,m_captureNum;
  162. double m_yFactor;
  163. double m_xFactor;
  164. int m_GridControl;
  165. BOOL m_bIsGridOn;
  166. pdc m_pdc_framRect,m_pdc_childRect,m_pdc_data,m_pdc_axis
  167. ,m_axis_xyLebal,m_pdc_grid;
  168. CRect m_dataRect;
  169. CRect m_frameRect;
  170. CPoint m_pTextPosition,m_start_POINT,m_end_point;
  171. CPoint m_pOrth;
  172. CPoint m_pMousePoint;
  173. int x,m_numOfBMP,m_numofData;
  174. double w,h;
  175. double m_x_start,m_x_end,m_y_start,m_y_end;
  176. int m_High,m_Low,m_dNum,m_Top,m_Bottom,m_dnum_top_bottom,m_lineWide;
  177. float m_Data_x[2000];
  178. float m_Data_y[2000];
  179. int m_dNumOfData;
  180. bool m_IsCrossMove,m_IsMove;
  181. CPoint m_move_formerpoint,m_enlarge_point;
  182. CPoint m_Select_Enlarge_p1,m_Select_Enlarge_p2,m_pNote_point,m_timeShow_point;
  183. COLORREF text_color,m_cross_color,title_color,m_selectRect_color,m_datacolor,m_SelectRect_Color,m_color_note,m_time_color;
  184. CString m_sAxis_xstr,m_sAxis_ystr,m_sTitle_str,m_sNote_text;
  185. bool m_IsCaptureSaveBMP,m_IsEnlarge,m_IsSelect_enlarge,m_IsEnlargeClose,m_IsNoteOn,m_IsTimeShow;
  186. int m_lineStyle;
  187. ////////////////////
  188. int m_numOf_Text;
  189. CPoint m_text_point[20];
  190. CString m_Text[20];
  191. };
  192. /////////////////////////////////////////////////////////////////////////////
  193. //{{AFX_INSERT_LOCATION}}
  194. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  195. #endif // !defined(AFX_DATASHOW_H__50A0E545_1AFF_4752_9317_5ACBACA5073D__INCLUDED_)