Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
G03ColorReader Class Reference

GDML reader for the color attributes. More...

#include <Doxymodules_persistency.h>

Inheritance diagram for G03ColorReader:
G4GDMLReadStructure G4GDMLReadParamvol G4GDMLReadSetup G4GDMLReadSolids G4GDMLReadMaterials G4GDMLReadDefine G4GDMLRead

Public Member Functions

 G03ColorReader ()
 
 ~G03ColorReader ()
 
void ExtensionRead (const xercesc::DOMElement *const element)
 
void ColorRead (const xercesc::DOMElement *const element)
 
G4VisAttributesGetVisAttribute (const G4String &ref)
 

Protected Member Functions

virtual void VolumeRead (const xercesc::DOMElement *const)
 

Private Attributes

std::map< G4String, G4VisAttributes * > fAttribs
 

Detailed Description

GDML reader for the color attributes.

Definition at line 48 of file Doxymodules_persistency.h.

Constructor & Destructor Documentation

◆ G03ColorReader()

G03ColorReader::G03ColorReader ( )

Definition at line 39 of file G03ColorReader.cc.

◆ ~G03ColorReader()

G03ColorReader::~G03ColorReader ( )

Definition at line 46 of file G03ColorReader.cc.

47{
48 std::map<G4String, G4VisAttributes*>::iterator pos;
49 for (pos=fAttribs.begin(); pos!=fAttribs.end(); pos++)
50 { delete pos->second; }
51}
std::map< G4String, G4VisAttributes * > fAttribs

Member Function Documentation

◆ ExtensionRead()

void G03ColorReader::ExtensionRead ( const xercesc::DOMElement *const  element)

Definition at line 55 of file G03ColorReader.cc.

56{
57 G4cout << "G4GDML: Reading GDML extension..." << G4endl;
58
59 for (xercesc::DOMNode* iter = extElement->getFirstChild();
60 iter != 0; iter = iter->getNextSibling())
61 {
62 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
63
64 const xercesc::DOMElement* const child
65 = dynamic_cast<xercesc::DOMElement*>(iter);
66 const G4String tag = Transcode(child->getTagName());
67
68 if (tag=="color") { ColorRead(child); }
69 else
70 {
71 G4String error_msg = "Unknown tag in structure: " + tag;
72 G4Exception("G03ColorReader::ExtensionRead()",
73 "ReadError", FatalException, error_msg);
74 }
75 }
76}
void ColorRead(const xercesc::DOMElement *const element)

◆ ColorRead()

void G03ColorReader::ColorRead ( const xercesc::DOMElement *const  element)

Definition at line 121 of file G03ColorReader.cc.

122{
123 G4String name;
124 G4VisAttributes* color = 0;
125 G4double r=0., g=0., b=0., a=0.;
126
127 const xercesc::DOMNamedNodeMap* const attributes
128 = colorElement->getAttributes();
129 XMLSize_t attributeCount = attributes->getLength();
130
131 for (XMLSize_t attribute_index=0;
132 attribute_index<attributeCount; attribute_index++)
133 {
134 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
135
136 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
137 { continue; }
138
139 const xercesc::DOMAttr* const attribute
140 = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
141 const G4String attName = Transcode(attribute->getName());
142 const G4String attValue = Transcode(attribute->getValue());
143
144 if (attName=="name")
145 { name = GenerateName(attValue); } else
146 if (attName=="R")
147 { r = eval.Evaluate(attValue); } else
148 if (attName=="G")
149 { g = eval.Evaluate(attValue); } else
150 if (attName=="B")
151 { b = eval.Evaluate(attValue); } else
152 if (attName=="A")
153 { a = eval.Evaluate(attValue); }
154 }
155
156 G4cout << "Color attribute (R,G,B,A) is: "
157 << r << ", " << g << ", " << b << ", " << a << " !" << G4endl;
158 color = new G4VisAttributes(G4Color(r,g,b,a));
159 fAttribs.insert(std::make_pair(name,color));
160}
std::vector< ExP01TrackerHit * > a

◆ GetVisAttribute()

G4VisAttributes * G03ColorReader::GetVisAttribute ( const G4String ref)

Definition at line 164 of file G03ColorReader.cc.

165{
166 G4VisAttributes* col = 0;
167 std::map<G4String, G4VisAttributes*>::iterator pos = fAttribs.find(ref);
168
169 if (pos != fAttribs.end())
170 {
171 col = pos->second;
172 }
173 else
174 {
175 G4String err_mess = "Attribute: " + ref + " NOT found !";
176 G4Exception("G03ColorReader::GetVisAttribute()",
177 "ReadError", FatalException, err_mess);
178 }
179 return col;
180}

◆ VolumeRead()

void G03ColorReader::VolumeRead ( const xercesc::DOMElement * const  volumeElement)
protectedvirtual

Definition at line 80 of file G03ColorReader.cc.

81{
82 G4VSolid* solidPtr = 0;
83 G4Material* materialPtr = 0;
84 G4VisAttributes* attrPtr = 0;
85 G4GDMLAuxListType auxList;
86
87 XMLCh *name_attr = xercesc::XMLString::transcode("name");
88 const G4String name = Transcode(volumeElement->getAttribute(name_attr));
89 xercesc::XMLString::release(&name_attr);
90
91 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
92 iter != 0; iter = iter->getNextSibling())
93 {
94 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
95
96 const xercesc::DOMElement* const child
97 = dynamic_cast<xercesc::DOMElement*>(iter);
98 const G4String tag = Transcode(child->getTagName());
99
100 if (tag=="auxiliary")
101 { auxList.push_back(AuxiliaryRead(child)); } else
102 if (tag=="materialref")
103 { materialPtr = GetMaterial(GenerateName(RefRead(child),true)); } else
104 if (tag=="solidref")
105 { solidPtr = GetSolid(GenerateName(RefRead(child))); } else
106 if (tag == "colorref")
107 { attrPtr = GetVisAttribute(GenerateName(RefRead(child))); }
108 }
109
110 pMotherLogical = new G4LogicalVolume(solidPtr,materialPtr,
111 GenerateName(name),0,0,0);
112 pMotherLogical->SetVisAttributes(attrPtr);
113
114 if (!auxList.empty()) { auxMap[pMotherLogical] = auxList; }
115
116 Volume_contentRead(volumeElement);
117}
G4VisAttributes * GetVisAttribute(const G4String &ref)

Member Data Documentation

◆ fAttribs

std::map<G4String, G4VisAttributes*> G03ColorReader::fAttribs
private

Definition at line 66 of file G03ColorReader.hh.


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

Applications | User Support | Publications | Collaboration