ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HepRepSceneHandler.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4HepRepSceneHandler.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 
32 #ifndef G4HEPREPSCENEHANDLER_HH
33 #define G4HEPREPSCENEHANDLER_HH 1
34 
35 #include "globals.hh"
36 #include <iostream>
37 #include <stack>
38 #include <map>
39 #include <vector>
40 
41 // HepRep
42 #include "HEPREP/HepRep.h"
43 
44 //G4
45 #include "G4Box.hh"
46 #include "G4Cons.hh"
47 #include "G4Tubs.hh"
48 #include "G4Trd.hh"
49 #include "G4Trap.hh"
50 #include "G4Sphere.hh"
51 #include "G4Para.hh"
52 #include "G4Torus.hh"
53 #include "G4Polycone.hh"
54 #include "G4Polyhedra.hh"
55 
56 #include "G4VGraphicsSystem.hh"
57 #include "G4VSceneHandler.hh"
58 #include "G4Visible.hh"
59 #include "G4Material.hh"
60 #include "G4LogicalVolume.hh"
61 #include "G4PhysicalVolumeModel.hh"
62 
64 
65  public:
67  virtual ~G4HepRepSceneHandler ();
68 
69  void AddSolid (const G4Box& box);
70  void AddSolid (const G4Cons& cons);
71  void AddSolid (const G4Tubs& tubs);
72  void AddSolid (const G4Trd& trd);
73  void AddSolid (const G4Trap& trap);
74  void AddSolid (const G4Sphere& sphere);
75  void AddSolid (const G4Para& para);
76  void AddSolid (const G4Torus& torus);
77  void AddSolid (const G4Polycone& polycone);
78  void AddSolid (const G4Polyhedra& polyhedra);
79  void AddSolid (const G4Orb& orb);
80  void AddSolid (const G4Ellipsoid& ellipsoid);
81  void AddSolid (const G4TessellatedSolid& tess);
82  void AddSolid (const G4VSolid& solid);
83 
84  void AddCompound (const G4VTrajectory&);
85  void AddCompound (const G4VHit& hit);
86  void AddCompound (const G4VDigi& digi) {
88  }
91  }
94  }
95 
96  void PreAddSolid (const G4Transform3D& objectTransformation, const G4VisAttributes& visAttribs);
97  void PostAddSolid ();
98 
99  void AddPrimitive (const G4Polyline&);
100  void AddPrimitive (const G4Text&);
101  void AddPrimitive (const G4Circle&);
102  void AddPrimitive (const G4Square&);
103  void AddPrimitive (const G4Polyhedron&);
104 
105  void AddPrimitive (const G4Polymarker&);
106  void AddPrimitive (const G4Scale& scale);
107 
108  void BeginPrimitives (const G4Transform3D& objectTransformation);
109  void EndPrimitives ();
110  void BeginModeling ();
111  void EndModeling ();
112 
113  void openHepRep();
114  bool closeHepRep(bool final = false);
115  void openFile(G4String name);
116  void closeFile();
117 
118  private:
122 
124 
125  std::ostream* out;
128 
129  // Methods
130  G4bool dontWrite();
131 
132  void setColor (HEPREP::HepRepAttribute *attribute, const G4Color& color,
133  const G4String& key = G4String("Color"));
135  G4Color getColorFor (const G4VSolid& solid);
136 
137  void setVisibility (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
138  void setLine (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
139 
140  void setVisibility (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
141  void setLine (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
142 
143  void setMarker (HEPREP::HepRepAttribute *attribute, const G4VMarker& marker);
144 
145  inline void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, char* value) {
146  setAttribute(attribute, name, G4String(value));
147  }
149  void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, bool value);
150  void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double value);
151  void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, int value);
152  void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double red, double green, double blue, double alpha);
153 
154  bool isEventData();
155 
156  void open(G4String name);
157  void close();
158 
159  void writeLayers(HEPREP::HepRep* heprep);
160 
162 
163  void addAttDefs(HEPREP::HepRepDefinition* definition, const std::map<G4String,G4AttDef>* attDefs);
164  void addAttVals(HEPREP::HepRepAttribute* attribute, const std::map<G4String,G4AttDef>* attDefs, std::vector<G4AttValue>* attValues);
165 
167 
169 
170  // Returns the particular instance/type or if not created, creates them and adds them to the HepRep
175  HEPREP::HepRepInstance* getGeometryInstance(G4String volumeName, int depth);
178  HEPREP::HepRepType* getGeometryType(G4String volumeName, int depth);
188 
189  G4String getFullTypeName(G4String volumeName, int depth);
190  G4String getParentTypeName(int currentDepth);
191 
192  // initialized Member Variables
196 
209 
210  // DO NOT USE member vars directly, use get methods.
214  std::vector<HEPREP::HepRepInstance*> _geometryInstance;
217  std::vector<G4String> _geometryTypeName;
218  std::map<G4String, HEPREP::HepRepType*> _geometryType;
228 
229  std::map<int, G4String> materialState;
230 };
231 
232 #endif
233