Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HepRepFileSceneHandler.hh
Go to the documentation of this file.
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 // $Id: G4HepRepFileSceneHandler.hh 66870 2013-01-14 23:38:59Z adotti $
28 //
29 //
30 // Joseph Perl 27th January 2002
31 // A base class for a scene handler to export geometry and trajectories
32 // to the HepRep xml file format.
33 
34 #ifndef G4HepRepFileSCENEHANDLER_HH
35 #define G4HepRepFileSCENEHANDLER_HH
36 
37 //#define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
38 
39 #include "G4VSceneHandler.hh"
40 #include "G4Box.hh"
41 #include "G4Cons.hh"
42 #include "G4Tubs.hh"
43 #include "G4Trd.hh"
44 #include "G4Trap.hh"
45 #include "G4Sphere.hh"
46 #include "G4Para.hh"
47 #include "G4Torus.hh"
48 #include "G4Polycone.hh"
49 #include "G4Polyhedra.hh"
50 
51 // HepRep
52 #include "G4HepRepFileXMLWriter.hh"
53 
54 class G4VPhysicalVolume;
55 class G4LogicalVolume;
57 class G4VisTrajContext;
58 
60 
61 public:
63  const G4String& name);
64  virtual ~G4HepRepFileSceneHandler();
65 
66  ////////////////////////////////////////////////////////////////
67  // No need to implement these, but if you do...
68  void AddSolid(const G4Box&);
69  void AddSolid(const G4Cons&);
70  void AddSolid(const G4Tubs&);
71  void AddSolid(const G4Trd&);
72  void AddSolid(const G4Trap&);
73  void AddSolid(const G4Sphere&);
74  void AddSolid(const G4Para&);
75  void AddSolid(const G4Torus&);
76  void AddSolid(const G4Polycone&);
77  void AddSolid(const G4Polyhedra&);
78  void AddSolid(const G4VSolid&);
79  void AddCompound (const G4VTrajectory&);
80  void InitTrajectory();
81  void AddCompound (const G4VHit&);
82  void InitHit();
83  void AddCompound (const G4THitsMap<G4double>& hits) {
85  }
86  void AddCompound (const G4VDigi& digi) {
88  }
89  // void PreAddSolid(const G4Transform3D& objectTransformation,
90  // const G4VisAttributes&);
91  // void PostAddSolid();
92 
93  ////////////////////////////////////////////////////////////////
94  // Required implementation of pure virtual functions...
95 
96  void AddPrimitive(const G4Polyline&);
97  void AddPrimitive(const G4Text&);
98  void AddPrimitive(const G4Circle&);
99  void AddPrimitive(const G4Square&);
100  void AddPrimitive(const G4Polyhedron&);
101 
102  ////////////////////////////////////////////////////////////////
103  ////////////////////////////////////////////////////////////////
104  // Further optional AddPrimtive methods. Explicitly invoke base
105  // class methods if not otherwise defined to avoid warnings about
106  // hiding of base class methods.
107  void AddPrimitive(const G4Polymarker&);
108  void AddPrimitive(const G4Scale& scale) {
110  }
111 
112  ////////////////////////////////////////////////////////////////
113  // Further optional virtual functions...
114 
115  // void BeginPrimitives(const G4Transform3D& objectTransformation);
116  // void EndPrimitives();
117 
118  void BeginModeling();
119  void EndModeling();
120 
121  void BeginPrimitives2D(const G4Transform3D& objectTransformation);
122  void EndPrimitives2D();
123 
124  //////////////////////////////////////////////////////////////
125  // Administration functions.
126 
127  //void ClearStore ();
128  void ClearTransientStore ();
129 
130  ////////////////////////////////////////////////////////////////
131  // Required...
132 
134 
135 protected:
136  static G4int fSceneIdCount; // Counter for HepRep scene handlers.
137 
138 private:
139  G4HepRepFileXMLWriter *hepRepXMLWriter;
140  void AddHepRepInstance(const char* primName,
141  const G4Visible visible);
142  void CheckFileOpen();
143  int fileCounter;
144  G4bool haveVisible;
145  G4bool inPrimitives2D;
146  G4bool warnedAbout3DText;
147  G4bool warnedAbout2DMarkers;
148  G4bool drawingTraj;
149  G4bool doneInitTraj;
150  G4bool drawingHit;
151  G4bool doneInitHit;
152 
153  const G4VisTrajContext* trajContext;
154 
155  std::vector<G4AttValue>* trajAttValues;
156  std::map<G4String,G4AttDef>* trajAttDefs;
157  std::vector<G4AttValue>* hitAttValues;
158  std::map<G4String,G4AttDef>* hitAttDefs;
159 
160 #ifdef G4HEPREPFILEDEBUG
161  void PrintThings();
162 #endif
163 
164 };
165 
166 #endif
Definition: G4Para.hh:76
Definition: G4Text.hh:73
void AddCompound(const G4VTrajectory &)
G4HepRepFileSceneHandler(G4VGraphicsSystem &system, const G4String &name)
Definition: G4Box.hh:63
Definition: G4Tubs.hh:84
void AddPrimitive(const G4Polyline &)
const XML_Char * name
Definition: G4VHit.hh:48
Definition: G4Trd.hh:71
int G4int
Definition: G4Types.hh:78
virtual void AddPrimitive(const G4Polyline &)=0
void AddPrimitive(const G4Scale &scale)
bool G4bool
Definition: G4Types.hh:79
void AddCompound(const G4VDigi &digi)
Definition: G4Cons.hh:82
virtual void AddCompound(const G4VTrajectory &)
void BeginPrimitives2D(const G4Transform3D &objectTransformation)
void AddCompound(const G4THitsMap< G4double > &hits)
G4HepRepFileXMLWriter * GetHepRepXMLWriter()