anatomist  5.1.2
3D neuroimaging data viewer
sliceable.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 
35 #ifndef ANA_OBJECT_SLICEABLE_H
36 #define ANA_OBJECT_SLICEABLE_H
37 
39 #include <aims/vector/vector.h>
40 #include <aims/rgb/rgb.h>
41 
42 namespace carto
43 {
44  template <typename T> class Volume;
45  template <typename T> class VolumeRef;
46 }
47 
48 namespace anatomist
49 {
50 
51  struct AImage;
52  struct SliceViewState;
53 
54 
58  class Sliceable : public GLComponent
59  {
60  public:
62  virtual ~Sliceable();
63 
64  virtual const Sliceable* sliceableAPI() const { return this; }
65  virtual Sliceable* sliceableAPI() { return this; }
66 
67  virtual unsigned glNumVertex( const ViewState & ) const;
68  virtual const GLfloat* glVertexArray( const ViewState & ) const;
69  virtual const GLfloat* glNormalArray( const ViewState & state ) const;
70  virtual unsigned glPolygonSize( const ViewState & ) const;
71  virtual unsigned glNumPolygon( const ViewState & ) const;
72  virtual const GLuint* glPolygonArray( const ViewState & ) const;
73 
74  virtual unsigned glDimTex( const ViewState &, unsigned tex = 0 ) const;
75  virtual unsigned glTexCoordSize( const ViewState &,
76  unsigned tex = 0 ) const;
77  virtual const GLfloat* glTexCoordArray( const ViewState &,
78  unsigned tex = 0 ) const;
79 
81  const ViewState & state, unsigned tex, int dimx = -1,
82  int dimy = -1, bool useTexScale = true ) const;
83  virtual bool glMakeTexImage( const ViewState & state,
84  const GLTexture & gltex, unsigned tex ) const;
85 
87  virtual bool update2DTexture( AImage &, const Point3df & posbase,
88  const SliceViewState &,
89  unsigned tex = 0 ) const;
92  int tex = 0 ) const;
95  const SliceViewState* = 0, int tex = 0 ) const;
96  virtual std::vector<float> glVoxelSize() const;
97  virtual std::vector<float> glMin2D() const = 0;
98  virtual std::vector<float> glMax2D() const = 0;
99  virtual bool glAllowedTexRGBInterpolation( unsigned tex = 0 ) const;
100  virtual const Referential *getReferential() const = 0;
101  virtual std::string viewStateID( glPart part, const ViewState & ) const;
102 
103  private:
104  struct Private;
105  Private *d;
106  };
107 
108 
111  class SliceableObject : public AObject, public Sliceable
112  {
113  public:
115  virtual ~SliceableObject();
116 
117  virtual const GLComponent* glAPI() const { return this; }
118  virtual GLComponent* glAPI() { return this; }
119  virtual const Sliceable* sliceableAPI() const { return this; }
120  virtual Sliceable* sliceableAPI() { return this; }
121 
122  virtual std::vector<float> glVoxelSize() const;
123  virtual std::vector<float> glMin2D() const;
124  virtual std::vector<float> glMax2D() const;
125 
126  virtual void glSetChanged( glPart, bool = true ) const;
127  virtual void glSetTexImageChanged( bool x = true, unsigned tex = 0 ) const;
128  virtual void glSetTexEnvChanged( bool x = true, unsigned tex = 0 ) const;
129 
130  virtual const Material *glMaterial() const;
131  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
132  const Referential *getReferential() const;
133  };
134 
135 }
136 
137 #endif
138 
Base Anatomist object (abstract)
Definition: Object.h:96
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:67
glPart
GL object parts, each driving a GL list.
Definition: glcomponent.h:114
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:55
AObject-inherited version of Sliceable.
Definition: sliceable.h:112
virtual const AObjectPalette * glPalette(unsigned tex=0) const
virtual const GLComponent * glAPI() const
OpenGL objects const API.
Definition: sliceable.h:117
virtual GLComponent * glAPI()
OpenGL objects API.
Definition: sliceable.h:118
virtual std::vector< float > glVoxelSize() const
virtual void glSetTexImageChanged(bool x=true, unsigned tex=0) const
const Referential * getReferential() const
virtual const Sliceable * sliceableAPI() const
Definition: sliceable.h:119
virtual const Material * glMaterial() const
virtual void glSetTexEnvChanged(bool x=true, unsigned tex=0) const
virtual void glSetChanged(glPart, bool=true) const
virtual Sliceable * sliceableAPI()
Definition: sliceable.h:120
virtual std::vector< float > glMin2D() const
virtual std::vector< float > glMax2D() const
Sliceable objects can draw themselves in a 2D texture.
Definition: sliceable.h:59
virtual const GLfloat * glVertexArray(const ViewState &) const
virtual const GLfloat * glNormalArray(const ViewState &state) const
normals array (optional), default=0 (no normals, flat shaded faces)
virtual void rgbaVolume(carto::Volume< AimsRGBA > &, const SliceViewState *=0, int tex=0) const
same as the other rgbaVolume() but fills an already allocated volume
virtual carto::VolumeRef< AimsRGBA > rgbaVolume(const SliceViewState *=0, int tex=0) const
fills a resampled RGBA volume
virtual const Referential * getReferential() const =0
virtual const GLfloat * glTexCoordArray(const ViewState &, unsigned tex=0) 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 std::vector< float > glMax2D() const =0
virtual bool update2DTexture(AImage &, const Point3df &posbase, const SliceViewState &, unsigned tex=0) const
this function must be overloaded to actually fill the slice image
virtual unsigned glPolygonSize(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
virtual const GLuint * glPolygonArray(const ViewState &) const
virtual bool glAllowedTexRGBInterpolation(unsigned tex=0) const
virtual unsigned glTexCoordSize(const ViewState &, unsigned tex=0) const
texture array size (must be >= numVertex to work), defalut=0
virtual std::vector< float > glVoxelSize() const
virtual Sliceable * sliceableAPI()
Definition: sliceable.h:65
virtual unsigned glDimTex(const ViewState &, unsigned tex=0) const
texture dimension (1, 2 [or 3])
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
virtual unsigned glNumPolygon(const ViewState &) const
virtual std::vector< float > glMin2D() const =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 unsigned glNumVertex(const ViewState &) const
virtual const Sliceable * sliceableAPI() const
Definition: sliceable.h:64
Specialization for a sliceable object.
Definition: viewstate.h:99
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67