Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:47

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // 
0029 // Andrew Walkden  10th February 1997
0030 // G4OpenGLStoredSceneHandler - creates OpenGL Display lists.
0031 
0032 #ifndef G4OPENGLSTOREDSCENEHANDLER_HH
0033 #define G4OPENGLSTOREDSCENEHANDLER_HH
0034 
0035 #include "globals.hh"
0036 #include "G4OpenGLSceneHandler.hh"
0037 #include "G4Text.hh"
0038 #include <map>
0039 #include <vector>
0040 
0041 class G4OpenGLStored;
0042 
0043 class G4OpenGLStoredSceneHandler: public G4OpenGLSceneHandler {
0044 
0045   friend class G4OpenGLStoredViewer;  // ..allows access to P/TODLs.
0046 
0047 public:
0048 
0049   G4OpenGLStoredSceneHandler (G4VGraphicsSystem& system, const G4String& name = "");
0050   virtual ~G4OpenGLStoredSceneHandler ();
0051   void BeginPrimitives (const G4Transform3D& objectTransformation);
0052   void EndPrimitives ();
0053   void BeginPrimitives2D (const G4Transform3D& objectTransformation);
0054   void EndPrimitives2D ();
0055   void BeginModeling ();
0056   void EndModeling ();
0057   using G4VSceneHandler::AddPrimitive;
0058   void AddPrimitive (const G4Polyline&);
0059   void AddPrimitive (const G4Polymarker&);
0060   void AddPrimitive (const G4Circle&);
0061   void AddPrimitive (const G4Square&);
0062   void AddPrimitive (const G4Text&);
0063   void AddPrimitive (const G4Polyhedron&);
0064   void ClearStore ();
0065   void ClearTransientStore ();
0066 
0067 protected:
0068 
0069   G4bool AddPrimitivePreamble(const G4VMarker& visible);
0070   G4bool AddPrimitivePreamble(const G4Polyline& visible);
0071   G4bool AddPrimitivePreamble(const G4Polyhedron& visible);
0072   // Return false if no further processing required.
0073 
0074   void AddPrimitivePostamble();
0075 
0076   // Two virtual functions for extra processing in a sub-class, for
0077   // example, to make a display tree.  They are to return true if the
0078   // visible object uses gl commands for drawing.  This is
0079   // predominantly true; a notable exception is Qt text.  In that
0080   // case, a display list does not need to be created; all relevant
0081   // information is assumed to be stored in the PO/TOList.
0082   virtual G4bool ExtraPOProcessing
0083   (const G4Visible&, size_t /*currentPOListIndex*/) {return true;}
0084   virtual G4bool ExtraTOProcessing
0085   (const G4Visible&, size_t /*currentTOListIndex*/) {return true;}
0086 
0087   static G4int fSceneIdCount;   // static counter for OpenGLStored scenes.
0088 
0089   // Display list management.  Static since there's only one OGL store.
0090   // Used to link a TODL or PODL to a display list.
0091   static G4int fDisplayListId;
0092 
0093   // Under some circumstances we need to prevent use of a display list.
0094   // For example, a transient display of the current time window during
0095   // a sequence of evolving time windows. This is set in
0096   // G4OpenGLStoredViewer::AddPrimitiveForASingleFrame and acted upon in
0097   // AddPrimitivePreambleInternal.
0098   G4bool fDoNotUseDisplayList;  // Avoid display list use if true
0099 
0100   // PODL = Persistent Object Display List.
0101   // This "top PODL" was made redundant when the PO list was
0102   // "unwrapped" 27th October 2011, but keep it for now in case we
0103   // need to wrap it again.
0104   GLint  fTopPODL;              // List which calls the other PODLs.
0105 
0106   // G4Text plus transform and 2/3D.
0107   struct G4TextPlus {
0108     G4TextPlus(const G4Text& text): fG4Text(text), fProcessing2D(false) {}
0109     G4Text fG4Text;
0110     G4bool fProcessing2D;
0111   };
0112 
0113   // PO = Persistent Object, i.e., run-durantion object, e.g., geometry.
0114   struct PO {
0115     PO();
0116     PO(const PO&);
0117     PO(G4int id, const G4Transform3D& tr = G4Transform3D());
0118     ~PO();
0119     PO& operator= (const PO&);
0120     G4int fDisplayListId;
0121     G4Transform3D fTransform;
0122     GLuint fPickName;
0123     G4Colour fColour;
0124     G4TextPlus* fpG4TextPlus;
0125     G4bool fMarkerOrPolyline;
0126   };
0127   std::vector<PO> fPOList; 
0128   
0129   // TO = Transient Object, e.g., trajectories.
0130   struct TO {
0131     TO();
0132     TO(const TO&);
0133     TO(G4int id, const G4Transform3D& tr = G4Transform3D());
0134     ~TO();
0135     TO& operator= (const TO&);
0136     G4int fDisplayListId;
0137     G4Transform3D fTransform;
0138     GLuint fPickName;
0139     G4double fStartTime, fEndTime;  // Time range (e.g., for trajectory steps).
0140     G4Colour fColour;
0141     G4TextPlus* fpG4TextPlus;
0142     G4bool fMarkerOrPolyline;
0143   };
0144   std::vector<TO> fTOList; 
0145   
0146   // Stop-gap solution of structure re-use.
0147   // A proper implementation would use geometry hierarchy.
0148   std::map <const G4VSolid*, G4int, std::less <const G4VSolid*> > fSolidMap;
0149 
0150 private:
0151   bool AddPrimitivePreambleInternal(const G4Visible& visible, bool isMarker, bool isPolyline);
0152 
0153 };
0154 
0155 #endif