source: trunk/geant4/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc@ 668

Last change on this file since 668 was 608, checked in by garnier, 18 years ago

r657@mac-90108: laurentgarnier | 2007-11-15 19:44:52 +0100
ajout d un flag pour debug

  • Property svn:mime-type set to text/cpp
File size: 7.3 KB
Line 
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: G4OpenGLImmediateQtViewer.cc,v 1.3 2007/11/15 18:24:28 lgarnier Exp $
28// GEANT4 tag $Name: $
29//
30//
31// Class G4OpenGLImmediateQtViewer : a class derived from G4OpenGLQtViewer and
32// G4OpenGLImmediateViewer.
33
34#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35
36#include "G4OpenGLImmediateQtViewer.hh"
37#include "G4VisManager.hh"
38
39#include "G4ios.hh"
40
41G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer
42(G4OpenGLImmediateSceneHandler& sceneHandler,
43 const G4String& name):
44 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLQtViewer (sceneHandler),
47 G4OpenGLImmediateViewer (sceneHandler),
48 QGLWidget() // FIXME : gerer le pb du parent !
49 {
50 nbPaint =0;
51 if (fViewId < 0) return; // In case error in base class instantiation.
52}
53
54G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQtViewer() {
55#ifdef GEANT4_QT_DEBUG
56 printf("GLWidget::~GLWidget \n");
57#endif
58 makeCurrent();
59#ifdef GEANT4_QT_DEBUG
60 printf("GLWidget::~GLWidget END\n");
61#endif
62}
63
64void G4OpenGLImmediateQtViewer::Initialise() {
65#ifdef GEANT4_QT_DEBUG
66 printf("GLWidget::Initialise \n");
67#endif
68#ifdef GEANT4_QT_DEBUG
69 printf("readyToPaint = false \n");
70#endif
71 readyToPaint = false;
72 CreateGLQtContext ();
73#ifdef GEANT4_QT_DEBUG
74 printf("G4OpenGLImmediateQtViewer::Initialise () 2\n");
75#endif
76
77 CreateMainWindow (this);
78#ifdef GEANT4_QT_DEBUG
79 printf("G4OpenGLImmediateQtViewer::Initialise () 3\n");
80#endif
81
82 CreateFontLists (); // FIXME Does nothing!
83
84#ifdef GEANT4_QT_DEBUG
85 printf("readyToPaint = true \n");
86#endif
87 readyToPaint = true;
88
89 // First Draw
90 SetView();
91#ifdef GEANT4_QT_DEBUG
92 printf(" ClearView\n");
93#endif
94 ClearView (); //ok, put the background correct
95 ShowView();
96 FinishView();
97}
98
99void G4OpenGLImmediateQtViewer::initializeGL () {
100
101 InitializeGLView ();
102
103#ifdef GEANT4_QT_DEBUG
104 printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n");
105#endif
106
107 // If a double buffer context has been forced upon us, ignore the
108 // back buffer for this OpenGLImmediate view.
109 glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
110 // clear the buffers and window.
111 ClearView ();
112#ifdef GEANT4_QT_DEBUG
113 // printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n");
114#endif
115 FinishView ();
116
117
118
119 glDepthFunc (GL_LEQUAL);
120 glDepthMask (GL_TRUE);
121
122#ifdef GEANT4_QT_DEBUG
123 printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n");
124#endif
125}
126
127
128void G4OpenGLImmediateQtViewer::DrawView () {
129
130#ifdef GEANT4_QT_DEBUG
131 printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
132#endif
133 // If a double buffer context has been forced upon us, ignore the
134 // back buffer for this OpenGLImmediate view.
135 glDrawBuffer (GL_FRONT);
136
137 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
138
139 //Make sure current viewer is attached and clean...
140 //Qt version needed
141 glViewport (0, 0, WinSize_x, WinSize_y);
142
143 if(style!=G4ViewParameters::hlr &&
144 haloing_enabled) {
145#ifdef GEANT4_QT_DEBUG
146 printf("G4OpenGLImmediateQtViewer::DrawView DANS LE IF\n");
147#endif
148
149 HaloingFirstPass ();
150 NeedKernelVisit ();
151 ProcessView ();
152 glFlush ();
153
154 HaloingSecondPass ();
155
156 }
157
158 NeedKernelVisit (); // Always need to visit G4 kernel.
159 ProcessView ();
160 FinishView ();
161#ifdef GEANT4_QT_DEBUG
162 printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
163#endif
164 readyToPaint = false;
165}
166
167
168//////////////////////////////////////////////////////////////////////////////
169void G4OpenGLImmediateQtViewer::FinishView (
170)
171//////////////////////////////////////////////////////////////////////////////
172//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
173{
174#ifdef GEANT4_QT_DEBUG
175 printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
176#endif
177
178 glFlush ();
179#ifdef GEANT4_QT_DEBUG
180 printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
181#endif
182
183}
184
185
186/**
187 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
188 */
189void G4OpenGLImmediateQtViewer::resizeGL(
190 int width
191,int height)
192{
193 int side = width;
194 if (width > height) {
195 side = height;
196 }
197 glViewport((width - side) / 2, (height - side) / 2, side, side);
198 glMatrixMode(GL_PROJECTION);
199 glLoadIdentity();
200 glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
201 glMatrixMode(GL_MODELVIEW);
202#ifdef GEANT4_QT_DEBUG
203 printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
204#endif
205}
206
207
208void G4OpenGLImmediateQtViewer::paintGL()
209 {
210 if (!readyToPaint) {
211 readyToPaint= true;
212 return;
213 }
214 // DO NOT RESIZE IF SIZE HAS NOT CHANGE
215 if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) {
216 return;
217 }
218 nbPaint++;
219#ifdef GEANT4_QT_DEBUG
220 printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
221#endif
222 WinSize_x = (G4int) width();
223 WinSize_y = (G4int) height();
224
225 glViewport (0, 0, width(), height());
226
227 SetView();
228#ifdef GEANT4_QT_DEBUG
229// // printf("before ClearView\n");
230#endif
231#ifdef GEANT4_QT_DEBUG
232 printf(" ClearView\n");
233#endif
234
235 ClearView (); //ok, put the background correct
236 DrawView();
237 readyToPaint = true; // could be set to false by DrawView
238
239
240#ifdef GEANT4_QT_DEBUG
241 printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint);
242#endif
243 }
244
245void G4OpenGLImmediateQtViewer::updateQWidget() {
246 updateGL();
247}
248
249#endif
Note: See TracBrowser for help on using the repository browser.