ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ColorCodeConverter Class Reference

#include <ColorCodeConverter.h>

Collaboration diagram for ColorCodeConverter:

Public Member Functions

SoMaterial * getMaterialFromColorCode (unsigned int colorCode=red)
 
 ~ColorCodeConverter ()
 

Static Public Attributes

static const unsigned int white = 0
 
static const unsigned int black = 1
 
static const unsigned int red = 2
 
static const unsigned int green = 3
 
static const unsigned int blue = 4
 
static const unsigned int yellow = 5
 
static const unsigned int magenta = 6
 
static const unsigned int cyan = 7
 

Private Member Functions

SoMaterial * lookup (unsigned int colorCode)
 

Private Attributes

std::map< unsigned int, SoMaterial * > m_materialCache
 

Static Private Attributes

static const double s_colorConversionTable [][3]
 
static const unsigned int s_colorConversionTableSize = 200
 

Detailed Description

Definition at line 23 of file ColorCodeConverter.h.

Constructor & Destructor Documentation

◆ ~ColorCodeConverter()

ColorCodeConverter::~ColorCodeConverter ( )

Definition at line 252 of file ColorCodeConverter.cxx.

253 {
254  std::map<unsigned int, SoMaterial*>::const_iterator it;
255  for( it = m_materialCache.begin(); it != m_materialCache.end(); ++it)
256  {
257  it->second->unref();
258  }
259 }

Member Function Documentation

◆ getMaterialFromColorCode()

SoMaterial * ColorCodeConverter::getMaterialFromColorCode ( unsigned int  colorCode = red)
inline

Definition at line 50 of file ColorCodeConverter.h.

51 {
52  return lookup( colorCode);
53 }

◆ lookup()

SoMaterial * ColorCodeConverter::lookup ( unsigned int  colorCode)
private

Definition at line 262 of file ColorCodeConverter.cxx.

263 {
264  SoMaterial* ret = nullptr;
265  //sroe: coverity 16515, original was "if (colorCode > s_colorConversionTableSize)"
266  //which still allows colorCode = 200, which is out-of-bounds.
267  if( colorCode >= s_colorConversionTableSize)
268  {
269  // if color code is out of bounds choose red as default color
270  colorCode = red; //red is defined as =2 in the header
271  }
272 
273  std::map<unsigned int, SoMaterial*>::const_iterator it = m_materialCache.find( colorCode);
274  if( it != m_materialCache.end())
275  {
276  ret = it->second;
277  }
278  else
279  {
280  ret = new SoMaterial;
281  ret->diffuseColor.setValue( s_colorConversionTable[colorCode][0],
282  s_colorConversionTable[colorCode][1],
283  s_colorConversionTable[colorCode][2]);
284  ret->ref();
285  m_materialCache[colorCode] = ret;
286  }
287 
288  return ret;
289 }

Member Data Documentation

◆ black

const unsigned int ColorCodeConverter::black = 1
static

Definition at line 27 of file ColorCodeConverter.h.

◆ blue

const unsigned int ColorCodeConverter::blue = 4
static

Definition at line 30 of file ColorCodeConverter.h.

◆ cyan

const unsigned int ColorCodeConverter::cyan = 7
static

Definition at line 33 of file ColorCodeConverter.h.

◆ green

const unsigned int ColorCodeConverter::green = 3
static

Definition at line 29 of file ColorCodeConverter.h.

◆ m_materialCache

std::map<unsigned int,SoMaterial*> ColorCodeConverter::m_materialCache
private

Definition at line 42 of file ColorCodeConverter.h.

◆ magenta

const unsigned int ColorCodeConverter::magenta = 6
static

Definition at line 32 of file ColorCodeConverter.h.

◆ red

const unsigned int ColorCodeConverter::red = 2
static

Definition at line 28 of file ColorCodeConverter.h.

◆ s_colorConversionTable

const double ColorCodeConverter::s_colorConversionTable
staticprivate

Definition at line 44 of file ColorCodeConverter.h.

◆ s_colorConversionTableSize

const unsigned int ColorCodeConverter::s_colorConversionTableSize = 200
staticprivate

Definition at line 45 of file ColorCodeConverter.h.

◆ white

const unsigned int ColorCodeConverter::white = 0
static

Definition at line 26 of file ColorCodeConverter.h.

◆ yellow

const unsigned int ColorCodeConverter::yellow = 5
static

Definition at line 31 of file ColorCodeConverter.h.


The documentation for this class was generated from the following files:
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ColorCodeConverter::s_colorConversionTable
static const double s_colorConversionTable[][3]
Definition: ColorCodeConverter.h:44
ColorCodeConverter::lookup
SoMaterial * lookup(unsigned int colorCode)
Definition: ColorCodeConverter.cxx:262
ColorCodeConverter::m_materialCache
std::map< unsigned int, SoMaterial * > m_materialCache
Definition: ColorCodeConverter.h:42
ColorCodeConverter::red
static const unsigned int red
Definition: ColorCodeConverter.h:28
ColorCodeConverter::s_colorConversionTableSize
static const unsigned int s_colorConversionTableSize
Definition: ColorCodeConverter.h:45