00001
00002 #ifndef vgui_range_map_params_h_
00003 #define vgui_range_map_params_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <vbl/vbl_ref_count.h>
00027 #include <vcl_iostream.h>
00028 #include <vcl_vector.h>
00029 #include <vcl_string.h>
00030
00031 class vgui_range_map_params : public vbl_ref_count
00032 {
00033 public:
00034
00035 enum {RGBA_m, RGB_m, XRG_m, RXB_m, RGX_m, END_m};
00036
00037 static vcl_vector<vcl_string> bmap;
00038
00039 unsigned n_components_;
00040 long double min_L_;
00041 long double max_L_;
00042 float gamma_L_;
00043 bool invert_;
00044 long double min_R_;
00045 long double max_R_;
00046 float gamma_R_;
00047 long double min_G_;
00048 long double max_G_;
00049 float gamma_G_;
00050 long double min_B_;
00051 long double max_B_;
00052 float gamma_B_;
00053 long double min_X_;
00054 long double max_X_;
00055 float gamma_X_;
00056 int band_map_;
00057
00058
00059 bool use_glPixelMap_;
00060 bool cache_mapped_pix_;
00061
00062
00063 vgui_range_map_params(const long double min_L,
00064 const long double max_L,
00065 const float gamma_L = 1.0f,
00066 const bool invert = false,
00067 const bool use_glPixelMap = false,
00068 const bool cache_mapped_pix= false)
00069 : n_components_(1),
00070 min_L_(min_L), max_L_(max_L), gamma_L_(gamma_L), invert_(invert),
00071 min_R_(0), max_R_(0), gamma_R_(1.0f),
00072 min_G_(0), max_G_(0), gamma_G_(1.0f),
00073 min_B_(0), max_B_(0), gamma_B_(1.0f),
00074 min_X_(0), max_X_(0), gamma_X_(1.0f), band_map_(0),
00075 use_glPixelMap_(use_glPixelMap), cache_mapped_pix_(cache_mapped_pix)
00076 {}
00077
00078
00079 vgui_range_map_params(const long double min_R,
00080 const long double max_R,
00081 const long double min_G,
00082 const long double max_G,
00083 const long double min_B,
00084 const long double max_B,
00085 const float gamma_R = 1.0f,
00086 const float gamma_G = 1.0f,
00087 const float gamma_B = 1.0f,
00088 const bool invert = false,
00089 const bool use_glPixelMap = false,
00090 const bool cache_mapped_pix= false)
00091 : n_components_(3),
00092 min_L_(0), max_L_(0), gamma_L_(1.0f), invert_(invert),
00093 min_R_(min_R), max_R_(max_R), gamma_R_(gamma_R),
00094 min_G_(min_G), max_G_(max_G), gamma_G_(gamma_G),
00095 min_B_(min_B), max_B_(max_B), gamma_B_(gamma_B),
00096 min_X_(0), max_X_(0), gamma_X_(1.0f), band_map_(0),
00097 use_glPixelMap_(use_glPixelMap), cache_mapped_pix_(cache_mapped_pix)
00098 {}
00099
00100
00101 vgui_range_map_params(const long double min_R,
00102 const long double max_R,
00103 const long double min_G,
00104 const long double max_G,
00105 const long double min_B,
00106 const long double max_B,
00107 const long double min_X,
00108 const long double max_X,
00109 const float gamma_R = 1.0f,
00110 const float gamma_G = 1.0f,
00111 const float gamma_B = 1.0f,
00112 const float gamma_X = 1.0f,
00113 const int band_map = 0,
00114 const bool invert = false,
00115 const bool use_glPixelMap = false,
00116 const bool cache_mapped_pix= false)
00117 : n_components_(4),
00118 min_L_(0), max_L_(0), gamma_L_(1.0f), invert_(invert),
00119 min_R_(min_R), max_R_(max_R), gamma_R_(gamma_R),
00120 min_G_(min_G), max_G_(max_G), gamma_G_(gamma_G),
00121 min_B_(min_B), max_B_(max_B), gamma_B_(gamma_B),
00122 min_X_(min_X), max_X_(max_X), gamma_X_(gamma_X), band_map_(band_map),
00123 use_glPixelMap_(use_glPixelMap), cache_mapped_pix_(cache_mapped_pix)
00124 {}
00125
00126
00127 vgui_range_map_params(vgui_range_map_params const& p)
00128 : vbl_ref_count(), n_components_(p.n_components_),
00129 min_L_(p.min_L_), max_L_(p.max_L_), gamma_L_(p.gamma_L_), invert_(p.invert_),
00130 min_R_(p.min_R_), max_R_(p.max_R_), gamma_R_(p.gamma_R_),
00131 min_G_(p.min_G_), max_G_(p.max_G_), gamma_G_(p.gamma_G_),
00132 min_B_(p.min_B_), max_B_(p.max_B_), gamma_B_(p.gamma_B_),
00133 min_X_(p.min_X_), max_X_(p.max_X_), gamma_X_(p.gamma_X_),
00134 band_map_(p.band_map_),
00135 use_glPixelMap_(p.use_glPixelMap_), cache_mapped_pix_(p.cache_mapped_pix_)
00136 {}
00137
00138
00139 inline bool operator==(vgui_range_map_params const& p) const
00140 {
00141 if (n_components_ != p.n_components_)
00142 return false;
00143 if (n_components_ == 1)
00144 return min_L_==p.min_L_ && max_L_== p.max_L_&& gamma_L_ == p.gamma_L_ &&
00145 invert_ == p.invert_ &&
00146 use_glPixelMap_ == p.use_glPixelMap_ &&
00147 cache_mapped_pix_ == p.cache_mapped_pix_;
00148 else if (n_components_ == 3||n_components_ == 4)
00149 return min_L_==p.min_L_ && max_L_==p.max_L_ && gamma_L_==p.gamma_L_ &&
00150 min_R_==p.min_R_ && max_R_==p.max_R_ && gamma_R_==p.gamma_R_ &&
00151 min_G_==p.min_G_ && max_G_==p.max_G_ && gamma_G_==p.gamma_G_ &&
00152 min_B_==p.min_B_ && max_B_==p.max_B_ && gamma_B_==p.gamma_B_ &&
00153 (n_components_ == 3 ||
00154 (min_X_==p.min_X_ && max_X_==p.max_X_ && gamma_X_==p.gamma_X_))&&
00155 band_map_==p.band_map_ &&
00156 invert_ == p.invert_ &&
00157 use_glPixelMap_ == p.use_glPixelMap_ &&
00158 cache_mapped_pix_ == p.cache_mapped_pix_;
00159 else
00160 return false;
00161 }
00162
00163 inline bool operator!=(vgui_range_map_params const& p)const
00164 { return !operator==(p); }
00165
00166 void print(vcl_ostream& os) const
00167 {
00168 os << '\n';
00169 if (n_components_ == 1)
00170 os << "range_map_params:\n"
00171 << "min L range value " << min_L_ << '\n'
00172 << "max L range value " << max_L_ << '\n'
00173 << "gammaL " << gamma_L_ << '\n';
00174 else if (n_components_ >=3)
00175 os << "range_map_params:\n"
00176 << "min R range value " << min_R_ << '\n'
00177 << "max R range value " << max_R_ << '\n'
00178 << "gammaR " << gamma_R_ << '\n'
00179 << "min G range value " << min_G_ << '\n'
00180 << "max G range value " << max_G_ << '\n'
00181 << "gammaG " << gamma_G_ << '\n'
00182 << "min B range value " << min_B_ << '\n'
00183 << "max B range value " << max_B_ << '\n'
00184 << "gammaB " << gamma_B_ << '\n';
00185
00186 if (n_components_ == 4)
00187 os << "min X range value " << min_X_ << '\n'
00188 << "max X range value " << max_X_ << '\n'
00189 << "gammaX " << gamma_X_ << '\n'
00190 << "band map " << bmap[band_map_] << '\n';
00191
00192 if (invert_)
00193 os << "invert true\n";
00194 else
00195 os << "invert false\n";
00196 if (use_glPixelMap_)
00197 os << "use_glPixelMap true\n";
00198 else
00199 os << "use_glPixelMap false\n";
00200
00201 if (cache_mapped_pix_)
00202 os << "cache_mapped_pix true\n";
00203 else
00204 os << "cache_mapped_pix false\n";
00205 }
00206 };
00207
00208 #include <vgui/vgui_range_map_params_sptr.h>
00209
00210 #endif // vgui_range_map_params_h_