BinToGamma.cxx

Go to the documentation of this file.
00001 
00012 #include "BinToGamma.h"
00013 
00014 #include <cmath>
00015 #include <cassert>
00016 
00017 using std::pow;
00018 
00019 using namespace hippodraw;
00020 
00021 BinToGamma::
00022 BinToGamma ( const char * name )
00023   : BinToColor ( name )
00024 {
00025   m_control_points.push_back(0.5);
00026 }
00027 
00028 BinToGamma::
00029 BinToGamma ( const BinToGamma & bin_to_color )
00030   : BinToColor ( bin_to_color )
00031 {
00032 }
00033 
00034 BinToColor * BinToGamma:: clone () const
00035 {
00036   return new BinToGamma ( *this );
00037 }
00038 
00039 
00040 void
00041 BinToGamma::
00042 doubleToColor ( double value, Color & color ) const
00043 {
00044    assert(m_control_points.size()!=0);
00045 
00046    // brk_pt which represents gamma ranges from [0,1]  
00047    double brk_pt = m_control_points[0];
00048 
00049    // convert gamma from [0,1] to [0,5]
00050    double gam= brk_pt * 8;
00051 
00052    int red=color.getRed();
00053    int green=color.getGreen();
00054    int blue=color.getBlue();
00055 
00056    double red_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) red);
00057    double green_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) green);
00058    double blue_tem= 255. - (pow(((value-m_vmin)/m_dv), gam)) * (255.-(double) blue);
00059 
00060    int ired_tmp = static_cast< int> ( red_tem );
00061    int igreen_tmp = static_cast< int> ( green_tem );
00062    int iblue_tmp = static_cast< int> ( blue_tem );
00063 
00064    //color.setColor ( red, green, blue );
00065    color.setColor ( ired_tmp, igreen_tmp, iblue_tmp );
00066 
00067 }
00068 
00069 bool
00070 BinToGamma::
00071 hasControlPoints () const
00072 {
00073   return true;
00074 }
00075 
00076 bool
00077 BinToGamma::
00078 isUserDefined () const
00079 {
00080   return true;
00081 }
00082 
00083 bool
00084 BinToGamma::
00085 acceptChangeColor () const
00086 { 
00087         return true;
00088 }

Generated for HippoDraw Class Library by doxygen