BinToGamma.cxx
Go to the documentation of this file.
1 
12 #include "BinToGamma.h"
13 
14 #include <cmath>
15 #include <cassert>
16 
17 using std::pow;
18 
19 using namespace hippodraw;
20 
22 BinToGamma ( const char * name )
23  : BinToColor ( name )
24 {
25  m_control_points.push_back(0.5);
26 }
27 
29 BinToGamma ( const BinToGamma & bin_to_color )
30  : BinToColor ( bin_to_color )
31 {
32 }
33 
35 {
36  return new BinToGamma ( *this );
37 }
38 
39 
40 void
42 doubleToColor ( double value, Color & color ) const
43 {
44  assert(m_control_points.size()!=0);
45 
46  // brk_pt which represents gamma ranges from [0,1]
47  double brk_pt = m_control_points[0];
48 
49  // convert gamma from [0,1] to [0,5]
50  double gam= brk_pt * 8;
51 
52  int red=color.getRed();
53  int green=color.getGreen();
54  int blue=color.getBlue();
55 
56  double red_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) red);
57  double green_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) green);
58  double blue_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) blue);
59 
60  int ired_tmp = static_cast< int> ( red_tem );
61  int igreen_tmp = static_cast< int> ( green_tem );
62  int iblue_tmp = static_cast< int> ( blue_tem );
63 
64  //color.setColor ( red, green, blue );
65  color.setColor ( ired_tmp, igreen_tmp, iblue_tmp );
66 
67 }
68 
69 bool
72 {
73  return true;
74 }
75 
76 bool
78 isUserDefined () const
79 {
80  return true;
81 }
82 
83 bool
86 {
87  return true;
88 }
BinToGamma(const char *name)
The constructor.
Definition: BinToGamma.cxx:22
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
BinToGamma class interface.
The class derived from the BinToColor class.
Definition: BinToGamma.h:29
int getRed() const
Definition: Color.cxx:164
double m_vmin
The minimum value expected.
Definition: BinToColor.h:54
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
int getGreen() const
Definition: Color.cxx:169
virtual bool acceptChangeColor() const
Returns true if object can accept changing color,i.e.
Definition: BinToGamma.cxx:85
virtual bool hasControlPoints() const
Returns true.
Definition: BinToGamma.cxx:71
BinToColor * clone() const
Creates a copy of itself.
Definition: BinToGamma.cxx:34
virtual bool isUserDefined() const
Returns true.
Definition: BinToGamma.cxx:78
double m_dv
The distance of the expected values, i.e.
Definition: BinToColor.h:50
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...
Definition: BinToGamma.cxx:42
int getBlue() const
Definition: Color.cxx:174

Generated for HippoDraw Class Library by doxygen