OpendTect-6_4  6.4
stratunitref.h
Go to the documentation of this file.
1 #ifndef stratunitref_h
2 #define stratunitref_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert Bril
9  Date: Dec 2003 / Sep 2010
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 -*/
15 
16 #include "stratmod.h"
17 #include "compoundkey.h"
18 #include "stratlevel.h"
19 #include "enums.h"
20 #include "iopar.h"
21 
22 
23 namespace Strat
24 {
25 
26 class RefTree;
27 class Lithology;
28 class NodeUnitRef;
29 class LeafUnitRef;
30 
39 {
40 public:
41 
42  enum Type { NodeOnly, Leaved, Leaf };
44 
45  UnitRef(NodeUnitRef*,const char* d=0);
46  virtual ~UnitRef();
47 
48  virtual Type type() const = 0;
49  virtual bool isEmpty() const { return false; }
50  virtual bool isUndef() const { return false; }
51  virtual bool hasChildren() const = 0;
52  bool isLeaf() const { return type()==Leaf; }
53  bool isLeaved() const { return type()==Leaved; }
54  CompoundKey fullCode() const;
55  CompoundKey parentCode() const;
56 
57  virtual const OD::String& code() const = 0;
58  virtual void setCode(const char*) {}
59  const OD::String& description() const { return desc_; }
60  virtual void setDescription( const char* d ) { desc_ = d; }
61  Color color() const { return color_; }
62  void setColor(Color);
63  IOPar& pars() { return pars_; }
64  const IOPar& pars() const { return pars_; }
65 
66  NodeUnitRef* upNode(int skip=0);
67  const NodeUnitRef* upNode( int skip=0 ) const
68  { return ((UnitRef*)this)->upNode( skip ); }
69  void setUpNode(NodeUnitRef* newpar)
70  { upnode_ = newpar; }
71  NodeUnitRef* topNode();
72  const NodeUnitRef* topNode() const;
73  RefTree& refTree(); // is the topNode
74  const RefTree& refTree() const;
75  virtual bool isParentOf(const UnitRef&) const { return false; }
76  virtual int level() const = 0;
77 
80 
81  virtual const LeafUnitRef* firstLeaf() const = 0;
82 
83 protected:
84 
86 
90 
91  void doFill(BufferString&,int) const;
92  void doUse(const char*,int*);
93  void notifChange(bool isrem=false);
94 
95  friend class NodeUnitRef;
96 
97 public:
98 
99  int treeDepth() const;
100  bool isBelow(const UnitRef*) const;
102  bool precedes(const UnitRef&) const;
104 
105  virtual void fill( BufferString& bs ) const { doFill(bs,mUdf(int));}
106  virtual void use( const char* s ) { doUse(s,0); }
107  virtual void getPropsFrom(const IOPar&);
108  virtual void putPropsTo(IOPar&) const;
109 
110  static const char* sKeyPropsFor() { return "Properties for "; }
111  static const char* sKeyTreeProps() { return "entire tree"; }
112 
113 };
114 
115 
119 {
120 public:
121 
122  NodeUnitRef(NodeUnitRef*,const char*,const char* d=0);
123  ~NodeUnitRef();
124  void setEmpty();
125 
126  virtual bool isEmpty() const { return refs_.isEmpty(); }
127  virtual bool hasChildren() const { return !refs_.isEmpty(); }
128  virtual bool hasLeaves() const = 0;
129 
130  virtual const OD::String& code() const { return code_; }
131  virtual void setCode( const char* c ) { code_ = c; }
132 
133  virtual Interval<float> timeRange() const { return timerg_; }
134  virtual void setTimeRange(const Interval<float>&);
135  void incTimeRange(const Interval<float>&);
136 
137  int nrRefs() const { return refs_.size(); }
138  UnitRef& ref( int idx ) { return *refs_[idx]; }
139  const UnitRef& ref( int idx ) const { return *refs_[idx]; }
140  int indexOf( const UnitRef* ur ) const
141  { return refs_.indexOf((const NodeUnitRef*)ur); }
142  virtual bool isParentOf(const UnitRef&) const;
143 
144  UnitRef* find( const char* urcode ) { return fnd(urcode); }
145  const UnitRef* find( const char* urcode ) const{ return fnd(urcode); }
146 
147  virtual int nrLeaves() const;
148  virtual int level() const { return upnode_?upnode_->level()+1:0; }
149 
150 protected:
151 
155 
156  UnitRef* fnd(const char*) const;
157  void takeChildrenFrom(NodeUnitRef*);
158  friend class RefTree;
159 
160 public:
161 
162  virtual bool add(UnitRef*,bool rev=false);
163  virtual bool insert(UnitRef*,int posidx);
164  virtual UnitRef* replace(int uridx,UnitRef*);
165  void swapChildren(int,int);
166  void remove( int uridx )
167  { delete refs_.removeSingle(uridx); }
168  void remove( const UnitRef* ur )
169  { remove( indexOf( ur ) ); }
171  { deepErase( refs_ ); }
172 
173  virtual void getPropsFrom(const IOPar&);
174  virtual void putPropsTo(IOPar&) const;
175 protected:
176  void changeTimeRange(float dtime);
177 
178 };
179 
180 
184 {
185 public:
186  NodeOnlyUnitRef( NodeUnitRef* up, const char* c,
187  const char* d=0 )
188  : NodeUnitRef(up,c,d) {}
189 
190  virtual bool hasLeaves() const { return false; }
191  virtual Type type() const { return NodeOnly; }
192  virtual const LeafUnitRef* firstLeaf() const;
193 
194 };
195 
196 
200 {
201 public:
202  LeavedUnitRef( NodeUnitRef* up, const char* c,
203  const char* d=0 )
204  : NodeUnitRef(up,c,d)
205  , levelid_(-1) {}
206 
207  virtual Type type() const { return Leaved; }
208  virtual bool hasLeaves() const { return true; }
209 
210  Level::ID levelID() const { return levelid_; }
211  void setLevelID(Level::ID);
212 
213  virtual int nrLeaves() const { return refs_.size(); }
214  virtual const LeafUnitRef* firstLeaf() const
215  { return refs_.isEmpty() ? 0 : refs_[0]->firstLeaf(); }
216 
217  LeafUnitRef* getLeaf(int);
218  const LeafUnitRef* getLeaf( int i ) const
219  { return const_cast<LeavedUnitRef*>(this)->getLeaf(i); }
220  LeafUnitRef* getLeaf(const Lithology&);
221  const LeafUnitRef* getLeaf( const Lithology& l ) const
222  { return const_cast<LeavedUnitRef*>(this)->getLeaf(l); }
223 
224 protected:
225 
227 
228  virtual void fill( BufferString& bs ) const { doFill(bs,levelid_); }
229  virtual void use( const char* s ) { doUse(s,&levelid_); }
230 
231 };
232 
233 
237 {
238 public:
239 
240  LeafUnitRef(NodeUnitRef*,int lithidx=-1,
241  const char* desc=0);
242  virtual bool isUndef() const;
243 
244  virtual Type type() const { return Leaf; }
245  virtual bool hasChildren() const { return false; }
246  virtual const OD::String& code() const;
247  int lithology() const { return lith_; }
248  void setLithology(int);
249 
250  const Lithology& getLithology() const;
251  Color dispColor(bool lith_else_upnode) const;
252  virtual int level() const { return upnode_?upnode_->level()+1:0; }
253  virtual const LeafUnitRef* firstLeaf() const { return this; }
254 
255 protected:
256 
257  int lith_;
258 
259  virtual void fill( BufferString& bs ) const { doFill(bs,lith_); }
260  virtual void use( const char* s ) { doUse(s,&lith_); }
261 
262 
263 public:
264 
265  virtual void getPropsFrom(const IOPar&);
266 
267 };
268 
269 
271 { return upnode_ ? upnode_->topNode() : (NodeUnitRef*)this; }
272 inline const NodeUnitRef* UnitRef::topNode() const
273 { return upnode_ ? upnode_->topNode() : (NodeUnitRef*)this; }
274 
275 
276 }; // namespace Strat
277 
278 #endif
#define mExpClass(module)
Definition: commondefs.h:160
int lithology() const
Definition: stratunitref.h:247
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
NodeUnitRef * topNode()
Definition: stratunitref.h:270
virtual int level() const
Definition: stratunitref.h:252
virtual void use(const char *s)
Definition: stratunitref.h:106
UnitRef for units containing Leaf units only.
Definition: stratunitref.h:199
virtual const LeafUnitRef * firstLeaf() const
Definition: stratunitref.h:214
const UnitRef & ref(int idx) const
Definition: stratunitref.h:139
UnitRef & ref(int idx)
Definition: stratunitref.h:138
UnitRef for units containing non-Leaf units only.
Definition: stratunitref.h:183
int lith_
Definition: stratunitref.h:257
bool isLeaved() const
Definition: stratunitref.h:53
NodeUnitRef * upnode_
Definition: stratunitref.h:85
virtual int level() const
Definition: stratunitref.h:148
NodeOnlyUnitRef(NodeUnitRef *up, const char *c, const char *d=0)
Definition: stratunitref.h:186
Interval< float > timerg_
Definition: stratunitref.h:153
virtual bool hasChildren() const
Definition: stratunitref.h:127
virtual const LeafUnitRef * firstLeaf() const
Definition: stratunitref.h:253
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
virtual bool isParentOf(const UnitRef &) const
Definition: stratunitref.h:75
virtual T * removeSingle(size_type, bool keep_order=true)
Definition: objectset.h:460
#define mDeclareEnumUtils(enm)
Some utilities surrounding the often needed enum <-> string table.
Definition: enums.h:258
const OD::String & description() const
Definition: stratunitref.h:59
Level::ID levelid_
Definition: stratunitref.h:226
Definition: callback.h:254
virtual void fill(BufferString &bs) const
Definition: stratunitref.h:259
Set of pointers to objects.
Definition: commontypes.h:32
virtual Interval< float > timeRange() const
Definition: stratunitref.h:133
virtual void use(const char *s)
Definition: stratunitref.h:260
Color color_
Definition: stratunitref.h:88
virtual void use(const char *s)
Definition: stratunitref.h:229
int ID
Definition: stratlevel.h:46
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
int indexOf(const UnitRef *ur) const
Definition: stratunitref.h:140
const NodeUnitRef * upNode(int skip=0) const
Definition: stratunitref.h:67
Level::ID levelID() const
Definition: stratunitref.h:210
bool isLeaf() const
Definition: stratunitref.h:52
void setUpNode(NodeUnitRef *newpar)
Definition: stratunitref.h:69
a name and an ID.
Definition: stratlith.h:37
Notifier< UnitRef > changed
Definition: stratunitref.h:78
virtual const OD::String & code() const
Definition: stratunitref.h:130
const LeafUnitRef * getLeaf(const Lithology &l) const
Definition: stratunitref.h:221
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
NodeUnitRef * upNode(int skip=0)
UnitRef for units containing other units only.
Definition: stratunitref.h:118
virtual Type type() const
Definition: stratunitref.h:191
virtual bool isEmpty() const
Definition: stratunitref.h:49
virtual bool isEmpty() const
Definition: stratunitref.h:126
UnitRef for layers.
Definition: stratunitref.h:236
const IOPar & pars() const
Definition: stratunitref.h:64
Color color() const
Definition: stratunitref.h:61
BufferString code_
Definition: stratunitref.h:154
static const char * sKeyPropsFor()
Definition: stratunitref.h:110
const LeafUnitRef * getLeaf(int i) const
Definition: stratunitref.h:218
Reference data for a stratigraphic unit.
Definition: stratunitref.h:38
virtual bool isUndef() const
Definition: stratunitref.h:50
virtual int nrLeaves() const
Definition: stratunitref.h:213
Type
Definition: stratunitref.h:42
Stratigraphy.
Definition: stratlevel.h:26
ObjectSet< UnitRef > refs_
Definition: stratunitref.h:152
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
const UnitRef * find(const char *urcode) const
Definition: stratunitref.h:145
virtual Type type() const
Definition: stratunitref.h:207
int nrRefs() const
Definition: stratunitref.h:137
Tree of UnitRef&#39;s.
Definition: stratreftree.h:29
virtual void setCode(const char *)
Definition: stratunitref.h:58
Concatenated short keys separated by dots. Used for Object identifiers in the Object Manager...
Definition: compoundkey.h:23
LeavedUnitRef(NodeUnitRef *up, const char *c, const char *d=0)
Definition: stratunitref.h:202
virtual void setCode(const char *c)
Definition: stratunitref.h:131
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
virtual bool hasLeaves() const
Definition: stratunitref.h:208
virtual void fill(BufferString &bs) const
Definition: stratunitref.h:105
bool isEmpty(const NLAModel *mdl)
virtual void setDescription(const char *d)
Definition: stratunitref.h:60
virtual bool hasChildren() const
Definition: stratunitref.h:245
UnitRef * find(const char *urcode)
Definition: stratunitref.h:144
void removeAllChildren()
Definition: stratunitref.h:170
Notifier< UnitRef > toBeDeleted
Definition: stratunitref.h:79
IOPar pars_
Definition: stratunitref.h:89
BufferString desc_
Definition: stratunitref.h:87
IOPar & pars()
Definition: stratunitref.h:63
virtual bool hasLeaves() const
Definition: stratunitref.h:190
virtual void fill(BufferString &bs) const
Definition: stratunitref.h:228
virtual Type type() const
Definition: stratunitref.h:244
static const char * sKeyTreeProps()
Definition: stratunitref.h:111
void deepErase(ObjectSet< T > &os)
empty the ObjectSet deleting all objects pointed to.
Definition: objectset.h:118

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