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

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