g4tools  5.4.0
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tools::sg::base_colormap Class Referenceabstract
Inheritance diagram for tools::sg::base_colormap:
Inheritance graph
[legend]

Public Member Functions

virtual void get_color (float, colorf &) const =0
 
virtual void * cast (const std::string &) const =0
 
 base_colormap ()
 
 base_colormap (const base_colormap &aFrom)
 
base_colormapoperator= (const base_colormap &aFrom)
 
virtual ~base_colormap ()
 
size_t colorn () const
 
size_t valn () const
 
colorf color (size_t a_index) const
 
float value (size_t a_index) const
 
void set_colors (void(*aGet)(float, colorf &), size_t a_ncell)
 
void set_PAW_coloring ()
 

Static Protected Member Functions

static float take_log (float aVal)
 

Protected Attributes

std::vector< float > m_values
 
std::vector< colorfm_colors
 

Detailed Description

Definition at line 18 of file colormap.

Constructor & Destructor Documentation

◆ base_colormap() [1/2]

tools::sg::base_colormap::base_colormap ( )
inline

Definition at line 29 of file colormap.

29  {
30 #ifdef TOOLS_MEM
31  mem::increment(s_class().c_str());
32 #endif
33  }

◆ base_colormap() [2/2]

tools::sg::base_colormap::base_colormap ( const base_colormap aFrom)
inline

Definition at line 34 of file colormap.

35  :m_values(aFrom.m_values),m_colors(aFrom.m_colors){
36 #ifdef TOOLS_MEM
37  mem::increment(s_class().c_str());
38 #endif
39  }

◆ ~base_colormap()

virtual tools::sg::base_colormap::~base_colormap ( )
inlinevirtual

Definition at line 45 of file colormap.

45  {
46 #ifdef TOOLS_MEM
47  mem::decrement(s_class().c_str());
48 #endif
49  }

Member Function Documentation

◆ cast()

virtual void* tools::sg::base_colormap::cast ( const std::string &  ) const
pure virtual

◆ color()

colorf tools::sg::base_colormap::color ( size_t  a_index) const
inline

Definition at line 53 of file colormap.

53  {
54  size_t n = m_colors.size();
55  if(a_index>=n) return colorf(0.5F,0.5F,0.5F);
56  return m_colors[a_index];
57  }

◆ colorn()

size_t tools::sg::base_colormap::colorn ( ) const
inline

Definition at line 51 of file colormap.

51 {return m_colors.size();}

◆ get_color()

virtual void tools::sg::base_colormap::get_color ( float  ,
colorf  
) const
pure virtual

◆ operator=()

base_colormap& tools::sg::base_colormap::operator= ( const base_colormap aFrom)
inline

Definition at line 40 of file colormap.

40  {
41  m_values = aFrom.m_values;
42  m_colors = aFrom.m_colors;
43  return *this;
44  }

◆ set_colors()

void tools::sg::base_colormap::set_colors ( void(*)(float, colorf &)  aGet,
size_t  a_ncell 
)
inline

Definition at line 65 of file colormap.

65  {
66  m_colors.clear();
67  m_colors.resize(a_ncell);
68  if(!a_ncell) return;
69  float d = 1.0F/(a_ncell-1);
70  for(size_t index=0;index<a_ncell;index++) {
71  aGet(d*index,m_colors[index]);
72  }
73  }

◆ set_PAW_coloring()

void tools::sg::base_colormap::set_PAW_coloring ( )
inline

Definition at line 75 of file colormap.

75  {
76  size_t _valn = m_values.size();
77  if(_valn==1) {
78  m_values[0] = take_log(m_values[0]);
79  } else if(_valn>=2) {
80  //CERN/PAW coloring :
81  if(m_values[0]==0) m_values[0] = 10e-5F;
82  float vmin = take_log(m_values[0]);
83  float vmax = take_log(m_values[_valn-1]);
84  float dv = (vmax-vmin)/(_valn-1);
85  for(size_t count=0;count<_valn;count++) {
86  m_values[count] = vmin + dv * count;
87  }
88  }
89  }

◆ take_log()

static float tools::sg::base_colormap::take_log ( float  aVal)
inlinestaticprotected

Definition at line 92 of file colormap.

92  {
93  if(aVal<=0) {
94  return -FLT_MAX;
95  } else {
96  return flog10(aVal);
97  }
98  }

◆ valn()

size_t tools::sg::base_colormap::valn ( ) const
inline

Definition at line 52 of file colormap.

52 {return m_values.size();}

◆ value()

float tools::sg::base_colormap::value ( size_t  a_index) const
inline

Definition at line 58 of file colormap.

58  {
59  size_t n = m_values.size();
60  if(a_index>=n) return 0;
61  return m_values[a_index];
62  }

Member Data Documentation

◆ m_colors

std::vector<colorf> tools::sg::base_colormap::m_colors
protected

Definition at line 102 of file colormap.

◆ m_values

std::vector<float> tools::sg::base_colormap::m_values
protected

Definition at line 101 of file colormap.


The documentation for this class was generated from the following file:
tools::sg::base_colormap::m_values
std::vector< float > m_values
Definition: colormap:101
tools::sg::base_colormap::m_colors
std::vector< colorf > m_colors
Definition: colormap:102
tools::sg::base_colormap::take_log
static float take_log(float aVal)
Definition: colormap:92
tools::flog10
float flog10(const float &x)
Definition: mathf:53