Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SceneTreeItem Class Reference

#include <G4SceneTreeItem.hh>

Public Types

enum  Type {
  unidentified , root , model , pvmodel ,
  ghost , touchable
}
 

Public Member Functions

 G4SceneTreeItem (Type type=unidentified)
 
 ~G4SceneTreeItem ()=default
 
 G4SceneTreeItem (const G4SceneTreeItem &)=default
 
G4SceneTreeItemoperator= (const G4SceneTreeItem &)=default
 
Type GetType () const
 
const G4StringGetTypeString () const
 
void SetType (Type type)
 
const G4StringGetPVPath () const
 
void SetPVPath (const G4String &PVPath)
 
const G4StringGetDescription () const
 
void SetDescription (const G4String &description)
 
const G4StringGetModelType () const
 
void SetModelType (const G4String &modelType)
 
const G4StringGetModelDescription () const
 
void SetModelDescription (const G4String &modelDescription)
 
const std::map< G4String, G4AttDef > * GetAttDefs () const
 
void SetAttDefs (const std::map< G4String, G4AttDef > *pAttDefs)
 
std::vector< G4AttValue > * GetAttValues () const
 
void SetAttValues (std::vector< G4AttValue > *pAttValues)
 
const G4VisAttributesGetVisAttributes () const
 
G4VisAttributesAccessVisAttributes ()
 
void SetVisAttributes (const G4VisAttributes &visAtts)
 
const std::list< G4SceneTreeItem > & GetChildren () const
 
std::list< G4SceneTreeItem >::iterator InsertChild (std::list< G4SceneTreeItem >::iterator pos, const G4SceneTreeItem &item)
 
std::list< G4SceneTreeItem > & AccessChildren ()
 
G4bool IsExpanded () const
 
void SetExpanded (G4bool expanded)
 
void ResetVisibility ()
 
G4bool FindTouchableFromRoot (const G4String &fullPathString, std::list< G4SceneTreeItem >::iterator &foundIter)
 
void DumpSingleItem (std::ostream &, G4int verbosity=0) const
 
void DumpTree (std::ostream &, G4int verbosity=0) const
 

Detailed Description

Definition at line 40 of file G4SceneTreeItem.hh.

Member Enumeration Documentation

◆ Type

Enumerator
unidentified 
root 
model 
pvmodel 
ghost 
touchable 

Definition at line 44 of file G4SceneTreeItem.hh.

Constructor & Destructor Documentation

◆ G4SceneTreeItem() [1/2]

G4SceneTreeItem::G4SceneTreeItem ( Type type = unidentified)
inlineexplicit

Definition at line 54 of file G4SceneTreeItem.hh.

54{ fType = type; }

◆ ~G4SceneTreeItem()

G4SceneTreeItem::~G4SceneTreeItem ( )
default

◆ G4SceneTreeItem() [2/2]

G4SceneTreeItem::G4SceneTreeItem ( const G4SceneTreeItem & )
default

Member Function Documentation

◆ AccessChildren()

std::list< G4SceneTreeItem > & G4SceneTreeItem::AccessChildren ( )
inline

Definition at line 101 of file G4SceneTreeItem.hh.

101{ return fChildren; }

◆ AccessVisAttributes()

G4VisAttributes & G4SceneTreeItem::AccessVisAttributes ( )
inline

Definition at line 91 of file G4SceneTreeItem.hh.

91{ return fVisAttributes; }

◆ DumpSingleItem()

void G4SceneTreeItem::DumpSingleItem ( std::ostream & os,
G4int verbosity = 0 ) const

Definition at line 96 of file G4SceneTreeItem.cc.

97{
98 static G4bool first = true;
99 if (first) {
100 first = false;
101 os << " Verbosity actions:"
102 << "\n >=0 one line"
103 << "\n >=1 a few lines"
104 << "\n >=2 check G4Atts"
105 << "\n >=3 print G4Atts"
106 << "\n >=4 print some attValues"
107 << '\n';
108 }
109
110 os << GetTypeString() << " (";
111 G4String status;
112 switch (fType) {
113 case unidentified:
114 status = "error";
115 break;
116 case root:
117 status = "active";
118 break;
119 case model:
120 [[fallthrough]];
121 case pvmodel:
122 status = (fVisAttributes.IsVisible() ? "active" : "inactive");
123 break;
124 case ghost:
125 [[fallthrough]];
126 case touchable:
127 status = (fVisAttributes.IsVisible() ? "visible" : "invisible");
128 break;
129 }
130 if (fExpanded) {
131 status += ",expanded";
132 } else {
133 status += ",collapsed";
134 }
135 os << status << ')';
136
137 G4String description;
138 switch (fType) {
139 case unidentified:
140 break;
141 case root:
142 break;
143 case model:
144 [[fallthrough]];
145 case pvmodel:
146 description = " \"" + fModelDescription + '"';
147 break;
148 case ghost:
149 [[fallthrough]];
150 case touchable:
151 description = " (" + fPVPath.substr(1, fPVPath.length() - 1) + ')';
152 break;
153 }
154 os << description;
155
156 if (fType == touchable) {
157 os << ' ' << fVisAttributes.GetColour();
158 }
159
160 // clang-format off
161 if (verbosity >= 1) {
162 os << "\n Description: " << GetDescription()
163 << "\n Model type: " << GetModelType()
164 << "\n Model description: " << GetModelDescription()
165 << "\n " << fChildren.size() << (fChildren.size()==1?" child":" children");
166 }
167 // clang-format on
168
169 if (verbosity >= 2) {
170 const auto& attDefs = GetAttDefs();
171 const auto& attValues = GetAttValues();
172 if (attDefs == nullptr || attValues == nullptr) {
173 os << "\n No G4Atts"; // Legitimate
174 }
175 else {
176 G4AttCheck attCheck(attValues, attDefs);
177 if (attCheck.Check("G4SceneTreeItem::Dump")) {
179 ed << "Item: " << attCheck;
180 G4Exception("G4SceneTreeItem::Dump", "greps0010", JustWarning, ed,
181 "G4Atts don't check out");
182 return;
183 }
184
185 if (verbosity >= 3) {
186 os << "\n G4Atts:\n" << attCheck;
187 static G4bool first1 = true;
188 if (first1) {
189 first1 = false;
190 os << "\n Available G4Atts for touchable:";
191 // clang-format off
192 for (const auto& att: *GetAttDefs()) {
193 os << "\n " << att.first
194 << ',' << att.second.GetName()
195 << ',' << att.second.GetDesc()
196 << ',' << att.second.GetCategory()
197 << ',' << att.second.GetExtra()
198 << ',' << att.second.GetValueType()
199 << ',' << att.second.GetTypeKey();
200 }
201 // clang-format on
202 os << '\n';
203 }
204 }
205
206 if (verbosity >= 4) {
207 for (G4String name : {"PVPath", "GlobalExtent"}) {
208 G4String result;
209 const auto& iterAttDef = attDefs->find(name);
210 if (iterAttDef != attDefs->end()) {
211 result = result + "\n " + iterAttDef->second.GetName();
212 result = result + ", " + iterAttDef->second.GetDesc();
213 }
214 const G4AttValue* pAttValue = nullptr;
215 for (const auto& attValue : *attValues) {
216 // Why are the attValues not in a map like the attDefs???
217 if (attValue.GetName() == name) {
218 pAttValue = &attValue; // Avoid copy
219 break;
220 }
221 }
222 if (pAttValue) {
223 result = result + ", " + pAttValue->GetValue();
224 }
225
226 os << result;
227 }
228 }
229 }
230 }
231
232 os << std::endl;
233}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
bool G4bool
Definition G4Types.hh:86
const G4String & GetValue() const
Definition G4AttValue.hh:64
const G4String & GetDescription() const
const G4String & GetModelDescription() const
const G4String & GetTypeString() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
const G4String & GetModelType() const
std::vector< G4AttValue > * GetAttValues() const
const G4Colour & GetColour() const
G4bool IsVisible() const

Referenced by DumpTree(), and FindTouchableFromRoot().

◆ DumpTree()

void G4SceneTreeItem::DumpTree ( std::ostream & os,
G4int verbosity = 0 ) const

Definition at line 236 of file G4SceneTreeItem.cc.

237{
238 static G4int depth = 0;
239 for (G4int i = 0; i < depth; i++) os << " ";
240 DumpSingleItem(os, verbosity);
241 for (auto& child : GetChildren()) {
242 depth++;
243 child.DumpTree(os, verbosity);
244 depth--;
245 }
246}
int G4int
Definition G4Types.hh:85
const std::list< G4SceneTreeItem > & GetChildren() const
void DumpSingleItem(std::ostream &, G4int verbosity=0) const

◆ FindTouchableFromRoot()

G4bool G4SceneTreeItem::FindTouchableFromRoot ( const G4String & fullPathString,
std::list< G4SceneTreeItem >::iterator & foundIter )

Definition at line 54 of file G4SceneTreeItem.cc.

56{
57 if (fType != root) {
59 ed << "Not a root item:\n";
61 G4Exception("G4SceneTreeItem::FindTouchableFromRoot", "greps0011", JustWarning, ed);
62 return false;
63 }
64
65 for (auto& aModel : fChildren) {
66 if (aModel.fModelType == "G4PhysicalVolumeModel") { // Top item, i.e., root of touchables
67 // Work down the path - "name id", then "name id name id", etc.
68 G4String partialPathString;
69 auto iter = aModel.fChildren.begin();
70 auto iterEnd = aModel.fChildren.end();
71 std::istringstream iss(fullPathString);
72 G4String name, copyNo;
73 while (iss >> name >> copyNo) {
74 partialPathString += ' ' + name + ' ' + copyNo;
75 for (; iter != iterEnd; ++iter) {
76 if (iter->fPVPath == partialPathString) {
77 if (partialPathString != fullPathString) {
78 // Go to next level
79 iter = iter->fChildren.begin();
80 iterEnd = iter->fChildren.end();
81 }
82 break;
83 }
84 }
85 if (iter != iterEnd) { // Found
86 foundIter = iter;
87 return true;
88 }
89 }
90 }
91 }
92 return false;
93}
const char * name(G4int ptype)

Referenced by G4VViewer::TouchableSetColour(), and G4VViewer::TouchableSetVisibility().

◆ GetAttDefs()

const std::map< G4String, G4AttDef > * G4SceneTreeItem::GetAttDefs ( ) const
inline

Definition at line 84 of file G4SceneTreeItem.hh.

84{ return fpAttDefs; }

Referenced by DumpSingleItem().

◆ GetAttValues()

std::vector< G4AttValue > * G4SceneTreeItem::GetAttValues ( ) const
inline

Definition at line 87 of file G4SceneTreeItem.hh.

87{ return fpAttValues; }

Referenced by DumpSingleItem().

◆ GetChildren()

const std::list< G4SceneTreeItem > & G4SceneTreeItem::GetChildren ( ) const
inline

Definition at line 94 of file G4SceneTreeItem.hh.

94{ return fChildren; }

Referenced by DumpTree(), and G4UIQt::UpdateSceneTree().

◆ GetDescription()

const G4String & G4SceneTreeItem::GetDescription ( ) const
inline

Definition at line 72 of file G4SceneTreeItem.hh.

72{ return fDescription; }

Referenced by DumpSingleItem(), and G4UIQt::UpdateSceneTree().

◆ GetModelDescription()

const G4String & G4SceneTreeItem::GetModelDescription ( ) const
inline

Definition at line 78 of file G4SceneTreeItem.hh.

78{ return fModelDescription; }

Referenced by DumpSingleItem().

◆ GetModelType()

const G4String & G4SceneTreeItem::GetModelType ( ) const
inline

Definition at line 75 of file G4SceneTreeItem.hh.

75{ return fModelType; }

Referenced by DumpSingleItem().

◆ GetPVPath()

const G4String & G4SceneTreeItem::GetPVPath ( ) const
inline

Definition at line 69 of file G4SceneTreeItem.hh.

69{ return fPVPath; }

◆ GetType()

Type G4SceneTreeItem::GetType ( ) const
inline

Definition at line 65 of file G4SceneTreeItem.hh.

65{ return fType; }

◆ GetTypeString()

const G4String & G4SceneTreeItem::GetTypeString ( ) const
inline

Definition at line 66 of file G4SceneTreeItem.hh.

66{ return fTypeMap[fType]; }

Referenced by DumpSingleItem().

◆ GetVisAttributes()

const G4VisAttributes & G4SceneTreeItem::GetVisAttributes ( ) const
inline

Definition at line 90 of file G4SceneTreeItem.hh.

90{ return fVisAttributes; }

◆ InsertChild()

std::list< G4SceneTreeItem >::iterator G4SceneTreeItem::InsertChild ( std::list< G4SceneTreeItem >::iterator pos,
const G4SceneTreeItem & item )
inline

Definition at line 96 of file G4SceneTreeItem.hh.

98 {
99 return fChildren.insert(pos, item);
100 }

◆ IsExpanded()

G4bool G4SceneTreeItem::IsExpanded ( ) const
inline

Definition at line 103 of file G4SceneTreeItem.hh.

103{ return fExpanded; }

◆ operator=()

G4SceneTreeItem & G4SceneTreeItem::operator= ( const G4SceneTreeItem & )
default

◆ ResetVisibility()

void G4SceneTreeItem::ResetVisibility ( )

Definition at line 44 of file G4SceneTreeItem.cc.

45{
46 // Reset all but the root item, which is always visible (i.e., active)
47 // Other items will be set visible if and when presented to the scene
48 if (fType != root) fVisAttributes.SetVisibility(false);
49 for (auto& child : fChildren)
50 child.ResetVisibility();
51}
void SetVisibility(G4bool=true)

Referenced by G4VSceneHandler::ProcessScene().

◆ SetAttDefs()

void G4SceneTreeItem::SetAttDefs ( const std::map< G4String, G4AttDef > * pAttDefs)
inline

Definition at line 85 of file G4SceneTreeItem.hh.

85{ fpAttDefs = pAttDefs; };

◆ SetAttValues()

void G4SceneTreeItem::SetAttValues ( std::vector< G4AttValue > * pAttValues)
inline

Definition at line 88 of file G4SceneTreeItem.hh.

88{ fpAttValues = pAttValues; }

◆ SetDescription()

void G4SceneTreeItem::SetDescription ( const G4String & description)
inline

Definition at line 73 of file G4SceneTreeItem.hh.

73{ fDescription = description; }

◆ SetExpanded()

void G4SceneTreeItem::SetExpanded ( G4bool expanded)
inline

Definition at line 104 of file G4SceneTreeItem.hh.

104{ fExpanded = expanded; }

◆ SetModelDescription()

void G4SceneTreeItem::SetModelDescription ( const G4String & modelDescription)
inline

Definition at line 79 of file G4SceneTreeItem.hh.

80 {
81 fModelDescription = modelDescription;
82 }

◆ SetModelType()

void G4SceneTreeItem::SetModelType ( const G4String & modelType)
inline

Definition at line 76 of file G4SceneTreeItem.hh.

76{ fModelType = modelType; }

◆ SetPVPath()

void G4SceneTreeItem::SetPVPath ( const G4String & PVPath)
inline

Definition at line 70 of file G4SceneTreeItem.hh.

70{ fPVPath = PVPath; }

◆ SetType()

void G4SceneTreeItem::SetType ( Type type)
inline

Definition at line 67 of file G4SceneTreeItem.hh.

67{ fType = type; }

Referenced by G4VViewer::G4VViewer().

◆ SetVisAttributes()

void G4SceneTreeItem::SetVisAttributes ( const G4VisAttributes & visAtts)
inline

Definition at line 92 of file G4SceneTreeItem.hh.

92{ fVisAttributes = visAtts; }

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