Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cGraphWnd.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_GraphWnd_H
6 #define _INC_GraphWnd_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "../CGraphCfg.h"
12 
13 #ifdef _MFC_VER
14 namespace GrayGraph
15 {
16  class CGraphPen;
17  class CGraphLabel;
18  class CGraphPlot;
19  class CGraphRulerTime; // horizontal
20  class CGraphRulerScale; // vertical
21  class CGraphIntervals;
22 
23 #pragma warning( disable : 4244 )
24 
25  class GRAYGRAPH_LINK CGraphWnd : public CWnd
26  {
30 
31  private:
32  CObArray m_aPens;
33  CGraphCfg* m_pCfg;
34 
35  ITERATE_t m_iActivePen;
36  CRect m_rectMain;
37 
38  bool m_bEditMode;
39  bool m_bActiveUpdateMode;
40  bool m_bGroupViewMode;
41 
42  CGraphIntervals* m_pCoordsX;
43  CGraphIntervals* m_pCoordsY;
44 
45 #ifdef _DEBUG
46  TIMESYS_t m_dwDebugGenTick;
47  CGraphTime m_timeDebugGen;
48 #endif
49 
50  public:
51  // What is being displayed ?
52  CGraphRect m_rectViewActual;
53  CGraphRect m_rectView;
54 
55  CButton m_wndIcon;
56  CGraphLabel* m_pwndLabel;
57  CGraphPlot* m_pwndPlot;
58  CGraphRulerTime* m_pwndTime;
59  CGraphRulerScale* m_pwndScale;
60 
61  int m_iPrvPropPage;
62  static int sm_iPrvPenPropPage;
63  // Operations
64  private:
65  void RecalcSize();
66 
67 #ifdef _DEBUG
68  void DebugGenerateTestData();
69 #endif
70 
71 
72  public:
73  CGraphWnd();
74 
75  void RecalcAll();
76 
77  void OnInitMenuBase(CMenu* pMenu);
78  BOOL OnCommandBase(WPARAM wParam, LPARAM lParam);
79  void CreatePropsSheet();
80 
81  // Display modes.
82 
83  bool isActveUpdateMode() const
84  {
85  return(m_bActiveUpdateMode);
86  }
87  void setActiveUpdateMode(bool fActive);
88  bool isEditMode() const
89  {
90  return(m_bEditMode);
91  }
92  void setEditMode(bool fEditMode);
93  bool isGroupViewMode() const
94  {
95  return m_bGroupViewMode;
96  }
97  void setGroupViewMode(bool fGroupViewMode);
98 
99  // Pens
100  void SetActivePen(ITERATE_t iPen, bool fChangeForce = false);
101  int getActivePenIndex() const
102  {
103  return m_iActivePen;
104  }
105  const CGraphPen* getActivePenPtr() const
106  {
107  return GetPen(m_iActivePen);
108  }
109  bool AddNewPenDlg();
110 
111  const CGraphPen* GetPen(ITERATE_t i) const;
112  void DeleteAllPenWnds();
113  CGraphPen* GetPen(ITERATE_t i);
114  int getPenQty() const
115  {
116  return(m_aPens.GetSize());
117  }
118  CGraphPenCfg* GetPenCfg(ITERATE_t i) const;
119 
120  // Pen Data
121  void AddPenSample(ITERATE_t iPen, GraphVal_t iVal);
122  void AddPenSample(ITERATE_t iPen, GraphVal_t iVal, CGraphTime time);
123  bool GetPensBoundRect(CGraphRect& rectBound) const;
124 
125  // The config storage.
126  void SetCfg(CGraphCfg * pCfg);
127  CGraphCfg* get_Cfg() const
128  {
129  ASSERT(m_pCfg);
130  return(m_pCfg);
131  }
132 
133  // Rulers
134  void UpdateRulerTitles(BOOL fXAxis, BOOL fRedraw);
135 
136  // Current View
137  void GetViewActualRect(CGraphRect& rectView) const
138  {
139  rectView = m_rectViewActual;
140  }
141  void GetViewRect(CGraphRect& rectView) const
142  {
143  rectView = m_rectView;
144  }
145  void SetViewRectFromPenCfg(CGraphPenCfg * pPenCfg);
146  void SetViewRectNow(const CGraphRect& rectView);
147  bool SetViewRect(const CGraphRect& rectView);
148 
149  CGraphTime get_ViewX1() const
150  {
151  return m_rectView.left;
152  };
153  CGraphTime get_ViewX2() const
154  {
155  return m_rectView.right;
156  };
157  CGraphTime get_ViewActualX1() const
158  {
159  return m_rectViewActual.left;
160  };
161  CGraphTime get_ViewActualX2() const
162  {
163  return m_rectViewActual.right;
164  };
165 
166  GraphVal_t get_ViewActualY1() const
167  {
168  return m_rectViewActual.top;
169  };
170  GraphVal_t get_ViewActualY2() const
171  {
172  return m_rectViewActual.bottom;
173  };
174 
175  void InitCoords();
176  CGraphIntervals * get_CoordsX();
177  CGraphIntervals * get_CoordsY();
178 
179  virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
180 
181  // Overrides
182  // ClassWizard generated virtual function overrides
183  //{{AFX_VIRTUAL(CGraphWnd)
184  public:
185  virtual void Serialize(CArchive& ar);
186  protected:
187  virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
188  //}}AFX_VIRTUAL
189 
190  public:
191  virtual void OnModifiedFlag(); // Config has been modified from the dialogs.
192  virtual void OnViewChange(); // The time or value range has changed.
193  virtual void OnActveUpdateModeChange();
194 
195  // Implementation
196  public:
197  virtual ~CGraphWnd();
198 
199  // Generated message map functions
200  protected:
201  //{{AFX_MSG(CGraphWnd)
202  afx_msg void OnPaint();
203  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
204  afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
205  afx_msg void OnSize(UINT nType, int cx, int cy);
206  afx_msg BOOL OnEraseBkgnd(CDC* pDC);
207  afx_msg void OnInitMenu(CMenu* pMenu);
208  afx_msg void OnTimer(UINT_PTR nIDEvent);
209  afx_msg void OnDestroy();
210  //}}AFX_MSG
211  DECLARE_MESSAGE_MAP()
212  };
213 
214 #pragma warning( default : 4244 )
215 
217 
218  //{{AFX_INSERT_LOCATION}}
219  // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
220 };
221 #endif
222 #endif // !defined(_INC_GraphWnd_H)
#define GRAYGRAPH_LINK
Definition: GrayGraph.h:19
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cArchive.h:20
Definition: GrayGraph.cpp:29
double GraphVal_t
this is the value type we are plotting. Must also be able to hold GraphTime_t.
Definition: cGraphCfg.h:66
cRectT< GraphVal_t > CGraphRect
x/y rect or time/value rect.
Definition: cGraphCfg.h:67
cTimeFile CGraphTime
Definition: cGraphCfg.h:60
cRectI CRect
Compatible with MFC 2d CRect.
Definition: cRectI.h:243
cWndHandle CWnd
Definition: cWndHandle.h:669
cPoint2i CPoint
Compatible with MFC 2d CPoint,CRect.
Definition: cPoint2.h:65
int ITERATE_t
like size_t but signed
Definition: Index.h:28
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27