OpendTect-6_4  6.4
visdata.h
Go to the documentation of this file.
1 #ifndef visdata_h
2 #define visdata_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 "visbasemod.h"
17 #include "callback.h"
18 #include "refcount.h"
19 #include "sets.h"
20 #include "visdataman.h"
21 
22 class SoNode;
23 class BufferString;
24 
25 namespace visBase { class DataObject; class EventInfo; }
26 
27 namespace osg { class Switch; class Node; }
28 namespace osgViewer { class CompositeViewer; }
29 
30 
31 #define mVisTrans visBase::Transformation
32 
33 namespace osg { class Switch; class StateSet; }
34 namespace visBase
35 {
36 
37 class Transformation;
38 class SelectionManager;
39 class DataManager;
40 class Scene;
41 class DataObjectGroup;
42 class NodeState;
43 
44 
45 // OSG traversal bitmasks defined by OpendTect
46 inline unsigned int cNoTraversalMask() { return 0; }
47 inline unsigned int cAllTraversalMask() { return 0xFFFFFFFF; }
48 inline unsigned int cEventTraversalMask() { return 0x00000001; }
49 inline unsigned int cBBoxTraversalMask() { return 0x00000002; }
50 
51 inline unsigned int cActiveIntersecTraversalMask() { return 0x00000004; }
52 inline unsigned int cPassiveIntersecTraversalMask() { return 0x00000008; }
53 inline unsigned int cIntersectionTraversalMask()
55 inline unsigned int cDraggerIntersecTraversalMask() { return 0x00000010; }
56 
57 
67 public:
68 
69  virtual const char* getClassName() const { return "Not impl"; }
70 
71  virtual bool isOK() const { return true; }
72 
73  int id() const { return id_; }
74 
75  void setID(int nid);
76  static int getID(const osg::Node*);
77 
78  uiString name() const;
79  virtual void setName(const uiString&);
80 
81  osg::Node* osgNode(bool skipswitch=false);
82  const osg::Node* osgNode(bool skipswitch=false) const;
83 
84  void enableTraversal(unsigned int mask,bool yn=true);
85  bool isTraversalEnabled(unsigned int mask) const;
86 
87  inline SoNode* getInventorNode() {return 0;}
88  inline const SoNode* getInventorNode() const
89  { return 0; }
90 
91  virtual bool turnOn(bool yn);
92  virtual bool isOn() const;
93 
94  bool isPickable(bool actively=true) const;
95  void setPickable(bool actively,bool passively=true);
99  virtual bool rightClickable() const { return selectable(); }
100  virtual bool selectable() const { return false; }
101  void select() const;
102  /*<! Is here for convenience. Will rewire to
103  SelectionManager. */
104  void deSelect() const;
105  /*<! Is here for convenience. Will rewire to
106  SelectionManager. */
107  void updateSel() const;
108  /*<! Is here for convenience. Will rewire to
109  SelectionManager. */
110 
111  virtual bool isSelected() const;
112  virtual NotifierAccess* selection() { return 0; }
113  virtual NotifierAccess* deSelection() { return 0; }
114  virtual NotifierAccess* rightClicked() { return 0; }
115  virtual const TypeSet<int>* rightClickedPath() const{ return 0; }
116 
117  virtual void setDisplayTransformation(const mVisTrans*);
126  virtual const mVisTrans* getDisplayTransformation() const { return 0; }
135  virtual void setRightHandSystem(bool yn) {}
138  virtual bool isRightHandSystem() const { return true; }
139 
140  virtual void setPixelDensity(float dpi);
141  static float getDefaultPixelDensity();
142  virtual float getPixelDensity() const;
143 
144  virtual const char* errMsg() const { return 0; }
145 
146  bool serialize(const char* filename,
147  bool binary=false);
148 
149  void setParent(DataObjectGroup* g) { parent_ = g; }
150 
151  template <class T> T* addNodeState(T* ns)
152  { doAddNodeState(ns); return ns; }
153  NodeState* removeNodeState(NodeState*);
154  NodeState* getNodeState( int idx );
155 
156  static void setVisualizationThread(const void*);
158  static bool isVisualizationThread();
159 
160  static void requestSingleRedraw();
161 
162  static void setCommonViewer(osgViewer::CompositeViewer*);
163  static osgViewer::CompositeViewer* getCommonViewer();
164 
165 protected:
166 
167  virtual osg::StateSet* getStateSet();
168  void doAddNodeState(NodeState* ns);
169 
170  friend class SelectionManager;
171  friend class Scene;
172  virtual void triggerSel() {}
174  virtual void triggerDeSel() {}
176  virtual void triggerRightClick(const EventInfo* =0) {}
177 
178  DataObject();
179 
181 
182  template <class T>
183  T* setOsgNode( T* t )
184  {
185  setOsgNodeInternal( (osg::Node*) t );
186  return t;
187  }
189 
190  void updateNodemask();
191 
192 private:
193  void setOsgNodeInternal(osg::Node*);
194  void updateOsgNodeData();
195 
197  osg::Node* osgnode_;
198  osg::Switch* osgoffswitch_;
199  int id_;
200  bool ison_;
202  unsigned int enabledmask_;
203  static const void* visualizationthread_;
204  static osgViewer::CompositeViewer* commonviewer_;
205 };
206 
207 };
208 
209 #define mCreateDataObj(clss) \
210 { \
211  return new clss; \
212 } \
213  \
214 private: \
215  static visBase::DataObject* createInternal() \
216  { return new clss; } \
217  clss& operator =(const clss&); \
218  clss(const clss&); \
219 public: \
220  clss(); \
221  static void initClass(); \
222  static const char* getStaticClassName(); \
223  static const char* sFactoryKeyword(); \
224  virtual const char* getClassName() const
225 
226 
227 #define mCreateFactoryEntry( clss ) \
228 const char* clss::getStaticClassName() { return #clss; } \
229 const char* clss::getClassName() const \
230 { return clss::getStaticClassName(); } \
231 const char* clss::sFactoryKeyword() { return #clss; } \
232 void clss::initClass() \
233 { visBase::DataManager::factory().addCreator( \
234  createInternal, getStaticClassName() ); }
235 
236 
237 
238 #endif
#define mRefCountImpl(ClassName)
Macro to setup a class with destructor for reference counting.
Definition: refcount.h:163
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
void turnOn(int flag)
Overrides the envirnonment variable.
unsigned int cDraggerIntersecTraversalMask()
Definition: visdata.h:55
DataObjectGroup * parent_
Definition: visdata.h:180
osg::Switch * osgoffswitch_
Definition: visdata.h:198
void setParent(DataObjectGroup *g)
Definition: visdata.h:149
virtual bool selectable() const
Definition: visdata.h:100
virtual const char * getClassName() const
Definition: visdata.h:69
uiString name_
Definition: visdata.h:201
Definition: visdatagroup.h:27
virtual NotifierAccess * rightClicked()
Definition: visdata.h:114
bool ison_
Definition: visdata.h:200
Interface class for Notifier. See comments there.
Definition: callback.h:161
T * setOsgNode(T *t)
Must be called during construction.
Definition: visdata.h:183
Definition: visdata.h:28
virtual NotifierAccess * deSelection()
Definition: visdata.h:113
DataObject is the base class off all objects that are used in Visualization and ought to be shared in...
Definition: visdata.h:65
virtual void triggerSel()
Definition: visdata.h:172
Definition: uistring.h:89
const SoNode * getInventorNode() const
Definition: visdata.h:88
SoNode * getInventorNode()
Definition: visdata.h:87
virtual bool isOK() const
Definition: visdata.h:71
Definition: visnodestate.h:27
virtual void triggerDeSel()
Definition: visdata.h:174
virtual bool rightClickable() const
Definition: visdata.h:99
Set of pointers to objects.
Definition: commontypes.h:32
unsigned int cBBoxTraversalMask()
Definition: visdata.h:49
T * addNodeState(T *ns)
Definition: visdata.h:151
bool isOn(int flag=0xffff)
SelectionManager handles DataObject that can be selected. If an object can be selected, it has to register himself with regSelObject. At registration it has to give two objects, first of all, he gives the object that outside users will associate him with when they want to add their CB to detect his selection.
Definition: visselman.h:44
#define mVisTrans
Definition: visdata.h:31
virtual void setRightHandSystem(bool yn)
Definition: visdata.h:135
unsigned int cActiveIntersecTraversalMask()
Definition: visdata.h:51
virtual void triggerRightClick(const EventInfo *=0)
Definition: visdata.h:176
unsigned int enabledmask_
Definition: visdata.h:202
static osgViewer::CompositeViewer * commonviewer_
Definition: visdata.h:204
static const void * visualizationthread_
Definition: visdata.h:203
osg::Node * osgnode_
Definition: visdata.h:197
virtual bool isRightHandSystem() const
Definition: visdata.h:138
virtual const visBase::Transformation * getDisplayTransformation() const
Definition: visdata.h:126
virtual const TypeSet< int > * rightClickedPath() const
Definition: visdata.h:115
Definition: visannot.h:43
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
virtual const char * errMsg() const
Definition: visdata.h:144
Scene manages all DataObjects and has some managing functions such as the selection management and va...
Definition: visscene.h:40
Open Scene Graph.
Definition: visannot.h:29
ObjectSet< NodeState > nodestates_
Definition: visdata.h:196
Definition: visevent.h:44
int id() const
Definition: visdata.h:73
int id_
Definition: visdata.h:199
virtual NotifierAccess * selection()
Definition: visdata.h:112
unsigned int cPassiveIntersecTraversalMask()
Definition: visdata.h:52
unsigned int cAllTraversalMask()
Definition: visdata.h:47
unsigned int cIntersectionTraversalMask()
Definition: visdata.h:53
unsigned int cNoTraversalMask()
Definition: visdata.h:46
unsigned int cEventTraversalMask()
Definition: visdata.h:48

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