ATLAS Offline Software
Loading...
Searching...
No Matches
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
std::optional< SbColor > outlineColour (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 setOutlineColour (const std::string &name, const SbColor &)
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

Imp * m_d

Detailed Description

Definition at line 64 of file VisAttributes.h.

Constructor & Destructor Documentation

◆ DetVisAttributes()

DetVisAttributes::DetVisAttributes ( )

Definition at line 186 of file VisAttributes.cxx.

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

Member Function Documentation

◆ add()

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

Definition at line 135 of file VisAttributes.cxx.

135 {
136 if (m_d->_map.find(name)!=m_d->_map.end()) {
137 std::cout<<"VisAttributes::add ERROR: Material " <<name<<" already added!"<<std::endl;
138 return;
139 }
140 material->ref();
141 m_d->_map[name]=material;
142 if (material->transparency.getNum()!=1)
143 std::cout<<"VisAttributes::add Warning: Found #transparency values different from 1 in material "<<name<<std::endl;
144 // FIXME. Commented out, because Ric and I are not sure why this is an issue
145 // We may want to add this back if this turns out to indicate a real problem
146 // if (material->transparency[0]!=0.0)
147 // std::cout<<"VisAttributes::add Warning: Found transparency value different from 0 in material "<<name<<std::endl;
148}

◆ applyState()

void VisAttributes::applyState ( QByteArray ba)
inherited

Definition at line 63 of file VisAttributes.cxx.

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

◆ get()

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

Definition at line 126 of file VisAttributes.cxx.

126 {
127 std::map <std::string, SoMaterial *>::const_iterator m = m_d->_map.find(name);
128 if (m!=m_d->_map.end()) {
129 return (*m).second;
130 } else {
131 return NULL;
132 }
133}

◆ getState()

QByteArray VisAttributes::getState ( bool onlyChangedMaterials = true)
inherited

Definition at line 34 of file VisAttributes.cxx.

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

◆ getValFromRGB()

float VisAttributes::getValFromRGB ( const int rgb)
privateinherited

Definition at line 157 of file VisAttributes.cxx.

158{
159 return rgb/255.0;
160}

◆ init()

void VisAttributes::init ( )
inherited

Definition at line 28 of file VisAttributes.cxx.

29{
30 m_d->initialState = m_d->currentState();
31}

◆ outlineColour()

std::optional< SbColor > VisAttributes::outlineColour ( const std::string & name) const
inherited

Definition at line 115 of file VisAttributes.cxx.

116{
117 const auto it = m_d->outlineColours.find(name);
118 return it == m_d->outlineColours.end() ? std::nullopt : std::optional<SbColor>(it->second);
119}

◆ overrideTransparencies()

void VisAttributes::overrideTransparencies ( float transpfact)
inherited

Definition at line 150 of file VisAttributes.cxx.

151{
152 std::map< std::string, SoMaterial *>::iterator it, itE = m_d->_map.end();
153 for (it=m_d->_map.begin();it!=itE;++it)
154 it->second->transparency.set1Value( 0, transpfact );
155}

◆ setColorFromRGB()

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

Definition at line 162 of file VisAttributes.cxx.

163{
164 const float fr = getValFromRGB(r);
165 const float fg = getValFromRGB(g);
166 const float fb = getValFromRGB(b);
167 if (type == "ambient")
168 mat->ambientColor.setValue(fr, fg, fb);
169 else if (type == "diffuse")
170 mat->diffuseColor.setValue(fr, fg, fb);
171 else if (type == "specular")
172 mat->specularColor.setValue(fr, fg, fb);
173 else if (type == "emissive")
174 mat->emissiveColor.setValue(fr, fg, fb);
175 else
176 std::cout << "ERROR! Color type not supported ==> " << type << std::endl;
177
178 // Debug Msg
179 //std::cout << "Set color (" << r << "," << g << "," << b << ") to (" << fr << "," << fg << "," << fb << ")" << std::endl;
180 return;
181}
float getValFromRGB(const int rgb)
int r
Definition globals.cxx:22

◆ setOutlineColour()

void VisAttributes::setOutlineColour ( const std::string & name,
const SbColor & colour )
protectedinherited

Definition at line 121 of file VisAttributes.cxx.

122{
123 m_d->outlineColours.insert_or_assign(name, colour);
124}

Member Data Documentation

◆ m_d

Imp* VisAttributes::m_d
privateinherited

Definition at line 55 of file VisAttributes.h.


The documentation for this class was generated from the following files: