47 , m_TextureAlphaLevels(1)
49 , m_MaxColorTableSize(16384)
51 , m_MaxColorTableSize(0)
64 , m_TextureAlphaLevels(1)
66 , m_MaxColorTableSize(16384)
68 , m_MaxColorTableSize(0)
130 if (dist < min_dist) {
152 size_t current_size =
m_Colors.size();
155 _TRACE(
"Warning - color table full");
182 float base_r = start_c.
GetRed();
184 float base_b = start_c.
GetBlue();
187 float d_r = end_c.
GetRed() - base_r;
188 float d_g = end_c.
GetGreen() - base_g;
189 float d_b = end_c.
GetBlue() - base_b;
190 float d_a = end_c.
GetAlpha() - base_a;
192 float K = 1.0f / (
n - 1);
193 for(
int i = 0;
i <
n;
i++ ) {
195 float r = base_r + d * d_r;
196 float g = base_g + d * d_g;
197 float b = base_b + d * d_b;
198 float a = base_a + d * d_a;
215 <<
"is an even number. Gradient table will not be symmetrical!");
229 _TRACE(
" no colors to create texture");
237 if (alpha_levels < 1)
254 if (
size > 1024*1024) {
265 vector<CRgbaColor> power_of_two_buffer =
m_Colors;
266 float alpha_factor = 1.0f;
270 for (
size_t j=0; j<
m_Colors.size(); ++j) {
273 power_of_two_buffer.push_back(c);
298 int alpha_level = color_idx /
int(
m_Colors.size());
301 if (color_idx >= (
int)
m_Colors.size()) {
302 _TRACE(
"Texture coord: " <<
f <<
" mapped to an invalid color index: " << color_idx);
322 alpha_level =
std::max(alpha_level, 0);
325 float level_offset = (float)(
m_Colors.size()*(size_t)alpha_level);
328 return ( (((
float)idx) + level_offset + 0.5f)/scaled_width );
class CRgbaColor provides a simple abstraction for managing colors.
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Warning(CExceptionArgs_Base &args)
GLsizei m_TextureWidth
Width of the 1D texture (if created).
static CGlResMgr & Instance()
CRgbaColor GetTexCoordColor(float f) const
Get color given a texture coord.
vector< CRgbaColor > m_Colors
size_t AddColor(const CRgbaColor &c)
Add a single color to the table.
CRgbaGradColorTable()
CRgbaGradColorTable.
CRgbaGradColorTable & operator=(const CRgbaGradColorTable &rhs)
float FindClosestColor(const CRgbaColor &c, size_t &idx) const
Return index of color with minimum color disance (as defined in CRgbaColor) from c.
void SetSize(size_t size)
float GetColorTexCoord(short idx, float alpha) const
Get position for color with alpha level closest to 'alpha'.
void FillGradient(const CRgbaColor &start_c, const CRgbaColor &end_c)
initialize the whole table with gradient colors in [start_c, end_c] range
int m_TextureAlphaLevels
Number of alpha levels stored in the texture.
static bool CheckGlError()
Check if there are any OpenGL errors.
GLint m_MaxColorTableSize
Maximum size of color texture.
bool FindColor(const CRgbaColor &c, size_t &idx) const
On exact match, returns true with index in idx, false otherwise.
void LoadTexture(int alpha_levels=8)
OpenGL parameters and operations to allow color table to (also) be stored as a 1D texture.
I3DTexture * Create1DRGBATexture(size_t width, float *data)
void ClearColors()
Empty color table.
CIRef< I3DTexture > m_Texture
static float ColorDistance(const CRgbaColor &c1, const CRgbaColor &c2)
returns the distance in the RGB color cube between the two colors, scaled to a range [0,...
float GetBlue(void) const
float GetGreen(void) const
float GetAlpha(void) const
float GetRed(void) const
Get specific channels in floating point values.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)