ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
VisAttributes Class Reference

#include <VisAttributes.h>

Inheritance diagram for VisAttributes:
Collaboration diagram for VisAttributes:

Classes

class  Imp
 

Public Member Functions

 VisAttributes ()
 
 VisAttributes (const VisAttributes &)=delete
 
VisAttributesoperator= (const VisAttributes &)=delete
 
void init ()
 
virtual ~VisAttributes ()
 
SoMaterial * get (const std::string &name) const
 
void overrideTransparencies (float transpfact)
 
QByteArray getState (bool onlyChangedMaterials=true)
 
void applyState (QByteArray)
 

Protected Member Functions

void add (const std::string &name, SoMaterial *)
 
void setColorFromRGB (SoMaterial *mat, const std::string &type, const int r, const int g, const int b)
 

Private Member Functions

float getValFromRGB (const int rgb)
 

Private Attributes

Impm_d
 

Detailed Description

Definition at line 14 of file VisAttributes.h.

Constructor & Destructor Documentation

◆ VisAttributes() [1/2]

VisAttributes::VisAttributes ( )

Definition at line 100 of file VisAttributes.cxx.

100  : m_d(new Imp) {
101 }

◆ VisAttributes() [2/2]

VisAttributes::VisAttributes ( const VisAttributes )
delete

◆ ~VisAttributes()

VisAttributes::~VisAttributes ( )
virtual

Definition at line 104 of file VisAttributes.cxx.

104  {
105 
107  for (m=m_d->_map.begin();m!=e;++m)
108  (*m).second->unref();
109 
110  delete m_d;
111 }

Member Function Documentation

◆ add()

void VisAttributes::add ( const std::string &  name,
SoMaterial *  material 
)
protected

Definition at line 122 of file VisAttributes.cxx.

122  {
123  if (m_d->_map.find(name)!=m_d->_map.end()) {
124  std::cout<<"VisAttributes::add ERROR: Material " <<name<<" already added!"<<std::endl;
125  return;
126  }
127  material->ref();
128  m_d->_map[name]=material;
129  if (material->transparency.getNum()!=1)
130  std::cout<<"VisAttributes::add Warning: Found #transparency values different from 1 in material "<<name<<std::endl;
131  // FIXME. Commented out, because Ric and I are not sure why this is an issue
132  // We may want to add this back if this turns out to indicate a real problem
133  // if (material->transparency[0]!=0.0)
134  // std::cout<<"VisAttributes::add Warning: Found transparency value different from 0 in material "<<name<<std::endl;
135 }

◆ applyState()

void VisAttributes::applyState ( QByteArray  ba)

Definition at line 61 of file VisAttributes.cxx.

62 {
63  //Get map out:
64  QMap<QString,QByteArray> storedstates;
65  QBuffer buffer(&ba);
66  buffer.open(QIODevice::ReadOnly);
67  QDataStream state(&buffer);
68  qint32 version;
69  state >> version;
70  if (version!=0)
71  return;//ignore silently
72  state >> storedstates;
73  buffer.close();
74 
76 
77  //Apply states from map:
78  QMap<QString,QByteArray>::const_iterator it, itE(storedstates.constEnd());
79  for (it = storedstates.constBegin(); it!=itE; ++it) {
80  itMat = m_d->_map.find(it.key().toStdString());
81  if (itMat!=itMatE) {
82  QByteArray b(it.value());
84  }
85  }
86 
87 }

◆ get()

SoMaterial * VisAttributes::get ( const std::string &  name) const

Definition at line 113 of file VisAttributes.cxx.

113  {
114  std::map <std::string, SoMaterial *>::const_iterator m = m_d->_map.find(name);
115  if (m!=m_d->_map.end()) {
116  return (*m).second;
117  } else {
118  return NULL;
119  }
120 }

◆ getState()

QByteArray VisAttributes::getState ( bool  onlyChangedMaterials = true)

Definition at line 32 of file VisAttributes.cxx.

33 {
34  //Figure out states to store
35  QMap<QString,QByteArray> storedstates, statesnow = m_d->currentState();
36  if (onlyChangedMaterials) {
37  QMap<QString,QByteArray>::const_iterator it, itE(statesnow.constEnd());
38  QMap<QString,QByteArray>::const_iterator itOrig, itOrigE(m_d->initialState.constEnd());
39  for (it = statesnow.constBegin(); it!=itE; ++it) {
40  itOrig = m_d->initialState.constFind(it.key());
41  if (itOrig==itOrigE||it.value()!=itOrig.value())
42  storedstates.insert(it.key(),it.value());
43  }
44  } else {
45  storedstates = statesnow;
46  }
47 
48  //Put map in bytearray and return:
49  QByteArray byteArray;
50  QBuffer buffer(&byteArray);
51  buffer.open(QIODevice::WriteOnly);
52  QDataStream out(&buffer);
53  out << qint32(0);//version
54  out << storedstates;
55  buffer.close();
56  return byteArray;
57 
58 }

◆ getValFromRGB()

float VisAttributes::getValFromRGB ( const int  rgb)
private

Definition at line 144 of file VisAttributes.cxx.

145 {
146  return rgb/255.0;
147 }

◆ init()

void VisAttributes::init ( )

Definition at line 26 of file VisAttributes.cxx.

27 {
29 }

◆ operator=()

VisAttributes& VisAttributes::operator= ( const VisAttributes )
delete

◆ overrideTransparencies()

void VisAttributes::overrideTransparencies ( float  transpfact)

Definition at line 137 of file VisAttributes.cxx.

138 {
140  for (it=m_d->_map.begin();it!=itE;++it)
141  it->second->transparency.set1Value( 0, transpfact );
142 }

◆ setColorFromRGB()

void VisAttributes::setColorFromRGB ( SoMaterial *  mat,
const std::string &  type,
const int  r,
const int  g,
const int  b 
)
protected

Definition at line 149 of file VisAttributes.cxx.

150 {
151  const float fr = getValFromRGB(r);
152  const float fg = getValFromRGB(g);
153  const float fb = getValFromRGB(b);
154  if (type == "ambient")
155  mat->ambientColor.setValue(fr, fg, fb);
156  else if (type == "diffuse")
157  mat->diffuseColor.setValue(fr, fg, fb);
158  else if (type == "specular")
159  mat->specularColor.setValue(fr, fg, fb);
160  else if (type == "emissive")
161  mat->emissiveColor.setValue(fr, fg, fb);
162  else
163  std::cout << "ERROR! Color type not supported ==> " << type << std::endl;
164 
165  // Debug Msg
166  //std::cout << "Set color (" << r << "," << g << "," << b << ") to (" << fr << "," << fg << "," << fb << ")" << std::endl;
167  return;
168 }

Member Data Documentation

◆ m_d

Imp* VisAttributes::m_d
private

Definition at line 48 of file VisAttributes.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
skel.it
it
Definition: skel.GENtoEVGEN.py:396
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
VP1QtInventorUtils::deserialiseSoMaterial
static bool deserialiseSoMaterial(QByteArray &, SoMaterial *&)
Definition: VP1QtInventorUtils.cxx:1188
TruthTest.itE
itE
Definition: TruthTest.py:25
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
VisAttributes::Imp::currentState
QMap< QString, QByteArray > currentState() const
Definition: VisAttributes.cxx:90
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
VisAttributes::Imp::_map
std::map< std::string, SoMaterial * > _map
Definition: VisAttributes.cxx:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VisAttributes::m_d
Imp * m_d
Definition: VisAttributes.h:47
get_generator_info.version
version
Definition: get_generator_info.py:33
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
grepfile.fr
fr
Definition: grepfile.py:32
VisAttributes::getValFromRGB
float getValFromRGB(const int rgb)
Definition: VisAttributes.cxx:144
VisAttributes::Imp::initialState
QMap< QString, QByteArray > initialState
Definition: VisAttributes.cxx:21