Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cGraphCfg.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_GraphCfg_H_
6 #define _INC_GraphCfg_H_
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "GrayGraph.h"
15 
16 #ifndef _MFC_VER
22 #endif
23 
24 namespace GrayGraph
25 {
27  {
30  // data stream info.
31  public:
33 
34  INT_PTR m_objId;
35  static const INT_PTR k_EMPTY_OBJECT_ID = 0;
36 
37  private:
38  void Copy(const CGraphDataSource* pSrc);
39  public:
40  virtual void Serialize(CArchive& ar) override;
42  {
43  Copy(&src);
44  return *this;
45  }
47  CGraphDataSource(CGraphDataSource& src) // copy constructor
48  {
49  Copy(&src);
50  }
52 
53  // Implementation
54  protected:
56  };
57 
58  // Time stamp variable.
59  typedef FILETIME_t GraphTime_t; // FILETIME in 64 bits QWORD
60  typedef cTimeFile CGraphTime; //
62 
63 #define CVT_TIME_TO_BASE(t) (t).get_Val() // convert to FILETIME_t units so it can be stored in
64 #define CVT_SPAN_TO_BASE(t) 0 // (t).GetTotalSeconds() // convert to FILETIME_t units
65 
66  typedef double GraphVal_t;
68 
70  {
72 
73  public:
75 
76  private:
77  cWndFont m_Font;
78  COLORREF m_color;
79  // COLORREF m_colorback;
80  private:
81  void Copy(const CGraphFont* psrc)
82  {
83  SetFontChanged();
84  m_FontCfg = psrc->m_FontCfg;
85  m_color = psrc->m_color;
86  }
87 
88  protected:
90 
91  public:
92  CGraphFont();
93  CGraphFont(CGraphFont& src) // copy constructor
94  {
95  Copy(&src);
96  }
97 
98  int GetWidth() const
99  {
100  return m_FontCfg.get_FontWidthA() ;
101  }
102  int GetHeight() const
103  {
104  return(m_FontCfg.get_FontSizeA());
105  }
107  {
109  m_Font.DeleteObject();
110  }
111  CFont* GetFont()
112  {
113  if (m_Font.m_hObject == WINHANDLE_NULL)
114  {
115  // We need to create it.
116  if (!m_Font.CreateFontIndirectX(&m_FontCfg))
117  return nullptr;
118  }
119  return &m_Font;
120  }
122  {
123  Copy(&src);
124  return *this;
125  }
126 
127  const cWinFontCfg& get_FontCfg() const
128  {
129  return m_FontCfg ;
130  }
131  void put_FontCfg(const cWinFontCfg& fontcfg)
132  {
133  if (m_FontCfg.IsSameFont(fontcfg))
134  return;
135  SetFontChanged();
136  m_FontCfg = fontcfg;
137  }
138 
140  {
141  return m_color;
142  }
144  {
145  m_color = color;
146  }
147 
148  virtual void Serialize(CArchive& ar);
149  };
150 
152  // configuration info.
153 
155  {
165  };
166 
168  {
180  };
181 
183  {
187  private:
188  static int sm_iNextUniqueID;
189  int m_iUniqueID;
190 
191  GraphPenStyle_Type m_Style;
192  GraphPenPoint_Type m_PointType;
193  COLORREF m_Color;
194 
195  public:
197 
198  // The data sources.
200  // ??? Is there an external file archive for the data stream.
203 
204  BOOL m_fMasked;
205  BOOL m_bShowExp;
206  BOOL m_bShowAvg;
207 
208  // Configure a time and unit range to display (by default)
209  // This is here because all the pens can become unsynced.
210 
213 
217 
219 
220  private:
221  void Copy(const CGraphPenCfg * pSrc);
222 
223  // Implementation
224  protected:
226  public:
228  {
229  m_iUniqueID = ++sm_iNextUniqueID;
230  }
231  int GetUniqueID() const
232  {
233  return(m_iUniqueID);
234  }
236  {
237  Copy(&src);
238  return(*this);
239  }
240  cString GetListName(ITERATE_t i) const;
241  static cString FindObjectName(const CGraphDataSource *pSrc);
242 
243  virtual void Serialize(CArchive& ar);
244 
246  {
247  ASSERT(style < GraphPenStyle_QTY);
248  m_Style = style;
249  }
251  {
252  return m_Style;
253  }
254 
256  {
257  ASSERT(PointType < GraphPenPoint_QTY);
258  m_PointType = PointType;
259  }
261  {
262  return m_PointType;
263  }
264 
266  {
267  return(m_Color);
268  }
269  void put_PenColor(COLORREF color)
270  {
271  m_Color = color;
272  }
273 
274  static void DrawDataPoint(CDC& dc, int x, int y, GraphPenStyle_Type PenStyle, GraphPenPoint_Type PointType, int iSize);
275  void DrawDataPoint(CDC& dc, int x, int y, int iSize)
276  {
277  DrawDataPoint(dc, x, y, get_PenStyle(), get_PenPointType(), iSize);
278  }
279 
280  void DrawPenLabel(CDC& dc, CRect& rect, int iPointWidth, int iPointSize, int iOffsetX, int iOffsetY);
281 
282  CGraphPenCfg();
283  CGraphPenCfg(CGraphPenCfg& src) // copy constructor
284  {
285  Copy(&src);
286  }
287  ~CGraphPenCfg();
288  };
289 
291  {
296  };
297 
299  {
304  };
305 
307  {
311 
312  private:
313  // What pens are we showing?
315 
316  public:
321 
322  // Frame Border
325 
326  // Label Area
328 
329  // Plot area
333  BOOL m_bPlotGrid;
334 
335  CBitmap m_bmpPlotBack;
336 
337  // Time Scale.
341 
342  // Pen value units area.
345 
346  // Fonts used for all sections.
351 
352  private:
353  void Copy(const CGraphCfg * psrc);
354  protected:
356  public:
357  CGraphCfg();
359  {
360  Copy(&src);
361  }
362 
363  ~CGraphCfg();
364 
366  {
367  Copy(&src);
368  return *this;
369  }
370  void CopyPenCfgs(const CGraphCfg * pSrc);
371 
373  {
374  return(m_PenCfg.GetSize());
375  }
377  {
379  return(&(const_cast <CGraphCfg*>(this)->m_PenCfg.ElementAt(i)));
380  }
382  {
383  return(&(m_PenCfg.ElementAt(i)));
384  }
386  {
387  return m_PenCfg.Add(PenCfg);
388  }
390  {
391  m_PenCfg.RemoveAt(i);
392  }
393 
394  void DrawPlotBackground(CDC& dc, CRect& rect);
395  virtual void Serialize(CArchive& ar);
396 
397  bool LoadPlotBackground(CString & sFilename, bool fTest);
398 
399  void GetViewRect(CGraphRect& rectView, int iActivePen) const;
400  void SetViewRect(CGraphRect& rectView, int iActivePen);
401 
402  bool IsPenColorUsed(COLORREF Color) const;
403  COLORREF GetUnusedPenColor() const;
404  bool IsPenPointTypeUsed(GraphPenPoint_Type ePenPoint) const;
405  GraphPenPoint_Type GetUnusedPenPointType() const;
406  };
407 };
408 
409 #endif // _INC_GraphCfg_H_
#define GRAYGRAPH_LINK
Definition: GrayGraph.h:19
#define DECLARE_SERIAL(class_name)
Definition: cArchive.h:119
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
UINT32 COLORREF
ABGR (high to low bits)
Definition: cVariantData.h:21
Definition: cGraphCfg.h:307
BOOL m_fTimeScaleSync
(NOT WORKING !)Sync all pens to the TimeScale.
Definition: cGraphCfg.h:338
void DelPenCfg(ITERATE_t i)
Definition: cGraphCfg.h:389
BOOL m_fPenUnitVertical
Definition: cGraphCfg.h:343
CGraphPenCfg * GetPenCfg(ITERATE_t i)
Definition: cGraphCfg.h:381
CGraphFont m_TimeScaleFont
Definition: cGraphCfg.h:349
CGraphFont m_PenLabelsFont
Definition: cGraphCfg.h:350
CString m_sPlotBackPic
(NOT WORKING !) Background picture.
Definition: cGraphCfg.h:332
BOOL m_fPenUnitSync
only one scale for all pens.
Definition: cGraphCfg.h:344
BOOL m_fShowLabel
label at the top ?
Definition: cGraphCfg.h:320
const CGraphPenCfg * GetPenCfg(ITERATE_t i) const
Definition: cGraphCfg.h:376
CGraphFont m_PenUnitsFont
Definition: cGraphCfg.h:348
BOOL m_fTimeScaleVertical
Definition: cGraphCfg.h:340
ITERATE_t GetPenCfgQty() const
Definition: cGraphCfg.h:372
int m_eShowPenLabels
list our pens GraphPlotShowPens_Bottom
Definition: cGraphCfg.h:319
CBitmap m_bmpPlotBack
(NOT WORKING !) Loaded on demand.
Definition: cGraphCfg.h:335
BOOL m_bPlotGrid
Background grid.
Definition: cGraphCfg.h:333
ITERATE_t AddPenCfg(CGraphPenCfg &PenCfg)
Definition: cGraphCfg.h:385
COLORREF m_PlotBackColor
Background color.
Definition: cGraphCfg.h:331
COLORREF m_BorderBackColor
Background color.
Definition: cGraphCfg.h:324
GraphPlotBackFormat_Type m_ePlotBackFormat
tiled, centered etc.
Definition: cGraphCfg.h:330
CGraphFont m_LabelFont
Definition: cGraphCfg.h:347
BOOL m_fShowPenUnits
range of the pens value.
Definition: cGraphCfg.h:317
const CGraphCfg & operator=(const CGraphCfg &src)
Definition: cGraphCfg.h:365
BOOL m_fShowTimeScale
time scale.
Definition: cGraphCfg.h:318
int m_iMarginSize
in dialog units.
Definition: cGraphCfg.h:323
CString m_sLabelText
A general label for the whole graph.
Definition: cGraphCfg.h:327
CGraphCfg(const CGraphCfg &src)
Definition: cGraphCfg.h:358
TIMESECD_t m_iTimeScaleGap
(NOT WORKING !) How big may the gap be before we remove it. (seconds)
Definition: cGraphCfg.h:339
Definition: cGraphCfg.h:27
INT_PTR m_objId
User defined value. When we resolve this m_sURL to real data.
Definition: cGraphCfg.h:34
const CGraphDataSource & operator=(const CGraphDataSource &src)
Definition: cGraphCfg.h:41
CString m_sURL
Full URL path for the data object. ("protocol://hostname.com/dataname")
Definition: cGraphCfg.h:32
CGraphDataSource(CGraphDataSource &src)
Definition: cGraphCfg.h:47
Definition: cGraphCfg.h:70
void SetFontChanged()
Definition: cGraphCfg.h:106
const cWinFontCfg & get_FontCfg() const
Definition: cGraphCfg.h:127
COLORREF get_FontColor() const
Definition: cGraphCfg.h:139
int GetHeight() const
Definition: cGraphCfg.h:102
void put_FontColor(COLORREF color)
Definition: cGraphCfg.h:143
cWinFontCfg m_FontCfg
wrapper for _GTN(LOGFONT) used to create m_Font
Definition: cGraphCfg.h:74
CGraphFont(CGraphFont &src)
Definition: cGraphCfg.h:93
CFont * GetFont()
Definition: cGraphCfg.h:111
void put_FontCfg(const cWinFontCfg &fontcfg)
Definition: cGraphCfg.h:131
const CGraphFont & operator=(const CGraphFont &src)
Definition: cGraphCfg.h:121
int GetWidth() const
Definition: cGraphCfg.h:98
Definition: cGraphCfg.h:183
GraphVal_t m_valMinDisp
Definition: cGraphCfg.h:214
void put_PenStyle(GraphPenStyle_Type style)
Definition: cGraphCfg.h:245
BOOL m_bShowExp
show the value with an exponent
Definition: cGraphCfg.h:205
CGraphTime m_TimeStop
Definition: cGraphCfg.h:212
CString m_sUnits
Units we should display if this is the primary pen.
Definition: cGraphCfg.h:202
GraphVal_t m_valMidDisp
a median line ?
Definition: cGraphCfg.h:216
BOOL m_bShowAvg
show the calculated avg line.
Definition: cGraphCfg.h:206
GraphPenStyle_Type get_PenStyle() const
Definition: cGraphCfg.h:250
void SetNewUniqueID()
Definition: cGraphCfg.h:227
GraphPenPoint_Type get_PenPointType() const
Definition: cGraphCfg.h:260
int GetUniqueID() const
Definition: cGraphCfg.h:231
const CGraphPenCfg & operator=(const CGraphPenCfg &src)
Definition: cGraphCfg.h:235
void DrawDataPoint(CDC &dc, int x, int y, int iSize)
Definition: cGraphCfg.h:275
void put_PenColor(COLORREF color)
Definition: cGraphCfg.h:269
CGraphPenCfg(CGraphPenCfg &src)
Definition: cGraphCfg.h:283
int m_iTmpDrawWidth
NOT STORED - last draw width.
Definition: cGraphCfg.h:218
COLORREF get_PenColor() const
Definition: cGraphCfg.h:265
CGraphDataSource m_Src
Definition: cGraphCfg.h:199
BOOL m_bShowUnits
Definition: cGraphCfg.h:201
BOOL m_fMasked
don't display the data at all.
Definition: cGraphCfg.h:204
CString m_sLabel
free descriptive name for the pen.
Definition: cGraphCfg.h:196
CGraphTime m_TimeStart
Definition: cGraphCfg.h:211
void put_PenPointType(GraphPenPoint_Type PointType)
Definition: cGraphCfg.h:255
GraphVal_t m_valMaxDisp
Definition: cGraphCfg.h:215
Definition: cRectI.h:22
Definition: cRectT.h:23
Definition: WinTypes.h:168
bool IsSameFont(const SUPER_t &rFont) const noexcept
Definition: WinTypes.h:201
int get_FontWidthA() const noexcept
Definition: WinTypes.h:220
int get_FontSizeA() const noexcept
Definition: WinTypes.h:210
Definition: cArray.h:99
TYPE & ElementAt(ITERATE_t nIndex)
Definition: cArray.h:167
ITERATE_t Add(ARG_TYPE newElement)
Definition: cArray.h:199
ITERATE_t GetSize() const noexcept
Definition: cArray.h:137
void RemoveAt(ITERATE_t nIndex)
Definition: cArray.h:367
Definition: cObject.h:67
Definition: cArchive.h:20
Definition: cTimeFile.h:31
Definition: cTimeFile.h:167
Definition: GrayGraph.cpp:29
GraphPenPoint_Type
Definition: cGraphCfg.h:168
@ GraphPenPoint_Square
Definition: cGraphCfg.h:173
@ GraphPenPoint_Triangle
Definition: cGraphCfg.h:174
@ GraphPenPoint_Plus
Definition: cGraphCfg.h:176
@ GraphPenPoint_X
Definition: cGraphCfg.h:175
@ GraphPenPoint_None
Definition: cGraphCfg.h:171
@ GraphPenPoint_Diamond
Definition: cGraphCfg.h:177
@ GraphPenPoint_Dot
Definition: cGraphCfg.h:172
@ GraphPenPoint_QTY
Definition: cGraphCfg.h:179
@ GraphPenPoint_InvertTri
Definition: cGraphCfg.h:178
double GraphVal_t
this is the value type we are plotting. Must also be able to hold GraphTime_t.
Definition: cGraphCfg.h:66
GraphPlotShowPens_Type
Definition: cGraphCfg.h:299
@ GraphPlotShowPens_Bottom
Definition: cGraphCfg.h:302
@ GraphPlotShowPens_Right
Definition: cGraphCfg.h:303
@ GraphPlotShowPens_None
Definition: cGraphCfg.h:301
cRectT< GraphVal_t > CGraphRect
x/y rect or time/value rect.
Definition: cGraphCfg.h:67
cTimeSpanFile CGraphTimeSpan
Definition: cGraphCfg.h:61
cTimeFile CGraphTime
Definition: cGraphCfg.h:60
GraphPenStyle_Type
Definition: cGraphCfg.h:155
@ GraphPenStyle_VLine
Definition: cGraphCfg.h:161
@ GraphPenStyle_Points
Definition: cGraphCfg.h:163
@ GraphPenStyle_Bar
Definition: cGraphCfg.h:160
@ GraphPenStyle_QTY
Definition: cGraphCfg.h:164
@ GraphPenStyle_HLine
Definition: cGraphCfg.h:162
@ GraphPenStyle_LineFill
Definition: cGraphCfg.h:159
@ GraphPenStyle_Line
Definition: cGraphCfg.h:158
FILETIME_t GraphTime_t
Definition: cGraphCfg.h:59
GraphPlotBackFormat_Type
Definition: cGraphCfg.h:291
@ GraphPlotBackFormat_TopLeft
Definition: cGraphCfg.h:293
@ GraphPlotBackFormat_Tile
Definition: cGraphCfg.h:295
@ GraphPlotBackFormat_Center
Definition: cGraphCfg.h:294
interface const RECTQ_t & rect
Definition: cQuadtree.h:44
int ITERATE_t
like size_t but signed
Definition: Index.h:28
int TIMESECD_t
signed delta seconds. like TIMESEC_t. redefined in TimeUnits.h.
Definition: cTimeSys.h:19
UINT64 FILETIME_t
replace FILETIME for 64 bit math. Absolute 64-bit 100-nanosecond since January 1, 1601 GMT
Definition: cTimeFile.h:28
Definition: cDebugAssert.h:29