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

#include <VisAttributes.h>

Inheritance diagram for DetVisAttributes:
Collaboration diagram for DetVisAttributes:

Public Member Functions

 DetVisAttributes ()
 
void init ()
 
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 57 of file VisAttributes.h.

Constructor & Destructor Documentation

◆ DetVisAttributes()

DetVisAttributes::DetVisAttributes ( )

Definition at line 173 of file VisAttributes.cxx.

173  {
174 
175  {
176  SoMaterial *material = new SoMaterial;
177  material->ambientColor.setValue(0, .157811, .187004);
178  material->diffuseColor.setValue(0, .631244, .748016);
179  material->specularColor.setValue(.915152, .915152, .915152);
180  material->shininess.setValue(0.642424);
181  add("Pixel",material);
182  }
183 
184  {
185  SoMaterial *material = new SoMaterial;
186  material->ambientColor.setValue(0, .157811, .187004);
187  material->diffuseColor.setValue(0, .631244, .748016);
188  material->specularColor.setValue(.915152, .915152, .915152);
189  material->shininess.setValue(0.642424);
190  add("ITkPixel",material);
191  }
192 
193  {
194  SoMaterial *material = new SoMaterial;
195  material->ambientColor.setValue(0, .157811, .187004);
196  material->diffuseColor.setValue(.40, .631244, .748016);
197  material->specularColor.setValue(.915152, .915152, .915152);
198  material->shininess.setValue(0.642424);
199  add("Tile",material);
200  }
201 
202  {
203  SoMaterial *material = new SoMaterial;
204  material->ambientColor.setValue(0, .157811, .187004);
205  material->diffuseColor.setValue(1, .8, .7);
206  material->specularColor.setValue(.915152, .915152, .915152);
207  material->shininess.setValue(0.642424);
208  add("BeamPipe",material);
209  }
210 
211  {
212  SoMaterial *material = new SoMaterial;
213  material->ambientColor.setValue(0, .6, .6);
214  material->diffuseColor.setValue(1, .8, .7);
215  material->specularColor.setValue(.91515, .915152, .915152);
216  material->shininess.setValue(0.642424);
217  add("CavernInfra",material);
218  }
219 
220  {
221  SoMaterial *material = new SoMaterial;
222  material->ambientColor.setValue(0.2, 0.2, 0.2);
223  material->diffuseColor.setValue(0, 0.6667, 1.0);
224  material->specularColor.setValue(0,0,0);
225  // material->shininess.setValue(0.642424);
226 // material->ambientColor.setValue(0, .157811, .187004);
227 // material->diffuseColor.setValue(1, 0, 0);
228 // material->specularColor.setValue(.915152, .915152, .915152);
229 // material->shininess.setValue(0.642424);
230 
231  add("Muon",material);
232 
233  {
234  SoMaterial *material = new SoMaterial;
235  material->ambientColor.setValue(0, .157811, .187004);
236  material->diffuseColor.setValue(.98, .8, .21);
237  material->specularColor.setValue(.915152, .915152, .915152);
238  material->shininess.setValue(0.2);
239  add("CSC",material);
240  }
241 
242  {
243  SoMaterial *material = new SoMaterial;
244  material->ambientColor.setValue(0, .157811, .187004);
245  material->diffuseColor.setValue(0, .9, .5);
246  material->specularColor.setValue(.915152, .915152, .915152);
247  material->shininess.setValue(0.2);
248  add("EndcapMdt",material);
249  }
250 
251  {
252  SoMaterial *material = new SoMaterial;
253  material->ambientColor.setValue(0,0,0);
254  material->diffuseColor.setValue(0.41,0,0.26);
255  material->specularColor.setValue(0,0,0);
256  material->shininess.setValue(0.2);
257  add("TGC",material);
258  }
259 
260  {
261  SoMaterial *material = new SoMaterial;
262 
263  material->ambientColor.setValue(0.2, 0.2, 0.2);
264  material->diffuseColor.setValue(0, 0.6667, 1.0);
265  material->specularColor.setValue(0,0,0);
266 // material->ambientColor.setValue(0, .157811, .187004);
267 // material->diffuseColor.setValue(1, .2, .7);
268 // material->specularColor.setValue(.915152, .915152, .915152);
269  material->shininess.setValue(0.2);
270 
271 
272  add("BarrelInner",material);
273  add("BarrelMiddle",material);
274  add("BarrelOuter",material);
275  }
276 
277  {
278  SoMaterial *material = new SoMaterial;
279  material->ambientColor.setValue(0, .157811, .187004);
280  material->diffuseColor.setValue(1, .5, .5);
281  material->specularColor.setValue(.915152, .915152, .915152);
282  material->shininess.setValue(0.2);
283  add("BarrelToroid",material);
284  add("EndcapToroid",material);
285  }
286 
287  {
288  SoMaterial *material = new SoMaterial;
289  material->ambientColor.setValue(0, .157811, .187004);
290  material->diffuseColor.setValue(.5, .5, 1.0);
291  material->specularColor.setValue(.915152, .915152, .915152);
292  material->shininess.setValue(0.2);
293  add("Feet",material);
294  }
295  }
296 
297  {
298  SoMaterial *material = new SoMaterial;
299  material->ambientColor.setValue(.37, .69, 1.00);
300  material->diffuseColor.setValue(.21, .64, 1.00);
301  material->specularColor.setValue(1, 1, 1);
302  material->shininess.setValue(1.0);
303  add("SCT",material);
304  }
305 
306  {
307  SoMaterial *material = new SoMaterial;
308  material->ambientColor.setValue(.37, .69, 1.00);
309  material->diffuseColor.setValue(.21, .64, 1.00);
310  material->specularColor.setValue(1, 1, 1);
311  material->shininess.setValue(1.0);
312  add("ITkStrip",material);
313  }
314 
315  {
316  SoMaterial *material = new SoMaterial;
317  add("LAr",material);
318  add("LArBarrel",material);
319  add("LArEndcapPos",material);
320  add("LArEndcapNeg",material);
321  }
322 
323  {
324  SoMaterial *material = new SoMaterial;
325  add("TRT",material);
326  }
327 
328  {
329  SoMaterial *material = new SoMaterial;
330  add("InDetServMat",material);
331  material->diffuseColor.setValue(0.4,0.31,0);
332  material->shininess.setValue(1.0);
333  }
334 
335  {
336  SoMaterial *material = new SoMaterial();
337  add("LucidSideA",material);
338  add("LucidSideC",material);
339  material->diffuseColor.setValue(0.6,0.11,0.3);
340  material->shininess.setValue(1.0);
341  }
342 
343  {
344  SoMaterial *material = new SoMaterial;
345  material->ambientColor.setValue(0, .157811, .187004);
346  material->diffuseColor.setValue(0., 0., 0.56862745);
347  material->specularColor.setValue(.915152, .915152, .915152);
348  material->shininess.setValue(0.2);
349  add("Zdc",material);
350  }
351 
352 
353  // {
354  // SoMaterial *material = new SoMaterial();
355  // add("LcdXXX",material);
356  // add("LcdYYY",material);
357  // material->diffuseColor.setValue(0.6,0.11,0.3);
358  // material->shininess.setValue(1.0);
359  // }
360 
361  init();
362 }

Member Function Documentation

◆ add()

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

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)
inherited

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
inherited

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)
inherited

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)
privateinherited

Definition at line 144 of file VisAttributes.cxx.

145 {
146  return rgb/255.0;
147 }

◆ init()

void VisAttributes::init ( )
inherited

Definition at line 26 of file VisAttributes.cxx.

27 {
29 }

◆ overrideTransparencies()

void VisAttributes::overrideTransparencies ( float  transpfact)
inherited

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 
)
protectedinherited

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
privateinherited

Definition at line 48 of file VisAttributes.h.


The documentation for this class was generated from the following files:
VisAttributes::add
void add(const std::string &name, SoMaterial *)
Definition: VisAttributes.cxx:122
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
VisAttributes::init
void init()
Definition: VisAttributes.cxx:26
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:228
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