ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GMocrenFileSceneHandler.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GMocrenFileSceneHandler.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 //
28 //
29 // Created: Mar. 31, 2009 Akinori Kimura
30 //
31 // Scene handler to export geometry and trajectories to a gMocren file.
32 //
33 #ifndef G4GMocrenFile_SCENE_HANDLER_HH
34 #define G4GMocrenFile_SCENE_HANDLER_HH
35 
36 #include "globals.hh"
37 
38 #include "G4VSceneHandler.hh"
39 
40 #include <fstream>
41 
42 #include "G4THitsMap.hh"
43 
44 class G4VisAttributes ;
45 class G4GMocrenFile;
46 class G4GMocrenMessenger;
47 class G4GMocrenIO;
48 class G4VSolid;
49 class G4Polyhedron;
50 class G4Colour;
51 
52 //-----
54 
55  friend class G4GMocrenFileViewer;
56 
57 public:
58 
59  //----- constructor and destructor
61  G4GMocrenMessenger & messenger,
62  const G4String& name = "");
63  virtual ~G4GMocrenFileSceneHandler ();
64 
65  //----- overriding base class methods
66  void AddPrimitive (const G4Polyline& line);
67  void AddPrimitive (const G4Polyhedron& p);
68  void AddPrimitive (const G4Text&);
69  void AddPrimitive (const G4Circle&);
70  void AddPrimitive (const G4Square&);
71 
72  //----- explicitly invoke base class methods to avoid warnings about
73  //----- hiding of base class methods.
74  void AddPrimitive (const G4Polymarker& polymarker)
75  { G4VSceneHandler::AddPrimitive (polymarker); }
76  void AddPrimitive (const G4Scale& scale)
78 
81 
82  virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
83  virtual void EndPrimitives ();
84 
85  void AddSolid ( const G4Box& box );
86  void AddSolid ( const G4Cons& cons );
87  void AddSolid ( const G4Tubs& tubs );
88  void AddSolid ( const G4Trd& trd );
89  void AddSolid ( const G4Trap& trap );
90  void AddSolid ( const G4Sphere& sphere );
91  void AddSolid ( const G4Para& para );
92  void AddSolid ( const G4Torus& torus );
93  void AddSolid ( const G4Polycone& polycone ) {
94  G4VSceneHandler::AddSolid (polycone);
95  }
96  void AddSolid ( const G4Polyhedra& polyhedra) {
97  G4VSceneHandler::AddSolid (polyhedra);
98  }
99  void AddSolid ( const G4Orb& orb ) {
101  }
102  void AddSolid ( const G4Ellipsoid& ellipsoid) {
103  G4VSceneHandler::AddSolid (ellipsoid);
104  }
105  void AddSolid ( const G4TessellatedSolid& tess) {
107  }
108  void AddSolid ( const G4VSolid& solid );
109  void AddCompound ( const G4VTrajectory& traj);
110  void AddCompound ( const G4VHit& hit);
111  void AddCompound ( const G4VDigi& hit);
112  void AddCompound ( const G4THitsMap<G4double> & hits);
113  void AddCompound ( const G4THitsMap<G4StatDouble> & hits);
114 
115 
116  void ClearTransientStore(); // Used for triggering detector re-drawing.
117 
118  //----- public methods inherent to this class
119  void GFBeginModeling () ;
120  void GFEndModeling () ;
122 
123  G4bool IsSavingGdd ( void ) { return kFlagSaving_g4_gdd ; }
124  void BeginSavingGdd( void );
125  void EndSavingGdd ( void ) ;
126  void SetGddFileName() ;
127 
128  G4GMocrenFile& GetSystem () { return kSystem ; }
129  const char* GetGddFileName () { return kGddFileName ; }
130 
131 
132 private:
133 
134  //----- initialize all parameters
135  void InitializeParameters();
136 
137  //----- Utilities etc.
138  G4bool IsVisible();
139 
140  //
141  void AddDetector(const G4VSolid & solid);
142  void ExtractDetector();
143 
144  void GetNestedVolumeIndex(G4int, G4int[3]);
145 
146 private:
147  G4GMocrenFile& kSystem; // Graphics system for this scene.
150 
151  std::map<G4int, float> kModality;
153  //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
156 
158  //std::vector<float *> fTrajectories;
159  //std::vector<unsigned char *> fTrajectoryColors;
161 
162  class Detector {
163  public:
167  unsigned char color[3];
168  Detector();
169  ~Detector();
170  void clear();
171  };
172  std::vector<Detector> kDetectors;
175  std::vector<G4String> kNestedVolumeNames;
178 
179  class Index3D {
180  public:
181  G4int x, y, z;
182 
183  Index3D();
184  Index3D(const Index3D & _index3D);
185  Index3D(G4int _x, G4int _y, G4int _z);
186  ~Index3D(){;}
187  G4bool operator < (const Index3D & _right) const;
188  G4bool operator == (const Index3D & _right) const;
189  private:
190  // Private assigment operator -
191  // assignment not allowed. Keeps Coverity happy.
192  // Index3D& operator = (const Index3D&);
193  };
194 
195  std::map<Index3D, float> kNestedModality;
196  //std::map<Index3D, G4double> * fTempNestedHits;
197  std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
198  //std::map<G4String, G4String> kNestedHitsUnit;
199 
200  std::ofstream kGddDest; // defined here
202  // true: GF_BEGIN_MODELING has sent to gMocrenFile, and
203  // GF_END_MODELING has not sent yet.
204  // false: otherwise
205  //
206  // kFlagInModeling is set to "true"
207  // in GFBeginModeling(), and to "false"
208  // in GFEndModeling().
209 
211 
212  G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
213  // 1: G4PhantomParameterisation
214  // 2: interactive scorer
216 
217  char kGddDestDir[256];
218  char kGddFileName[256];
220 
221 };
222 
223 #endif