ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BlockDisplayAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BlockDisplayAction.cc
2 
4 #include <g4main/PHG4Utils.h>
5 
6 #include <phparameter/PHParameters.h>
7 
8 #include <Geant4/G4Colour.hh> // for G4Colour
9 #include <Geant4/G4LogicalVolume.hh>
10 #include <Geant4/G4VisAttributes.hh>
11 
12 #include <cmath> // for isfinite
13 
15  : PHG4DisplayAction(name)
16  , m_Params(pars)
17  , m_MyVolume(nullptr)
18  , m_VisAtt(nullptr)
19  , m_Colour(nullptr)
20 {
21 }
22 
24 {
25  delete m_VisAtt;
26  delete m_Colour;
27 }
28 
30 {
31  // check if vis attributes exist, if so someone else has set them and we do nothing
33  {
34  return;
35  }
36  m_VisAtt = new G4VisAttributes();
37  if (m_Params->get_int_param("blackhole"))
38  {
39  PHG4Utils::SetColour(m_VisAtt, "BlackHole");
40  m_VisAtt->SetVisibility(false);
41  m_VisAtt->SetForceSolid(false);
42  }
43  else
44  {
46  m_VisAtt->SetVisibility(true);
47  m_VisAtt->SetForceSolid(true);
48  }
49  if (m_Colour)
50  {
52  m_Colour->GetGreen(),
53  m_Colour->GetBlue(),
54  m_Colour->GetAlpha());
55  m_VisAtt->SetVisibility(true);
56  m_VisAtt->SetForceSolid(true);
57  }
59  return;
60 }
61 
62 void PHG4BlockDisplayAction::SetColor(const double red, const double green, const double blue, const double alpha)
63 {
64  if (std::isfinite(red) && std::isfinite(green) && std::isfinite(blue) && std::isfinite(alpha))
65  {
66  m_Colour = new G4Colour(red, green, blue, alpha);
67  }
68  return;
69 }