anatomist 6.0.4
3D neuroimaging data viewer
glcomponent.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34#ifndef ANA_SURFACE_GLCOMPONENT_H
35#define ANA_SURFACE_GLCOMPONENT_H
36
41#include <aims/rgb/rgb.h>
42#include <cartobase/object/object.h>
43#include <cartodata/volume/volume.h>
44#include <vector>
45#include <set>
46
47
48namespace anatomist
49{
50
51 class Material;
52 class AObjectPalette;
53 class Sliceable;
54 class Referential;
55
56
67 {
68 public:
98
104
156
166
175
177
179 {
181
182 // min of data in memory (for OpenGL: between 0 and 1)
183 std::vector<float> min;
184 // max of data in memory (for OpenGL: between 0 and 1)
185 std::vector<float> max;
186 // min of initial (quantified) data
187 std::vector<float> minquant;
188 // max of initial (quantified) data
189 std::vector<float> maxquant;
190 bool scaled;
191 };
192
193 struct TexInfo;
194
196 virtual ~GLComponent();
197
199
200 virtual const GLComponent* glAPI() const { return this; }
201 virtual GLComponent* glAPI() { return this; }
202 virtual const Sliceable* sliceableAPI() const { return 0; }
203 virtual Sliceable* sliceableAPI() { return 0; }
204
205 virtual void glClearHasChangedFlags() const;
206 virtual void glSetChanged( glPart, bool = true ) const;
207 virtual bool glHasChanged( glPart ) const;
208
209 void setShader(const Shader &shader);
210 void removeShader();
213 const Shader *getShader() const;
214 Shader *getShader();
215 virtual void setShaderParameters(const Shader &shader,
216 const ViewState & state) const;
217
218 virtual const Material *glMaterial() const;
219 virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
220
221 virtual unsigned glNumVertex( const ViewState & ) const;
222 virtual const GLfloat* glVertexArray( const ViewState & ) const;
224 virtual const GLfloat* glNormalArray( const ViewState & ) const;
226 virtual unsigned glPolygonSize( const ViewState & ) const;
227 virtual unsigned glNumPolygon( const ViewState & ) const;
228 virtual const GLuint* glPolygonArray( const ViewState & ) const;
231 virtual unsigned long glMaxNumDisplayedPolygons() const;
232 virtual void glSetMaxNumDisplayedPolygons( unsigned long n );
233 static unsigned long glGlobalMaxNumDisplayedPolygons();
234 static void glSetGlobalMaxNumDisplayedPolygons( unsigned long n );
235
236 // Texturing functions
237 virtual void glSetTexImageChanged( bool x = true,
238 unsigned tex = 0 ) const ;
239 virtual void glSetTexEnvChanged( bool x = true, unsigned tex = 0 ) const;
240 virtual unsigned glNumTextures() const;
241 virtual unsigned glNumTextures( const ViewState & ) const;
242 virtual glTextureMode glTexMode( unsigned tex = 0 ) const;
243 virtual void glSetTexMode( glTextureMode mode, unsigned tex = 0 );
244 virtual float glTexRate( unsigned tex = 0 ) const;
245 virtual void glSetTexRate( float rate, unsigned tex = 0 );
246 virtual glTextureFiltering glTexFiltering( unsigned tex = 0 ) const;
247 virtual void glSetTexFiltering( glTextureFiltering x, unsigned tex = 0 );
248 virtual glAutoTexturingMode glAutoTexMode( unsigned tex = 0 ) const;
249 virtual glTextureWrapMode glTexWrapMode( unsigned coord = 0,
250 unsigned tex = 0 ) const;
251 virtual void glSetTexWrapMode( glTextureWrapMode x, unsigned coord = 0,
252 unsigned tex = 0 );
254 unsigned tex = 0 );
255 virtual const float *glAutoTexParams( unsigned coord = 0,
256 unsigned tex = 0 ) const;
257 virtual void glSetAutoTexParams( const float* params, unsigned coord = 0,
258 unsigned tex = 0 );
259 virtual bool glTexImageChanged( unsigned tex = 0 ) const;
260 virtual bool glTexEnvChanged( unsigned tex = 0 ) const;
261 virtual GLint glGLTexMode( unsigned tex = 0) const;
262 virtual GLint glGLTexFiltering( unsigned tex = 0 ) const;
263 GLint glGLTexWrapMode( unsigned coord = 0, unsigned tex = 0 ) const;
264 virtual void glSetTexRGBInterpolation( bool x, unsigned tex = 0 );
265 virtual bool glTexRGBInterpolation( unsigned tex = 0 ) const;
267 virtual unsigned glDimTex( const ViewState &, unsigned tex = 0 ) const;
269 virtual unsigned glTexCoordSize( const ViewState &,
270 unsigned tex = 0 ) const;
271 virtual const GLfloat* glTexCoordArray( const ViewState &,
272 unsigned tex = 0 ) const;
273 virtual const TexExtrema & glTexExtrema( unsigned tex = 0 ) const;
274 virtual TexExtrema & glTexExtrema( unsigned tex = 0 );
275
276 virtual GLPrimitives glMainGLL( const ViewState & );
292 virtual void glGarbageCollector( int nkept = -1 );
296 unsigned glStateMemory() const;
297 virtual void glSetStateMemory( unsigned n );
298
303 virtual bool glMakeBodyGLL( const ViewState & state,
304 const GLList & gllist ) const;
306 virtual void glBeforeBodyGLL( const ViewState & state,
307 GLPrimitives & pl ) const;
309 virtual void glAfterBodyGLL( const ViewState & state,
310 GLPrimitives & pl ) const;
325 const ViewState & state, unsigned tex, int dimx = -1,
326 int dimy = -1, bool useTexScale = true ) const;
335 virtual bool glMakeTexImage( const ViewState & state,
336 const GLTexture & gltex, unsigned tex ) const;
337 virtual bool glMakeTexEnvGLL( const ViewState & state,
338 const GLList & gllist, unsigned tex ) const;
339
340 virtual GLPrimitives glBodyGLL( const ViewState & state ) const;
341 virtual GLPrimitives glMaterialGLL( const ViewState & state ) const;
343 unsigned tex = 0 ) const;
345 unsigned tex = 0 ) const;
346 virtual void glSetMainGLL( const std::string & state, GLPrimitives x );
347 virtual void glSetBodyGLL( const std::string & state, RefGLItem x );
348 virtual void glSetMaterialGLL( const std::string & state, RefGLItem x );
349 virtual void glSetTexNameGLL( const std::string & state, RefGLItem x,
350 unsigned tex = 0 );
352 virtual std::set<glTextureMode>
353 glAllowedTexModes( unsigned tex = 0 ) const;
354 virtual std::set<glTextureFiltering>
355 glAllowedTexFilterings( unsigned tex = 0 ) const;
356 virtual std::set<glAutoTexturingMode>
357 glAllowedAutoTexModes( unsigned tex = 0 ) const;
358 virtual bool glAllowedTexRGBInterpolation( unsigned tex = 0 ) const;
359 virtual bool glAllowedTexRate( unsigned tex = 0 ) const;
360
371 virtual std::string viewStateID( glPart part, const ViewState & ) const;
372 virtual carto::Object debugInfo() const;
373
376 const Referential* myref );
380 const Referential* myref );
381 int glObjectID() const;
382 virtual TexInfo & glTexInfo( unsigned tex = 0 ) const;
383
384 protected:
385 void glAddTextures( unsigned ntex = 1 );
386
387 private:
388 struct Private;
389 Private *d;
390 Shader *_shader;
391 };
392
393
394 inline void GLComponent::setShader(const Shader &shader)
395 {
396 if (_shader) delete _shader;
397 _shader = new Shader(shader);
399 }
401 {
402 if (_shader)
403 {
404 delete _shader;
405 _shader = NULL;
407 }
408 }
409 inline const Material *GLComponent::glMaterial() const { return 0; }
410 inline const Shader *GLComponent::getShader() const { return _shader; }
411 inline Shader *GLComponent::getShader() { return _shader; }
412 inline void GLComponent::setShaderParameters(const Shader &shader, const ViewState & state) const { shader.setShaderParameters(*this, state); }
413 inline const AObjectPalette* GLComponent::glPalette( unsigned ) const
414 { return 0; }
415 inline unsigned GLComponent::glNumVertex( const ViewState & ) const
416 { return 0; }
417 inline const GLfloat* GLComponent::glVertexArray( const ViewState & ) const
418 { return 0; }
419 inline const GLfloat* GLComponent::glNormalArray( const ViewState & ) const
420 { return 0; }
421 inline unsigned GLComponent::glPolygonSize( const ViewState & ) const
422 { return 3; }
423 inline unsigned GLComponent::glNumPolygon( const ViewState & ) const
424 { return 0; }
425 inline const GLuint* GLComponent::glPolygonArray( const ViewState & ) const
426 { return 0; }
427
428 inline unsigned GLComponent::glDimTex( const ViewState &, unsigned ) const
429 { return 1; }
430 inline unsigned GLComponent::glTexCoordSize( const ViewState &,
431 unsigned ) const
432 { return 0; }
433 inline const GLfloat* GLComponent::glTexCoordArray( const ViewState &,
434 unsigned ) const
435 { return 0; }
436
437}
438
439
440#endif
441
442
virtual void glSetBodyGLL(const std::string &state, RefGLItem x)
virtual void glBeforeBodyGLL(const ViewState &state, GLPrimitives &pl) const
GL list to execute before the body is rendered.
virtual void glSetTexWrapMode(glTextureWrapMode x, unsigned coord=0, unsigned tex=0)
virtual bool glTexEnvChanged(unsigned tex=0) const
void setupShader()
create, setup, or remove the shader
glPart
GL object parts, each driving a GL list.
@ glGENERAL
General list, this one calls the others, so should be rebuilt when any other part changes.
@ glTEXENV_NUM
glTEXENV_NUM + 2* texnum flags texture #texnum, reserved for Observable pattern
@ glPALETTE
Palette settings.
@ glGEOMETRY
Geometry is the polygons, normals arrays.
@ glTEXENV
Texture environment part: activate texture units, bind textures, setup their properties.
@ glBODY
Body part: gathers vertices, polygons, normals, textures alltogether.
@ glMATERIAL
Material / coloring list.
@ glTEXIMAGE
Texture image part.
@ glREFERENTIAL
Coordinates transformations list.
@ glTEXIMAGE_NUM
glTEXIMAGE_NUM + 2* texnum flags texture #texnum, reserved for Observable pattern
GLint glGLTexWrapMode(unsigned coord=0, unsigned tex=0) const
virtual const AObjectPalette * glPalette(unsigned tex=0) const
virtual void glSetTexRGBInterpolation(bool x, unsigned tex=0)
virtual std::set< glAutoTexturingMode > glAllowedAutoTexModes(unsigned tex=0) const
virtual std::set< glTextureMode > glAllowedTexModes(unsigned tex=0) const
List of actually allowed texturing modes for this particular object.
virtual void glSetAutoTexParams(const float *params, unsigned coord=0, unsigned tex=0)
virtual const GLfloat * glTexCoordArray(const ViewState &, unsigned tex=0) const
void setShader(const Shader &shader)
virtual bool glAllowedTexRate(unsigned tex=0) const
virtual unsigned glDimTex(const ViewState &, unsigned tex=0) const
texture dimension (1, 2 [or 3])
virtual GLPrimitives glMainGLL(const ViewState &)
unsigned glStateMemory() const
Number of unused display lists in different states kept in memory (default: 4)
virtual const GLComponent * glAPI() const
virtual bool glHasChanged(glPart) const
virtual unsigned glPolygonSize(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
virtual bool glTexImageChanged(unsigned tex=0) const
virtual TexExtrema & glTexExtrema(unsigned tex=0)
virtual void glSetMaxNumDisplayedPolygons(unsigned long n)
virtual void setShaderParameters(const Shader &shader, const ViewState &state) const
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
virtual void glSetAutoTexMode(glAutoTexturingMode mode, unsigned tex=0)
virtual void glSetTexMode(glTextureMode mode, unsigned tex=0)
virtual bool glMakeBodyGLL(const ViewState &state, const GLList &gllist) const
If you want to make a non-standard GL display list for the body geometry, overload this function to f...
virtual void glSetMainGLL(const std::string &state, GLPrimitives x)
virtual const Material * glMaterial() const
static void glSetGlobalMaxNumDisplayedPolygons(unsigned long n)
virtual TexInfo & glTexInfo(unsigned tex=0) const
virtual glAutoTexturingMode glAutoTexMode(unsigned tex=0) const
virtual glTextureWrapMode glTexWrapMode(unsigned coord=0, unsigned tex=0) const
virtual void glClearHasChangedFlags() const
virtual const TexExtrema & glTexExtrema(unsigned tex=0) const
virtual const GLfloat * glNormalArray(const ViewState &) const
normals array (optional), default=0 (no normals, flat shaded faces)
virtual Sliceable * sliceableAPI()
void glAddTextures(unsigned ntex=1)
virtual glTextureMode glTexMode(unsigned tex=0) const
virtual GLint glGLTexFiltering(unsigned tex=0) const
virtual const Sliceable * sliceableAPI() const
virtual bool glMakeTexImage(const ViewState &state, const GLTexture &gltex, unsigned tex) const
If you make non-standard textures (ie not from a palette), overload this function to fill gltex.
virtual bool glTexRGBInterpolation(unsigned tex=0) const
static unsigned long glGlobalMaxNumDisplayedPolygons()
virtual GLint glGLTexMode(unsigned tex=0) const
virtual void glSetTexEnvChanged(bool x=true, unsigned tex=0) const
static GLPrimitives glPopTransformation(const ViewState &vs, const Referential *myref)
called after glHandleTransformation() and glMainGLL() to pop the transformation matrix
virtual carto::Object debugInfo() const
virtual GLPrimitives glTexNameGLL(const ViewState &, unsigned tex=0) const
virtual GLPrimitives glBodyGLL(const ViewState &state) const
virtual std::set< glTextureFiltering > glAllowedTexFilterings(unsigned tex=0) const
virtual void glSetStateMemory(unsigned n)
virtual bool glAllowedTexRGBInterpolation(unsigned tex=0) const
virtual void glSetMaterialGLL(const std::string &state, RefGLItem x)
virtual void glSetTexImageChanged(bool x=true, unsigned tex=0) const
virtual GLPrimitives glMaterialGLL(const ViewState &state) const
virtual unsigned glNumPolygon(const ViewState &) const
virtual unsigned glNumTextures(const ViewState &) const
virtual void glAfterBodyGLL(const ViewState &state, GLPrimitives &pl) const
GL list to execute after the body is rendered.
virtual GLPrimitives glTexEnvGLL(const ViewState &, unsigned tex=0) const
virtual glTextureFiltering glTexFiltering(unsigned tex=0) const
ViewState::glSelectRenderMode glSelectRenderMode
virtual unsigned long glMaxNumDisplayedPolygons() const
Limit to the number of displayed polygons (default: 0, unlimited or ) global default value)
virtual bool glMakeTexEnvGLL(const ViewState &state, const GLList &gllist, unsigned tex) const
virtual void glSetTexFiltering(glTextureFiltering x, unsigned tex=0)
virtual float glTexRate(unsigned tex=0) const
virtual void glSetTexNameGLL(const std::string &state, RefGLItem x, unsigned tex=0)
virtual void glGarbageCollector(int nkept=-1)
Frees unused display lists.
virtual const GLuint * glPolygonArray(const ViewState &) const
static GLPrimitives glHandleTransformation(const ViewState &vs, const Referential *myref)
helper function used in AObject::render()
virtual const GLfloat * glVertexArray(const ViewState &) const
virtual void glSetTexRate(float rate, unsigned tex=0)
virtual carto::VolumeRef< AimsRGBA > glBuildTexImage(const ViewState &state, unsigned tex, int dimx=-1, int dimy=-1, bool useTexScale=true) const
If you make non-standard textures (ie not from a palette), overload this function.
virtual const float * glAutoTexParams(unsigned coord=0, unsigned tex=0) const
virtual GLComponent * glAPI()
const Shader * getShader() const
virtual unsigned glNumTextures() const
virtual unsigned glTexCoordSize(const ViewState &, unsigned tex=0) const
texture array size (must be >= numVertex to work), defalut=0
virtual unsigned glNumVertex(const ViewState &) const
virtual void glSetChanged(glPart, bool=true) const
This class has to be rewritten, it's really really a shame.......
Definition Material.h:48
Referential: marker for transformations, with an associated color.
Definition Referential.h:56
void setShaderParameters(const GLComponent &obj, const ViewState &state) const
Sliceable objects can draw themselves in a 2D texture.
Definition sliceable.h:59
carto::rc_ptr< GLItem > RefGLItem
Definition primitive.h:129
std::list< RefGLItem > GLPrimitives
Definition primitive.h:156
ViewState holds information about how a view wants to see an object.
Definition viewstate.h:67