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 }

Generated for HippoDraw Class Library by doxygen