ICF 3.1.1.10
Technical documentation of ICF Libraries
CComplexDoubleManip.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef imath_CComplexDoubleManip_included
7#define imath_CComplexDoubleManip_included
8
9
10// STL includes
11#include <limits>
12#include <cmath>
13
14// ICF includes
15#include <istd/TRange.h>
17
18
19namespace imath
20{
21
22
24{
25public:
27
29 int precision = 1,
30 RoundingType roundingType = RT_NORMAL,
31 double scaleFactor = 1.0,
32 double offset = 0.0,
33 const istd::CRange& range = istd::CRange(
34 -std::numeric_limits<double>::max(),
35 std::numeric_limits<double>::max()));
36
37 const istd::CRange& GetRange() const;
38 void SetRange(const istd::CRange& range);
39 double GetScaleFactor() const;
40 void SetScaleFactor(double value);
41 double GetOffset() const;
42 void SetOffset(double value);
43
44 // overloaded (imath::CFixedPointManip)
45 void SetPrecision(int precision);
46
47 // reimplemented (imath::TIValueManip)
48 virtual QString GetString(const double& value) const;
49 virtual bool GetParsed(const QString& text, double& result) const;
50
51protected:
52 // reimplemented (imath::TIValueManip)
53 virtual qint32 GetInternalValue(double value) const;
54
55private:
56 double m_scaleFactor;
57 double m_offset;
58 istd::CRange m_range;
59
60 int m_scaledPrecision;
61};
62
63
64// inline methods
65
67{
68 return m_range;
69}
70
71
73{
74 m_range = range;
75}
76
77
79{
80 return m_scaleFactor;
81}
82
83
84inline void CComplexDoubleManip::SetScaleFactor(double value)
85{
86 m_scaleFactor = value;
87
88 m_scaledPrecision = GetPrecision() - int(std::log10(m_scaleFactor));
89}
90
91
92inline double CComplexDoubleManip::GetOffset() const
93{
94 return m_offset;
95}
96
97
98inline void CComplexDoubleManip::SetOffset(double value)
99{
100 m_offset = value;
101}
102
103
104// overloaded (imath::CFixedPointManip)
105
106inline void CComplexDoubleManip::SetPrecision(int precision)
107{
108 BaseClass::SetPrecision(precision);
109
110 m_scaledPrecision = GetPrecision() - int(std::log10(m_scaleFactor));
111}
112
113
114} // namespace imath
115
116
117#endif // !imath_CComplexDoubleManip_included
118
119
virtual qint32 GetInternalValue(double value) const
const istd::CRange & GetRange() const
void SetRange(const istd::CRange &range)
void SetScaleFactor(double value)
virtual QString GetString(const double &value) const
Get this value as string.
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 >::max(), std::numeric_limits< double >::max()))
virtual bool GetParsed(const QString &text, double &result) const
Get value converted from string.
Implementation of imath::IDoubleManip interface for fixed point arithmentic.
@ RT_NORMAL
Normal mathematical rounding to the nearest value.
void SetPrecision(int precision)
Set fixed point precision.
virtual int GetPrecision() const
Get number of digits after point.
Package with mathematical functions and algebraical primitives.

© Witold Gantzke and Kirill Lepskiy