anatomist 6.0.4
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
50 {
51 public:
57
58 typedef AimsRGBA (*MixMethod)(
59 const carto::Volume<AimsRGBA> & map1,
60 const carto::Volume<AimsRGBA> *map2,
61 unsigned x, unsigned y,
62 const AObjectPalette & pal );
63
66 virtual ~AObjectPalette();
67
68 virtual AObjectPalette* clone() const;
69
71
73 { if( dim == 1 ) return _refPal2; else return( _refPal ); }
76 { if( dim == 1 ) setRefPalette2( pal );
77 else setRefPalette1( pal ); }
79 { setRefPalette1( pal ); } // FIXME to be removed
81 { if( _refPal != pal ) { clearColors(); _refPal = pal; } }
84 { if( !_colors.get() ) const_cast<AObjectPalette *>(this)->fill();
85 return _colors.get(); }
87 { if( !_colors.get() ) fill(); return _colors.get(); }
88 void create( unsigned dimx, unsigned dimy = 1, unsigned dimz = 1,
89 unsigned dimt = 1 );
90 virtual void fill();
91 double min1() const { return( _min ); }
92 double max1() const { return( _max ); }
93 double min2() const { return( _min2 ); }
94 double max2() const { return( _max2 ); }
95 double min( int dim = 0 ) const { return dim == 1 ? min2() : min1(); }
96 double max( int dim = 0 ) const { return dim == 1 ? max2() : max1(); }
97 int palette1DMapping() const { return (_palette1DMapping) ; }
98 std::string palette1DMappingName() const
99 { return (_palette1DMapping == 1 ? "Diagonal" : "FirstLine" ) ; }
100 void setMin1( double x )
101 { _min = x; if( isnan( x ) || isinf( x ) ) _min = 0; }
102 void setMax1( double x )
103 { _max = x; if( isnan( x ) || isinf( x ) ) _max = 0; }
104 void setMin2( double x ) { _min2 = x; }
105 void setMax2( double x ) { _max2 = x; }
106 void setMin( int dim, double x )
107 { if( dim == 1 ) setMin2( x ); else setMin1( x ); }
108 void setMax( int dim, double x )
109 { if( dim == 1 ) setMax2( x ); else setMax1( x ); }
110
112 double absMin1( const AObject * obj ) const;
114 double absMax1( const AObject * obj ) const;
116 double absMin2( const AObject * obj ) const;
118 double absMax2( const AObject * obj ) const;
119 double absMin( int dim, const AObject* obj ) const
120 { return dim == 1 ? absMin2( obj ) : absMin1( obj ); }
121 double absMax( int dim, const AObject* obj ) const
122 { return dim == 1 ? absMax2( obj ) : absMax1( obj ); }
123
124 void setAbsMin1( const AObject * obj, double x );
126 void setAbsMax1( const AObject * obj, double x );
128 void setAbsMin2( const AObject * obj, double x );
130 void setAbsMax2( const AObject * obj, double x );
131 void setAbsMin( int dim, const AObject *obj, double x )
132 { if( dim == 1 ) setAbsMin2( obj, x ); else setAbsMin1( obj, x ); }
133 void setAbsMax( int dim, const AObject *obj, double x )
134 { if( dim == 1 ) setAbsMax2( obj, x ); else setAbsMax1( obj, x ); }
135 double relValue1( const AObject * obj, double absval ) const;
136 double relValue2( const AObject * obj, double absval ) const;
137 double relValue( int dim, const AObject* obj, double absval ) const
138 { return dim == 1 ? relValue2( obj, absval ) : relValue1( obj, absval ); }
139 double absValue1( const AObject * obj, double relval ) const;
140 double absValue2( const AObject * obj, double relval ) const;
141 double absValue( int dim, const AObject* obj, double relval ) const
142 { return dim == 1 ? absValue2( obj, relval ) : absValue1( obj, relval ); }
143
149 std::string mixMethodName() const { return( _mixMethodName ); }
150 void setMixMethod( const std::string & name );
151 double linearMixFactor() const { return( _linMixFactor ); }
152 void setLinearMixFactor( double x ) { _linMixFactor = x; }
153 bool is2dMode() const { return _mode2d; }
154 void set2dMode( bool x ) { _mode2d = x; }
155 bool isTransparent() const { return _transp; }
156 AimsRGBA normColor( double x, double y = 0 ) const;
157 AimsRGBA normColor( const Point2df & pos ) const;
158 bool zeroCenteredAxis1() const { return _zeroCentered1; }
159 bool zeroCenteredAxis2() const { return _zeroCentered2; }
160 bool zeroCenteredAxis( int dim = 0 ) const
161 { return dim == 1 ? zeroCenteredAxis2() : zeroCenteredAxis1(); }
162 void setZeroCenteredAxis1( bool x ) { _zeroCentered1 = x; }
163 void setZeroCenteredAxis2( bool x ) { _zeroCentered2 = x; }
164 void setZeroCenteredAxis( int dim, bool x )
165 { if( dim == 1 ) setZeroCenteredAxis2( x ); else setZeroCenteredAxis1( x );
166 }
167
169 const carto::Volume<AimsRGBA> *map2,
170 unsigned x, unsigned y,
171 const AObjectPalette & pal );
173 const carto::Volume<AimsRGBA> *map2,
174 unsigned x, unsigned y,
175 const AObjectPalette & pal );
177 const carto::Volume<AimsRGBA> *map2,
178 unsigned x, unsigned y,
179 const AObjectPalette & pal );
180 bool set( const carto::GenericObject & );
187 int maxSizeX() const { return _maxSizeX; }
188 int maxSizeY() const { return _maxSizeY; }
189 void setMaxSize( int maxsizex, int maxsizey );
195 int glMaxSizeX() const { return _glMaxSizeX; }
196 int glMaxSizeY() const { return _glMaxSizeY; }
197 void glSetMaxSize( int glmaxsizex, int glmaxsizey );
200 void copyColors( const AObjectPalette & pal );
202 void copyOrFillColors( const AObjectPalette & pal );
203
204 static std::map<std::string, MixMethod> mixMethods;
214 QImage* toQImage( int w = 0, int h = 0, double min1 = 0., double max1 = 1.,
215 double zero1 = 0.5, double min2 = 0., double max2 = 1.,
216 double zero2 = 0.5 ) const;
218 toVolume( int w = 0, int h = 0, bool scaled = true ) const;
219
220 protected:
221 static std::map<std::string, MixMethod> defaultMixMethods();
222
225 double _min;
226 double _max;
228 double _min2;
229 double _max2;
231 std::string _mixMethodName;
242 };
243
244}
245
246
247#endif
carto::rc_ptr< APalette > _refPal2
int glMaxSizeX() const
Maximum size of the OpenGL palette image, after scaling.
void create(unsigned dimx, unsigned dimy=1, unsigned dimz=1, unsigned dimt=1)
AObjectPalette(const AObjectPalette &x)
void setMaxSize(int maxsizex, int maxsizey)
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 &)
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 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
void setRefPalette2(carto::rc_ptr< APalette > pal)
void setMax(int dim, double x)
double absMax(int dim, const AObject *obj) const
void setZeroCenteredAxis1(bool x)
static std::map< std::string, MixMethod > mixMethods
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 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 copyColors(const AObjectPalette &pal)
if pal colors size is compatible, just copy it
void setRefPalette1(carto::rc_ptr< APalette > pal)
AObjectPalette(carto::rc_ptr< APalette > pal)
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)
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()
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
virtual AObjectPalette & operator=(const AObjectPalette &x)
double absValue(int dim, const AObject *obj, double relval) 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
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
carto::VoxelRGBA AimsRGBA
AimsVector< float, 2 > Point2df