OpendTect  6.3
attribparam.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: Kristofer Tingdahl
8  Date: 07-10-1999
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "attributeenginemod.h"
14 #include "attribparambase.h"
15 #include "datainpspec.h"
16 
17 
18 namespace Attrib
19 {
20 
35 mExpClass(AttributeEngine) BinIDParam : public ValParam
37 public:
38  BinIDParam(const char*);
39  BinIDParam(const char*,const BinID&,
40  bool isreq=true);
41  BinIDParam* clone() const;
42  void setLimits(const Interval<int>& inlrg,
43  const Interval<int>& crlrg);
44  void setLimits(int mininl,int maxinl,
45  int mincrl,int maxcrl);
46 
47  virtual bool setCompositeValue(const char*);
48  virtual bool getCompositeValue(BufferString&) const;
49 
50  void setDefaultValue(const BinID&);
51  BinID getDefaultBinIDValue() const;
52  BufferString getDefaultValue() const;
53  BinID getValue() const;
54 
55  void toString(BufferString&,const BinID&) const;
56 };
57 
58 
63 mExpClass(AttributeEngine) BoolParam : public ValParam
65 public:
66  BoolParam(const char*);
67  BoolParam(const char*,bool, bool isreq=true);
68  BoolParam* clone() const;
69 
70  virtual bool setCompositeValue(const char*);
71  BufferString getDefaultValue() const;
72 
73  bool isSet() const;
74  void setSet(bool yn=true);
75 };
76 
77 
82 mExpClass(AttributeEngine) EnumParam : public ValParam
84 public:
85  EnumParam(const char*);
86  EnumParam(const char*,int defval,
87  bool isreq=true);
88  EnumParam* clone() const;
89  BufferString getDefaultValue() const;
90 
91  void addEnum(const char*);
92  void addEnums(const char**);
93  void setEnums(const EnumDef&);
95 
96  void fillDefStr(BufferString&) const;
97  bool isSet() const;
98  void setSet(bool yn=true);
99 };
100 
101 
106 mExpClass(AttributeEngine) StringParam : public ValParam
108 public:
109  StringParam(const char* key);
110  StringParam(const char* key,const char* defstr,
111  bool isreq=true);
112  StringParam* clone() const;
113 
114  virtual bool setCompositeValue(const char*);
115  virtual bool getCompositeValue(BufferString&) const;
117  { return getDefaultStringValue(); }
118 };
119 
120 
126 template <class T>
127 mClass(AttributeEngine) NumParam : public ValParam
129 public:
130  NumParam(const char* key)
131  : ValParam(key,new NumInpSpec<T>()) {}
132  NumParam(const char* key,T defval,
133  bool isreq=true);
134  NumParam(const NumParam<T>&);
135 
136  virtual NumParam<T>* clone() const
137  { return new NumParam<T>(*this); }
138 
139  void setLimits(const Interval<T>&);
140  void setLimits(const StepInterval<T>&);
141  void setLimits(T start,T stop,T step=1);
142  const StepInterval<T>* limits() const;
143  virtual bool getCompositeValue(BufferString& res) const;
144  virtual bool setCompositeValue(const char*);
145 
146  virtual int getIntValue(int idx=0) const;
147  virtual float getFValue(int idx=0) const;
148  virtual double getDValue(int idx=0) const;
149  virtual BufferString getDefaultValue() const;
150 };
151 
152 
153 template <class T>
155  : ValParam(np.key_,np.spec_->clone())
156 {
157  enabled_ = np.enabled_;
158  required_ = np.required_;
159 }
160 
161 
162 template <class T>
163 NumParam<T>::NumParam( const char* key, T defval, bool isreq )
164  : ValParam( key, new NumInpSpec<T>() )
165 {
166  setValue( defval );
167  setDefaultValue( defval );
168  required_ = isreq;
169 }
170 
171 
172 template <class T>
174 {
175  res = spec_ && !spec_->isUndef() ? spec_->text() : "1e30";
176  return spec_;
177 }
178 
179 
180 template <class T>
181 float NumParam<T>::getFValue( int idx ) const
182 {
183  if ( !spec_ ) return mUdf(float);
184  float res = spec_->isUndef() ? mUdf(float) : ValParam::getFValue( idx );
185  return res;
186 }
187 
188 template <class T>
189 int NumParam<T>::getIntValue( int idx ) const
190 {
191  if ( !spec_ ) return mUdf(int);
192  int res = spec_->isUndef() ? mUdf(int) : ValParam::getIntValue( idx );
193  return res;
194 }
195 
196 
197 template <class T>
198 double NumParam<T>::getDValue( int idx ) const
199 {
200  if ( !spec_ ) return mUdf(double);
201  double res = spec_->isUndef() ? mUdf(double) : ValParam::getDValue( idx );
202  return res;
203 }
204 
205 template <class T>
206 bool NumParam<T>::setCompositeValue( const char* nv )
207 {
208  spec_->setText(nv,0);
209  return true;
210 }
211 
212 
213 template <class T>
215 { setLimits( StepInterval<T>(limit.start,limit.stop,(T)1) ); }
216 
217 template <class T>
219 { reinterpret_cast<NumInpSpec<T>*>(spec_)->setLimits( limit ); }
220 
221 template <class T>
222 void NumParam<T>::setLimits( T start, T stop, T step )
223 { setLimits( StepInterval<T>( start, stop, step ) ); }
224 
225 template <class T>
227 { return reinterpret_cast<NumInpSpec<T>*>(spec_)->limits(); }
228 
229 
230 template <class T>
232 {
233  BufferString res =
234  toString(reinterpret_cast<NumInpSpec<T>*>(spec_)->defaultValue() );
235  return res;
236 }
237 
238 
242 
243 
249 template <class T>
250 mClass(AttributeEngine) NumGateParam : public ValParam
252 public:
253  NumGateParam(const char* key)
254  : ValParam(key,new NumInpIntervalSpec<T>())
255  {}
256 
257  NumGateParam(const char* key,
258  const Interval<T>& defaultgate,
259  bool isreq=true);
260 
262 
263  virtual NumGateParam<T>* clone() const
264  { return new NumGateParam<T>(*this); }
265 
266  void setLimits(const Interval<T>&);
267  void setLimits(T start,T stop);
268  virtual bool getCompositeValue(BufferString& res) const;
269  virtual bool setCompositeValue(const char*);
270 
271  void setValue(const Interval<T>&);
272  Interval<T> getValue() const;
273  void setDefaultValue(const Interval<T>&);
274  virtual BufferString getDefaultValue() const;
275  Interval<T> getDefaultGateValue() const;
276 
277  void toString(BufferString&,
278  const Interval<T>&) const;
279 };
280 
281 
282 template <class T>
284  : ValParam(np.key_,np.spec_->clone())
285 {
286  enabled_ = np.enabled_;
287  required_ = np.required_;
288 }
289 
290 
291 template <class T>
292 NumGateParam<T>::NumGateParam( const char* key, const Interval<T>& defaultgate,
293  bool isreq )
294  : ValParam(key,new NumInpIntervalSpec<T>())
295 {
296  setValue( defaultgate );
297  setDefaultValue( defaultgate );
298  setRequired( isreq );
299 }
300 
301 
302 template <class T>
304 {
305  NumInpIntervalSpec<T>* sp = reinterpret_cast<NumInpIntervalSpec<T>*>(spec_);
306  if ( !sp ) return false;
307 
308  Interval<T> intv( sp->value(0), sp->value(1) );
309  toString( res, intv );
310  return true;
311 }
312 
313 
314 template <class T>
316 {
317  NumInpIntervalSpec<T>* spec =
318  reinterpret_cast<NumInpIntervalSpec<T>*>(spec_);
319  if ( !spec ) return Interval<T>(mUdf(T),mUdf(T));
320  return Interval<T>( spec->value(0), spec->value(1) );
321 }
322 
323 
324 template <class T>
325 bool NumGateParam<T>::setCompositeValue( const char* gatestr )
326 {
327  if ( !gatestr || !*gatestr )
328  return false;
329 
330  BufferString rgstr( gatestr );
331  rgstr.unEmbed( '[', ']' );
332  if ( rgstr.isEmpty() )
333  return false;
334  char* ptrval2 = rgstr.find( ',' );
335  if ( !ptrval2 )
336  return false;
337 
338  *ptrval2++ = '\0';
339  spec_->setText( rgstr.buf(), 0 );
340  spec_->setText( ptrval2, 1 );
341  return true;
342 }
343 
344 
345 template <class T>
347 { reinterpret_cast<NumInpIntervalSpec<T>*>(spec_)->setLimits( limit ); }
348 
349 
350 template <class T>
351 void NumGateParam<T>::setLimits( T start, T stop )
352 { reinterpret_cast<NumInpIntervalSpec<T>*>(spec_)->setLimits(
353  Interval<T>(start,stop) ); }
354 
355 
356 template <class T>
358 { reinterpret_cast<NumInpIntervalSpec<T>*>(spec_)->setValue( gate ); }
359 
360 
361 template <class T>
363 { reinterpret_cast<NumInpIntervalSpec<T>*>(spec_)->setDefaultValue( defgate ); }
364 
365 
366 template <class T>
368 {
369  NumInpIntervalSpec<T>* spec =
370  reinterpret_cast<NumInpIntervalSpec<T>*>(spec_);
371  return Interval<T>( spec->defaultValue(0), spec->defaultValue(1) );
372 }
373 
374 
375 template <class T>
377 {
379  BufferString res;
380  toString( res, intv );
381  return res;
382 }
383 
384 
385 template <class T>
387 {
388  res.set( "[" ).add( gate.start ).add( "," ).add( gate.stop ).add( "]" );
389 }
390 
391 
395 
396 #define mLargestZGate 10000
398 
399 
404 mExpClass(AttributeEngine) SeisStorageRefParam : public StringParam
406 public:
407  SeisStorageRefParam(const char* key);
408  SeisStorageRefParam* clone() const;
409  bool isOK() const;
410 };
411 
412 
413 }; // namespace Attrib
Attribute Value Parameter.
Definition: attribparambase.h:92
virtual int getIntValue(int idx=0) const
Definition: attribparam.h:189
#define mExpClass(module)
Definition: commondefs.h:157
DataInpSpec * spec_
Definition: attribparambase.h:137
virtual BufferString getDefaultValue() const
Definition: attribparam.h:231
Interval< T > getValue() const
Definition: attribparam.h:315
void setDefaultValue(int, int idx=0)
virtual bool setCompositeValue(const char *)
Definition: attribparam.h:325
virtual BufferString getDefaultValue() const
Definition: attribparam.h:376
Enum parameter that is used by an attribute.
Definition: attribparam.h:82
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
virtual double getDValue(int idx=0) const
const StepInterval< T > * limits() const
Definition: attribparam.h:226
mODTextTranslationClass(NumGateParam)
Stored seismic input parameter used by an attribute.
Definition: attribparam.h:404
virtual bool getCompositeValue(BufferString &res) const
Definition: attribparam.h:303
NumGateParam< float > ZGateParam
Definition: attribparam.h:397
virtual BufferString getDefaultValue() const
Definition: attribparam.h:116
void setValue(const Interval< T > &)
Definition: attribparam.h:357
bool enabled_
Definition: attribparambase.h:77
virtual NumGateParam< T > * clone() const
Definition: attribparam.h:263
virtual int getIntValue(int idx=0) const
virtual bool getCompositeValue(BufferString &res) const
Definition: attribparam.h:173
NumGateParam< int > IntGateParam
Definition: attribparam.h:392
virtual float getFValue(int idx=0) const
NumGateParam< float > FloatGateParam
Definition: attribparam.h:393
Bool parameter that is used by an attribute.
Definition: attribparam.h:63
T value(int idx=0) const
Definition: datainpspec.h:414
virtual double getDValue(int idx=0) const
Definition: attribparam.h:198
BufferString & unEmbed(char open, char close)
BufferString key_
Definition: attribparambase.h:74
virtual const char * text(int idx=0) const =0
void setValue(int, int idx=0)
bool required_
Definition: attribparambase.h:78
void setLimits(const Interval< T > &)
Definition: attribparam.h:214
void setLimits(const Interval< T > &)
Definition: attribparam.h:346
NumGateParam(const char *key)
Definition: attribparam.h:253
virtual bool isOK() const
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
void setRequired(bool yn=true)
Definition: attribparambase.h:53
void toString(BufferString &, const Interval< T > &) const
Definition: attribparam.h:386
NumGateParam< double > DoubleGateParam
Definition: attribparam.h:394
Interval with step.
Definition: commontypes.h:29
T defaultValue(int idx=0) const
Definition: datainpspec.h:426
NumParam< float > FloatParam
Definition: attribparam.h:240
BufferString & set(const char *)
Definition: bufstring.h:227
Specifications for numerical inputs that may or may not have limits.
Definition: datainpspec.h:176
virtual bool setText(const char *, int idx=0)=0
BufferString toString(const DBKey &ky)
Definition: dbkey.h:115
const char * buf() const
Definition: odstring.h:45
mODTextTranslationClass(NumParam)
virtual bool setCompositeValue(const char *)
Definition: attribparam.h:206
virtual bool isUndef(int idx=0) const =0
T stop
Definition: ranges.h:91
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
bool isEmpty() const
Definition: odstring.h:49
char * find(char)
Interval< T > getDefaultGateValue() const
Definition: attribparam.h:367
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:28
BufferString & add(char)
T start
Definition: ranges.h:90
Specifications for numerical intervals.
Definition: datainpspec.h:311
virtual NumParam< T > * clone() const
Definition: attribparam.h:136
#define mClass(module)
Definition: commondefs.h:161
NumParam(const char *key)
Definition: attribparam.h:130
NumParam< double > DoubleParam
Definition: attribparam.h:241
String parameter that is used by an attribute.
Definition: attribparam.h:106
A parameter that is used by an attribute.
Definition: attribparam.h:35
Holds data pertinent to a certain enum. It does not know the enum values themselves, but treat them as integers.
Definition: enums.h:44
void setDefaultValue(const Interval< T > &)
Definition: attribparam.h:362
Numerical parameter that is used by an attribute. For example: IntParam, FloatParam and DoubleParam...
Definition: attribparam.h:127
Semblance Attribute.
Definition: attribdataholder.h:21
virtual float getFValue(int idx=0) const
Definition: attribparam.h:181
Gate parameter that is used by an attribute. For example: IntGateParam, FloatGateParam, DoubleGateParam and ZGateParam.
Definition: attribparam.h:250
NumParam< int > IntParam
Definition: attribparam.h:239

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