OpendTect-6_4  6.4
uigeninput.h
Go to the documentation of this file.
1 #ifndef uigeninput_h
2 #define uigeninput_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: Oct 2000
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uitoolsmod.h"
16 #include "uigroup.h"
17 #include "datainpspec.h"
18 #include "position.h"
19 #include "uistring.h"
20 
21 class BinIDValue;
22 class uiLineEdit;
23 class uiLabel;
24 class uiCheckBox;
25 class uiString;
26 class uiButton;
27 class uiGenInputInputFld;
28 class uiGenInputFieldIdx;
29 class DataInpSpec;
30 class UserInputObj;
31 
58 mExpClass(uiTools) uiGenInput : public uiGroup
60 public:
61  uiGenInput( uiParent* p, const uiString& disptxt
62  , const char* inputStr=0 );
63 
64  uiGenInput( uiParent* p, const uiString& disptxt,
65  const DataInpSpec& );
66 
67  uiGenInput( uiParent* p, const uiString&,
68  const DataInpSpec& ,const DataInpSpec& );
69 
70  uiGenInput( uiParent* p, const uiString&,
71  const DataInpSpec&, const DataInpSpec&,
72  const DataInpSpec& );
73 
74  virtual ~uiGenInput();
75 
76  void addInput( const DataInpSpec& );
77 
91  const DataInpSpec* dataInpSpec(int nr=0) const;
92 
98  bool newSpec(const DataInpSpec& nw, int nr);
99 
101  void updateSpecs();
102 
103  bool isUndef( int nr=0 ) const;
104 
105 #undef mDeclArgs
106 #define mDeclArgs(type) int nr=0, type undefval=mUdf(type)
107 
108  const char* text( mDeclArgs(const char*) ) const;
109  const char* text( const char* undefval) const
110  { return text(0,undefval); }
111 
112  int getIntValue( mDeclArgs(int) ) const;
113  bool getBoolValue( mDeclArgs(bool) ) const;
114 
115  double getDValue( mDeclArgs(double) ) const;
116  double getDValue( double undefval ) const
117  { return getDValue(0,undefval) ; }
118 
119  float getFValue( mDeclArgs(float) ) const;
120  float getFValue( float undefval ) const
121  { return getFValue(0,undefval); }
122 
123  inline Interval<int> getIInterval( mDeclArgs(int) ) const
124  { return Interval<int>( getIntValue(nr*2,undefval),
125  getIntValue(nr*2+1,undefval) );}
126 
127  inline Interval<float> getFInterval( mDeclArgs(float) ) const
128  { return Interval<float>( getFValue(nr*2,undefval),
129  getFValue(nr*2+1,undefval) );}
130  inline Interval<float> getFInterval( float undefval ) const
131  { return getFInterval(0,undefval); }
132 
133  inline Interval<double> getDInterval( mDeclArgs(double) ) const
134  { return Interval<double>(getDValue(nr*2,undefval),
135  getDValue(nr*2+1,undefval) );}
136  inline Interval<double> getDInterval( double undefval ) const
137  { return getDInterval(0,undefval); }
138 
140  { return StepInterval<int>(getIntValue(nr*3,undefval),
141  getIntValue(nr*3+1,undefval),
142  getIntValue(nr*3+2,undefval)
143  ); }
145  { return StepInterval<float>(getFValue(nr*3,undefval),
146  getFValue(nr*3+1,undefval),
147  getFValue(nr*3+2,undefval)
148  ); }
149  inline StepInterval<float> getFStepInterval( float undefval ) const
150  { return getFStepInterval(0,undefval); }
151 
153  { return StepInterval<double>(getDValue(nr*3,undefval),
154  getDValue(nr*3+1,undefval),
155  getDValue(nr*3+2,undefval) ); }
156  inline StepInterval<double> getDStepInterval( double undefval ) const
157  { return getDStepInterval(0,undefval); }
158 
159  Coord getCoord( mDeclArgs(double) ) const;
160  BinID getBinID( mDeclArgs(int) ) const;
161  int getTrcNr( mDeclArgs(int) ) const;
162  float getOffset( mDeclArgs(float) ) const;
163 
164 
165 #undef mDeclArgs
166 
167  void setText(const char*,int nr=0);
168  void setValue(int,int nr=0);
169  void setValue(double,int nr=0);
170  void setValue(float,int nr=0);
171  void setValue(bool,int nr=0);
172 
173  inline void setTexts( const char* v1, const char* v2 )
174  { setText(v1,0); setText(v2,1); }
175  inline void setValues( int v1, int v2 )
176  { setValue(v1,0); setValue(v2,1); }
177  inline void setValues( double v1, double v2 )
178  { setValue(v1,0); setValue(v2,1); }
179  inline void setValues( float v1, float v2 )
180  { setValue(v1,0); setValue(v2,1); }
181  inline void setValues( bool v1, bool v2 )
182  { setValue(v1,0); setValue(v2,1); }
183  inline void setValue( const Coord& c )
184  { setValue(c.x,0); setValue(c.y,1); }
185  inline void setValue( const BinID& b )
186  { setValue(b.inl(),0); setValue(b.crl(),1); }
187  inline void setValue(const BinIDValue&);
188  void setValue(const Interval<int>&);
189  void setValue(const Interval<float>&);
190  void setValue(const Interval<double>&);
191 
192  void displayField(bool yn=true,int elemnr=-1,int fldnr=-1);
193  void setReadOnly( bool yn=true,int elemnr=-1,int fldnr=-1);
194  void setSensitive(bool yn=true,int elemnr=-1,int fldnr=-1);
195  void setEmpty(int nr=-1);
196 
198  UserInputObj* element(int idx);
199  uiObject* rightObj();
200  int nrElements() const;
201  void setElemSzPol( uiObject::SzPolicy p ) { elemszpol_=p;}
202  uiObject::SzPolicy elemSzPol() const { return elemszpol_; }
203  void setToolTip(const uiString&,int ielem=0);
204 
205  virtual const uiString& titleText();
206  virtual void setTitleText(const uiString&);
207 
208  void setChecked(bool yn);
209  bool isChecked() const { return checked_; }
210  bool isCheckable() const { return withchk_ || cbox_; }
211 
212  virtual bool isSingleLine() const { return true; }
213 
214  void setWithCheck( bool yn=true ) { withchk_ = yn; }
215  void setWithSelect( bool yn=true );
216 
217  void setNrDecimals(int nrdec,int fldnr=0);
218  void setRequired(bool yn=true);
219 
224 
225 protected:
226 
229 
231 
233  bool withchk_;
235 
239  uiButton* selbut_;
240 
242  void doSelect_(CallBacker*);
244  virtual void doSelect(CallBacker*) {}
245  void doClear(CallBacker*);
246 
247  void checkBoxSel(CallBacker*);
248 
250  uiGenInputInputFld& createInpFld(const DataInpSpec&);
251  void doFinalise(CallBacker*);
252  inline DataInpSpec* spec( int nr )
253  {
254  return const_cast<DataInpSpec*>
255  ( ((const uiGenInput*)this)->dataInpSpec(nr) );
256  }
257 
258 private:
259 
260  bool checked_;
261 
262  bool rdonly_;
264 
266 
268 
269  DataInpSpec* getInputSpecAndIndex(const int,int&) const;
270  uiGenInputInputFld* getInputFldAndIndex(const int,int&) const;
271 
272 public:
273  /*mDeprecated*/ double getdValue( int nr=0, double uv=mUdf(double) ) const
274  { return getDValue( nr, uv ); }
275  /*mDeprecated*/ double getdValue( float undefval ) const
276  { return getDValue(0,undefval); }
277  /*mDeprecated*/ float getfValue( int nr=0, float udfval=mUdf(float) ) const
278  { return getFValue( nr, udfval ); }
279  /*mDeprecated*/ float getfValue( float undefval ) const
280  { return getFValue(0,undefval); }
281  /*mDeprecated*/ bool isChecked();
282  /*mDeprecated*/ bool isCheckable() { return withchk_ || cbox_; }
283 };
284 
285 
286 #endif
Definition: uigroup.h:54
virtual const char * text() const =0
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
uiCheckBox * cbox_
Definition: uigeninput.h:238
virtual int getIntValue() const =0
virtual void setToolTip(const uiString &)=0
uiLabel * labl_
Definition: uigeninput.h:236
StepInterval< double > getDStepInterval(double undefval) const
Definition: uigeninput.h:156
void setValues(float v1, float v2)
Definition: uigeninput.h:179
virtual double getDValue() const =0
void setWithCheck(bool yn=true)
Definition: uigeninput.h:214
StepInterval< float > getFStepInterval(int nr=0, float undefval=mUdf(float)) const
Definition: uigeninput.h:144
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
ObjectSet< DataInpSpec > inputs_
Definition: uigeninput.h:265
void setTexts(const char *v1, const char *v2)
Definition: uigeninput.h:173
Interval< int > getIInterval(int nr=0, int undefval=mUdf(int)) const
Definition: uigeninput.h:123
uiObject::SzPolicy elemszpol_
Definition: uigeninput.h:267
IdxType & inl()
Definition: posidxpair.h:43
uiString titletext_
Definition: uigeninput.h:237
uiString selText_
Definition: uigeninput.h:232
uiButton * selbut_
Definition: uigeninput.h:239
The base class for most UI elements.
Definition: uiobj.h:38
Definition: uistring.h:89
bool isCheckable() const
Definition: uigeninput.h:210
Definition: uiparent.h:26
double getdValue(int nr=0, double uv=mUdf(double)) const
Definition: uigeninput.h:273
A cartesian coordinate in 2D space.
Definition: coord.h:25
bool rdonly_
Definition: uigeninput.h:262
Notifier< uiGenInput > checked
Definition: uigeninput.h:220
void setElemSzPol(uiObject::SzPolicy p)
Definition: uigeninput.h:201
ObjectSet< uiGenInputInputFld > flds_
Definition: uigeninput.h:227
bool withchk_
Definition: uigeninput.h:233
float getfValue(float undefval) const
Definition: uigeninput.h:279
const char * text(const char *undefval) const
Definition: uigeninput.h:109
SzPolicy
How should the object&#39;s size behave? Undef : use default. Small : 1 base sz. Medium : 2* base sz + 1...
Definition: uiobj.h:58
Notifier< uiGenInput > valuechanging
Definition: uigeninput.h:221
Notifier< uiGenInput > valuechanged
Definition: uigeninput.h:222
Specification of input characteristics.
Definition: datainpspec.h:89
Interval< double > getDInterval(double undefval) const
Definition: uigeninput.h:136
void setValues(int v1, int v2)
Definition: uigeninput.h:175
bool rdonlyset_
Definition: uigeninput.h:263
virtual void setReadOnly(bool=true)=0
virtual bool getBoolValue() const =0
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
StepInterval< double > getDStepInterval(int nr=0, double undefval=mUdf(double)) const
Definition: uigeninput.h:152
T y
Definition: geometry.h:67
StepInterval< float > getFStepInterval(float undefval) const
Definition: uigeninput.h:149
General Input Element.
Definition: uigeninput.h:58
BinID and a value.
Definition: binidvalue.h:31
#define mDeclArgs(type)
Definition: uigeninput.h:106
Interval< double > getDInterval(int nr=0, double undefval=mUdf(double)) const
Definition: uigeninput.h:133
void setValues(double v1, double v2)
Definition: uigeninput.h:177
virtual void setText(const char *)=0
virtual void setValue(const char *s)
virtual void doSelect(CallBacker *)
Select is pressed. Called by doSelect_.
Definition: uigeninput.h:244
bool checked_
Definition: uigeninput.h:260
virtual void setEmpty()=0
float getFValue(float undefval) const
Definition: uigeninput.h:120
void setValue(const Coord &c)
Definition: uigeninput.h:183
double getDValue(double undefval) const
Definition: uigeninput.h:116
virtual bool isSingleLine() const
Definition: uigeninput.h:212
float getfValue(int nr=0, float udfval=mUdf(float)) const
Definition: uigeninput.h:277
DataInpSpec * spec(int nr)
Definition: uigeninput.h:252
IdxType & crl()
Definition: posidxpair.h:48
uiObject::SzPolicy elemSzPol() const
Definition: uigeninput.h:202
Interval< float > getFInterval(int nr=0, float undefval=mUdf(float)) const
Definition: uigeninput.h:127
TypeSet< uiGenInputFieldIdx > & idxes_
Definition: uigeninput.h:228
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:30
Definition: uilabel.h:24
T x
Definition: geometry.h:66
void setValues(bool v1, bool v2)
Definition: uigeninput.h:181
Notifier< uiGenInput > updateRequested
Definition: uigeninput.h:223
Definition: userinputobj.h:25
virtual float getFValue() const =0
bool isrequired_
Definition: uigeninput.h:234
double getdValue(float undefval) const
Definition: uigeninput.h:275
Definition: uilineedit.h:51
bool isChecked() const
Definition: uigeninput.h:209
void setValue(const BinID &b)
Definition: uigeninput.h:185
Generalised data input field.
Definition: uigeninput_impl.h:32
bool isCheckable()
Definition: uigeninput.h:282
Definition: uibutton.h:134
bool finalised_
Definition: uigeninput.h:230
StepInterval< int > getIStepInterval(int nr=0, int undefval=mUdf(int)) const
Definition: uigeninput.h:139
Interval< float > getFInterval(float undefval) const
Definition: uigeninput.h:130

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