OpendTect-6_4  6.4
emobject.h
Go to the documentation of this file.
1 #ifndef emobject_h
2 #define emobject_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Kristofer Tingdahl
9  Date: 4-11-2002
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 -*/
15 
16 #include "earthmodelmod.h"
17 #include "bufstring.h"
18 #include "callback.h"
19 #include "trckeyzsampling.h"
20 #include "draw.h"
21 #include "emposid.h"
22 #include "multiid.h"
23 #include "coord.h"
24 #include "refcount.h"
25 #include "uistring.h"
26 
27 class TrcKeyZSampling;
28 class Executor;
29 class IOObj;
30 class IOObjContext;
31 class TaskRunner;
32 
33 namespace Geometry { class Element; }
34 
35 template <class T> class Selector;
36 template <class T> class Array2D;
37 
38 namespace EM
39 {
40 class EMManager;
41 
47 {
48 public:
50  : pid0( 0, 0, 0 )
51  , pid1( 0, 0, 0 )
52  , attrib( -1 )
53  , flagfor2dviewer( false )
54  , event( EMObjectCallbackData::Undef )
55  {}
56 
57 
58  EMObjectCallbackData( const EMObjectCallbackData& data )
59  : pid0( data.pid0 )
60  , pid1( data.pid1 )
61  , attrib( data.attrib )
62  , flagfor2dviewer( data.flagfor2dviewer )
63  , event( data.event )
64  {}
65 
66 
67  enum Event { Undef, PositionChange, PosIDChange, PrefColorChange, Removal,
68  AttribChange, SectionChange, NameChange, SelectionChange,
69  LockChange, BurstAlert, LockColorChange } event;
70 
72  EM::PosID pid1; //Only used in PosIDChange
73  int attrib; //Used only with AttribChange
74  bool flagfor2dviewer; //Used only with BurstAlert for 2DViewer
75 };
76 
77 
78 
83 mExpClass(EarthModel) CBDataSet
84 {
85 public:
87 {
88  Threads::Locker locker( lock_ );
89  emcallbackdata_ += data;
90 }
91 
93 {
94  Threads::Locker locker( lock_ );
95  return emcallbackdata_.validIdx(idx) ? emcallbackdata_[idx] : 0;
96 }
97 
98 void clearData()
99 {
100  Threads::Locker locker( lock_ );
101  deepErase( emcallbackdata_ );
102 }
103 
104 int size() const
105 {
106  return emcallbackdata_.size();
107 }
108 
109 protected:
112 };
113 
114 
115 
123 {
124 public:
125  virtual ~EMObjectIterator() {}
126  virtual EM::PosID next() = 0;
128  virtual int approximateSize() const { return maximumSize(); }
129  virtual int maximumSize() const { return -1; }
130  virtual bool canGoTo() const { return false; }
131  virtual EM::PosID goTo(od_int64) { return EM::PosID(-1,-1,-1); }
132 };
133 
134 
139 mExpClass(EarthModel) PosAttrib
140 {
141 public:
143 
144  enum Type { PermanentControlNode, TemporaryControlNode,
145  EdgeControlNode, TerminationNode, SeedNode,
146  IntersectionNode };
147 
150  bool locked_;
151 };
152 
153 
158 mExpClass(EarthModel) EMObject : public CallBacker
159 {
160 mRefCountImplWithDestructor(EMObject,virtual ~EMObject(),
161 { prepareForDelete(); delete this; } );
162 public:
163  enum NodeSourceType { None = (int)'0', Manual=(int)'1',
164  Auto=(int)'2', Gridding=(int)'3' };
165 
166  const ObjectID& id() const { return id_; }
167  virtual const char* getTypeStr() const = 0;
168  virtual uiString getUserTypeStr() const = 0;
169  const MultiID& multiID() const { return storageid_; }
170  void setMultiID(const MultiID&);
171 
172  virtual bool isOK() const { return true; }
173 
174  void setName( const char* nm ) { objname_ = nm; }
176  BufferString name() const;
177  uiString uiName() const { return toUiString(name()); }
178  virtual void setNewName();
179 
180  virtual int nrSections() const = 0;
181  virtual SectionID sectionID(int) const = 0;
182  virtual BufferString sectionName(const SectionID&) const;
183  virtual bool canSetSectionName() const;
184  virtual bool setSectionName(const SectionID&,const char*,
185  bool addtohistory);
186  virtual int sectionIndex(const SectionID&) const;
187  virtual bool removeSection(SectionID,bool hist )
188  { return false; }
189 
190  const Geometry::Element* sectionGeometry(const SectionID&) const;
191  Geometry::Element* sectionGeometry(const SectionID&);
192 
193  const Color& preferredColor() const;
194  void setPreferredColor(const Color&,
195  bool addtohistory=false);
196  const OD::LineStyle& preferredLineStyle() const;
197  void setPreferredLineStyle(const OD::LineStyle&);
198  void setBurstAlert(bool yn);
199  bool hasBurstAlert() const;
200 
201  virtual Coord3 getPos(const EM::PosID&) const;
202  virtual Coord3 getPos(const EM::SectionID&,
203  const EM::SubID&) const;
204  virtual bool isDefined(const EM::PosID&) const;
205  virtual bool isDefined(const EM::SectionID&,
206  const EM::SubID&) const;
207  virtual bool setPos(const EM::PosID&,const Coord3&,
208  bool addtohistory);
209  virtual bool setPos(const EM::SectionID&,const EM::SubID&,
210  const Coord3&,bool addtohistory);
211  virtual bool unSetPos(const EM::PosID&,bool addtohistory);
212  virtual bool unSetPos(const EM::SectionID&,const EM::SubID&,
213  bool addtohistory);
214  virtual void setNodeSourceType(const TrcKey&,
215  NodeSourceType){};
216  virtual bool isNodeSourceType(const PosID&,
217  NodeSourceType) const {return false;}
218  virtual bool isNodeSourceType(const TrcKey&,
219  NodeSourceType)const {return false;}
220 
221  virtual void setNodeLocked(const TrcKey&,bool locked){};
222  virtual bool isNodeLocked(const TrcKey&) const
223  { return false; }
224  virtual bool isNodeLocked(const PosID&)const {return false;}
225 
226  virtual void lockAll() {};
227  virtual void unlockAll(){};
228  virtual const Array2D<char>*
229  getLockedNodes() const { return 0; }
230  virtual void setLockColor(const Color&);
231  virtual const Color& getLockColor() const;
232  virtual bool hasLockedNodes() const {return haslockednodes_;}
233  virtual bool hasNodeSourceType( const PosID& ) const
234  { return false; }
235 
236  void setSelectionColor(const Color&);
237  const Color& getSelectionColor() const;
238 
239  virtual bool enableGeometryChecks(bool);
240  virtual bool isGeometryChecksEnabled() const;
241 
242  virtual bool isAtEdge(const EM::PosID&) const;
243 
244  void changePosID(const EM::PosID& from,
245  const EM::PosID& to,
246  bool addtohistory);
252  virtual void getLinkedPos(const EM::PosID& posid,
253  TypeSet<EM::PosID>&) const
254  { return; }
260  const TrcKeyZSampling* =0) const
261  { return 0; }
265  virtual int nrPosAttribs() const;
266  virtual int posAttrib(int idx) const;
267  virtual void addPosAttrib(int attr);
268  virtual void removePosAttribList(int attr,
269  bool addtohistory=true);
270  virtual void setPosAttrib(const EM::PosID&,
271  int attr,bool yn,bool addtohistory=true);
273  virtual bool isPosAttrib(const EM::PosID&,int attr) const;
274  virtual const char* posAttribName(int) const;
275  virtual int addPosAttribName(const char*);
276  const TypeSet<PosID>* getPosAttribList(int attr) const;
277  const MarkerStyle3D& getPosAttrMarkerStyle(int attr);
278  void setPosAttrMarkerStyle(int attr,
279  const MarkerStyle3D&);
280  virtual void lockPosAttrib(int attr,bool yn);
281  virtual bool isPosAttribLocked(int attr) const;
282  virtual void removeSelected(const Selector<Coord3>&,
283  TaskRunner*);
284  void removeSelected(const TypeSet<EM::SubID>&);
285 
286  void removeListOfSubIDs(const TypeSet<EM::SubID>&,
287  const EM::SectionID&);
288  void removeAllUnSeedPos();
289  const TrcKeyZSampling getRemovedPolySelectedPosBox();
290  void emptyRemovedPolySelectedPosBox();
291 
293 
294  virtual Executor* loader() { return 0; }
295  virtual bool isLoaded() const { return false; }
296  virtual Executor* saver() { return 0; }
297  virtual bool isChanged() const { return changed_; }
298  virtual bool isEmpty() const;
299  virtual void setChangedFlag() { changed_=true; }
300  virtual void resetChangedFlag() { changed_=false; }
301  bool isFullyLoaded() const { return fullyloaded_; }
302  void setFullyLoaded(bool yn) { fullyloaded_=yn; }
303 
304  virtual bool isLocked() const { return locked_; }
305  virtual void lock(bool yn) { locked_=yn;}
306 
307  bool isInsideSelRemoval() const
308  { return insideselremoval_; }
309  bool isSelRemoving() const { return selremoving_; }
310 
311  uiString errMsg() const;
312  void setErrMsg(const uiString& m) { errmsg_ = m; }
313 
314  virtual bool usePar(const IOPar&);
315  virtual void fillPar(IOPar&) const;
316  void saveDisplayPars() const;
317 
318  virtual bool useDisplayPar(const IOPar&);
319  virtual void fillDisplayPar(IOPar&) const;
320 
321  static int sPermanentControlNode();
322  static int sTemporaryControlNode();
323  static int sEdgeControlNode();
324  static int sTerminationNode();
325  static int sSeedNode();
326  static int sIntersectionNode();
327 
328  virtual const IOObjContext& getIOObjContext() const = 0;
329 
330 protected:
331  EMObject( EMManager& );
333  virtual Geometry::Element* sectionGeometryInternal(const SectionID&);
334  virtual void prepareForDelete() const;
335  void posIDChangeCB(CallBacker*);
336  const MarkerStyle3D& preferredMarkerStyle3D() const;
337  void setPreferredMarkerStyle3D(const MarkerStyle3D&);
338  void useDisplayPars(const IOPar&);
344 
350 
352 
353  bool changed_;
355  bool locked_;
361 
364 
365  static const char* nrposattrstr();
366  static const char* posattrprefixstr();
367  static const char* posattrsectionstr();
368  static const char* posattrposidstr();
369 };
370 
371 } // namespace EM
372 
373 #define mDefineEMObjFuncs( clss ) \
374 mODTextTranslationClass( clss ); \
375 public: \
376  clss(EM::EMManager&); \
377  static void initClass(); \
378  static EMObject* create(EM::EMManager&); \
379  static clss* create(const char* nm); \
380  static FixedString typeStr(); \
381  const char* getTypeStr() const; \
382  void setNewName(); \
383 protected: \
384  ~clss()
385 
386 #define mImplementEMObjFuncs( clss, typenm ) \
387 void clss::initClass() \
388 { \
389  EMOF().addCreator( create, typeStr() ); \
390 } \
391  \
392  \
393 EMObject* clss::create( EM::EMManager& emm ) \
394 { \
395  EMObject* obj = new clss( emm ); \
396  if ( !obj ) return 0; \
397  obj->ref(); \
398  emm.addObject( obj ); \
399  obj->unRefNoDelete(); \
400  return obj; \
401 } \
402 \
403 clss* clss::create( const char* nm ) \
404 { \
405  const ObjectID objid = EMM().createObject( typeStr(), nm ); \
406  EMObject* emobj = EMM().getObject( objid ); \
407  mDynamicCastGet(clss*,newobj,emobj); \
408  return newobj; \
409 } \
410 \
411 FixedString clss::typeStr() { return typenm; } \
412 const char* clss::getTypeStr() const { return typeStr(); } \
413 void clss::setNewName() \
414 {\
415  static int objnr = 1; \
416  BufferString nm( "<New ", typenm, " " ); \
417  nm.add( objnr++ ).add( ">" ); \
418  setName( nm ); \
419 }
420 
421 #endif
od_int16 SectionID
Definition: emposid.h:25
#define mExpClass(module)
Definition: commondefs.h:160
od_int32 ObjectID
Definition: emposid.h:24
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
BufferString objname_
Definition: emobject.h:339
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:85
Definition: ioobj.h:58
virtual void getLinkedPos(const EM::PosID &posid, TypeSet< EM::PosID > &) const
Definition: emobject.h:252
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:53
T to(const F &fr)
Definition: convert.h:33
Event
Definition: emobject.h:67
FixedString Undef()
Definition: keystrs.h:142
virtual bool isNodeSourceType(const TrcKey &, NodeSourceType) const
Definition: emobject.h:218
Export_Basic uiString toUiString(ViewStyle)
Is an identifier for each position in the earthmodel.
Definition: emposid.h:37
bool locked_
Definition: emobject.h:355
Color & preferredcolor_
Definition: emobject.h:345
virtual int approximateSize() const
Definition: emobject.h:128
virtual bool hasLockedNodes() const
Definition: emobject.h:232
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
#define od_int64
Definition: plftypes.h:36
Definition: draw.h:118
ObjectSet< PosAttrib > posattribs_
Definition: emobject.h:348
Type type_
Definition: emobject.h:148
virtual void unlockAll()
Definition: emobject.h:227
Position attribute.
Definition: emobject.h:139
TypeSet< int > attribs_
Definition: emobject.h:349
bool isSelRemoving() const
Definition: emobject.h:309
TypeSet< PosID > posids_
Definition: emobject.h:149
int attrib
Definition: emobject.h:73
Thread safe set of EMObjectCallbackData.
Definition: emobject.h:83
EM::PosID pid0
Definition: emobject.h:71
uiString uiName() const
Definition: emobject.h:177
Definition: uistring.h:89
virtual bool isOK() const
Definition: emobject.h:172
EMObjectCallbackData()
Definition: emobject.h:49
od_int64 SubID
Definition: emposid.h:26
virtual void setNodeLocked(const TrcKey &, bool locked)
Definition: emobject.h:221
FixedString None()
Definition: keystrs.h:90
Definition: emobject.h:145
ObjectSet< EMObjectCallbackData > emcallbackdata_
Definition: emobject.h:110
class EMManager & manager_
Definition: emobject.h:342
void setErrMsg(const uiString &m)
Definition: emobject.h:312
Set of pointers to objects.
Definition: commontypes.h:32
virtual void setChangedFlag()
Definition: emobject.h:299
Iterator that iterates a number of positions (normally all) on an EMObject. The object is created by ...
Definition: emobject.h:122
MultiID storageid_
Definition: emobject.h:341
void addCallBackData(EM::EMObjectCallbackData *data)
Definition: emobject.h:86
bool haslockednodes_
Definition: emobject.h:358
virtual bool isNodeLocked(const TrcKey &) const
Definition: emobject.h:222
virtual int maximumSize() const
Definition: emobject.h:129
Set of (small) copyable elements.
Definition: commontypes.h:30
int burstalertcount_
Definition: emobject.h:356
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:131
Class that can execute a task.
Definition: task.h:169
bool insideselremoval_
Definition: emobject.h:362
const ObjectID & id() const
Definition: emobject.h:166
const MultiID & multiID() const
Definition: emobject.h:169
virtual const Array2D< char > * getLockedNodes() const
Definition: emobject.h:229
virtual EM::PosID goTo(od_int64)
Definition: emobject.h:131
bool fullyloaded_
Definition: emobject.h:354
virtual bool isNodeSourceType(const PosID &, NodeSourceType) const
Definition: emobject.h:216
Manages the loaded/half loaded EM objects in OpendTect.
Definition: emmanager.h:46
Hor+Vert sampling in 3D surveys.
Definition: trckeyzsampling.h:35
bool selremoving_
Definition: emobject.h:363
virtual bool isLoaded() const
Definition: emobject.h:295
MarkerStyle3D & preferredmarkerstyle_
Definition: emobject.h:347
bool isInsideSelRemoval() const
Definition: emobject.h:307
EM::EMObjectCallbackData * getCallBackData(int idx)
Definition: emobject.h:92
EM::PosID pid1
Definition: emobject.h:72
bool isFullyLoaded() const
Definition: emobject.h:301
void setFullyLoaded(bool yn)
Definition: emobject.h:302
Interface for classes that select on basis of a key.
Definition: selector.h:25
virtual void lockAll()
Definition: emobject.h:226
virtual bool canGoTo() const
Definition: emobject.h:130
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
void clearData()
Definition: emobject.h:98
CNotifier< EMObject, const EMObjectCallbackData & > change
Definition: emobject.h:292
Definition: draw.h:88
A cartesian coordinate in 3D space.
Definition: coord.h:72
Threads::Lock lock_
Definition: emobject.h:111
Definition: geomelement.h:37
Type
Definition: emobject.h:144
virtual ~EMObjectIterator()
Definition: emobject.h:125
virtual Executor * saver()
Definition: emobject.h:296
virtual void lock(bool yn)
Definition: emobject.h:305
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
bool flagfor2dviewer
Definition: emobject.h:74
uiString errmsg_
Definition: emobject.h:343
virtual bool isNodeLocked(const PosID &) const
Definition: emobject.h:224
void setName(const char *nm)
Definition: emobject.h:174
BufferString errmsg_
Definition: horizontracker.h:119
virtual Executor * loader()
Definition: emobject.h:294
Color selectioncolor_
Definition: emobject.h:360
PosAttrib()
Definition: emobject.h:142
EMObjectCallbackData(const EMObjectCallbackData &data)
Definition: emobject.h:58
Base class for all EarthModel objects.
Definition: emobject.h:158
OD::LineStyle & preferredlinestyle_
Definition: emobject.h:346
EM object callback data.
Definition: emobject.h:46
Earth Model objects like horizons, faults, fault-sticks and bodies.
Definition: embody.h:25
Notifier with automatic capsule creation.
Definition: callback.h:395
Threads::Lock setposlock_
Definition: emobject.h:357
NodeSourceType
Definition: emobject.h:163
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
virtual bool isLocked() const
Definition: emobject.h:304
ObjectID id_
Definition: emobject.h:340
virtual EMObjectIterator * createIterator(const EM::SectionID &, const TrcKeyZSampling *=0) const
Definition: emobject.h:259
const char * errMsg() const
Definition: horizontracker.h:61
Represents a unique trace position in one of the surveys that OpendTect is managing.
Definition: trckey.h:28
virtual bool isChanged() const
Definition: emobject.h:297
Color lockcolor_
Definition: emobject.h:359
bool isEmpty(const NLAModel *mdl)
TrcKeyZSampling removebypolyposbox_
Definition: emobject.h:351
virtual bool removeSection(SectionID, bool hist)
Definition: emobject.h:187
virtual void setNodeSourceType(const TrcKey &, NodeSourceType)
Definition: emobject.h:214
int size() const
Definition: emobject.h:104
virtual void resetChangedFlag()
Definition: emobject.h:300
Definition: arraytesselator.h:21
bool locked_
Definition: emobject.h:150
IOObjContext * getIOObjContext(Seis::GeomType, bool forread)
Compound key consisting of ints.
Definition: multiid.h:25
bool changed_
Definition: emobject.h:353
virtual bool hasNodeSourceType(const PosID &) const
Definition: emobject.h:233
Specification to enable chunkwise execution of a process.
Definition: executor.h:39
Holds the context for selecting and/or creating IOObjs.
Definition: ctxtioobj.h:62
void deepErase(ObjectSet< T > &os)
empty the ObjectSet deleting all objects pointed to.
Definition: objectset.h:118
Definition: emobject.h:67

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