00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // Joseph Perl 27th January 2002 00031 // A base class for a scene handler to export geometry and trajectories 00032 // to the HepRep xml file format. 00033 00034 #ifndef G4HepRepFileSCENEHANDLER_HH 00035 #define G4HepRepFileSCENEHANDLER_HH 00036 00037 //#define G4HEPREPFILEDEBUG // Comment this out to suppress debug code. 00038 00039 #include "G4VSceneHandler.hh" 00040 #include "G4Box.hh" 00041 #include "G4Cons.hh" 00042 #include "G4Tubs.hh" 00043 #include "G4Trd.hh" 00044 #include "G4Trap.hh" 00045 #include "G4Sphere.hh" 00046 #include "G4Para.hh" 00047 #include "G4Torus.hh" 00048 #include "G4Polycone.hh" 00049 #include "G4Polyhedra.hh" 00050 00051 // HepRep 00052 #include "G4HepRepFileXMLWriter.hh" 00053 00054 class G4VPhysicalVolume; 00055 class G4LogicalVolume; 00056 class G4ModelingParameters; 00057 class G4VisTrajContext; 00058 00059 class G4HepRepFileSceneHandler: public G4VSceneHandler { 00060 00061 public: 00062 G4HepRepFileSceneHandler(G4VGraphicsSystem& system, 00063 const G4String& name); 00064 virtual ~G4HepRepFileSceneHandler(); 00065 00067 // No need to implement these, but if you do... 00068 void AddSolid(const G4Box&); 00069 void AddSolid(const G4Cons&); 00070 void AddSolid(const G4Tubs&); 00071 void AddSolid(const G4Trd&); 00072 void AddSolid(const G4Trap&); 00073 void AddSolid(const G4Sphere&); 00074 void AddSolid(const G4Para&); 00075 void AddSolid(const G4Torus&); 00076 void AddSolid(const G4Polycone&); 00077 void AddSolid(const G4Polyhedra&); 00078 void AddSolid(const G4VSolid&); 00079 void AddCompound (const G4VTrajectory&); 00080 void InitTrajectory(); 00081 void AddCompound (const G4VHit&); 00082 void InitHit(); 00083 void AddCompound (const G4THitsMap<G4double>& hits) { 00084 G4VSceneHandler::AddCompound(hits); 00085 } 00086 void AddCompound (const G4VDigi& digi) { 00087 G4VSceneHandler::AddCompound(digi); 00088 } 00089 // void PreAddSolid(const G4Transform3D& objectTransformation, 00090 // const G4VisAttributes&); 00091 // void PostAddSolid(); 00092 00094 // Required implementation of pure virtual functions... 00095 00096 void AddPrimitive(const G4Polyline&); 00097 void AddPrimitive(const G4Text&); 00098 void AddPrimitive(const G4Circle&); 00099 void AddPrimitive(const G4Square&); 00100 void AddPrimitive(const G4Polyhedron&); 00101 void AddPrimitive(const G4NURBS&); 00102 00105 // Further optional AddPrimtive methods. Explicitly invoke base 00106 // class methods if not otherwise defined to avoid warnings about 00107 // hiding of base class methods. 00108 void AddPrimitive(const G4Polymarker&); 00109 void AddPrimitive(const G4Scale& scale) { 00110 G4VSceneHandler::AddPrimitive (scale); 00111 } 00112 00114 // Further optional virtual functions... 00115 00116 // void BeginPrimitives(const G4Transform3D& objectTransformation); 00117 // void EndPrimitives(); 00118 00119 void BeginModeling(); 00120 void EndModeling(); 00121 00122 void BeginPrimitives2D(const G4Transform3D& objectTransformation); 00123 void EndPrimitives2D(); 00124 00126 // Administration functions. 00127 00128 //void ClearStore (); 00129 void ClearTransientStore (); 00130 00132 // Required... 00133 00134 G4HepRepFileXMLWriter *GetHepRepXMLWriter(); 00135 00136 protected: 00137 static G4int fSceneIdCount; // Counter for HepRep scene handlers. 00138 00139 private: 00140 G4HepRepFileXMLWriter *hepRepXMLWriter; 00141 void AddHepRepInstance(const char* primName, 00142 const G4Visible visible); 00143 void CheckFileOpen(); 00144 int fileCounter; 00145 G4bool haveVisible; 00146 G4bool inPrimitives2D; 00147 G4bool warnedAbout3DText; 00148 G4bool warnedAbout2DMarkers; 00149 G4bool drawingTraj; 00150 G4bool doneInitTraj; 00151 G4bool drawingHit; 00152 G4bool doneInitHit; 00153 00154 const G4VisTrajContext* trajContext; 00155 00156 std::vector<G4AttValue>* trajAttValues; 00157 std::map<G4String,G4AttDef>* trajAttDefs; 00158 std::vector<G4AttValue>* hitAttValues; 00159 std::map<G4String,G4AttDef>* hitAttDefs; 00160 00161 #ifdef G4HEPREPFILEDEBUG 00162 void PrintThings(); 00163 #endif 00164 00165 }; 00166 00167 #endif