OpendTect  6.3
scaler.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H.Bril
8  Date: 8-9-1995
9  Contents: Scaler objects
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "algomod.h"
15 #include "gendefs.h"
16 #include "undefval.h"
17 
18 #define sLinScaler "Linear"
19 #define sLogScaler "Logarithmic"
20 #define sExpScaler "Exponential"
21 #define sAsymptScaler "Asymptotic"
22 
23 
31 {
32 public:
33 
34  static Scaler* get(const char*);
35  virtual ~Scaler() {}
36  void put(char*) const;
37 
38  virtual bool isEmpty() const { return false; }
39  virtual Scaler* clone() const = 0;
40  virtual Scaler* inverse() const { return 0; }
41  virtual const char* type() const = 0;
42 
43  virtual double scale(double) const = 0;
44  virtual double unScale(double) const { return mUdf(double); }
45  virtual const char* toString() const = 0;
46  virtual void fromString(const char*) = 0;
47 
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  virtual LinScaler* inverse() const;
65  inline bool isEmpty() const;
66 
67  const char* type() const { return sLinScaler; }
68 
69  double scale(double) const;
70  double unScale(double) const;
71  const char* toString() const;
72  void fromString(const char*);
73 
74  bool operator==( const LinScaler& oth ) const
75  {
76  return constant_ == oth.constant_
77  && factor_ == oth.factor_;
78  }
79 
80  double constant_;
81  double factor_;
82 };
83 
84 inline bool LinScaler::isEmpty() const
85 {
86  return !constant_ && factor_ == 1.;
87 }
88 
89 
92 mExpClass(Algo) LogScaler : public Scaler
93 {
94 public:
95  LogScaler( bool powerof10=true )
96  : ten_(powerof10) {}
97  const char* type() const { return sLogScaler; }
98  virtual LogScaler* clone() const
99  { return new LogScaler(ten_); }
100  virtual Scaler* inverse() const;
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& oth ) const
107  { return ten_==oth.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  virtual Scaler* inverse() const;
126 
127  double scale(double) const;
128  double unScale(double) const;
129  const char* toString() const;
130  void fromString(const char*);
131 
132  bool operator==( const ExpScaler& oth ) const
133  { return ten_==oth.ten_; }
134 
135  bool ten_;
136 };
137 
138 
152 {
153 public:
154  AsymptScaler( double c=0, double w=1, double l=0.95 )
155  : center_(c), width_(w), linedge_(l), factor_(1)
156  { set(c,w,l); }
157  const char* type() const { return sAsymptScaler; }
158  virtual AsymptScaler* clone() const
159  { return new AsymptScaler(center_,width_,linedge_); }
160 
161  double scale(double) const;
162  double unScale(double) const;
163  const char* toString() const;
164  void fromString(const char*);
165 
166  inline bool operator==( const AsymptScaler& oth ) const
167  { return center_ == oth.center_
168  && width_ == oth.width_
169  && linedge_ == oth.linedge_; }
170 
171  void set(double,double,double);
172  inline double center() const { return center_; }
173  inline double width() const { return width_; }
174  inline double linedge() const { return linedge_; }
175 
176 protected:
177 
178  double center_;
179  double width_;
180  double linedge_;
181 
182  double factor_;
183 };
#define mExpClass(module)
Definition: commondefs.h:157
double center() const
Definition: scaler.h:172
double unScale(double) const
bool operator==(const LinScaler &oth) const
Definition: scaler.h:74
virtual LinScaler * clone() const
Definition: scaler.h:62
double linedge_
Definition: scaler.h:180
ExpScaler(bool powerof10=true)
Definition: scaler.h:120
Exponential scaling, base e or ten.
Definition: scaler.h:117
virtual LogScaler * clone() const
Definition: scaler.h:98
const char * type() const
Definition: scaler.h:97
#define sLinScaler
Definition: scaler.h:18
AsymptScaler(double c=0, double w=1, double l=0.95)
Definition: scaler.h:154
double scale(double) const
double width_
Definition: scaler.h:179
#define sAsymptScaler
Definition: scaler.h:21
const char * toString() const
bool isEmpty() const
Definition: scaler.h:84
const char * type() const
Definition: scaler.h:67
bool operator==(const ExpScaler &oth) const
Definition: scaler.h:132
double factor_
Definition: scaler.h:182
virtual LinScaler * inverse() const
virtual ~Scaler()
Definition: scaler.h:35
virtual AsymptScaler * clone() const
Definition: scaler.h:158
#define sExpScaler
Definition: scaler.h:20
Logarithmic scaling, base e or ten.
Definition: scaler.h:92
virtual double unScale(double) const
Definition: scaler.h:44
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
double linedge() const
Definition: scaler.h:174
bool operator==(const AsymptScaler &oth) const
Definition: scaler.h:166
const char * type() const
Definition: scaler.h:157
virtual bool isEmpty() const
Definition: scaler.h:38
const char * type() const
Definition: scaler.h:122
Scaling of floating point numbers.
Definition: scaler.h:30
double factor_
Definition: scaler.h:81
BufferString toString(const DBKey &ky)
Definition: dbkey.h:115
double width() const
Definition: scaler.h:173
bool isEmpty(const char *)
bool ten_
Definition: scaler.h:109
#define sLogScaler
Definition: scaler.h:19
LinScaler(double c=0, double f=1.)
Definition: scaler.h:58
bool ten_
Definition: scaler.h:135
virtual Scaler * inverse() const
Definition: scaler.h:40
bool operator==(const LogScaler &oth) const
Definition: scaler.h:106
virtual ExpScaler * clone() const
Definition: scaler.h:123
double center_
Definition: scaler.h:178
LogScaler(bool powerof10=true)
Definition: scaler.h:95
void fromString(const char *)
Linear scaling.
Definition: scaler.h:55
double constant_
Definition: scaler.h:80
Asymptotic or 'Squeeze' scaling, with a linear (main) part.
Definition: scaler.h:151

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