OpendTect-6_4  6.4
picksetmgr.h
Go to the documentation of this file.
1 #ifndef picksetmgr_h
2 #define picksetmgr_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: May 2001 / Mar 2016
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "pickset.h"
15 #include "multiid.h"
16 #include "undo.h"
17 
18 
19 namespace Pick
20 {
21 
34 mExpClass(General) SetMgr : public NamedObject
35 {
36 public:
37 
38  ~SetMgr();
39  int size() const { return pss_.size(); }
40  Set& get( int idx ) { return *pss_[idx]; }
41  const Set& get( int idx ) const { return *pss_[idx]; }
42  const MultiID& id( int idx ) const;
43 
44  int indexOf(const char*) const;
45  int indexOf(const Set&) const;
46  int indexOf(const MultiID&) const;
47 
48  // Convenience. Check indexOf() if presence is not sure
49  Set& get( const MultiID& i ) { return *find(i); }
50  const Set& get( const MultiID& i ) const { return *find(i); }
51  const MultiID& get( const Set& s ) const { return *find(s); }
52  Set& get( const char* s ) { return *find(s); }
53  const Set& get( const char* s ) const { return *find(s); }
54 
55  void set(const MultiID&,Set*);
59  void setID(int idx,const MultiID&);
60 
61  struct ChangeData : public CallBacker
62  {
63  enum Ev { Added, Changed, ToBeRemoved };
64 
65  ChangeData( Ev e, const Set* s, int l )
66  : ev_(e), set_(s), loc_(l) {}
67 
69  const Set* set_;
70  const int loc_;
71  //<refers to the idx in set_
72  };
73 
74  void reportChange(CallBacker* sender,const ChangeData&);
75  void reportChange(CallBacker* sender,const Set&);
76  void reportDispChange(CallBacker* sender,const Set&);
77 
83  void removeCBs(CallBacker*);
84 
85  bool isChanged( int idx ) const
86  { return idx < changed_.size()
87  ? (bool) changed_[idx] : false;}
88  void setUnChanged( int idx, bool yn=true )
89  { if ( changed_.validIdx(idx) ) changed_[idx] = !yn; }
90 
91  Undo& undo();
92  const Undo& undo() const;
93 
94  static BufferString getDispFileName(const MultiID&);
95  bool readDisplayPars(const MultiID&,IOPar&) const;
96  bool writeDisplayPars(const MultiID&,const IOPar&) const;
97 
98  static SetMgr& getMgr(const char*);
99 
100  SetMgr( const char* nm );
103 
104 protected:
105 
110 
111  void add(const MultiID&,Set*);
112  Set* find(const MultiID&) const;
113  MultiID* find(const Set&) const;
114  Set* find(const char*) const;
115 
116  void survChg(CallBacker*);
117  void objRm(CallBacker*);
118  void removeAll();
119 };
120 
121 inline SetMgr& Mgr();
122 
123 } // namespace Pick
124 
125 
127 {
128  return SetMgr::getMgr(0);
129 }
130 
131 
132 #endif
const Set * set_
Definition: picksetmgr.h:69
#define mExpClass(module)
Definition: commondefs.h:160
Notifier< SetMgr > setDispChanged
passes Set*
Definition: picksetmgr.h:82
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Ev
Definition: picksetmgr.h:63
Undo & undo_
Definition: picksetmgr.h:106
Notifier< SetMgr > setAdded
passes Set*
Definition: picksetmgr.h:80
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
Ev ev_
Definition: picksetmgr.h:68
bool isChanged(int idx) const
Definition: picksetmgr.h:85
Class to handle undo/redo information.
Definition: undo.h:42
Definition: callback.h:254
Set of picks with something in common.
Definition: pickset.h:31
Set of pointers to objects.
Definition: commontypes.h:32
const int loc_
Definition: picksetmgr.h:70
Notifier< SetMgr > locationChanged
Passes ChangeData*.
Definition: picksetmgr.h:78
void removeAll()
Notifier< SetMgr > setChanged
passes Set*
Definition: picksetmgr.h:81
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Notifier< SetMgr > setToBeRemoved
Passes Set*.
Definition: picksetmgr.h:79
void setUnChanged(int idx, bool yn=true)
Definition: picksetmgr.h:88
BoolTypeSet changed_
Definition: picksetmgr.h:109
const T * find(const ObjectSet< T > &os, const S &val)
Get const object in set.
Definition: objectset.h:183
static SetMgr & getMgr(const char *)
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Object with a name.
Definition: namedobj.h:35
Definition: picklocation.h:21
TypeSet< MultiID > ids_
Definition: picksetmgr.h:108
int size() const
Definition: picksetmgr.h:39
SetMgr & Mgr()
Definition: picksetmgr.h:126
Definition: picksetmgr.h:61
Utility to manage pick set lifecycles. Also supports change notifications.
Definition: picksetmgr.h:34
ObjectSet< Set > pss_
Definition: picksetmgr.h:107
ChangeData(Ev e, const Set *s, int l)
Definition: picksetmgr.h:65
Compound key consisting of ints.
Definition: multiid.h:25

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