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

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