OpendTect  6.3
stratlith.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: Bert Bril
8  Date: Dec 2003
9 ________________________________________________________________________
10 
11 
12 -*/
13 
14 #include "stratmod.h"
15 #include "namedobj.h"
16 #include "notify.h"
17 #include "manobjectset.h"
18 #include "color.h"
19 class BufferStringSet;
20 
21 
22 namespace Strat
23 {
24 
33 {
34 public:
35 
36  typedef int ID;
37 
38  Lithology(ID id,const char* nm,bool por=false);
39  Lithology( const Lithology& l )
40  : id_(l.id_) { *this = l; }
41  Lithology& operator =(const Lithology&);
42  bool operator ==( const Lithology& l ) const
43  { return l.id_ == id_; }
44 
45  bool isUdf() const { return this == &undef(); }
46  static bool isUdf( ID id ) { return id == undef().id_; }
47 
48  ID id() const { return id_; }
49  bool& porous() { return porous_; }
50  bool porous() const { return porous_; }
51  Color& color() { return color_; }
52  const Color& color() const { return color_; }
53 
54  static const Lithology& undef();
55 
56 protected:
57 
58  const ID id_;
59  bool porous_;
61 
62  friend class LithologySet;
63 
64 public:
65 
66  Lithology(const char*); // from string in file
67  void fill(BufferString&) const;
68 
69 };
70 
71 
73 {
74 public:
76  : anyChange(this) {}
77 
78  int size() const { return lths_.size(); }
79  bool isEmpty() const { return lths_.isEmpty(); }
80  Lithology& getLith( int i ) { return *lths_[i]; }
81  const Lithology& getLith( int i ) const { return *lths_[i]; }
82 
83  int indexOf( const char* nm ) const { return idxOf(nm,-2);}
84  bool isPresent(const char* nm) const { return gtLith(nm,-2);}
85  int indexOf( Lithology::ID id ) const { return idxOf(0,id);}
86  bool isPresent( Lithology::ID id ) const { return gtLith(0,id);}
87 
88  Lithology* get( const char* nm ) { return gtLith(nm,-2);}
89  const Lithology* get( const char* nm ) const { return gtLith(nm,-2);}
90  Lithology* get( Lithology::ID id ) { return gtLith(0,id); }
91  const Lithology* get( Lithology::ID id ) const { return gtLith(0,id); }
92 
93  enum PorSel { OnlyPorous, NotPorous, AllPor };
94  void getNames(BufferStringSet&,PorSel ps=AllPor) const;
95 
96  void reportAnyChange() { anyChange.trigger(); }
98 
99 protected:
100 
102 
103  int idxOf(const char*,Lithology::ID) const;
104  Lithology* gtLith( const char* nm, Lithology::ID id ) const
105  { const int idx = idxOf(nm,id); return idx < 0 ? 0
106  : const_cast<Lithology*>(lths_[idx]); }
107 
108 public:
109 
110  void setEmpty() { lths_.erase(); }
111  const char* add(Lithology*);
113 
114  const ObjectSet<Lithology>& lithologies() const { return lths_; }
115  ObjectSet<Lithology>& lithologies() { return lths_; }
116 
117 };
118 
119 
120 }; // namespace Strat
#define mExpClass(module)
Definition: commondefs.h:157
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
Definition: stratlith.h:72
Notifier< LithologySet > anyChange
Definition: stratlith.h:97
bool & porous()
Definition: stratlith.h:49
Color color_
Definition: stratlith.h:60
PorSel
Definition: stratlith.h:93
void setEmpty()
Definition: stratlith.h:110
int indexOf(const char *nm) const
Definition: stratlith.h:83
Set of BufferString objects.
Definition: bufstringset.h:25
bool isUdf() const
Definition: stratlith.h:45
ID id() const
Definition: stratlith.h:48
Class to help setup a callback handling.
Definition: notify.h:121
Set of pointers to objects.
Definition: commontypes.h:28
Lithology & getLith(int i)
Definition: stratlith.h:80
int indexOf(Lithology::ID id) const
Definition: stratlith.h:85
static bool isUdf(ID id)
Definition: stratlith.h:46
a name and an ID.
Definition: stratlith.h:32
int ID
Definition: stratlith.h:36
int size() const
Definition: stratlith.h:78
ManagedObjectSet< Lithology > lths_
Definition: stratlith.h:101
virtual void erase()
Definition: manobjectset.h:141
Lithology * gtLith(const char *nm, Lithology::ID id) const
Definition: stratlith.h:104
bool porous_
Definition: stratlith.h:59
const ObjectSet< Lithology > & lithologies() const
Definition: stratlith.h:114
Stratigraphy.
Definition: stratlevel.h:25
const Lithology & getLith(int i) const
Definition: stratlith.h:81
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
LithologySet()
Definition: stratlith.h:75
const Color & color() const
Definition: stratlith.h:52
object with a name.
Definition: namedobj.h:20
Lithology(const Lithology &l)
Definition: stratlith.h:39
Color & color()
Definition: stratlith.h:51
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:24
bool isPresent(Lithology::ID id) const
Definition: stratlith.h:86
const ID id_
Definition: stratlith.h:58
ObjectSet where the objects contained are owned by this set.
Definition: manobjectset.h:49
ObjectSet< Lithology > & lithologies()
Definition: stratlith.h:115
bool isPresent(const char *nm) const
Definition: stratlith.h:84
bool isEmpty() const
Definition: stratlith.h:79
bool porous() const
Definition: stratlith.h:50
void reportAnyChange()
Definition: stratlith.h:96

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