DGtal  1.3.beta
GradientColorMap.h
1 
17 #pragma once
18 
31 #if defined(GradientColorMap_RECURSES)
32 #error Recursive header files inclusion detected in GradientColorMap.h
33 #else // defined(GradientColorMap_RECURSES)
34 
35 #define GradientColorMap_RECURSES
36 
37 #if !defined GradientColorMap_h
38 
39 #define GradientColorMap_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "Board/Board.h"
46 #include "DGtal/io/Color.h"
48 
49 #ifndef DGTAL_RGB2INT
50 #define DGTAL_RGB2INT(R,G,B) (((R)<<16)|((G)<<8)|(B))
51 #define DGTAL_RED_COMPONENT(I) (((I)>>16)&0xFF)
52 #define DGTAL_GREEN_COMPONENT(I) (((I)>>8)&0xFF)
53 #define DGTAL_BLUE_COMPONENT(I) ((I)&0xFF)
54 #endif
55 
56 namespace DGtal
57 {
58 
59  // ----------------------- Related enumerations -----------------------------
71 
73  // template class GradientColorMap
115  template <typename PValue,
116  int PDefaultPreset = CMAP_CUSTOM,
117  int PDefaultFirstColor = -1,
118  int PDefaultLastColor = -1 >
120  {
121 
122  public:
123 
124  typedef PValue Value;
125 
126  // ----------------------- Standard services ------------------------------
127  public:
128 
139  GradientColorMap( const PValue & min,
140  const PValue & max,
141  const ColorGradientPreset preset
142  = static_cast<ColorGradientPreset>( PDefaultPreset ),
143  const Color firstColor
144  =
145  ( PDefaultFirstColor == -1 ) ? Color::None :
146  Color( DGTAL_RED_COMPONENT( PDefaultFirstColor ),
147  DGTAL_GREEN_COMPONENT( PDefaultFirstColor ),
148  DGTAL_BLUE_COMPONENT( PDefaultFirstColor ) ),
149  const Color lastColor
150  =
151  ( PDefaultFirstColor == -1 ) ? Color::None :
152  Color( DGTAL_RED_COMPONENT( PDefaultLastColor ),
153  DGTAL_GREEN_COMPONENT( PDefaultLastColor ),
154  DGTAL_BLUE_COMPONENT( PDefaultLastColor ) )
155  );
156 
164  Color operator()( const PValue & value ) const;
165 
170 
175  GradientColorMap ( const GradientColorMap & other );
176 
182  GradientColorMap & operator= ( const GradientColorMap & other );
183 
184  // ----------------------- Interface --------------------------------------
185  public:
186 
191  void clearColors();
192 
198  void addColor( const Color & color );
199 
204  void selfDisplay ( std::ostream & out ) const;
205 
210  bool isValid() const;
211 
217  const PValue & min() const;
218 
224  const PValue & max() const;
225 
226  // ----------------------- Static methods ---------------------------------
227 
239  static Color getColor( const std::vector<Color> & colors,
240  const PValue & min,
241  const PValue & max,
242  PValue value );
243 
244  // ------------------------- Protected Datas ------------------------------
245  private:
246 
247  // ------------------------- Private Datas --------------------------------
248  private:
249 
250  // ------------------------- Hidden services ------------------------------
251  protected:
252 
253  PValue myMin;
254  PValue myMax;
255  std::vector<Color> myColors;
262 
263  // ------------------------- Internals ------------------------------------
264  private:
265 
266 
267  }; // end of class GradientColorMap
268 
275  template <typename PValue,
276  int PDefaultPreset,
277  int PDefaultFirstColor,
278  int PDefaultLastColor >
279  std::ostream&
281 
282 } // namespace DGtal
283 
284 
286 // Includes inline functions.
287 #include "DGtal/io/colormaps/GradientColorMap.ih"
288 
289 // //
291 
292 #endif // !defined GradientColorMap_h
293 
294 #undef GradientColorMap_RECURSES
295 #endif // else defined(GradientColorMap_RECURSES)
DGtal::CMAP_CUSTOM
@ CMAP_CUSTOM
Definition: GradientColorMap.h:60
DGtal::CMAP_SUMMER
@ CMAP_SUMMER
Definition: GradientColorMap.h:63
DGtal::CMAP_SPRING
@ CMAP_SPRING
Definition: GradientColorMap.h:62
DGtal::GradientColorMap::operator()
Color operator()(const PValue &value) const
DGtal::GradientColorMap::myMin
PValue myMin
Definition: GradientColorMap.h:253
DGtal::GradientColorMap::operator=
GradientColorMap & operator=(const GradientColorMap &other)
DGtal::GradientColorMap::getColor
static Color getColor(const std::vector< Color > &colors, const PValue &min, const PValue &max, PValue value)
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::GradientColorMap::isValid
bool isValid() const
DGtal::GradientColorMap::~GradientColorMap
~GradientColorMap()
DGtal::GradientColorMap::Value
PValue Value
Definition: GradientColorMap.h:124
DGtal::GradientColorMap::min
const PValue & min() const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::CMAP_HOT
@ CMAP_HOT
Definition: GradientColorMap.h:68
DGtal::GradientColorMap::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::CMAP_JET
@ CMAP_JET
Definition: GradientColorMap.h:69
DGtal::GradientColorMap::myMax
PValue myMax
Definition: GradientColorMap.h:254
DGtal::GradientColorMap::max
const PValue & max() const
DGtal::CMAP_COOL
@ CMAP_COOL
Definition: GradientColorMap.h:66
DGtal::GradientColorMap::myColors
std::vector< Color > myColors
Definition: GradientColorMap.h:255
DGtal::CMAP_AUTUMN
@ CMAP_AUTUMN
Definition: GradientColorMap.h:64
DGtal::CMAP_VIRIDIS
@ CMAP_VIRIDIS
Definition: GradientColorMap.h:70
DGtal::GradientColorMap::clearColors
void clearColors()
DGtal::CMAP_GRAYSCALE
@ CMAP_GRAYSCALE
Definition: GradientColorMap.h:61
DGtal::GradientColorMap::addColor
void addColor(const Color &color)
DGtal::ColorGradientPreset
ColorGradientPreset
Definition: GradientColorMap.h:60
DGtal::CMAP_COPPER
@ CMAP_COPPER
Definition: GradientColorMap.h:67
DGtal::Color::None
static const Color None
Definition: Color.h:412
DGtal::GradientColorMap::GradientColorMap
GradientColorMap()
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition: GradientColorMap.h:119
DGtal::CMAP_WINTER
@ CMAP_WINTER
Definition: GradientColorMap.h:65