CComplexDoubleManip.h
Go to the documentation of this file.
1 #ifndef imath_CComplexDoubleManip_included
2 #define imath_CComplexDoubleManip_included
3 
4 
5 // STL includes
6 #include <limits>
7 #include <cmath>
8 
9 // ACF includes
10 #include <istd/TRange.h>
11 #include <imath/CFixedPointManip.h>
12 
13 
14 namespace imath
15 {
16 
17 
19 {
20 public:
22 
24  int precision = 1,
25  RoundingType roundingType = RT_NORMAL,
26  double scaleFactor = 1.0,
27  double offset = 0.0,
28  const istd::CRange& range = istd::CRange(
29  std::numeric_limits<double>::min(),
30  std::numeric_limits<double>::max()));
31 
32  const istd::CRange& GetRange() const;
33  void SetRange(const istd::CRange& range);
34  double GetScaleFactor() const;
35  void SetScaleFactor(double value);
36  double GetOffset() const;
37  void SetOffset(double value);
38 
39  // overloaded (imath::CFixedPointManip)
40  void SetPrecision(int precision);
41 
42  // reimplemented (imath::TIValueManip)
43  virtual QString GetString(const double& value) const;
44  virtual bool GetParsed(const QString& text, double& result) const;
45 
46 protected:
47  // reimplemented (imath::TIValueManip)
48  virtual qint32 GetInternalValue(double value) const;
49 
50 private:
51  double m_scaleFactor;
52  double m_offset;
53  istd::CRange m_range;
54 
55  int m_scaledPrecision;
56 };
57 
58 
59 // inline methods
60 
62 {
63  return m_range;
64 }
65 
66 
68 {
69  m_range = range;
70 }
71 
72 
74 {
75  return m_scaleFactor;
76 }
77 
78 
79 inline void CComplexDoubleManip::SetScaleFactor(double value)
80 {
81  m_scaleFactor = value;
82 
83  m_scaledPrecision = GetPrecision() - int(std::log10(m_scaleFactor));
84 }
85 
86 
87 inline double CComplexDoubleManip::GetOffset() const
88 {
89  return m_offset;
90 }
91 
92 
93 inline void CComplexDoubleManip::SetOffset(double value)
94 {
95  m_offset = value;
96 }
97 
98 
99 // overloaded (imath::CFixedPointManip)
100 
101 inline void CComplexDoubleManip::SetPrecision(int precision)
102 {
103  BaseClass::SetPrecision(precision);
104 
105  m_scaledPrecision = GetPrecision() - int(std::log10(m_scaleFactor));
106 }
107 
108 
109 } // namespace imath
110 
111 
112 #endif // !imath_CComplexDoubleManip_included
113 
114 
const istd::CRange & GetRange() const
virtual QString GetString(const double &value) const
Get this value as string.
Normal mathematical rounding to the nearest value.
void SetPrecision(int precision)
Set fixed point precision.
virtual bool GetParsed(const QString &text, double &result) const
Get value converted from string.
Implementation of imath::IDoubleManip interface for fixed point arithmentic.
virtual int GetPrecision() const
Get number of digits after point.
virtual qint32 GetInternalValue(double value) const
void SetScaleFactor(double value)
void SetPrecision(int precision)
CComplexDoubleManip(int precision=1, RoundingType roundingType=RT_NORMAL, double scaleFactor=1.0, double offset=0.0, const istd::CRange &range=istd::CRange(std::numeric_limits< double >::min(), std::numeric_limits< double >::max()))
void SetRange(const istd::CRange &range)

© 2007-2017 Witold Gantzke and Kirill Lepskiy