OpendTect  6.3
attribdesc.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 "refcount.h"
15 #include "bufstring.h"
16 #include "bufstringset.h"
17 #include "seistype.h"
18 #include "attribdescid.h"
19 #include "typeset.h"
20 
21 
22 namespace Attrib
23 {
24 
25 class Desc;
26 class Param;
27 class DescSet;
28 class ValParam;
29 
30 typedef void(*DescStatusUpdater)(Desc&);
31 typedef void(*DescDefaultsUpdater)(Desc&);
32 
37 mExpClass(AttributeEngine) DescSetup
38 {
39  public:
40  DescSetup();
41  mDefSetupClssMemb(DescSetup,bool,is2d)
42  mDefSetupClssMemb(DescSetup,bool,ps)
43  mDefSetupClssMemb(DescSetup,bool,singletraceonly)
44  mDefSetupClssMemb(DescSetup,bool,usingtrcpos)
45  mDefSetupClssMemb(DescSetup,bool,depthonly)
46  mDefSetupClssMemb(DescSetup,bool,timeonly)
47  mDefSetupClssMemb(DescSetup,bool,hidden)
48  mDefSetupClssMemb(DescSetup,bool,steering)
49  mDefSetupClssMemb(DescSetup,bool,stored)
50 };
51 
52 
57 mExpClass(AttributeEngine) InputSpec
58 {
59 public:
60  InputSpec( const char* d, bool enabled )
61  : desc_(d), enabled_(enabled)
62  , issteering_(false) {}
63 
64  const char* getDesc() const { return desc_; }
65 
68  bool enabled_;
70 
71  bool operator==(const InputSpec&) const;
72 };
73 
74 
87 mExpClass(AttributeEngine) Desc : public RefCount::Referenced
89 public:
90 
91  enum Locality { SingleTrace, PossiblyMultiTrace, MultiTrace };
92 
93  Desc(const Desc&);
94  Desc(const char* attrname,
95  DescStatusUpdater updater=0,
96  DescDefaultsUpdater defupdater=0);
97 
98  const OD::String& attribName() const;
99 
100  void setDescSet(DescSet*);
101  DescSet* descSet() const;
102  DescID id() const;
103  bool getParentID(DescID cid,DescID& pid,int&) const;
104  void getAncestorIDs(DescID cid,
105  TypeSet<DescID>&,TypeSet<int>&) const;
106  /*ordered from parent to oldest original*/
107 
108  bool getDefStr(BufferString&) const;
109  bool parseDefStr(const char*);
110 
111  const char* userRef() const;
112  void setUserRef(const char*);
113 
114  int nrOutputs() const;
115  void selectOutput(int);
116  int selectedOutput() const;
117 
118  Seis::DataType dataType(int output=-1) const;
121  Locality locality() const { return locality_; }
122  void setLocality( Locality l ) { locality_ = l; }
123  bool usesTracePosition() const { return usestrcpos_;}
124  void setUsesTrcPos( bool yn ) { usestrcpos_ = yn; }
125  bool isSteering() const { return issteering_;}
126  void setSteering( bool yn ) { issteering_ = yn; }
127  bool isHidden() const { return hidden_; }
129  void setHidden( bool yn ) { hidden_ = yn; }
132  bool isStored() const;
133  bool isStoredInMem() const;
134  DBKey getStoredID(bool recursive=false) const;
135 
136  void setNeedProvInit( bool yn=true )
137  { needprovinit_ = yn; }
138  bool needProvInit() const
139  { return needprovinit_;}
140 
141  int nrInputs() const;
142  InputSpec& inputSpec(int);
143  const InputSpec& inputSpec(int) const;
144  bool setInput(int,const Desc*);
145  Desc* getInput(int);
146  const Desc* getInput(int) const;
147  void getInputs(TypeSet<Attrib::DescID>&) const;
148  void getDependencies(TypeSet<Attrib::DescID>&) const;
152  bool is2D() const { return is2d_; }
153  void set2D( bool yn ) { is2d_ = yn; }
154  bool isPS() const { return isps_; }
155  void setPS( bool yn ) { isps_ = yn; }
156 
157  enum SatisfyLevel { AllOk, Warning, Error };
158  SatisfyLevel isSatisfied() const;
161  const uiString errMsg() const;
162  void setErrMsg( const uiString str ) { errmsg_=str; }
163 
164  bool isIdenticalTo(const Desc&,
165  bool cmpoutput=true) const;
166  bool isIdentifiedBy(const char*) const;
167  DescID inputId(int idx) const;
168 
169  /* Interface to factory */
170  void addParam(Param*);
172  const Param* getParam(const char* key) const;
173  Param* getParam(const char* key);
174  const ValParam* getValParam(const char* key) const;
175  ValParam* getValParam(const char* key);
176  void setParamEnabled(const char* key,bool yn=true);
177  bool isParamEnabled(const char* key) const;
178  void setParamRequired(const char* key,bool yn=true);
179  bool isParamRequired(const char* key) const;
180 
181  void updateParams();
182  void updateDefaultParams();
183  void changeStoredID(const DBKey&);
184 
185  void addInput(const InputSpec&);
186  bool removeInput(int idx);
187  void removeOutputs();
188  void addOutputDataType(Seis::DataType);
189  void setNrOutputs(Seis::DataType,int);
190  void addOutputDataTypeSameAs(int);
191  void changeOutputDataType(int,Seis::DataType);
192 
193  static bool getAttribName(const char* defstr,BufferString&);
194  static bool getParamString(const char* defstr,
195  const char* key,BufferString&);
196 
197  Desc* getStoredInput() const;
198  DescID getMultiOutputInputID() const;
199 
200  //Used to clone an attribute chain and apply it on multiple components
201  //of the same input cube (different offsets for instance)
202  Desc* cloneDescAndPropagateInput(const DescID&,
203  BufferString);
204 
205  static const char* sKeyInlDipComp();
206  static const char* sKeyCrlDipComp();
207  static const char* sKeyLineDipComp();
208 
209  static void getKeysVals(const char* defstr,
210  BufferStringSet& keys,
211  BufferStringSet& vals,
212  const char* onlyneedkey=0);
217 protected:
218  ~Desc();
219 
220  bool setInput_(int,Desc*);
221  Param* findParam(const char* key);
222 
226  bool hidden_;
228  bool is2d_;
229  bool isps_;
230  Locality locality_;
232 
235 
238 
242 
246 };
247 
248 } // namespace Attrib
249 
250 #define mGetIntFromDesc( __desc, var, varstring ) \
251 {\
252  var = __desc.getValParam(varstring)->getIntValue(0); \
253  if ( mIsUdf(var) )\
254  var = __desc.getValParam(varstring)->getDefaultIntValue(0);\
255 }
256 
257 #define mGetFloatFromDesc( __desc, var, varstring ) \
258 {\
259  var = __desc.getValParam(varstring)->getFValue(0); \
260  if ( mIsUdf(var) )\
261  var = __desc.getValParam(varstring)->getDefaultFValue(0);\
262 }
263 
264 
265 #define mGetDoubleFromDesc( __desc, var, varstring ) \
266 {\
267  var = __desc.getValParam(varstring)->getDValue(0); \
268  if ( mIsUdf(var) )\
269  var = __desc.getValParam(varstring)->getDefaultDValue(0);\
270 }
271 
272 
273 #define mGetBoolFromDesc( __desc, var, varstring ) \
274 {\
275  Attrib::ValParam* valparam##var = \
276  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
277  mDynamicCastGet(Attrib::BoolParam*,boolparam##var,valparam##var);\
278  if ( boolparam##var ) \
279  var = boolparam##var->isSet() ? boolparam##var->getBoolValue(0)\
280  : boolparam##var->getDefaultBoolValue(0);\
281 }
282 
283 #define mGetEnumFromDesc( __desc, var, varstring ) \
284 {\
285  Attrib::ValParam* valparam##var = \
286  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
287  mDynamicCastGet(Attrib::EnumParam*,enumparam##var,valparam##var);\
288  if ( enumparam##var ) \
289  var = enumparam##var->isSet() ? enumparam##var->getIntValue(0)\
290  : enumparam##var->getDefaultIntValue(0);\
291 }
292 
293 #define mGetStringFromDesc( __desc, var, varstring ) \
294 {\
295  var = __desc.getValParam(varstring)->getStringValue(0); \
296  if ( FixedString(var).isEmpty() )\
297  var = __desc.getValParam(varstring)->getDefaultStringValue(0); \
298 }
299 
300 #define mGetBinIDFromDesc( __desc, var, varstring ) \
301 {\
302  var.inl() = __desc.getValParam(varstring)->getIntValue(0); \
303  var.crl() = __desc.getValParam(varstring)->getIntValue(1); \
304  if ( mIsUdf(var.inl()) || mIsUdf(var.crl()) )\
305  {\
306  Attrib::ValParam* valparam##var = \
307  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
308  mDynamicCastGet(Attrib::BinIDParam*,binidparam##var,valparam##var);\
309  if ( binidparam##var ) \
310  var = binidparam##var->getDefaultBinIDValue();\
311  }\
312  if ( __desc.descSet()->is2D() ) \
313  var.inl() = 0; \
314 }
315 
316 #define mGetFloatIntervalFromDesc( __desc, var, varstring ) \
317 {\
318  var.start = __desc.getValParam(varstring)->getFValue(0); \
319  var.stop = __desc.getValParam(varstring)->getFValue(1); \
320  if ( mIsUdf(var.start) || mIsUdf(var.stop) )\
321  {\
322  Attrib::ValParam* valparam##var = \
323  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
324  mDynamicCastGet(Attrib::ZGateParam*,gateparam##var,valparam##var);\
325  if ( gateparam##var ) \
326  var = gateparam##var->getDefaultGateValue();\
327  }\
328 }
329 
330 #define mGetFloat( var, varstring ) \
331  mGetFloatFromDesc( desc_, var, varstring )
332 #define mGetInt( var, varstring ) \
333  mGetIntFromDesc( desc_, var, varstring )
334 #define mGetBool( var, varstring ) \
335  mGetBoolFromDesc( desc_, var, varstring )
336 #define mGetEnum( var, varstring ) \
337  mGetEnumFromDesc( desc_, var, varstring )
338 #define mGetString( var, varstring ) \
339  mGetStringFromDesc( desc_, var, varstring )
340 #define mGetBinID( var, varstring ) \
341  mGetBinIDFromDesc( desc_, var, varstring )
342 #define mGetFloatInterval( var, varstring ) \
343  mGetFloatIntervalFromDesc( desc_, var, varstring )
344 #define mGetDouble( var, varstring ) \
345  mGetDoubleFromDesc( desc_, var, varstring )
Attribute Value Parameter.
Definition: attribparambase.h:92
#define mExpClass(module)
Definition: commondefs.h:157
ObjectSet< Param > params_
Definition: attribdesc.h:237
BufferString userref_
Definition: attribdesc.h:239
DescStatusUpdater statusupdater_
Definition: attribdesc.h:243
Locality locality() const
Definition: attribdesc.h:121
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
bool issteering_
Definition: attribdesc.h:225
void(* DescDefaultsUpdater)(Desc &)
Definition: attribdesc.h:31
#define mDefSetupClssMemb(clss, typ, memb)
Definition: commondefs.h:125
bool isps_
Definition: attribdesc.h:229
bool usestrcpos_
Definition: attribdesc.h:231
Set of attribute descriptions.
Definition: attribdescset.h:29
bool isSteering() const
Definition: attribdesc.h:125
DescDefaultsUpdater defaultsupdater_
Definition: attribdesc.h:244
bool is2d_
Definition: attribdesc.h:228
AttribDesc ID: each Desc has a unique ID in a set; the boolean isstored allows us to know whether thi...
Definition: attribdescid.h:25
Definition: uistring.h:88
TypeSet< int > outputtypelinks_
Definition: attribdesc.h:224
void setLocality(Locality l)
Definition: attribdesc.h:122
Set of BufferString objects.
Definition: bufstringset.h:25
bool needprovinit_
Definition: attribdesc.h:227
InputSpec(const char *d, bool enabled)
Definition: attribdesc.h:60
void set2D(bool yn)
Definition: attribdesc.h:153
Set of pointers to objects.
Definition: commontypes.h:28
int seloutput_
Definition: attribdesc.h:240
Specification of input data of an attribute.
Definition: attribdesc.h:57
bool hidden_
Definition: attribdesc.h:226
TypeSet< InputSpec > inputspecs_
Definition: attribdesc.h:233
FixedString Desc()
Definition: keystrs.h:60
void setNeedProvInit(bool yn=true)
Definition: attribdesc.h:136
bool is2D() const
Definition: attribdesc.h:152
bool enabled_
Definition: attribdesc.h:68
Description of an attribute in an Attrib::DescSet. Each attribute has a name (e.g. "Similarity"), a user reference (e.g. "My similarity"), and at least one output. In addition, it may have parameters and inputs. If it has multiple outputs, only one of the outputs are selected.
Definition: attribdesc.h:87
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
Setup class for Attrib::Desc.
Definition: attribdesc.h:37
A parameter that is used by an attribute.
Definition: attribparambase.h:34
void setUsesTrcPos(bool yn)
Definition: attribdesc.h:124
bool usesTracePosition() const
Definition: attribdesc.h:123
DescSet * descset_
Definition: attribdesc.h:241
bool issteering_
Definition: attribdesc.h:69
Locality locality_
Definition: attribdesc.h:230
ObjectSet< Desc > inputs_
Definition: attribdesc.h:234
TypeSet< Seis::DataType > forbiddenDts_
Definition: attribdesc.h:67
void setPS(bool yn)
Definition: attribdesc.h:155
void setErrMsg(const uiString str)
Definition: attribdesc.h:162
void(* DescStatusUpdater)(Desc &)
Definition: attribdesc.h:30
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
Definition: attribdesc.h:157
BufferString errmsg_
Definition: horizontracker.h:117
bool isPS() const
Definition: attribdesc.h:154
void setHidden(bool yn)
Definition: attribdesc.h:129
bool isHidden() const
Definition: attribdesc.h:127
uiString errmsg_
Definition: attribdesc.h:245
BufferString attribname_
Definition: attribdesc.h:236
Full key to any object in the OpendTect data store.
Definition: dbkey.h:36
DataType
Definition: seistype.h:52
const char * errMsg() const
Definition: horizontracker.h:59
void setSteering(bool yn)
Definition: attribdesc.h:126
bool needProvInit() const
Definition: attribdesc.h:138
SatisfyLevel
Definition: attribdesc.h:157
Semblance Attribute.
Definition: attribdataholder.h:21
TypeSet< Seis::DataType > outputtypes_
Definition: attribdesc.h:223
const char * getDesc() const
Definition: attribdesc.h:64
BufferString desc_
Definition: attribdesc.h:66

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