OpendTect-6_4  6.4
visshape.h
Go to the documentation of this file.
1 #ifndef visshape_h
2 #define visshape_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 #include "visbasemod.h"
16 #include "visobject.h"
17 #include "indexedshape.h"
18 #include "draw.h"
19 
20 namespace osg
21 {
22  class Geode;
23  class Geometry;
24  class PrimitiveSet;
25  class StateAttribute;
26  class Switch;
27 }
28 
29 namespace visBase
30 {
31 
32 class NodeState;
33 class ForegroundLifter;
34 class VisColorTab;
35 class Material;
36 class Coordinates;
37 class Normals;
38 class TextureChannels;
39 class TextureCoords;
40 
41 
42 #undef mDeclSetGetItem
43 #define mDeclSetGetItem( ownclass, clssname, variable ) \
44 protected: \
45  clssname* gt##clssname() const; \
46 public: \
47  inline clssname* get##clssname() { return gt##clssname(); } \
48  inline const clssname* get##clssname() const { return gt##clssname(); } \
49  void set##clssname(clssname*)
50 
51 
53 {
54 public:
55 
56  mDeclSetGetItem( Shape, Material, material_ );
57 
58  void setMaterialBinding( int );
59  static int cOverallMaterialBinding() { return 0; }
60  static int cPerVertexMaterialBinding() { return 2; }
61 
62  int getMaterialBinding() const;
63 
64  void setRenderMode(RenderMode);
65  void enableRenderLighting(bool);
67 
68  int usePar(const IOPar&);
69  void fillPar(IOPar&) const;
70 
71 protected:
72  Shape();
73  virtual ~Shape();
74 
76 
77  static const char* sKeyOnOff();
78  static const char* sKeyTexture();
79  static const char* sKeyMaterial();
80 };
81 
82 
84 {
85  class TextureCallbackHandler;
86  class NodeCallbackHandler;
87 
88 public:
89 
90  static VertexShape* create()
92 
93  void setPrimitiveType(Geometry::PrimitiveSet::PrimitiveType);
95 
96  mDeclSetGetItem( VertexShape, Normals, normals_ );
97  mDeclSetGetItem( VertexShape, TextureCoords, texturecoords_ );
98 
99  virtual void setCoordinates(Coordinates* coords);
100  virtual Coordinates* getCoordinates() { return coords_; }
101  virtual const Coordinates* getCoordinates() const { return coords_; }
102  virtual void setLineStyle(const OD::LineStyle&){};
103 
104  void removeSwitch();
110  virtual void setDisplayTransformation( const mVisTrans* );
114  const mVisTrans* getDisplayTransformation() const;
117  void dirtyCoordinates();
118 
119  void addPrimitiveSet(Geometry::PrimitiveSet*);
120  void removePrimitiveSet(const Geometry::PrimitiveSet*);
121  void removeAllPrimitiveSets();
122  int nrPrimitiveSets() const;
123  virtual void touchPrimitiveSet(int) {}
124  Geometry::PrimitiveSet* getPrimitiveSet(int);
125  void setMaterial( Material* mt );
126  void materialChangeCB( CallBacker* );
127  void coordinatesChangedCB( CallBacker* );
129  { usecoordinateschangedcb_ = yn; }
130  void useOsgAutoNormalComputation(bool);
132  { return useosgsmoothnormal_; }
133  Coord3 getOsgNormal(int) const;
134 
135  enum BindType{ BIND_OFF = 0,BIND_OVERALL,
137  BIND_PER_PRIMITIVE, BIND_PER_VERTEX};
138  void setColorBindType(BindType);
139  int getNormalBindType();
140  void setNormalBindType(BindType);
141  void updatePartialGeometry(Interval<int>);
142  void useVertexBufferRender(bool);
146  void setTextureChannels(TextureChannels*);
147  const unsigned char* getTextureData(int&,int&,int&) const;
148  void forceRedraw(bool=true);
149  void setAttribAndMode(osg::StateAttribute*);
150 
151 protected:
153  bool creategeode );
154  ~VertexShape();
155 
156  void setupOsgNode();
157 
158  virtual void addPrimitiveSetToScene(osg::PrimitiveSet*);
159  virtual void removePrimitiveSetFromScene(const osg::PrimitiveSet*);
160 
161  void setUpdateVar(bool& var,bool yn);
163 
164  bool needstextureupdate_; // Only set via setUpdateVar(.)
165 
169 
170  osg::Node* node_;
171 
172  osg::Geode* geode_;
174 
177 
180 
182  NodeCallbackHandler* nodecallbackhandler_;
183  TextureCallbackHandler* texturecallbackhandler_;
186 
188 
193 
194 };
195 
196 #undef mDeclSetGetItem
197 
198 
199 
201 {
202  Geometry::PrimitiveSet* doCreate( bool, bool );
203 };
204 
205 
206 
207 }
208 
209 #endif
Definition: visobject.h:37
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
RenderMode
Base class for all objects that are visual on the scene.
Definition: visobject.h:34
Material * material_
Definition: visshape.h:75
Definition: vistexturecoords.h:28
ObjectSet< Geometry::PrimitiveSet > primitivesets_
Definition: visshape.h:192
Definition: indexedshape.h:29
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:53
Definition: vistexturechannels.h:50
osg::Geometry * osggeom_
Definition: visshape.h:173
void enableCoordinatesChangedCB(bool yn)
Definition: visshape.h:128
Threads::Lock redrawlock_
Definition: visshape.h:184
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
virtual void setLineStyle(const OD::LineStyle &)
Definition: visshape.h:102
bool isredrawing_
Definition: visshape.h:185
Definition: draw.h:118
TextureCoords * texturecoords_
Definition: visshape.h:168
bool useosgsmoothnormal_
Definition: visshape.h:175
NodeCallbackHandler * nodecallbackhandler_
Definition: visshape.h:182
bool usecoordinateschangedcb_
Definition: visshape.h:176
BindType
Definition: visshape.h:135
BindType normalbindtype_
Definition: visshape.h:179
BindType colorbindtype_
Definition: visshape.h:178
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
static VertexShape * create()
Definition: visshape.h:90
Definition: visnormals.h:32
RefMan< TextureChannels > channels_
Definition: visshape.h:181
Normals * normals_
Definition: visshape.h:166
#define mVisTrans
Definition: visdata.h:31
bool needstextureupdate_
Will trigger redraw request if necessary.
Definition: visshape.h:164
osg::Node * node_
Definition: visshape.h:170
Geometry::PrimitiveSet::PrimitiveType primitivetype_
Definition: visshape.h:187
Definition: vismaterial.h:37
osg::Geode * geode_
Definition: visshape.h:172
Coordinates * coords_
Definition: visshape.h:167
virtual void touchPrimitiveSet(int)
Definition: visshape.h:123
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
A cartesian coordinate in 3D space.
Definition: coord.h:72
A set of coordinates. The coordinates will be transformed by the transformation before given to Coin...
Definition: viscoord.h:46
Definition: visannot.h:43
TextureCallbackHandler * texturecallbackhandler_
Definition: visshape.h:183
Open Scene Graph.
Definition: visannot.h:29
static int cPerVertexMaterialBinding()
Definition: visshape.h:60
#define mCreateDataObj(clss)
Definition: visdata.h:209
Definition: visshape.h:83
virtual const Coordinates * getCoordinates() const
Definition: visshape.h:101
Definition: indexedshape.h:99
Definition: arraytesselator.h:21
Definition: visshape.h:52
bool useOsgAutoNormalComputation() const
Definition: visshape.h:131
Definition: ptrman.h:168
Threads::Lock lock_
Definition: visshape.h:189
PrimitiveType
Definition: indexedshape.h:33
static int cOverallMaterialBinding()
Definition: visshape.h:59
#define mDeclSetGetItem(ownclass, clssname, variable)
Definition: visshape.h:43
FixedString Geometry()
Definition: keystrs.h:69
Definition: visshape.h:200

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