Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLSceneHandler.hh
Go to the documentation of this file.
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$
28 //
29 //
30 // Andrew Walkden 27th March 1996
31 // OpenGL scene handler - base for immediate mode and stored mode classes to
32 // inherit from.
33 
34 #ifdef G4VIS_BUILD_OPENGL_DRIVER
35 
36 #ifndef G4OPENGLSCENEHANDLER_HH
37 #define G4OPENGLSCENEHANDLER_HH
38 
39 #include "globals.hh"
40 
41 #include "G4VSceneHandler.hh"
42 #include "G4OpenGL.hh"
43 
44 #include <map>
45 
46 class G4AttHolder;
47 
48 // Base class for various OpenGLSceneHandler classes.
49 class G4OpenGLSceneHandler: public G4VSceneHandler {
50 
51  friend class G4OpenGLViewer;
52 
53 public:
54  virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
55  virtual void EndPrimitives ();
56  virtual void BeginPrimitives2D (const G4Transform3D& objectTransformation);
57  virtual void EndPrimitives2D ();
58  void AddPrimitive (const G4Polyline&);
59  void AddPrimitive (const G4Polymarker&);
60  void AddPrimitive (const G4Text&);
61  void AddPrimitive (const G4Circle&);
62  void AddPrimitive (const G4Square&);
63  void AddPrimitivesCircle (const std::vector <G4VMarker>&);
64  void AddPrimitivesSquare (const std::vector <G4VMarker>&);
65  void AddPrimitive (const G4Scale&);
66  void AddPrimitive (const G4Polyhedron&);
67  void AddPrimitive (const G4NURBS&);
68 
69  void PreAddSolid (const G4Transform3D& objectTransformation,
70  const G4VisAttributes&);
71  void AddSolid (const G4Box&);
72  void AddSolid (const G4Cons&);
73  void AddSolid (const G4Tubs&);
74  void AddSolid (const G4Trd&);
75  void AddSolid (const G4Trap&);
76  void AddSolid (const G4Sphere&);
77  void AddSolid (const G4Para&);
78  void AddSolid (const G4Torus&);
79  void AddSolid (const G4Polycone&);
80  void AddSolid (const G4Polyhedra&);
81  void AddSolid (const G4VSolid&);
82  void AddCompound (const G4VTrajectory&);
83  void AddCompound (const G4VHit&);
84  void AddCompound (const G4VDigi&);
85  void AddCompound (const G4THitsMap<G4double>&);
86 
87  G4int GetEventsDrawInterval() {return fEventsDrawInterval;}
88  void SetEventsDrawInterval(G4int interval) {fEventsDrawInterval = interval;}
89 
90 protected:
91 
92  G4OpenGLSceneHandler (G4VGraphicsSystem& system,
93  G4int id,
94  const G4String& name = "");
95  virtual ~G4OpenGLSceneHandler ();
96 
97  void ProcessScene();
100 
101  void ClearAndDestroyAtts(); // Destroys att holders and clears pick map.
102 
103  GLuint fPickName;
104  std::map<GLuint, G4AttHolder*> fPickMap; // For picking.
105 
106  // Shared code to wait until we make a single glFlush
107  void ScaledFlush () ;
108  // Number of events to wait until we make a single glFlush
109  G4int fEventsDrawInterval;
110  // Number of events waiting to be flushed
111  G4int fEventsWaitingToBeFlushed;
112 
113  // True if caller of primitives is capable of processing three passes.
114  G4bool fThreePassCapable;
115 
116  G4bool fSecondPassForTransparencyRequested;
117  G4bool fSecondPassForTransparency;
118 
119  G4bool fThirdPassForNonHiddenMarkersRequested;
120  G4bool fThirdPassForNonHiddenMarkers;
121 
122  static const GLubyte fStippleMaskHashed [128];
123 };
124 
125 #include "G4OpenGLSceneHandler.icc"
126 
127 #endif
128 
129 #endif