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