OpendTect-6_4  6.4
scaler.h
Go to the documentation of this file.
1 #ifndef scaler_h
2 #define scaler_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H.Bril
9  Date: 8-9-1995
10  Contents: Scaler objects
11  RCS: $Id$
12 ________________________________________________________________________
13 
14 -*/
15 
16 #include "algomod.h"
17 #include "gendefs.h"
18 #include "undefval.h"
19 
20 #define sLinScaler "Linear"
21 #define sLogScaler "Logarithmic"
22 #define sExpScaler "Exponential"
23 #define sAsymptScaler "Asymptotic"
24 
25 
34 {
35 public:
36  static Scaler* get(const char*);
37  virtual ~Scaler() {}
38  void put(char*) const;
39 
40  virtual bool isEmpty() const { return false; }
41  virtual Scaler* clone() const = 0;
42  virtual const char* type() const = 0;
43 
44  virtual double scale(double) const = 0;
45  virtual double unScale(double) const { return mUdf(double); }
46  virtual const char* toString() const = 0;
47  virtual void fromString(const char*) = 0;
48 };
49 
50 
55 mExpClass(Algo) LinScaler : public Scaler
56 {
57 public:
58  LinScaler( double c=0, double f=1 )
59  : constant(c), factor(f) {}
60  LinScaler( double x0, double y0, double x1, double y1 );
61  void set( double x0, double y0, double x1, double y1 );
62  virtual LinScaler* clone() const
63  { return new LinScaler(constant,factor); }
64  inline bool isEmpty() const;
65 
66  const char* type() const { return sLinScaler; }
67 
68  double scale(double) const;
69  double unScale(double) const;
70  const char* toString() const;
71  void fromString(const char*);
72 
73  bool operator==( const LinScaler& b ) const
74  {
75  return mIsEqual(constant,b.constant,mDefEps) &&
76  mIsEqual(factor,b.factor,mDefEps);
77  }
78 
79  double constant;
80  double factor;
81 };
82 
83 inline bool LinScaler::isEmpty() const
84 {
85  return constant > -1e-15 && constant < 1e-15 && mIsEqual(factor,1,mDefEps);
86 }
87 
88 
93 mExpClass(Algo) LogScaler : public Scaler
94 {
95 public:
96  LogScaler( bool powerof10=true )
97  : ten_(powerof10) {}
98  const char* type() const { return sLogScaler; }
99  virtual LogScaler* clone() const
100  { return new LogScaler(ten_); }
101 
102  double scale(double) const;
103  double unScale(double) const;
104  const char* toString() const;
105  void fromString(const char*);
106  bool operator==( const LogScaler& b ) const
107  { return ten_==b.ten_; }
108 
109  bool ten_;
110 };
111 
112 
117 mExpClass(Algo) ExpScaler : public Scaler
118 {
119 public:
120  ExpScaler( bool powerof10=true )
121  : ten_(powerof10) {}
122  const char* type() const { return sExpScaler; }
123  virtual ExpScaler* clone() const
124  { return new ExpScaler(ten_); }
125 
126  double scale(double) const;
127  double unScale(double) const;
128  const char* toString() const;
129  void fromString(const char*);
130 
131  bool operator==( const ExpScaler& b ) const
132  { return ten_==b.ten_; }
133 
134  bool ten_;
135 };
136 
137 
151 {
152 public:
153  AsymptScaler( double c=0, double w=1, double l=0.95 )
154  : center_(c), width_(w), linedge_(l), factor(1)
155  { set(c,w,l); }
156  const char* type() const { return sAsymptScaler; }
157  virtual AsymptScaler* clone() const
158  { return new AsymptScaler(center_,width_,linedge_); }
159 
160  double scale(double) const;
161  double unScale(double) const;
162  const char* toString() const;
163  void fromString(const char*);
164 
165  inline bool operator==( const AsymptScaler& b ) const
166  { return mIsEqual(center_,b.center_,mDefEps)
167  && mIsEqual(width_,b.width_,mDefEps)
168  && mIsEqual(linedge_,b.linedge_,mDefEps); }
169 
170  void set(double,double,double);
171  inline double center() const { return center_; }
172  inline double width() const { return width_; }
173  inline double linedge() const { return linedge_; }
174 
175 protected:
176 
177  double center_;
178  double width_;
179  double linedge_;
180 
181  double factor;
182 };
183 
184 
185 #endif
#define mExpClass(module)
Definition: commondefs.h:160
double center() const
Definition: scaler.h:171
double unScale(double) const
virtual LinScaler * clone() const
Definition: scaler.h:62
double linedge_
Definition: scaler.h:179
ExpScaler(bool powerof10=true)
Definition: scaler.h:120
Exponential scaling, base e or ten.
Definition: scaler.h:117
double factor
Definition: scaler.h:80
virtual LogScaler * clone() const
Definition: scaler.h:99
const char * type() const
Definition: scaler.h:98
#define sLinScaler
Definition: scaler.h:20
double constant
Definition: scaler.h:79
bool operator==(const LinScaler &b) const
Definition: scaler.h:73
AsymptScaler(double c=0, double w=1, double l=0.95)
Definition: scaler.h:153
double scale(double) const
bool operator==(const ExpScaler &b) const
Definition: scaler.h:131
double width_
Definition: scaler.h:178
#define mIsEqual(x, y, eps)
Definition: commondefs.h:54
#define sAsymptScaler
Definition: scaler.h:23
const char * toString() const
bool isEmpty() const
Definition: scaler.h:83
const char * type() const
Definition: scaler.h:66
virtual ~Scaler()
Definition: scaler.h:37
virtual AsymptScaler * clone() const
Definition: scaler.h:157
#define sExpScaler
Definition: scaler.h:22
Logarithmic scaling, base e or ten.
Definition: scaler.h:93
virtual double unScale(double) const
Definition: scaler.h:45
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
double linedge() const
Definition: scaler.h:173
const char * type() const
Definition: scaler.h:156
virtual bool isEmpty() const
Definition: scaler.h:40
const char * type() const
Definition: scaler.h:122
bool operator==(const LogScaler &b) const
Definition: scaler.h:106
Scaling of floating point numbers.
Definition: scaler.h:33
#define mDefEps
Definition: commondefs.h:58
bool operator==(const AsymptScaler &b) const
Definition: scaler.h:165
double factor
Definition: scaler.h:181
double width() const
Definition: scaler.h:172
bool ten_
Definition: scaler.h:109
#define sLogScaler
Definition: scaler.h:21
bool ten_
Definition: scaler.h:134
virtual ExpScaler * clone() const
Definition: scaler.h:123
bool isEmpty(const NLAModel *mdl)
double center_
Definition: scaler.h:177
LogScaler(bool powerof10=true)
Definition: scaler.h:96
LinScaler(double c=0, double f=1)
Definition: scaler.h:58
Export_Basic const char * toString(ViewStyle)
void fromString(const char *)
Linear scaling.
Definition: scaler.h:55
Asymptotic or &#39;Squeeze&#39; scaling, with a linear (main) part.
Definition: scaler.h:150

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019