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

Last change on this file since 555 was 555, checked in by garnier, 17 years ago

r710@mac-90108: laurentgarnier | 2007-07-12 16:45:14 +0200
il ny a plus de ClearView et les glDrawBuffer dont a GL_BACK...

  • Property svn:mime-type set to text/cpp
File size: 7.4 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.16 2007/06/25 16:38:13 $
28// GEANT4 tag $Name: geant4-08-02-patch-01 $
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
38#include "G4ios.hh"
39
40G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer
41(G4OpenGLImmediateSceneHandler& sceneHandler,
42 const G4String&  name):
43 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
44 G4OpenGLViewer (sceneHandler),
45 G4OpenGLQtViewer (sceneHandler),
46 G4OpenGLImmediateViewer (sceneHandler),
47 QGLWidget()                      // FIXME : gerer le pb du parent !
48 {
49
50  if (fViewId < 0) return;  // In case error in base class instantiation.
51}
52
53G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQtViewer() {
54   printf("GLWidget::~GLWidget \n");
55     makeCurrent();
56   printf("GLWidget::~GLWidget END\n");
57}
58
59void G4OpenGLImmediateQtViewer::Initialise() {
60   printf("GLWidget::Initialise \n");
61   printf("readyToPaint = false \n");
62   readyToPaint = false;
63   //  printf("G4OpenGLImmediateQtViewer::Initialise () 1\n");
64  //  CreateGLQtContext ();
65  printf("G4OpenGLImmediateQtViewer::Initialise () 2\n");
66
67  CreateMainWindow (this);
68  printf("G4OpenGLImmediateQtViewer::Initialise () 3\n");
69
70  //  CreateFontLists ();  // FIXME Does nothing!
71
72  printf("readyToPaint = true \n");
73  readyToPaint = true;
74}
75
76void G4OpenGLImmediateQtViewer::initializeGL () {
77
78   InitializeGLView ();
79
80   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n");
81
82   glDrawBuffer (GL_BACK); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
83   // clear the buffers and window.
84   ClearView ();
85   //   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n");
86   FinishView ();
87
88   // If a double buffer context has been forced upon us, ignore the
89   // back buffer for this OpenGLImmediate view.
90
91
92   glDepthFunc (GL_LEQUAL);
93   glDepthMask (GL_TRUE);
94
95   printf("G4OpenGLImmediateQtViewer::InitialiseGL  -------------------------------------------------------------------------------------\n");
96}
97
98
99void G4OpenGLImmediateQtViewer::DrawView () {
100
101  printf("G4OpenGLImmediateQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
102    glDraw();
103  printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
104
105}
106
107void G4OpenGLImmediateQtViewer::DrawView2 () {
108
109  printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
110   // If a double buffer context has been forced upon us, ignore the
111   // back buffer for this OpenGLImmediate view.
112  glDrawBuffer (GL_BACK);
113
114   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
115
116   //Make sure current viewer is attached and clean...
117   //Qt version needed
118   //glXMakeCurrent (dpy, win, cx);
119   glViewport (0, 0, WinSize_x, WinSize_y);
120
121   if(style!=G4ViewParameters::hlr &&
122      haloing_enabled) {
123
124     HaloingFirstPass ();
125     NeedKernelVisit ();
126     ProcessView ();
127     glFlush ();
128
129     HaloingSecondPass ();
130
131   }
132
133   NeedKernelVisit ();  // Always need to visit G4 kernel.
134   ProcessView ();
135   FinishView ();
136  printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
137
138}
139
140
141//////////////////////////////////////////////////////////////////////////////
142void G4OpenGLImmediateQtViewer::FinishView (
143)
144//////////////////////////////////////////////////////////////////////////////
145//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
146{
147  printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
148//   //    if(!fHDC) return;
149
150   glFlush ();
151  printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
152
153  // Empty the Windows message queue :
154//   MSG event;
155//   while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
156//     ::TranslateMessage(&event);
157//     ::DispatchMessage (&event);
158//   }
159}
160
161
162void G4OpenGLImmediateQtViewer::resizeGL(
163 int width
164,int height)
165{
166  printf("G4OpenGLImmediateQtViewer::resizeGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");
167 
168  int side = qMin(width, height);
169  glViewport((width - side) / 2, (height - side) / 2, side, side);
170  glMatrixMode(GL_PROJECTION);
171  glLoadIdentity();
172  glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
173  glMatrixMode(GL_MODELVIEW);
174 
175  printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
176}
177
178void G4OpenGLImmediateQtViewer::paintGL()
179 {
180   if (!readyToPaint)
181     return;
182//    printf("GLWidget::paintGL\n");
183//      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
184//      glLoadIdentity();
185//      glTranslated(0.0, 0.0, -10.0);
186//      glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
187//      glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
188//      glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
189//      glCallList(object);
190//    printf("GLWidget::paintGL END\n");
191   printf("G4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");
192//   float b=3;
193
194   WinSize_x = (G4int) width();
195   WinSize_y = (G4int) height();
196
197   //   glViewport (0, 0, width(), height());
198
199   //   SetView();
200//   //  printf("before ClearView\n");
201//   //  makeCurrent();
202//   //  for (int a=0;a<100000000;a++) {b = b/3.1456;}
203   printf("    ClearView\n");
204   //   ClearView (); //ok, put the background correct
205   DrawView2();
206   //  ShowView();
207   //  printf("before ClearView\n");
208   //  ClearView (); //ok, put the background correct
209//   // FIXME
210//  FinishView();
211//   //  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
212//   //  glLoadIdentity();
213//   //  glTranslated(0.0, 0.0, -10.0);
214
215   printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
216 }
217
218
219#endif
Note: See TracBrowser for help on using the repository browser.