Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGLStoredXmViewer.cc
이 파일의 문서화 페이지로 가기
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: G4OpenGLStoredXmViewer.cc 97241 2016-05-30 12:06:54Z gcosmo $
28 //
29 //
30 // Andrew Walkden 10th February 1997
31 // Class G4OpenGLStoredXmViewer : a class derived from G4OpenGLXmViewer
32 // and G4OpenGLStoredViewer.
33 
34 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
35 
37 
39 #include "G4ios.hh"
40 #include "G4Threading.hh"
41 
42 G4OpenGLStoredXmViewer::
43 G4OpenGLStoredXmViewer (G4OpenGLStoredSceneHandler& sceneHandler,
44  const G4String& name)
45  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
46  G4OpenGLViewer (sceneHandler),
47  G4OpenGLXmViewer (sceneHandler),
48  G4OpenGLStoredViewer (sceneHandler)
49 {
50 
51  if (fViewId < 0) return; // In case error in base class instantiation.
52 
53  if (!vi_stored) {
54  fViewId = -1; // This flags an error.
55  G4cerr << "G4OpenGLStoredXmViewer::G4OpenGLStoredXmViewer -"
56  " G4OpenGLXmViewer couldn't get a visual." << G4endl;
57  return;
58  }
59 }
60 
61 G4OpenGLStoredXmViewer::~G4OpenGLStoredXmViewer () {
62  GetSceneHandler()->RemoveViewerFromList(this);
63 }
64 
65 void G4OpenGLStoredXmViewer::Initialise () {
66 
67  CreateGLXContext (vi_stored);
68  CreateMainWindow ();
69  CreateFontLists ();
70 
71  InitializeGLView ();
72 
73  glDrawBuffer (GL_BACK);
74 }
75 
76 void G4OpenGLStoredXmViewer::DrawView () {
77 #ifdef G4DEBUG_VIS_OGL
78  printf("G4OpenGLStoredXmViewer::DrawView \n");
79 #endif
80 
81  G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
82 
83  //See if things have changed from last time and remake if necessary...
84  // /vis/viewer/rebuild, but if not, make decision and set flag only
85  // if necessary...
86  if (!fNeedKernelVisit) KernelVisitDecision ();
87  G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
88  ProcessView ();
89 
90  if(style!=G4ViewParameters::hlr &&
91  haloing_enabled) {
92 
93  HaloingFirstPass ();
94  DrawDisplayLists ();
95 #ifdef G4DEBUG_VIS_OGL
96  printf("G4OpenGLStoredXmViewer::DrawView () flush\n");
97 #endif
98  glFlush ();
99 
100  HaloingSecondPass ();
101 
102  DrawDisplayLists ();
103  FinishView ();
104 
105  } else {
106 
107 #ifdef G4DEBUG_VIS_OGL
108  printf("G4OpenGLStoredXmViewer::DrawView not hlr \n");
109 #endif
110  // If kernel visit was needed, drawing and FinishView will already
111  // have been done, so...
112  if (!kernelVisitWasNeeded) {
113 #ifdef G4DEBUG_VIS_OGL
114  printf("G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n");
115 #endif
116  DrawDisplayLists ();
117  FinishView ();
118  } else {
119 #ifdef G4DEBUG_VIS_OGL
120  printf("G4OpenGLStoredXmViewer::ComputeView Need kernel Visit \n");
121 #endif
122  // However, union cutaways are implemented in DrawDisplayLists, so make
123  // an extra pass...
124  if (fVP.IsCutaway() &&
125  fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
126  ClearView();
127  DrawDisplayLists ();
128  FinishView ();
129  } else { // ADD TO AVOID KernelVisit=1 and nothing to display
130  DrawDisplayLists ();
131  FinishView ();
132  }
133  }
134  }
135 #ifdef G4DEBUG_VIS_OGL
136  printf("G4OpenGLStoredXmViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
137 #endif
138 }
139 
140 void G4OpenGLStoredXmViewer::FinishView () {
141  glXWaitGL (); //Wait for effects of all previous OpenGL commands to
142  //be propogated before progressing.
143 
144 #ifdef G4DEBUG_VIS_OGL
145  printf("G4OpenGLStoredXmViewer::FinishView () flush \n");
146 #endif
147  glFlush (); //FIXME
148 
149  GLint renderMode;
150  glGetIntegerv(GL_RENDER_MODE, &renderMode);
151  if (renderMode == GL_RENDER) glXSwapBuffers (dpy, win);
152 }
153 
154 #endif
const XML_Char * name
Definition: expat.h:151
#define G4endl
Definition: G4ios.hh:61
bool G4bool
Definition: G4Types.hh:79
printf("%d Experimental points found\n", nlines)
G4GLOB_DLL std::ostream G4cerr