Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VTKViewer_PolyDataMapper.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef VTKViewer_POLYDATAMAPPER_H
21 #define VTKViewer_POLYDATAMAPPER_H
22 
23 #include "VTKViewer.h"
24 #include "VTKViewer_MarkerDef.h"
25 
26 #ifdef WIN32
27 #include <windows.h>
28 #endif
29 
30 #include <map>
31 
32 #ifdef __APPLE__
33 #include <OpenGL/gl.h>
34 #else
35 #include <GL/gl.h>
36 #endif
37 
38 #include <vtkSmartPointer.h>
39 
40 class vtkImageData;
41 
42 #ifndef VTK_IMPLEMENT_MESA_CXX
43 #include <vtkOpenGLPolyDataMapper.h>
44 #define MAPPER_SUPERCLASS vtkOpenGLPolyDataMapper
45 #else
46 #include <vtkMesaPolyDataMapper.h>
47 #define MAPPER_SUPERCLASS vtkMesaPolyDataMapper
48 #endif
49 
50 #include "VTKViewer_OpenGLHelper.h"
51 
52 //----------------------------------------------------------------------------
54 
63 {
64 public:
65  enum ExtensionsState { ES_None = 0, ES_Error, ES_Ok };
66 
67 public:
68  static VTKViewer_PolyDataMapper* New();
70 
72  void SetMarkerEnabled( bool );
73 
75  void SetBallEnabled( bool );
76 
77  bool GetBallEnabled( );
78 
80  void SetBallScale( double );
81 
82  double GetBallScale( );
83 
85  void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
86 
88  void SetMarkerTexture( int, VTK::MarkerTexture );
89 
91  VTK::MarkerType GetMarkerType();
92 
94  VTK::MarkerScale GetMarkerScale();
95 
97  int GetMarkerTexture();
98 
100  virtual void RenderPiece( vtkRenderer*, vtkActor* );
102 #ifndef VTK_OPENGL2
103  virtual int Draw( vtkRenderer*, vtkActor* );
104 #else
105  virtual void RenderPieceDraw( vtkRenderer*, vtkActor* );
106 #endif
107 
108 protected:
111 
113  int InitExtensions();
114 
116  void InitPointSprites();
117 
119  void CleanupPointSprites();
120 
122  void InitTextures();
123 
125  int InitShader();
126 
127  void InternalDraw(vtkRenderer*, vtkActor*);
128 
129 private:
131 
133 
134  vtkSmartPointer<vtkImageData> ImageData;
135 
138 #ifdef VTK_OPENGL2
139  GLhandleARB VertexShader;
140  GLhandleARB FragmentShader;
141  GLuint VertexArrayObject;
142 #endif
143 
144  struct Locations {
145  static const GLint INVALID_LOCATION = -1;
146 
148  GLint Projection;
150  GLint PointSprite;
151 
153  : ModelViewProjection (INVALID_LOCATION),
154  Projection (INVALID_LOCATION),
155  GeneralPointSize (INVALID_LOCATION),
156  PointSprite (INVALID_LOCATION)
157  {
158  //
159  }
160  } myLocations;
161 
164  double BallScale;
167  int MarkerId;
168 
169  typedef std::map< int, vtkSmartPointer<vtkImageData> > ImageDataMap;
172  ImageDataMap SpecialTextures; //special predefined textures, used to draw point sprites.
173 };
174 
175 #endif