OpendTect  6.6
picksetmgr.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
8  Date: May 2001 / Mar 2016
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "pickset.h"
14 #include "multiid.h"
15 #include "undo.h"
16 
17 
18 namespace Pick
19 {
20 
33 mExpClass(General) SetMgr : public NamedCallBacker
34 {
35 public:
36 
38  int size() const { return pss_.size(); }
39  Set& get( int idx ) { return *pss_[idx]; }
40  const Set& get( int idx ) const { return *pss_[idx]; }
41  const MultiID& id( int idx ) const;
42 
43  int indexOf(const char*) const;
44  int indexOf(const Set&) const;
45  int indexOf(const MultiID&) const;
46 
47  // Convenience. Check indexOf() if presence is not sure
48  Set& get( const MultiID& i ) { return *find(i); }
49  const Set& get( const MultiID& i ) const { return *find(i); }
50  const MultiID& get( const Set& s ) const { return *find(s); }
51  Set& get( const char* s ) { return *find(s); }
52  const Set& get( const char* s ) const { return *find(s); }
53 
54  void set(const MultiID&,Set*);
58  void setID(int idx,const MultiID&);
59 
60  struct ChangeData : public CallBacker
61  {
62  enum Ev { Added, Changed, ToBeRemoved };
63 
64  ChangeData( Ev e, const Set* s, int l )
65  : ev_(e), set_(s), loc_(l) {}
66 
68  const Set* set_;
69  const int loc_;
70  //<refers to the idx in set_
71  };
72 
73  void reportChange(CallBacker* sender,const ChangeData&);
74  void reportChange(CallBacker* sender,const Set&);
75  void reportDispChange(CallBacker* sender,const Set&);
76 
82 
83  struct BulkChangeData : public CallBacker
84  {
85  enum Ev { Added, ToBeRemoved };
86 
87  BulkChangeData( Ev e, const Set* s,
88  const TypeSet<int>& l )
89  : ev_(e), set_(s), locs_(l) {}
90 
92  const Set* set_;
94  //<refers to the indexes in set_ (sorted)
95  };
96 
98  const BulkChangeData&);
100 
102 
103  bool isChanged( int idx ) const
104  { return idx < changed_.size()
105  ? (bool) changed_[idx] : false;}
106  void setUnChanged( int idx, bool yn=true )
107  { if ( changed_.validIdx(idx) ) changed_[idx] = !yn; }
108 
109  Undo& undo();
110  const Undo& undo() const;
111 
113  bool readDisplayPars(const MultiID&,IOPar&) const;
114  bool writeDisplayPars(const MultiID&,const IOPar&) const;
115 
116  static SetMgr& getMgr(const char*);
117 
118  SetMgr( const char* nm );
121 
122 protected:
123 
128 
129  void add(const MultiID&,Set*);
130  Set* find(const MultiID&) const;
131  MultiID* find(const Set&) const;
132  Set* find(const char*) const;
133 
136  void removeAll();
137 };
138 
139 inline SetMgr& Mgr();
140 
141 } // namespace Pick
142 
143 
145 {
146  return SetMgr::getMgr(0);
147 }
148 
149 
Pick::SetMgr::BulkChangeData::set_
const Set * set_
Definition: picksetmgr.h:92
Pick::SetMgr::removeAll
void removeAll()
Pick::SetMgr::BulkChangeData
Definition: picksetmgr.h:84
Pick::SetMgr::reportChange
void reportChange(CallBacker *sender, const Set &)
Pick::SetMgr::indexOf
int indexOf(const MultiID &) const
Pick::SetMgr::indexOf
int indexOf(const Set &) const
Pick::SetMgr::readDisplayPars
bool readDisplayPars(const MultiID &, IOPar &) const
Pick::SetMgr::size
int size() const
Definition: picksetmgr.h:38
Pick::SetMgr::ChangeData::set_
const Set * set_
Definition: picksetmgr.h:68
Pick::Set
Set of picks with something in common.
Definition: pickset.h:34
Pick::SetMgr::set
void set(const MultiID &, Set *)
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
Pick::SetMgr::SetMgr
SetMgr(const char *nm)
Pick::SetMgr::ChangeData::ChangeData
ChangeData(Ev e, const Set *s, int l)
Definition: picksetmgr.h:64
ObjectSet
Set of pointers to objects.
Definition: commontypes.h:31
Pick::SetMgr::setAdded
Notifier< SetMgr > setAdded
passes Set*
Definition: picksetmgr.h:79
Pick::SetMgr::setChanged
Notifier< SetMgr > setChanged
passes Set*
Definition: picksetmgr.h:80
Pick::SetMgr::add
void add(const MultiID &, Set *)
Pick::SetMgr::get
const Set & get(const char *s) const
Definition: picksetmgr.h:52
Pick::SetMgr::reportDispChange
void reportDispChange(CallBacker *sender, const Set &)
Pick::SetMgr::ChangeData::ev_
Ev ev_
Definition: picksetmgr.h:67
Pick
Definition: picklocation.h:21
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
Pick::SetMgr::objRm
void objRm(CallBacker *)
Pick::SetMgr::getDispFileName
static BufferString getDispFileName(const MultiID &)
Pick::SetMgr::setUnChanged
void setUnChanged(int idx, bool yn=true)
Definition: picksetmgr.h:106
CallBacker
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
Pick::SetMgr::find
Set * find(const MultiID &) const
Pick::SetMgr::setToBeRemoved
Notifier< SetMgr > setToBeRemoved
Passes Set*.
Definition: picksetmgr.h:78
Pick::SetMgr::BulkChangeData::ev_
Ev ev_
Definition: picksetmgr.h:91
Pick::SetMgr::changed_
BoolTypeSet changed_
Definition: picksetmgr.h:127
Pick::SetMgr::survChg
void survChg(CallBacker *)
multiid.h
Pick::SetMgr::BulkChangeData::locs_
TypeSet< int > locs_
Definition: picksetmgr.h:93
Pick::SetMgr::get
Set & get(const char *s)
Definition: picksetmgr.h:51
Pick::SetMgr::undo_
Undo & undo_
Definition: picksetmgr.h:124
find
const BufferString * find(const BufferStringSet &, const char *)
Pick::SetMgr::get
const Set & get(int idx) const
Definition: picksetmgr.h:40
Pick::SetMgr
Utility to manage pick set lifecycles. Also supports change notifications.
Definition: picksetmgr.h:34
undo.h
Pick::SetMgr::removeCBs
void removeCBs(CallBacker *)
Pick::SetMgr::locationChanged
Notifier< SetMgr > locationChanged
Passes ChangeData*.
Definition: picksetmgr.h:77
Pick::SetMgr::undo
const Undo & undo() const
Pick::SetMgr::getMgr
static SetMgr & getMgr(const char *)
Notifier
Class to help setup a callback handling.
Definition: notify.h:126
Pick::SetMgr::ChangeData::loc_
const int loc_
Definition: picksetmgr.h:69
Pick::SetMgr::ChangeData
Definition: picksetmgr.h:61
Pick::SetMgr::undo
Undo & undo()
Pick::SetMgr::get
Set & get(int idx)
Definition: picksetmgr.h:39
Pick::Mgr
SetMgr & Mgr()
Definition: picksetmgr.h:144
pickset.h
Pick::SetMgr::BulkChangeData::Ev
Ev
Definition: picksetmgr.h:85
Pick::SetMgr::BulkChangeData::BulkChangeData
BulkChangeData(Ev e, const Set *s, const TypeSet< int > &l)
Definition: picksetmgr.h:87
MultiID
Compound key consisting of ints.
Definition: multiid.h:24
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
Pick::SetMgr::reportChange
void reportChange(CallBacker *sender, const ChangeData &)
Pick::SetMgr::isChanged
bool isChanged(int idx) const
Definition: picksetmgr.h:103
Pick::SetMgr::pss_
ObjectSet< Set > pss_
Definition: picksetmgr.h:125
Pick::SetMgr::writeDisplayPars
bool writeDisplayPars(const MultiID &, const IOPar &) const
Pick::SetMgr::get
const MultiID & get(const Set &s) const
Definition: picksetmgr.h:50
Pick::SetMgr::id
const MultiID & id(int idx) const
Pick::SetMgr::get
Set & get(const MultiID &i)
Definition: picksetmgr.h:48
Pick::SetMgr::find
MultiID * find(const Set &) const
Pick::SetMgr::setDispChanged
Notifier< SetMgr > setDispChanged
passes Set*
Definition: picksetmgr.h:81
Pick::SetMgr::reportBulkChange
void reportBulkChange(CallBacker *sender, const BulkChangeData &)
Pick::SetMgr::indexOf
int indexOf(const char *) const
Pick::SetMgr::ChangeData::Ev
Ev
Definition: picksetmgr.h:62
Pick::SetMgr::get
const Set & get(const MultiID &i) const
Definition: picksetmgr.h:49
Pick::SetMgr::find
Set * find(const char *) const
Pick::SetMgr::~SetMgr
~SetMgr()
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
Pick::SetMgr::setID
void setID(int idx, const MultiID &)
Pick::SetMgr::ids_
TypeSet< MultiID > ids_
Definition: picksetmgr.h:126
Pick::SetMgr::bulkLocationChanged
Notifier< SetMgr > bulkLocationChanged
Passes BulkChangeData*.
Definition: picksetmgr.h:99
TypeSet< int >
Undo
Class to handle undo/redo information.
Definition: undo.h:42

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