OpendTect-6_4  6.4
paramsetget.h
Go to the documentation of this file.
1 #ifndef paramsetget_h
2 #define paramsetget_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: N. Hemstra
9  Date: May 2005
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
17 #define mSetFloatInterval( str, newval ) \
18 { \
19  mDynamicCastGet(Attrib::FloatGateParam*,param,desc.getParam(str)) \
20  const Interval<float> oldval( param->getFValue(0), param->getFValue(1) ); \
21  if ( chtr_.set(oldval,newval) ) param->setValue( newval ); \
22 }
23 
24 #define mSetFloat( str, newval ) \
25 { \
26  Attrib::ValParam* param = desc.getValParam( str ); \
27  const float oldval = param->getFValue(); \
28  if ( chtr_.set(oldval,newval) ) \
29  param->setValue( newval ); \
30 }
31 
32 #define mSetDouble( str, newval ) \
33 { \
34  Attrib::ValParam* param = desc.getValParam( str ); \
35  const double oldval = param->getDValue(); \
36  if ( chtr_.set(oldval,newval) ) \
37  param->setValue( newval ); \
38 }
39 
40 #define mSetInt( str, newval ) \
41 { \
42  Attrib::ValParam* param = desc.getValParam( str ); \
43  const int oldval = param->getIntValue(); \
44  if ( chtr_.set(oldval,newval) ) \
45  param->setValue( newval ); \
46 }
47 
48 #define mSetBool( str, newval ) \
49 { \
50  mDynamicCastGet(Attrib::BoolParam*,param,desc.getValParam(str)) \
51  const bool oldval = param->getBoolValue(); \
52  if ( chtr_.set(oldval,newval) ) \
53  param->setValue( newval ); \
54  else\
55  param->setSet();\
56 }
57 
58 #define mSetEnum( str, newval ) \
59 { \
60  mDynamicCastGet(Attrib::EnumParam*,param,desc.getValParam(str)) \
61  const int oldval = param->getIntValue(); \
62  if ( chtr_.set(oldval,newval) ) \
63  param->setValue( newval ); \
64  else\
65  param->setSet();\
66 }
67 
68 #define mSetBinID( str, newval ) \
69 { \
70  mDynamicCastGet(Attrib::BinIDParam*,param,desc.getValParam(str)) \
71  const BinID oldval = param->getValue(); \
72  if ( chtr_.set(oldval,newval) ) \
73  { param->setValue( newval.inl(), 0 ); param->setValue( newval.crl(), 1 ); } \
74 }
75 
76 
77 #define mSetString( str, newval ) \
78 { \
79  Attrib::ValParam* param = desc.getValParam( str ); \
80  BufferString oldval = param->getStringValue(); \
81  if ( chtr_.set(oldval,newval) ) \
82  param->setValue( newval ); \
83 }
84 
85 
86 // Get macros
87 
88 #define mIfGetBool( str, var, setfunc ) \
89 Attrib::ValParam* valparam##var = \
90  const_cast<Attrib::ValParam*>(desc.getValParam(str));\
91 mDynamicCastGet(Attrib::BoolParam*,boolparam##var,valparam##var);\
92 if ( boolparam##var ) \
93 {\
94  bool var;\
95  if ( boolparam##var->isSet() )\
96  var = boolparam##var->getBoolValue(0);\
97  else\
98  var = boolparam##var->getDefaultBoolValue(0);\
99  setfunc;\
100 }
101 
102 #define mIfGetFloat( str, var, setfunc ) \
103 if ( desc.getValParam(str) ) \
104 {\
105  float var = desc.getValParam(str)->getFValue(0);\
106  if ( mIsUdf(var) )\
107  var = desc.getValParam(str)->getDefaultfValue(0);\
108  setfunc;\
109 }
110 
111 #define mIfGetDouble( str, var, setfunc ) \
112 if ( desc.getValParam(str) ) \
113 {\
114  double var = desc.getValParam(str)->getDValue(0);\
115  if ( mIsUdf(var) )\
116  var = desc.getValParam(str)->getDefaultdValue(0);\
117  setfunc;\
118 }
119 
120 #define mIfGetInt( str, var, setfunc ) \
121 if ( desc.getValParam(str) ) \
122 {\
123  int var = desc.getValParam(str)->getIntValue(0);\
124  if ( mIsUdf(var) )\
125  var = desc.getValParam(str)->getDefaultIntValue(0);\
126  setfunc;\
127 }
128 
129 #define mIfGetEnum( str, var, setfunc ) \
130 Attrib::ValParam* valparam##var = \
131  const_cast<Attrib::ValParam*>(desc.getValParam(str));\
132 mDynamicCastGet(Attrib::EnumParam*,enumparam##var,valparam##var);\
133 if ( enumparam##var ) \
134 {\
135  int var;\
136  if ( enumparam##var->isSet() )\
137  var = enumparam##var->getIntValue(0);\
138  else\
139  var = enumparam##var->getDefaultIntValue(0);\
140  setfunc;\
141 }
142 
143 #define mIfGetString( str, var, setfunc ) \
144 if ( desc.getValParam(str) ) \
145 { \
146  BufferString var = desc.getValParam(str)->getStringValue(0); \
147  if ( var.isEmpty() ) \
148  var = desc.getValParam(str)->getDefaultStringValue(0); \
149  setfunc;\
150 }
151 
152 #define mIfGetBinID( str, var, setfunc ) \
153 Attrib::ValParam* valparam##var = \
154  const_cast<Attrib::ValParam*>(desc.getValParam(str));\
155 mDynamicCastGet(Attrib::BinIDParam*,binidparam##var,valparam##var);\
156 if ( binidparam##var ) \
157 { \
158  BinID var; \
159  var = binidparam##var->getValue(); \
160  if ( mIsUdf(var.inl()) || mIsUdf(var.crl()) )\
161  var = binidparam##var->getDefaultBinIDValue();\
162  setfunc; \
163 }
164 
165 #define mIfGetFloatInterval( str, var, setfunc ) \
166 Attrib::ValParam* valparam##var =\
167  const_cast<Attrib::ValParam*>(desc.getValParam(str));\
168 if ( valparam##var ) \
169 { \
170  Interval<float> var; \
171  var.start = valparam##var->getFValue(0); \
172  var.stop = valparam##var->getFValue(1); \
173  if ( mIsUdf(var.start) || mIsUdf(var.stop) )\
174  {\
175  mDynamicCastGet(Attrib::FloatGateParam*,gateparam##var,valparam##var);\
176  if ( gateparam##var ) \
177  var = gateparam##var->getDefaultGateValue();\
178  }\
179  setfunc; \
180 }
181 
182 
183 #endif

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