source: trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc@ 566

Last change on this file since 566 was 565, checked in by garnier, 18 years ago

r570@mac-90108: laurentgarnier | 2007-08-14 17:00:14 +0200
debut de l'EPS

  • Property svn:mime-type set to text/cpp
File size: 8.6 KB
RevLine 
[531]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//
[564]27// $Id: G4OpenGLStoredQtViewer.cc,v 1.16 2007/06/25 16:38:13 $
[531]28// GEANT4 tag $Name: geant4-08-02-patch-01 $
29//
[564]30//
[533]31// Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and
[564]32// G4OpenGLStoredViewer.
[531]33
[533]34#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
[531]35
[533]36#include "G4OpenGLStoredQtViewer.hh"
[564]37#include "G4VisManager.hh"
[531]38
39#include "G4ios.hh"
40
[533]41G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
[531]42(G4OpenGLStoredSceneHandler& sceneHandler,
43 const G4String& name):
[564]44 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLQtViewer (sceneHandler),
47 G4OpenGLStoredViewer (sceneHandler),
48 QGLWidget() // FIXME : gerer le pb du parent !
49 {
50 nbPaint =0;
51 hasToRepaint =false;
[531]52 if (fViewId < 0) return; // In case error in base class instantiation.
53}
54
[564]55G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
56 printf("GLWidget::~GLWidget \n");
57 makeCurrent();
58 printf("GLWidget::~GLWidget END\n");
59}
[531]60
[564]61void G4OpenGLStoredQtViewer::Initialise() {
62 printf("GLWidget::Initialise \n");
63 readyToPaint = false;
64 CreateGLQtContext ();
65 printf("G4OpenGLStoredQtViewer::Initialise () 2\n");
[531]66
[564]67 CreateMainWindow (this);
68 printf("G4OpenGLStoredQtViewer::Initialise () 3\n");
[531]69
[564]70 CreateFontLists (); // FIXME Does nothing!
71
72 printf("readyToPaint = true \n");
73 readyToPaint = true;
74
75 // First Draw
76 SetView();
77 printf(" ClearView\n");
78 ClearView (); //ok, put the background correct
79 ShowView();
80 FinishView();
81}
[531]82
[564]83void G4OpenGLStoredQtViewer::initializeGL () {
84
85 InitializeGLView ();
86
87 printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n");
88
89 // clear the buffers and window.
90 ClearView ();
91 // printf("G4OpenGLStoredQtViewer::InitialiseGL () 2\n");
92 FinishView ();
93
94 glDepthFunc (GL_LEQUAL);
95 glDepthMask (GL_TRUE);
96
97 hasToRepaint =true;
98
99 printf("G4OpenGLStoredQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n");
[531]100}
101
[564]102
[533]103void G4OpenGLStoredQtViewer::DrawView () {
[531]104
[564]105 printf("G4OpenGLStoredQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
[531]106
[564]107 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
[531]108
[564]109 //Make sure current viewer is attached and clean...
110 //Qt version needed
111 glViewport (0, 0, WinSize_x, WinSize_y);
[531]112
[564]113 //See if things have changed from last time and remake if necessary...
114 // The fNeedKernelVisit flag might have been set by the user in
115 // /vis/viewer/rebuild, but if not, make decision and set flag only
116 // if necessary...
[565]117 if (!fNeedKernelVisit)
118 printf("*************************** CASE 0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
119
[564]120 if (!fNeedKernelVisit) KernelVisitDecision ();
[565]121 printf("*************************** kernelVisit:%d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",fNeedKernelVisit);
122
[564]123 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
124 ProcessView ();
125
[531]126
[564]127 if(style!=G4ViewParameters::hlr &&
128 haloing_enabled) {
129 printf("G4OpenGLStoredQtViewer::DrawView DANS LE IF\n");
[531]130
[564]131 HaloingFirstPass ();
132 DrawDisplayLists ();
133 glFlush ();
[531]134
[564]135 HaloingSecondPass ();
[531]136
[564]137 DrawDisplayLists ();
[565]138 FinishView ();
[531]139
[564]140 } else {
[565]141 printf("*************************** CASE 1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[564]142
143 // If kernel visit was needed, drawing and FinishView will already
144 // have been done, so...
145 if (!kernelVisitWasNeeded) {
[565]146 printf("*************************** CASE 2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[564]147 DrawDisplayLists ();
[565]148 FinishView ();
[564]149 } else {
[565]150 printf("*************************** CASE 3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[564]151 // However, union cutaways are implemented in DrawDisplayLists, so make
152 // an extra pass...
153 if (fVP.IsCutaway() &&
154 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
155 ClearView();
156 DrawDisplayLists ();
[565]157 FinishView ();
158 printf("*************************** CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
159 } else { // ADD TO AVOID KernelVisit=1 and nothing to display
160 DrawDisplayLists ();
161 FinishView ();
[564]162 }
163 }
164 }
165
[565]166 printf("G4OpenGLStoredQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
[564]167 hasToRepaint =true;
[531]168}
169
[564]170
[531]171//////////////////////////////////////////////////////////////////////////////
[533]172void G4OpenGLStoredQtViewer::FinishView (
[531]173)
174//////////////////////////////////////////////////////////////////////////////
175//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
176{
[564]177 printf("G4OpenGLStoredQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
[531]178
179 glFlush ();
[564]180 swapBuffers ();
181 printf("G4OpenGLStoredQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
182
[531]183}
184
[564]185
186/**
187 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
188 */
189void G4OpenGLStoredQtViewer::resizeGL(
190 int aWidth
191,int aHeight)
192{
193 glViewport(0, 0, aWidth, aHeight);
194 glMatrixMode(GL_PROJECTION);
195 glMatrixMode(GL_MODELVIEW);
196
197 if (((WinSize_x != (G4int)aWidth)) || (WinSize_y != (G4int) aHeight)) {
198 hasToRepaint =true;
199 }
200 WinSize_x = (G4int) aWidth;
201 WinSize_y = (G4int) aHeight;
202
203 printf("G4OpenGLStoredQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d %d=%d %d=%d\n",hasToRepaint,width(),aWidth,height(),aHeight);
204}
205
206
207
208void G4OpenGLStoredQtViewer::paintGL()
209 {
210 if (!readyToPaint) {
211 printf("\n\nG4OpenGLStoredQtViewer::paintGL ============ Not ready %d\n",readyToPaint);
212 readyToPaint= true;
213 return;
214 }
215 // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
216 // WHEN CLICK ON THE FRAME FOR EXAMPLE
217 // EXECEPT WHEN MOUSE MOVE EVENT
218 if ( !hasToRepaint) {
219 if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) {
220 printf("\n\nG4OpenGLStoredQtViewer::paintGL ============ Dont repaint\n");
221 return;
222 }
223 }
224 nbPaint++;
225 printf("\n\nG4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
226 WinSize_x = (G4int) width();
227 WinSize_y = (G4int) height();
228
229 glViewport (0, 0, width(), height());
230 // glLoadIdentity();
231
232
233 SetView();
234
235// // printf("before ClearView\n");
236 printf(" ClearView\n");
237
238 ClearView (); //ok, put the background correct
239 DrawView();
240
241 hasToRepaint =false;
242
243 printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint);
244 }
245
246void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
247{
248 printf("G4OpenGLStoredQtViewer::mousePressEvent\n");
249 G4MousePressEvent(event->pos());
250}
251
252void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
253{
254 G4MouseMoveEvent(event->x(),event->y(),event->buttons());
255 // DrawView();
256}
257
258
259void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
260{
261 manageContextMenuEvent(e);
262}
263
264void G4OpenGLStoredQtViewer::updateQWidget() {
265 hasToRepaint= true;
266 updateGL();
267 hasToRepaint= false;
268}
269
[531]270#endif
Note: See TracBrowser for help on using the repository browser.