anatomist 6.0.18
3D neuroimaging data viewer
objectPalette.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_COLOR_OBJECTPALETTE_H
36#define ANA_COLOR_OBJECTPALETTE_H
37
39#include <cartodata/volume/volume.h>
40#include <aims/rgb/rgb.h>
41#include <cartobase/object/object.h>
42
43class QImage;
44
45namespace anatomist
46{
47 class AObject;
48 class GLComponent;
49
51 {
52 public:
58
59 typedef AimsRGBA (*MixMethod)(
60 const carto::Volume<AimsRGBA> & map1,
61 const carto::Volume<AimsRGBA> *map2,
62 unsigned x, unsigned y,
63 const AObjectPalette & pal );
64
67 virtual ~AObjectPalette();
68
69 virtual AObjectPalette* clone() const;
70
72
74 { if( dim == 1 ) return _refPal2; else return( _refPal ); }
77 { if( dim == 1 ) setRefPalette2( pal );
78 else setRefPalette1( pal ); }
80 { setRefPalette1( pal ); } // FIXME to be removed
82 { if( _refPal != pal ) { clearColors(); _refPal = pal; } }
85 { if( !_colors.get() ) const_cast<AObjectPalette *>(this)->fill();
86 return _colors.get(); }
88 { if( !_colors.get() ) fill(); return _colors.get(); }
89 void create( unsigned dimx, unsigned dimy = 1, unsigned dimz = 1,
90 unsigned dimt = 1 );
91 virtual void fill();
92 double min1() const { return( _min ); }
93 double max1() const { return( _max ); }
94 double min2() const { return( _min2 ); }
95 double max2() const { return( _max2 ); }
96 double min( int dim = 0 ) const { return dim == 1 ? min2() : min1(); }
97 double max( int dim = 0 ) const { return dim == 1 ? max2() : max1(); }
98 int palette1DMapping() const { return (_palette1DMapping) ; }
99 std::string palette1DMappingName() const
100 { return (_palette1DMapping == 1 ? "Diagonal" : "FirstLine" ) ; }
101 void setMin1( double x )
102 { _min = x; if( isnan( x ) || isinf( x ) ) _min = 0; }
103 void setMax1( double x )
104 { _max = x; if( isnan( x ) || isinf( x ) ) _max = 0; }
105 void setMin2( double x ) { _min2 = x; }
106 void setMax2( double x ) { _max2 = x; }
107 void setMin( int dim, double x )
108 { if( dim == 1 ) setMin2( x ); else setMin1( x ); }
109 void setMax( int dim, double x )
110 { if( dim == 1 ) setMax2( x ); else setMax1( x ); }
111
113 double absMin1( const AObject * obj ) const;
115 double absMax1( const AObject * obj ) const;
117 double absMin2( const AObject * obj ) const;
119 double absMax2( const AObject * obj ) const;
120 double absMin( int dim, const AObject* obj ) const
121 { return dim == 1 ? absMin2( obj ) : absMin1( obj ); }
122 double absMax( int dim, const AObject* obj ) const
123 { return dim == 1 ? absMax2( obj ) : absMax1( obj ); }
124
125 void setAbsMin1( const AObject * obj, double x );
127 void setAbsMax1( const AObject * obj, double x );
129 void setAbsMin2( const AObject * obj, double x );
131 void setAbsMax2( const AObject * obj, double x );
132 void setAbsMin( int dim, const AObject *obj, double x )
133 { if( dim == 1 ) setAbsMin2( obj, x ); else setAbsMin1( obj, x ); }
134 void setAbsMax( int dim, const AObject *obj, double x )
135 { if( dim == 1 ) setAbsMax2( obj, x ); else setAbsMax1( obj, x ); }
136
138 double absMin1( const GLComponent *glcj ) const;
140 double absMax1( const GLComponent *glc ) const;
142 double absMin2( const GLComponent *glc ) const;
144 double absMax2( const GLComponent *glc ) const;
145 double absMin( int dim, const GLComponent *glc ) const
146 { return dim == 1 ? absMin2( glc ) : absMin1( glc ); }
147 double absMax( int dim, const GLComponent *glc ) const
148 { return dim == 1 ? absMax2( glc ) : absMax1( glc ); }
149
150 void setAbsMin1( const GLComponent *glc, double x );
152 void setAbsMax1( const GLComponent *glc, double x );
154 void setAbsMin2( const GLComponent *glc, double x );
156 void setAbsMax2( const GLComponent *glc, double x );
157 void setAbsMin( int dim, const GLComponent *glc, double x )
158 { if( dim == 1 ) setAbsMin2( glc, x ); else setAbsMin1( glc, x ); }
159 void setAbsMax( int dim, const GLComponent *glc, double x )
160 { if( dim == 1 ) setAbsMax2( glc, x ); else setAbsMax1( glc, x ); }
161
162 double relValue1( const AObject *obj, double absval ) const;
163 double relValue2( const AObject *obj, double absval ) const;
164 double relValue( int dim, const AObject *obj, double absval ) const
165 { return dim == 1 ? relValue2( obj, absval ) : relValue1( obj, absval ); }
166 double absValue1( const AObject *obj, double relval ) const;
167 double absValue2( const AObject *obj, double relval ) const;
168 double absValue( int dim, const AObject* obj, double relval ) const
169 { return dim == 1 ? absValue2( obj, relval ) : absValue1( obj, relval ); }
170
171 double relValue1( const GLComponent *glc, double absval ) const;
172 double relValue2( const GLComponent *glc, double absval ) const;
173 double relValue( int dim, const GLComponent *glc, double absval ) const
174 { return dim == 1 ? relValue2( glc, absval ) : relValue1( glc, absval ); }
175 double absValue1( const GLComponent *glc, double relval ) const;
176 double absValue2( const GLComponent *glc, double relval ) const;
177 double absValue( int dim, const GLComponent* glc, double relval ) const
178 { return dim == 1 ? absValue2( glc, relval ) : absValue1( glc, relval ); }
179
185 std::string mixMethodName() const { return( _mixMethodName ); }
186 void setMixMethod( const std::string & name );
187 double linearMixFactor() const { return( _linMixFactor ); }
188 void setLinearMixFactor( double x ) { _linMixFactor = x; }
189 bool is2dMode() const { return _mode2d; }
190 void set2dMode( bool x ) { _mode2d = x; }
191 bool isTransparent() const { return _transp; }
192 AimsRGBA normColor( double x, double y = 0 ) const;
193 AimsRGBA normColor( const Point2df & pos ) const;
194 bool zeroCenteredAxis1() const { return _zeroCentered1; }
195 bool zeroCenteredAxis2() const { return _zeroCentered2; }
196 bool zeroCenteredAxis( int dim = 0 ) const
197 { return dim == 1 ? zeroCenteredAxis2() : zeroCenteredAxis1(); }
198 void setZeroCenteredAxis1( bool x ) { _zeroCentered1 = x; }
199 void setZeroCenteredAxis2( bool x ) { _zeroCentered2 = x; }
200 void setZeroCenteredAxis( int dim, bool x )
201 { if( dim == 1 ) setZeroCenteredAxis2( x ); else setZeroCenteredAxis1( x );
202 }
203
205 const carto::Volume<AimsRGBA> *map2,
206 unsigned x, unsigned y,
207 const AObjectPalette & pal );
209 const carto::Volume<AimsRGBA> *map2,
210 unsigned x, unsigned y,
211 const AObjectPalette & pal );
213 const carto::Volume<AimsRGBA> *map2,
214 unsigned x, unsigned y,
215 const AObjectPalette & pal );
216 bool set( const carto::GenericObject & );
223 int maxSizeX() const { return _maxSizeX; }
224 int maxSizeY() const { return _maxSizeY; }
225 void setMaxSize( int maxsizex, int maxsizey );
231 int glMaxSizeX() const { return _glMaxSizeX; }
232 int glMaxSizeY() const { return _glMaxSizeY; }
233 void glSetMaxSize( int glmaxsizex, int glmaxsizey );
236 void copyColors( const AObjectPalette & pal );
238 void copyOrFillColors( const AObjectPalette & pal );
239
240 static std::map<std::string, MixMethod> mixMethods;
250 QImage* toQImage( int w = 0, int h = 0, double min1 = 0., double max1 = 1.,
251 double zero1 = 0.5, double min2 = 0., double max2 = 1.,
252 double zero2 = 0.5 ) const;
254 toVolume( int w = 0, int h = 0, bool scaled = true ) const;
255
256 protected:
257 static std::map<std::string, MixMethod> defaultMixMethods();
258
261 double _min;
262 double _max;
264 double _min2;
265 double _max2;
267 std::string _mixMethodName;
278 };
279
280}
281
282
283#endif
carto::rc_ptr< APalette > _refPal2
int glMaxSizeX() const
Maximum size of the OpenGL palette image, after scaling.
double absMax1(const GLComponent *glc) const
get the absolute max for a given object
void create(unsigned dimx, unsigned dimy=1, unsigned dimz=1, unsigned dimt=1)
AObjectPalette(const AObjectPalette &x)
void setMaxSize(int maxsizex, int maxsizey)
double absMin1(const GLComponent *glcj) const
get the absolute min for a given object
QImage * toQImage(int w=0, int h=0, double min1=0., double max1=1., double zero1=0.5, double min2=0., double max2=1., double zero2=0.5) const
Get the palette image in a QImage.
void setAbsMax2(const AObject *obj, double x)
set the max from an absolute value for a given object
bool set(const carto::GenericObject &)
void setAbsMin1(const GLComponent *glc, double x)
set the min from an absolute value for a given object
double relValue2(const AObject *obj, double absval) const
void setAbsMax(int dim, const AObject *obj, double x)
static AimsRGBA linearMixMethod(const carto::Volume< AimsRGBA > &map1, const carto::Volume< AimsRGBA > *map2, unsigned x, unsigned y, const AObjectPalette &pal)
double absValue(int dim, const GLComponent *glc, double relval) const
double absValue1(const AObject *obj, double relval) const
carto::rc_ptr< carto::Volume< AimsRGBA > > toVolume(int w=0, int h=0, bool scaled=true) const
bool zeroCenteredAxis(int dim=0) const
virtual AObjectPalette * clone() const
Palette1DMapping _palette1DMapping
void setAbsMin2(const AObject *obj, double x)
set the min from an absolute value for a given object
double absMax(int dim, const GLComponent *glc) const
void setRefPalette2(carto::rc_ptr< APalette > pal)
void setMax(int dim, double x)
double absMin(int dim, const GLComponent *glc) const
double absMax(int dim, const AObject *obj) const
void setZeroCenteredAxis1(bool x)
static std::map< std::string, MixMethod > mixMethods
void setAbsMax(int dim, const GLComponent *glc, double x)
void setZeroCenteredAxis(int dim, bool x)
double linearMixFactor() const
void setAbsMin1(const AObject *obj, double x)
set the min from an absolute value for a given object
double relValue2(const GLComponent *glc, double absval) const
double relValue(int dim, const AObject *obj, double absval) const
void setAbsMin(int dim, const AObject *obj, double x)
carto::rc_ptr< APalette > refPalette(int dim=0) const
void setPalette1DMapping(Palette1DMapping palette1DMapping)
std::string palette1DMappingName() const
void setAbsMax1(const GLComponent *glc, double x)
set the max from an absolute value for a given object
void copyColors(const AObjectPalette &pal)
if pal colors size is compatible, just copy it
double absValue1(const GLComponent *glc, double relval) const
void setRefPalette1(carto::rc_ptr< APalette > pal)
AObjectPalette(carto::rc_ptr< APalette > pal)
double absValue2(const GLComponent *glc, double relval) const
static std::map< std::string, MixMethod > defaultMixMethods()
void setPalette1DMappingName(std::string palette1DMappingName)
AimsRGBA normColor(double x, double y=0) const
void setRefPalette(int dim, carto::rc_ptr< APalette > pal)
void setAbsMax1(const AObject *obj, double x)
set the max from an absolute value for a given object
carto::VolumeRef< AimsRGBA > _colors
void glSetMaxSize(int glmaxsizex, int glmaxsizey)
void setLinearMixFactor(double x)
void setAbsMin(int dim, const GLComponent *glc, double x)
double absMax1(const AObject *obj) const
get the absolute max for a given object
double absMin(int dim, const AObject *obj) const
carto::rc_ptr< APalette > refPalette2() const
static AimsRGBA geometricMixMethod(const carto::Volume< AimsRGBA > &map1, const carto::Volume< AimsRGBA > *map2, unsigned x, unsigned y, const AObjectPalette &pal)
carto::Volume< AimsRGBA > * colors()
double relValue(int dim, const GLComponent *glc, double absval) const
int maxSizeX() const
Maximum size of the internal palette image.
void copyOrFillColors(const AObjectPalette &pal)
if pal colors size is compatible, just copy it; otherwise call fill()
carto::Object genericDescription() const
const carto::Volume< AimsRGBA > * colors() const
AimsRGBA normColor(const Point2df &pos) const
double absValue2(const AObject *obj, double relval) const
double relValue1(const AObject *obj, double absval) const
void setMin(int dim, double x)
double max(int dim=0) const
double absMin2(const AObject *obj) const
get the absolute min for a given object
double absMin2(const GLComponent *glc) const
get the absolute min for a given object
virtual AObjectPalette & operator=(const AObjectPalette &x)
void setAbsMax2(const GLComponent *glc, double x)
set the max from an absolute value for a given object
double absMax2(const GLComponent *glc) const
get the absolute max for a given object
double absValue(int dim, const AObject *obj, double relval) const
double relValue1(const GLComponent *glc, double absval) const
double absMax2(const AObject *obj) const
get the absolute max for a given object
AimsRGBA(* MixMethod)(const carto::Volume< AimsRGBA > &map1, const carto::Volume< AimsRGBA > *map2, unsigned x, unsigned y, const AObjectPalette &pal)
std::string mixMethodName() const
double min(int dim=0) const
void setMixMethod(const std::string &name)
double absMin1(const AObject *obj) const
get the absolute min for a given object
void setAbsMin2(const GLComponent *glc, double x)
set the min from an absolute value for a given object
carto::rc_ptr< APalette > _refPal
void setZeroCenteredAxis2(bool x)
static AimsRGBA palette2DMixMethod(const carto::Volume< AimsRGBA > &map1, const carto::Volume< AimsRGBA > *map2, unsigned x, unsigned y, const AObjectPalette &pal)
void setRefPalette(carto::rc_ptr< APalette > pal)
Base Anatomist object (abstract)
Definition Object.h:97
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition glcomponent.h:67
carto::VoxelRGBA AimsRGBA
AimsVector< float, 2 > Point2df