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3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 //
 28 // 
 29 // Andrew Walkden  10th February 1997
 30 // G4OpenGLStoredSceneHandler - creates OpenGL Display lists.
 31 
 32 #ifndef G4OPENGLSTOREDSCENEHANDLER_HH
 33 #define G4OPENGLSTOREDSCENEHANDLER_HH
 34 
 35 #include "globals.hh"
 36 #include "G4OpenGLSceneHandler.hh"
 37 #include "G4Text.hh"
 38 #include <map>
 39 #include <vector>
 40 
 41 class G4OpenGLStored;
 42 
 43 class G4OpenGLStoredSceneHandler: public G4OpenGLSceneHandler {
 44 
 45   friend class G4OpenGLStoredViewer;  // ..allows access to P/TODLs.
 46 
 47 public:
 48 
 49   G4OpenGLStoredSceneHandler (G4VGraphicsSystem& system, const G4String& name = "");
 50   virtual ~G4OpenGLStoredSceneHandler ();
 51   void BeginPrimitives (const G4Transform3D& objectTransformation);
 52   void EndPrimitives ();
 53   void BeginPrimitives2D (const G4Transform3D& objectTransformation);
 54   void EndPrimitives2D ();
 55   void BeginModeling ();
 56   void EndModeling ();
 57   using G4VSceneHandler::AddPrimitive;
 58   void AddPrimitive (const G4Polyline&);
 59   void AddPrimitive (const G4Polymarker&);
 60   void AddPrimitive (const G4Circle&);
 61   void AddPrimitive (const G4Square&);
 62   void AddPrimitive (const G4Text&);
 63   void AddPrimitive (const G4Polyhedron&);
 64   void ClearStore ();
 65   void ClearTransientStore ();
 66 
 67 protected:
 68 
 69   G4bool AddPrimitivePreamble(const G4VMarker& visible);
 70   G4bool AddPrimitivePreamble(const G4Polyline& visible);
 71   G4bool AddPrimitivePreamble(const G4Polyhedron& visible);
 72   // Return false if no further processing required.
 73 
 74   void AddPrimitivePostamble();
 75 
 76   // Two virtual functions for extra processing in a sub-class, for
 77   // example, to make a display tree.  They are to return true if the
 78   // visible object uses gl commands for drawing.  This is
 79   // predominantly true; a notable exception is Qt text.  In that
 80   // case, a display list does not need to be created; all relevant
 81   // information is assumed to be stored in the PO/TOList.
 82   virtual G4bool ExtraPOProcessing
 83   (const G4Visible&, size_t /*currentPOListIndex*/) {return true;}
 84   virtual G4bool ExtraTOProcessing
 85   (const G4Visible&, size_t /*currentTOListIndex*/) {return true;}
 86 
 87   static G4int fSceneIdCount;   // static counter for OpenGLStored scenes.
 88 
 89   // Display list management.  Static since there's only one OGL store.
 90   // Used to link a TODL or PODL to a display list.
 91   static G4int fDisplayListId;
 92 
 93   // Under some circumstances we need to prevent use of a display list.
 94   // For example, a transient display of the current time window during
 95   // a sequence of evolving time windows. This is set in
 96   // G4OpenGLStoredViewer::AddPrimitiveForASingleFrame and acted upon in
 97   // AddPrimitivePreambleInternal.
 98   G4bool fDoNotUseDisplayList;  // Avoid display list use if true
 99 
100   // PODL = Persistent Object Display List.
101   // This "top PODL" was made redundant when the PO list was
102   // "unwrapped" 27th October 2011, but keep it for now in case we
103   // need to wrap it again.
104   GLint  fTopPODL;              // List which calls the other PODLs.
105 
106   // G4Text plus transform and 2/3D.
107   struct G4TextPlus {
108     G4TextPlus(const G4Text& text): fG4Text(text), fProcessing2D(false) {}
109     G4Text fG4Text;
110     G4bool fProcessing2D;
111   };
112 
113   // PO = Persistent Object, i.e., run-durantion object, e.g., geometry.
114   struct PO {
115     PO();
116     PO(const PO&);
117     PO(G4int id, const G4Transform3D& tr = G4Transform3D());
118     ~PO();
119     PO& operator= (const PO&);
120     G4int fDisplayListId;
121     G4Transform3D fTransform;
122     GLuint fPickName;
123     G4Colour fColour;
124     G4TextPlus* fpG4TextPlus;
125     G4bool fMarkerOrPolyline;
126   };
127   std::vector<PO> fPOList; 
128   
129   // TO = Transient Object, e.g., trajectories.
130   struct TO {
131     TO();
132     TO(const TO&);
133     TO(G4int id, const G4Transform3D& tr = G4Transform3D());
134     ~TO();
135     TO& operator= (const TO&);
136     G4int fDisplayListId;
137     G4Transform3D fTransform;
138     GLuint fPickName;
139     G4double fStartTime, fEndTime;  // Time range (e.g., for trajectory steps).
140     G4Colour fColour;
141     G4TextPlus* fpG4TextPlus;
142     G4bool fMarkerOrPolyline;
143   };
144   std::vector<TO> fTOList; 
145   
146   // Stop-gap solution of structure re-use.
147   // A proper implementation would use geometry hierarchy.
148   std::map <const G4VSolid*, G4int, std::less <const G4VSolid*> > fSolidMap;
149 
150 private:
151   bool AddPrimitivePreambleInternal(const G4Visible& visible, bool isMarker, bool isPolyline);
152 
153 };
154 
155 #endif
156