OpendTect-6_4  6.4
stratlevel.h
Go to the documentation of this file.
1 #ifndef stratlevel_h
2 #define stratlevel_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
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "generalmod.h"
16 #include "undefval.h"
17 #include "namedobj.h"
18 #include "ranges.h"
19 #include "color.h"
20 #include "repos.h"
21 #include "objectset.h"
22 class ascistream;
23 class BufferStringSet;
24 
25 
26 namespace Strat
27 {
28 class LevelSet;
29 
30 
42 mExpClass(General) Level : public NamedObject
43 {
44 public:
45 
46  typedef int ID;
47 
48  bool operator ==(const Level&) const;
49  bool isDifferentFrom(const Level&) const;
50 
51  ID id() const { return id_; }
52  Color color() const { return color_; }
53  const IOPar& pars() const { return pars_; }
54 
55  void setName(const char*);
56  void setColor(Color);
57  void setPars(const IOPar&);
58 
61 
62  static const Level& undef();
63 
64 protected:
65 
66  Level(const char* nm,const LevelSet*);
67  Level(const Level&);
68 
69  ID id_;
72  const LevelSet* lvlset_;
73 
74  void fillPar(IOPar&) const;
75  void usePar(const IOPar&);
76 
77  friend class LevelSet;
78 
79 public:
80 
81  virtual ~Level();
82 
83  const char* checkName(const char*) const;
86 
87 };
88 
89 
99 mExpClass(General) LevelSet : public CallBacker
100 {
101 public:
102 
103  LevelSet();
104  LevelSet(Level::ID startat);
105  LevelSet(const LevelSet&);
106  virtual ~LevelSet();
107  LevelSet& operator =(const LevelSet&);
108 
109  bool isEmpty() const { return lvls_.isEmpty(); }
110  int size() const { return lvls_.size(); }
111  const ObjectSet<Level>& levels() const { return lvls_; }
112  void setEmpty() { lvls_.erase(); }
113 
114  inline bool isPresent( const char* nm ) const
115  { return gtIdxOf(nm,-1) >= 0; }
116  inline bool isPresent( Level::ID id ) const
117  { return gtIdxOf(0,id) >= 0; }
118  inline int indexOf( const char* nm ) const
119  { return gtIdxOf(nm,-1); }
120  inline int indexOf( Level::ID id ) const
121  { return gtIdxOf(0,id); }
122 
123  Level* get( const char* nm ) { return gtLvl(nm,-1); }
124  const Level* get( const char* nm ) const { return gtLvl(nm,-1); }
125  Level* get( Level::ID id ) { return gtLvl(0,id); }
126  const Level* get( Level::ID id ) const { return gtLvl(0,id); }
127 
128  Level* add( const char* lvlnm, const Color& c )
129  { return set(lvlnm,c,-1); }
130  Level* insert( const char* lvlnm, const Color& c ,int idx=-1 )
131  { return set(lvlnm,c,idx); }
132  Level* set( const char* lvlnm, const Color& c )
133  { return set(lvlnm,c,-1); }
134  void remove(Level::ID);
135 
136  Level* add(const Level&);
137  void add(const BufferStringSet&,const TypeSet<Color>&);
138 
142  int notifLvlIdx() const { return notiflvlidx_; }
144 
145  bool readFrom(const char*);
146  bool writeTo(const char*) const;
147  bool needStore() const { return ischanged_; }
148 
149  static void getStdNames(BufferStringSet&);
150  static LevelSet* createStd(const char*);
151  static LevelSet* read(const MultiID&);
152  static bool write(const LevelSet&,const MultiID&);
153 
154  inline const Level& getLevel( int idx ) const
155  { return idx<size() ? *lvls_[idx] : Level::undef(); }
156  int levelID( int idx ) const
157  { return getLevel(idx).id(); }
158  Color color( int idx ) const
159  { return getLevel(idx).color(); }
160  void getNames(BufferStringSet&) const;
161 
162 protected:
163 
165 
166  mutable int notiflvlidx_;
169 
170  Level* getNew(const Level* lvl=0) const;
171  Level* set(const char*,const Color&,int);
172  int gtIdxOf(const char*,Level::ID) const;
173  Level* gtLvl(const char*,Level::ID) const;
174  void addLvl(Level*);
175  void getLevelsFrom(const LevelSet&);
176  void makeMine(Level&);
177  void readPars(ascistream&,bool);
178 
179  void lvlChgCB( CallBacker* cb ) { notif(cb,true); }
180  void lvlRemCB( CallBacker* cb ) { notif(cb,false); }
181  void notif(CallBacker*,bool);
182 
183  static bool haveCurSet();
184 
185 public:
186 
187  Repos::Source readOldRepos();
188  friend class LevelSetMgr;
189 
190  bool store(Repos::Source) const;
191  bool read(Repos::Source);
192 };
193 
194 mGlobal(General) const LevelSet& LVLS();
195 inline LevelSet& eLVLS() { return const_cast<LevelSet&>(LVLS()); }
196 
197 // Needless to say that if you push, make sure you pop (so afterwards the real
198 // default levels are restored
199 mGlobal(General) void pushLevelSet(LevelSet*);
200 mGlobal(General) void popLevelSet();
201 mGlobal(General) const LevelSet& unpushedLVLS();
202 
203 mGlobal(General) void setLVLS(LevelSet*);
204 
205 mGlobal(General) BufferString getStdFileName(const char* inpnm,const char* basenm);
207 
208 } // namespace Strat
209 
210 #endif
#define mExpClass(module)
Definition: commondefs.h:160
const LevelSet * lvlset_
Definition: stratlevel.h:72
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Set of Stratigraphic levels.
Definition: stratlevel.h:99
void popLevelSet()
Level * add(const char *lvlnm, const Color &c)
Definition: stratlevel.h:128
void setLVLS(LevelSet *)
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
FixedString Level()
Definition: keystrs.h:78
Level * insert(const char *lvlnm, const Color &c, int idx=-1)
Definition: stratlevel.h:130
#define mGlobal(module)
Definition: commondefs.h:163
IOPar & pars_
Definition: stratlevel.h:71
Notifier< Level > toBeRemoved
Definition: stratlevel.h:60
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
void lvlChgCB(CallBacker *cb)
Definition: stratlevel.h:179
bool isPresent(const char *nm) const
Definition: stratlevel.h:114
int notiflvlidx_
Definition: stratlevel.h:166
ID id_
Definition: stratlevel.h:69
void lvlRemCB(CallBacker *cb)
Definition: stratlevel.h:180
int size() const
Definition: stratlevel.h:110
Notifier< LevelSet > levelToBeRemoved
Definition: stratlevel.h:141
bool isEmpty() const
Definition: stratlevel.h:109
void setEmpty()
Definition: stratlevel.h:112
Set of BufferString objects.
Definition: bufstringset.h:28
ObjectSet< Level > lvls_
Definition: stratlevel.h:164
const LevelSet & LVLS()
const LevelSet & unpushedLVLS()
int notifLvlIdx() const
if < 0 then more than one level have changed
Definition: stratlevel.h:142
Level::ID lastlevelid_
Definition: stratlevel.h:167
Definition: callback.h:254
Set of pointers to objects.
Definition: commontypes.h:32
Color color_
Definition: stratlevel.h:70
Stratigraphic level.
Definition: stratlevel.h:42
int levelID(int idx) const
Definition: stratlevel.h:156
int ID
Definition: stratlevel.h:46
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
const ObjectSet< Level > & levels() const
Definition: stratlevel.h:111
Source
Definition: repos.h:25
Notifier< LevelSet > levelChanged
Definition: stratlevel.h:140
int indexOf(Level::ID id) const
Definition: stratlevel.h:120
const Level & getLevel(int idx) const
Definition: stratlevel.h:154
bool isPresent(Level::ID id) const
Definition: stratlevel.h:116
ID id() const
Definition: stratlevel.h:51
const IOPar & pars() const
Definition: stratlevel.h:53
Notifier< LevelSet > levelAdded
Definition: stratlevel.h:139
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
int indexOf(const char *nm) const
Definition: stratlevel.h:118
OpendTect standard ascii format file reading.
Definition: ascstream.h:83
LevelSet & eLVLS()
Definition: stratlevel.h:195
Stratigraphy.
Definition: stratlevel.h:26
bool needStore() const
Definition: stratlevel.h:147
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Notifier< Level > changed
Definition: stratlevel.h:59
Object with a name.
Definition: namedobj.h:35
BufferString getStdFileName(const char *inpnm, const char *basenm)
example: getStdFileName("North Sea","Levels")
Color color() const
Definition: stratlevel.h:52
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
static const Level & undef()
bool ischanged_
Definition: stratlevel.h:168
Color color(int idx) const
Definition: stratlevel.h:158
void pushLevelSet(LevelSet *)
Compound key consisting of ints.
Definition: multiid.h:25

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