Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGLSceneHandler.hh
이 파일의 문서화 페이지로 가기
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: G4OpenGLSceneHandler.hh 99440 2016-09-22 08:34:04Z gcosmo $
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 
68  void PreAddSolid (const G4Transform3D& objectTransformation,
69  const G4VisAttributes&);
70  void AddSolid (const G4Box&);
71  void AddSolid (const G4Cons&);
72  void AddSolid (const G4Tubs&);
73  void AddSolid (const G4Trd&);
74  void AddSolid (const G4Trap&);
75  void AddSolid (const G4Sphere&);
76  void AddSolid (const G4Para&);
77  void AddSolid (const G4Torus&);
78  void AddSolid (const G4Polycone&);
79  void AddSolid (const G4Polyhedra&);
80  void AddSolid (const G4Orb&);
81  void AddSolid (const G4Ellipsoid&);
82  void AddSolid (const G4VSolid&);
83  void AddCompound (const G4VTrajectory&);
84  void AddCompound (const G4VHit&);
85  void AddCompound (const G4VDigi&);
86  void AddCompound (const G4THitsMap<G4double>&);
88 
89  // enum for /vis/ogl/flushAt.
90  enum FlushAction {
91  endOfEvent,
92  endOfRun,
93  eachPrimitive,
94  NthPrimitive,
95  NthEvent,
96  never
97  };
98  static G4int GetEntitiesFlushInterval()
99  {return fEntitiesFlushInterval;}
100  static FlushAction GetFlushAction()
101  {return fFlushAction;}
102  static void SetEntitiesFlushInterval(G4int interval)
103  {fEntitiesFlushInterval = interval;}
104  static void SetFlushAction(FlushAction action)
105  {fFlushAction = action;}
106 
107 #ifdef G4OPENGL_VERSION_2
108  private :
109  // vertex vector to be given to the graphic card
110  std::vector<double> fOglVertex;
111  // indices vector to be given to the graphic card
112  std::vector<unsigned short> fOglIndices;
113  // before, drawyType (as GL_QUADS, GL_TRIANGLES...) was
114  // given in glBegin. Now it has to be given in glDrawArray (at the end)
115  GLenum fDrawArrayType;
116  // emulate GL_QUADS behaviour by inverting two last positions
117  bool fEmulate_GL_QUADS;
118  // Try to optimize a bit the pipeline
119  void OptimizeVBOForTrd();
120  void OptimizeVBOForCons(G4int aNoFacet);
121  // emulating glEnd and glBegin
122  void glEndVBO();
123  void glBeginVBO(GLenum type);
124  void drawVBOArray(std::vector<double> vertices);
125 
126  // Buffers used to access vertex and indices elements
127 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
128  GLuint fVertexBufferObject;
129  GLuint fIndicesBufferObject;
130 #else
131  Wt::WGLWidget::Buffer fVertexBufferObject;
132  Wt::WGLWidget::Buffer fIndicesBufferObject;
133 #endif // G4VIS_BUILD_OPENGLWT_DRIVER
134 
135 #endif //G4OPENGL_VERSION_2
136 
137 protected:
138 
139  G4OpenGLSceneHandler (G4VGraphicsSystem& system,
140  G4int id,
141  const G4String& name = "");
142  virtual ~G4OpenGLSceneHandler ();
143 
144  void ProcessScene();
147 
148  void ClearAndDestroyAtts(); // Destroys att holders and clears pick map.
149 
150 #ifdef G4OPENGL_VERSION_2
151  // Special case for VBO, we want to have acces to the VBO drawer everywhere
152  // because instead of OpenGL call which are static, VBO openGL functions :
153  // - Are functions of an WGLWidget object(G4OpenGLImmediateViewer in our case)
154  // - Needs an access to the QGLSHader
155  // - Have to be redefined in a VBO way
156 
157  inline void setVboDrawer(G4OpenGLVboDrawer* drawer) {
158  fVboDrawer = drawer;
159  }
160  G4OpenGLVboDrawer* fVboDrawer;
161 #endif // G4OPENGL_VERSION_2
162 
163  GLuint fPickName;
164  std::map<GLuint, G4AttHolder*> fPickMap; // For picking.
165 
166  // Shared code to wait until we make a single glFlush
167  void ScaledFlush () ;
168  // Static so that they apply to all OGL scene handlers...
169  static FlushAction fFlushAction;
170  // Number of entities between flushes
171  static G4int fEntitiesFlushInterval;
172 
173  // True if caller of primitives is capable of processing three passes.
174  G4bool fThreePassCapable;
175 
176  G4bool fSecondPassForTransparencyRequested;
177  G4bool fSecondPassForTransparency;
178 
179  G4bool fThirdPassForNonHiddenMarkersRequested;
180  G4bool fThirdPassForNonHiddenMarkers;
181 
182  static const GLubyte fStippleMaskHashed [128];
183  bool fEdgeFlag;
184 };
185 
186 #include "G4OpenGLSceneHandler.icc"
187 
188 #endif // G4OPENGLSCENEHANDLER_HH
189 
190 #endif // G4VIS_BUILD_OPENGL_DRIVER
const XML_Char * name
Definition: expat.h:151
system("rm -rf microbeam.root")
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
Definition: G4Tubs.hh:85
Definition: G4VHit.hh:48
virtual G4VSolid * CreateSectionSolid()
virtual void ProcessScene()
virtual void AddCompound(const G4VTrajectory &)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Text.hh:73
Definition: G4Cons.hh:83
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation)
Definition: G4Box.hh:64
Definition: G4Orb.hh:62
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void AddSolid(const G4Box &)
int G4int
Definition: G4Types.hh:78
virtual void AddPrimitive(const G4Polyline &)=0
Definition: G4Trd.hh:72
virtual G4VSolid * CreateCutawaySolid()
Definition: G4Para.hh:86
virtual void EndPrimitives2D()
virtual void EndPrimitives()