ACF $AcfVersion:0$
CComplexDoubleManip.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// STL includes
6#include <limits>
7#include <cmath>
8
9// ACF includes
10#include <istd/TRange.h>
12
13
14namespace imath
15{
16
17
19{
20public:
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>::max(),
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 override;
44 virtual bool GetParsed(const QString& text, double& result) const override;
45
46protected:
47 // reimplemented (imath::TIValueManip)
48 virtual qint32 GetInternalValue(double value) const override;
49
50private:
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
79inline void CComplexDoubleManip::SetScaleFactor(double value)
80{
81 m_scaleFactor = value;
82
83 m_scaledPrecision = GetPrecision() - int(std::log10(m_scaleFactor));
84}
85
86
87inline double CComplexDoubleManip::GetOffset() const
88{
89 return m_offset;
90}
91
92
93inline void CComplexDoubleManip::SetOffset(double value)
94{
95 m_offset = value;
96}
97
98
99// overloaded (imath::CFixedPointManip)
100
101inline 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
virtual QString GetString(const double &value) const override
Get this value as string.
virtual bool GetParsed(const QString &text, double &result) const override
Get value converted from string.
virtual qint32 GetInternalValue(double value) const override
const istd::CRange & GetRange() const
void SetRange(const istd::CRange &range)
void SetScaleFactor(double value)
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()))
Implementation of double value manipulator with fixed-point arithmetic and rounding.
@ RT_NORMAL
Normal mathematical rounding to the nearest value.
virtual int GetPrecision() const override
Get number of digits after point.
void SetPrecision(int precision)
Set fixed point precision.
Package with mathematical functions and algebraical primitives.