DGtal  0.9.2
TickedColorMap.h
1 
17 #pragma once
18 
31 #if defined(TickedColorMap_RECURSES)
32 #error Recursive header files inclusion detected in TickedColorMap.h
33 #else // defined(TickedColorMap_RECURSES)
34 
35 #define TickedColorMap_RECURSES
36 
37 #if !defined TickedColorMap_h
38 
39 #define TickedColorMap_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <vector>
45 #include <utility>
46 #include <algorithm>
47 #include "DGtal/base/Common.h"
48 #include "DGtal/io/Color.h"
49 #include "DGtal/io/colormaps/CColorMap.h"
51 
52 namespace DGtal
53 {
54 
56  // template class TickedColorMap
77  template <typename TValue, typename TColorMap>
79  {
80 
81  public:
82 
84  typedef TValue Value;
85 
87  typedef TColorMap ColorMap;
88 
91 
92  // ----------------------- Standard services ------------------------------
93  public:
94 
104  TickedColorMap(const Value & aMin,
105  const Value & aMax,
106  const Color &color = Color::White);
107 
117  Color operator()( const Value & value ) const;
118 
122  ~TickedColorMap();
123 
128  TickedColorMap ( const TickedColorMap & other );
129 
135  TickedColorMap & operator= ( const TickedColorMap & other );
136 
137  // ----------------------- Interface --------------------------------------
138  public:
139 
147  void addTick(const Value position,
148  const Value thickness);
149 
156  void addRegularTicks(const unsigned int nbTicks,
157  const Value thickness);
158 
165  void finalize();
166 
170  ColorMap * colormap() const
171  {
172  return myColorMap;
173  }
174 
179  void selfDisplay ( std::ostream & out ) const;
180 
185  bool isValid() const;
186 
192  const Value & min() const;
193 
199  const Value & max() const;
200 
201 
202  // ------------------------- Hidden services ------------------------------
203  protected:
204 
205  Value myMin;
206  Value myMax;
207  ColorMap *myColorMap;
210  std::vector< std::pair<Value,Value> > myTicks;
212 
217  TickedColorMap();
218 
219  }; // end of class TickedColorMap2d
220 
221 
227  template <typename TValue, typename CMAP >
228  std::ostream&
229  operator<< ( std::ostream & out, const TickedColorMap<TValue,CMAP> & object );
230 
231 } // namespace DGtal
232 
233 
235 // Includes inline functions.
236 #include "DGtal/io/colormaps/TickedColorMap.ih"
237 
238 // //
240 
241 #endif // !defined TickedColorMap_h
242 
243 #undef TickedColorMap_RECURSES
244 #endif // else defined(TickedColorMap_RECURSES)
TickedColorMap & operator=(const TickedColorMap &other)
void selfDisplay(std::ostream &out) const
ColorMap * colormap() const
void addTick(const Value position, const Value thickness)
bool isValid() const
BOOST_CONCEPT_ASSERT((concepts::CColorMap< ColorMap >))
TColorMap ColorMap
Adapted colormap type.
BOOST_STATIC_ASSERT((concepts::ConceptUtils::SameType< Value, typename ColorMap::Value >::value))
void addRegularTicks(const unsigned int nbTicks, const Value thickness)
std::vector< std::pair< Value, Value > > myTicks
Sorted vector of ticks.
DGtal is the top-level namespace which contains all DGtal functions and types.
const Value & max() const
TValue Value
Value type.
const Value & min() const
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
static const Color White
Definition: Color.h:390
Aim: Defines the concept describing a color map. A color map converts a value within a given range in...
Definition: CColorMap.h:93
Color operator()(const Value &value) const
Aim: This class adapts any colormap to add "ticks" in the colormap colors.