BinToColorMap.cxx
Go to the documentation of this file.
1 
12 #include "BinToColorMap.h"
13 
14 #include <cmath>
15 using std :: string;
16 
17 #include <cassert>
18 
19 namespace hippodraw {
20 
21 BinToColorMap::BinToColorMap ( const char * name )
22  : BinToColor ( name )
23 {
24  m_control_points.push_back ( .5 );
25  calcGamma ( );
26 }
27 
28 bool
31 {
32  return true;
33 }
34 
35 void
37 setControlPoints ( const std::vector < double > & points )
38 {
39  m_control_points[0] = points[0];
40  calcGamma ( );
41 }
42 
43 void
46 {
47  double f = m_control_points[0];
48  m_gamma = std::pow ( 100., ( f - 0.5) );
49 }
50 
52  : BinToColor ( bin_to_color )
53 
54 {
55  m_reds = bin_to_color.m_reds;
56  m_greens = bin_to_color.m_greens;
57  m_blues = bin_to_color.m_blues;
58  m_control_points = bin_to_color.m_control_points;
59  calcGamma ();
60 }
61 
62 
63 
65 {
66 }
67 
68 void
70 doubleToColor ( double value, Color & color ) const
71 {
72  double tmp = ( value - m_vmin ) / m_dv;
73  int index = static_cast < int > (255. * std::pow( tmp, m_gamma) );
74  assert ( index < 256 );
75  color.setColor ( m_reds[index], m_greens[index], m_blues[index] );
76 }
77 
78 } // namespace hippodraw
79 
double m_gamma
The gamma correction factor.
Definition: BinToColorMap.h:35
bool hasControlPoints() const
Retruns true.
std::vector< int > m_reds
vector of reds for color map.
Definition: BinToColorMap.h:44
The base class for the value to the color transformation.
Definition: BinToColor.h:30
void setColor(const std::string &)
Sets the color.
Definition: Color.cxx:112
BinToColorMap(const char *name)
The constructor.
double m_vmin
The minimum value expected.
Definition: BinToColor.h:54
hippodraw::BinToColorMap class interface
std::vector< double > m_control_points
A set of control points that might be used for the value to color transform.
Definition: BinToColor.h:46
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
The base class for the value to the color transformation.
Definition: BinToColorMap.h:29
void calcGamma()
Calculate the gamma factor based on current control points.
virtual ~BinToColorMap()
The destructor.
std::vector< int > m_greens
vector of greens for color map.
Definition: BinToColorMap.h:47
virtual void setControlPoints(const std::vector< double > &points)
Set the value of the control points.
virtual void doubleToColor(double value, Color &color) const
This function does the actual calculation that transforms the given value into a color using the curr...
std::vector< int > m_blues
vector of blues for color map.
Definition: BinToColorMap.h:50
double m_dv
The distance of the expected values, i.e.
Definition: BinToColor.h:50
return index
Definition: PickTable.cxx:182

Generated for HippoDraw Class Library by doxygen