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

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