Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cGraphCoords.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_GraphCoords_H_
7 #define _INC_GraphCoords_H_
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 #include "CGraphCfg.h"
12 
13 namespace GrayGraph
14 {
16  {
19  protected:
20  double m_capacity;
21 
22  private:
23  void CalcCapacity()
24  {
25  if (left != right)
26  m_capacity = get_DiffY() / get_DiffX();
27  else
28  m_capacity = 0;
29  }
30 
31  public:
32  CGraphCoords(double _pix1, double _pix2, double _w1, double _w2) :
33  CGraphRect(_pix1, _pix2, _w1, _w2)
34  {
35  CalcCapacity();
36  }
37  CGraphCoords(const CGraphCoords& coords)
38  {
39  left = coords.left;
40  right = coords.right;
41  top = coords.top;
42  bottom = coords.bottom;
43  m_capacity = coords.m_capacity;
44  }
45 
46  static int GetExponent(double value);
47 
48  double CvtWtoX(double value) const
49  {
50  if (m_capacity == 0) // left == right
51  return left;
52  return left + (value - top) / m_capacity;
53  }
54  double CvtXtoW(double value) const
55  {
56  if (top == bottom)
57  return top;
58  return top + (value - left)*m_capacity;
59  }
60  };
61 
63  {
66  private:
67  double m_Delta;
68  double m_ExpDelta;
69  CArray <double, double> m_WorldPts; // time or value.
70  CArray <double, double> m_ScreenPts;
71  int m_iMaxExp;
72 
73  private:
74  double CountGrid(int NMax, double mx1, double mx2);
75  bool SetupDecimal(int NMax);
76  bool SetupTime(int NMax);
77 
78  double GetScaledVal(double val) const;
79  double GetUnScaledVal(double val) const;
80 
81  public:
82  CGraphIntervals(bool fTime, int iNMax, double _pix1, double _pix2, double _w1, double _w2);
83  ~CGraphIntervals();
84 
85  const TCHAR* GetTimeFormatStr() const;
86  const TCHAR* GetTimeLabelStr() const;
87  int get_MaxExp() const
88  {
89  return m_iMaxExp;
90  }
91 
93  {
94  return(m_WorldPts.GetSize());
95  }
96  int GetScreenPt(ITERATE_t i) const
97  {
98  //ASSERT( i >= 0 && i < GetCount() );
99  return((int)(m_ScreenPts[i]));
100  }
101  double GetMid(ITERATE_t i) const
102  {
103  //ASSERT( i >= 0 && i < GetCount() );
104  return(m_WorldPts[i]);
105  }
106  double GetScaledMid(ITERATE_t i) const;
107  double GetMidLo(ITERATE_t i) const
108  {
109  return(GetMid(i) - (m_Delta / 2));
110  }
111  double GetMidHi(ITERATE_t i) const
112  {
113  return(GetMid(i) + (m_Delta / 2));
114  }
115  };
116 };
117 
118 #endif // _INC_GraphCoords_H_
#define GRAYGRAPH_LINK
Definition: GrayGraph.h:19
Definition: cGraphCoords.h:16
double CvtWtoX(double value) const
Definition: cGraphCoords.h:48
double m_capacity
Definition: cGraphCoords.h:20
CGraphCoords(double _pix1, double _pix2, double _w1, double _w2)
Definition: cGraphCoords.h:32
double CvtXtoW(double value) const
Definition: cGraphCoords.h:54
CGraphCoords(const CGraphCoords &coords)
Definition: cGraphCoords.h:37
Definition: cGraphCoords.h:63
ITERATE_t get_Count() const
Definition: cGraphCoords.h:92
double GetMidHi(ITERATE_t i) const
Definition: cGraphCoords.h:111
int get_MaxExp() const
Definition: cGraphCoords.h:87
int GetScreenPt(ITERATE_t i) const
Definition: cGraphCoords.h:96
double GetMidLo(ITERATE_t i) const
Definition: cGraphCoords.h:107
double GetMid(ITERATE_t i) const
Definition: cGraphCoords.h:101
Definition: cRectT.h:23
TYPE bottom
Definition: cRectT.h:35
TYPE right
Definition: cRectT.h:35
TYPE left
Definition: cRectT.h:35
TYPE top
Definition: cRectT.h:35
ITERATE_t GetSize() const noexcept
Definition: cArray.h:137
Definition: GrayGraph.cpp:29
int ITERATE_t
like size_t but signed
Definition: Index.h:28