DGtal  1.0.0
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 
116  TickedColorMap( const ColorMap & other,
117  const Color & color = Color::White );
118 
128  Color operator()( const Value & value ) const;
129 
133  ~TickedColorMap();
134 
139  TickedColorMap ( const TickedColorMap & other );
140 
146  TickedColorMap & operator= ( const TickedColorMap & other );
147 
148  // ----------------------- Interface --------------------------------------
149  public:
150 
158  void addTick(const Value position,
159  const Value thickness);
160 
167  void addRegularTicks(const unsigned int nbTicks,
168  const Value thickness);
169 
176  void finalize();
177 
181  ColorMap * colormap() const
182  {
183  return myColorMap;
184  }
185 
190  void selfDisplay ( std::ostream & out ) const;
191 
196  bool isValid() const;
197 
203  const Value & min() const;
204 
210  const Value & max() const;
211 
212 
213  // ------------------------- Hidden services ------------------------------
214  protected:
215 
221  std::vector< std::pair<Value,Value> > myTicks;
223 
228  TickedColorMap();
229 
230  }; // end of class TickedColorMap2d
231 
232 
238  template <typename TValue, typename CMAP >
239  std::ostream&
240  operator<< ( std::ostream & out, const TickedColorMap<TValue,CMAP> & object );
241 
242 } // namespace DGtal
243 
244 
246 // Includes inline functions.
247 #include "DGtal/io/colormaps/TickedColorMap.ih"
248 
249 // //
251 
252 #endif // !defined TickedColorMap_h
253 
254 #undef TickedColorMap_RECURSES
255 #endif // else defined(TickedColorMap_RECURSES)
TickedColorMap & operator=(const TickedColorMap &other)
bool isValid() const
const Value & max() const
Color operator()(const Value &value) const
void selfDisplay(std::ostream &out) const
ColorMap * colormap() const
void addTick(const Value position, const Value thickness)
BOOST_CONCEPT_ASSERT((concepts::CColorMap< ColorMap >))
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
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 & min() const
TValue Value
Value type.
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
Aim: This class adapts any colormap to add "ticks" in the colormap colors.