g4tools  5.4.0
Public Member Functions | Protected Types | List of all members
tools::sg::style_colormap Class Reference
Inheritance diagram for tools::sg::style_colormap:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::style_colormap:
Collaboration graph
[legend]

Public Member Functions

 style_colormap ()
 
virtual ~style_colormap ()
 
 style_colormap (const style_colormap &a_from)
 
style_colormapoperator= (const style_colormap &a_from)
 
bool get_color (unsigned int a_index, colorf &a_col) const
 
bool get_color (const std::string &a_s, colorf &a_col) const
 
bool get_string_color (unsigned int a_index, std::string &a_s) const
 
void add (const style_color &a_color)
 

Protected Types

typedef std::map< unsigned int, style_colormap_t
 

Detailed Description

Definition at line 20 of file style_colormap.

Member Typedef Documentation

◆ map_t

typedef std::map<unsigned int,style_color> tools::sg::style_colormap::map_t
protected

Definition at line 23 of file style_colormap.

Constructor & Destructor Documentation

◆ style_colormap() [1/2]

tools::sg::style_colormap::style_colormap ( )
inline

Definition at line 27 of file style_colormap.

27  :parent(){
28 #ifdef TOOLS_MEM
29  mem::increment(s_class().c_str());
30 #endif
31  }

◆ ~style_colormap()

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

Definition at line 32 of file style_colormap.

32  {
33 #ifdef TOOLS_MEM
34  mem::decrement(s_class().c_str());
35 #endif
36  }

◆ style_colormap() [2/2]

tools::sg::style_colormap::style_colormap ( const style_colormap a_from)
inline

Definition at line 38 of file style_colormap.

38  :parent(a_from){
39 #ifdef TOOLS_MEM
40  mem::increment(s_class().c_str());
41 #endif
42  }

Member Function Documentation

◆ add()

void tools::sg::style_colormap::add ( const style_color a_color)
inline

Definition at line 78 of file style_colormap.

78  {
79  (*this)[uint32((*this).size())] = a_color;
80  }

◆ get_color() [1/2]

bool tools::sg::style_colormap::get_color ( const std::string &  a_s,
colorf a_col 
) const
inline

Definition at line 57 of file style_colormap.

57  {
58  tools_mforcit(unsigned int,style_color,*this,it) {
59  if((*it).second.first==a_s) {
60  a_col = (*it).second.second;
61  return true;
62  }
63  }
64  //we do not set a_col to something.
65  return false;
66  }

◆ get_color() [2/2]

bool tools::sg::style_colormap::get_color ( unsigned int  a_index,
colorf a_col 
) const
inline

Definition at line 48 of file style_colormap.

48  {
49  map_t::const_iterator it = find(a_index);
50  if(it==end()) {
51  a_col.set_value(0.5F,0.5F,0.5F,1);
52  return false;
53  }
54  a_col = (*it).second.second;
55  return true;
56  }

◆ get_string_color()

bool tools::sg::style_colormap::get_string_color ( unsigned int  a_index,
std::string &  a_s 
) const
inline

Definition at line 67 of file style_colormap.

67  {
68  map_t::const_iterator it = find(a_index);
69  if(it==end()) {a_s.clear();return false;}
70  colorf c = (*it).second.second;
71 
72  char ss[192]; //3*64 = 192
73  snpf(ss,sizeof(ss),"%g %g %g",c[0],c[1],c[2]);
74  a_s = std::string(ss);
75  return true;
76  }

◆ operator=()

style_colormap& tools::sg::style_colormap::operator= ( const style_colormap a_from)
inline

Definition at line 43 of file style_colormap.

43  {
44  parent::operator=(a_from);
45  return *this;
46  }

The documentation for this class was generated from the following file:
tools::find
bool find(const std::map< K, V > &a_map, const K &a_key, V &a_value)
Definition: mapmanip:86
tools::snpf
int snpf(char *a_s, size_t a_n, const char *a_fmt,...)
Definition: snpf:27
tools_mforcit
#define tools_mforcit(a__K, a__V, a__m, a__it)
Definition: forit:49
tools::waxml::end
void end(std::ostream &a_writer)
Definition: begend:31
tools::uint32
unsigned int uint32
Definition: typedefs:71