G4XXXSGSceneHandler.hh

Go to the documentation of this file.
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 // John Allison  10th March 2006
00031 // A template for a sophisticated graphics driver with a scene graph.
00032 //?? Lines beginning like this require specialisation for your driver.
00033 
00034 #ifndef G4XXXSGSCENEHANDLER_HH
00035 #define G4XXXSGSCENEHANDLER_HH
00036 
00037 #include "G4VSceneHandler.hh"
00038 
00039 #include "G4PhysicalVolumeModel.hh"
00040 #include <iostream>
00041 
00042 namespace JA {
00043   // Ad hoc tree class and utilities.
00044   
00045   typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
00046   typedef std::vector<PVNodeID> PVPath;
00047 
00048   struct Node {
00049     Node(PVNodeID pvNodeID = PVNodeID(), G4int index = -1):
00050       fPVNodeID(pvNodeID), fIndex(index) {}
00051     PVNodeID fPVNodeID;
00052     G4int fIndex;
00053     std::vector<Node*> fDaughters;
00054   };
00055 
00056   void Insert(const PVNodeID* pvPath, size_t pathLength,
00057               G4int index, Node* node);
00058 
00059   void PrintTree(std::ostream&, Node*);
00060 
00061   void Clear(Node*);
00062 }
00063 
00064 typedef JA::Node SceneGraph;
00065 
00066 class G4XXXSGSceneHandler: public G4VSceneHandler {
00067 
00068   friend class G4XXXSGViewer;
00069 
00070 public:
00071   G4XXXSGSceneHandler(G4VGraphicsSystem& system,
00072                         const G4String& name);
00073   virtual ~G4XXXSGSceneHandler();
00074 
00076   // Optional virtual functions...
00077   void AddSolid(const G4Box&);
00078   // Further optional AddSolid functions.  Explicitly invoke base
00079   // class methods if not otherwise defined to avoid warnings about
00080   // hiding of base class methods.
00081   void AddSolid(const G4Cons& cons)
00082   {G4VSceneHandler::AddSolid(cons);}
00083   void AddSolid(const G4Tubs& tubs)
00084   {G4VSceneHandler::AddSolid(tubs);}
00085   void AddSolid(const G4Trd& trd)
00086   {G4VSceneHandler::AddSolid(trd);}
00087   void AddSolid(const G4Trap& trap)
00088   {G4VSceneHandler::AddSolid(trap);}
00089   void AddSolid(const G4Sphere& sphere)
00090   {G4VSceneHandler::AddSolid(sphere);}
00091   void AddSolid(const G4Para& para)
00092   {G4VSceneHandler::AddSolid(para);}
00093   void AddSolid(const G4Torus& torus)
00094   {G4VSceneHandler::AddSolid(torus);}
00095   void AddSolid(const G4Polycone& polycone)
00096   {G4VSceneHandler::AddSolid(polycone);}
00097   void AddSolid(const G4Polyhedra& polyhedra)
00098   {G4VSceneHandler::AddSolid(polyhedra);}
00099   void AddSolid(const G4VSolid& solid)
00100   {G4VSceneHandler::AddSolid(solid);}
00101   // More optional functions...
00102   // void AddCompound(const G4VTrajectory&);
00103   // void AddCompound(const G4VHit&);
00104   // void AddCompound(const G4THitsMap<G4double>&);
00105   void PreAddSolid(const G4Transform3D& objectTransformation,
00106                    const G4VisAttributes&);
00107   void PostAddSolid();
00108 
00110   // Required implementation of pure virtual functions...
00111 
00112   void AddPrimitive(const G4Polyline&);
00113   void AddPrimitive(const G4Text&);
00114   void AddPrimitive(const G4Circle&);
00115   void AddPrimitive(const G4Square&);
00116   void AddPrimitive(const G4Polyhedron&);
00117   void AddPrimitive(const G4NURBS&);
00118   // Further optional AddPrimitive methods.  Explicitly invoke base
00119   // class methods if not otherwise defined to avoid warnings about
00120   // hiding of base class methods.
00121   void AddPrimitive(const G4Polymarker& polymarker)
00122   {G4VSceneHandler::AddPrimitive (polymarker);}
00123   void AddPrimitive(const G4Scale& scale)
00124   {G4VSceneHandler::AddPrimitive (scale);}
00125   // Further related optional virtual functions...
00126   void BeginPrimitives(const G4Transform3D& objectTransformation);
00127   void EndPrimitives();
00128 
00130   // Further optional virtual functions...
00131 
00132   // void BeginModeling();
00133   // void EndModeling();
00134 
00136   // Administration functions.
00137 
00138   void ClearStore ();
00139   void ClearTransientStore ();
00140 
00141 protected:
00142 
00143   static G4int fSceneIdCount;  // Counter for XXXSG scene handlers.
00144 
00145   // Utility for PreAddSolid and BeginPrimitives.
00146   void CreateCurrentItem(const G4String&);
00147 
00148   //?? Define the scene graph.  (For emulation, use an ad hoc tree class.)
00149   SceneGraph fSceneGraph;
00150 
00151 private:
00152 
00153 #ifdef G4XXXFileDEBUG
00154   void PrintThings();
00155 #endif
00156 
00157 };
00158 
00159 #endif

Generated on Mon May 27 17:50:28 2013 for Geant4 by  doxygen 1.4.7