58 #include <ACG/Utils/ColorCoder.hh>
77 val0_ = val1_ = val2_ = val3_ = val4_ = _min;
80 std::swap(_min, _max);
83 val2_ = 0.5 * (val0_ + val4_);
84 val1_ = 0.5 * (val0_ + val2_);
85 val3_ = 0.5 * (val2_ + val4_);
87 signed_mode_ = _signed;
93 return signed_mode_ ? color_signed(_v) : color_unsigned(_v);
101 c = color_signed(_v);
103 c = color_unsigned(_v);
112 c = color_signed(_v);
114 c = color_unsigned(_v);
115 return (
ACG::Vec3f(c[0], c[1], c[2]) / 255.f);
123 c = color_signed(_v);
125 c = color_unsigned(_v);
126 return (
ACG::Vec4f(c[0], c[1], c[2], c[3]) / 255.f);
134 c = color_signed(_v);
136 c = color_unsigned(_v);
138 return(QColor(c[0], c[1], c[2], c[3]));
152 ACG::Vec4uc ColorCoder::color_unsigned(
float _v)
const
167 u = (
unsigned char) (255.0 * (_v - val0_) / (val1_ - val0_));
172 u = (
unsigned char) (255.0 * (_v - val1_) / (val2_ - val1_));
178 u = (
unsigned char) (255.0 * (_v - val2_) / (val3_ - val2_));
183 u = (
unsigned char) (255.0 * (_v - val3_) / (val4_ - val3_));
189 ACG::Vec4uc ColorCoder::color_signed(
float _v)
const
194 unsigned char r, g, b;
202 r = val0_ ? (
unsigned char) (255.0 * _v / val0_) : 0;
206 b = val4_ ? (
unsigned char) (255.0 * _v / val4_) : 0;
float max() const
max scalar value
Namespace providing different geometric functions concerning angles.
ACG::Vec3f color_float(float _v) const
color coding
float min() const
min scalar value
ACG::Vec4uc color4(float _v) const
color coding
ColorCoder(float _min=0.0, float _max=1.0, bool _signed=false)
Default constructor.
QColor color_qcolor(float _v) const
color coding
ACG::Vec4f color_float4(float _v) const
color coding
void set_range(float _min, float _max, bool _signed)
set the color coding range for unsigned coding
VectorT< unsigned char, 4 > Vec4uc
ACG::Vec3uc color(float _v) const
color coding