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

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

r712@mac-90108: laurentgarnier | 2007-07-12 17:36:33 +0200
Init NOK Run OK, mais le clear l211 est en commentaire

  • Property svn:mime-type set to text/cpp
File size: 7.6 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   nbPaint =0;
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  // First Draw
76    SetView();
77    //   //  printf("before ClearView\n");
78    //   //  makeCurrent();
79    //   //  for (int a=0;a<100000000;a++) {b = b/3.1456;}
80    printf("    ClearView\n");
81    ClearView (); //ok, put the background correct
82    //    DrawView2();
83    ShowView();
84   //  printf("before ClearView\n");
85   //  ClearView (); //ok, put the background correct
86//   // FIXME
87    FinishView();
88}
89
90void G4OpenGLImmediateQtViewer::initializeGL () {
91
92   InitializeGLView ();
93
94   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n");
95
96   //   glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
97   // clear the buffers and window.
98   ClearView ();
99   //   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n");
100   FinishView ();
101
102   // If a double buffer context has been forced upon us, ignore the
103   // back buffer for this OpenGLImmediate view.
104
105
106   glDepthFunc (GL_LEQUAL);
107   glDepthMask (GL_TRUE);
108
109   printf("G4OpenGLImmediateQtViewer::InitialiseGL  -------------------------------------------------------------------------------------\n");
110}
111
112
113void G4OpenGLImmediateQtViewer::DrawView () {
114
115  printf("G4OpenGLImmediateQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
116  //    glDraw();
117  DrawView2();
118  printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
119
120}
121
122void G4OpenGLImmediateQtViewer::DrawView2 () {
123
124  printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
125   // If a double buffer context has been forced upon us, ignore the
126   // back buffer for this OpenGLImmediate view.
127  //  glDrawBuffer (GL_FRONT);
128
129   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
130
131   //Make sure current viewer is attached and clean...
132   //Qt version needed
133   //glXMakeCurrent (dpy, win, cx);
134   glViewport (0, 0, WinSize_x, WinSize_y);
135
136   if(style!=G4ViewParameters::hlr &&
137      haloing_enabled) {
138     printf("G4OpenGLImmediateQtViewer::DrawView2 DANS LE IF\n");
139
140     HaloingFirstPass ();
141     NeedKernelVisit ();
142     ProcessView ();
143     glFlush ();
144
145     HaloingSecondPass ();
146
147   }
148
149   NeedKernelVisit ();  // Always need to visit G4 kernel.
150   ProcessView ();
151   FinishView ();
152  printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
153
154}
155
156
157//////////////////////////////////////////////////////////////////////////////
158void G4OpenGLImmediateQtViewer::FinishView (
159)
160//////////////////////////////////////////////////////////////////////////////
161//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
162{
163  printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
164//   //    if(!fHDC) return;
165
166   glFlush ();
167  printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
168
169  // Empty the Windows message queue :
170//   MSG event;
171//   while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
172//     ::TranslateMessage(&event);
173//     ::DispatchMessage (&event);
174//   }
175}
176
177
178void G4OpenGLImmediateQtViewer::resizeGL(
179 int width
180,int height)
181{
182  printf("G4OpenGLImmediateQtViewer::resizeGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");
183 
184  int side = qMin(width, height);
185  glViewport((width - side) / 2, (height - side) / 2, side, side);
186  glMatrixMode(GL_PROJECTION);
187  glLoadIdentity();
188  glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
189  glMatrixMode(GL_MODELVIEW);
190 
191  printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
192}
193
194void G4OpenGLImmediateQtViewer::paintGL()
195 {
196   if (!readyToPaint)
197     return;
198   nbPaint++;
199   printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d\n",nbPaint);
200
201   WinSize_x = (G4int) width();
202   WinSize_y = (G4int) height();
203
204   glViewport (0, 0, width(), height());
205
206   SetView();
207//   //  printf("before ClearView\n");
208//   //  makeCurrent();
209//   //  for (int a=0;a<100000000;a++) {b = b/3.1456;}
210   printf("    ClearView\n");
211   //   ClearView (); //ok, put the background correct
212   DrawView2();
213   // INIT ok  RUN nok      ShowView();
214   //  printf("before ClearView\n");
215   //  ClearView (); //ok, put the background correct
216//   // FIXME
217// INIT ok  RUN nok      FinishView();
218//   //  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
219//   //  glLoadIdentity();
220//   //  glTranslated(0.0, 0.0, -10.0);
221
222   printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n");
223 }
224
225
226#endif
Note: See TracBrowser for help on using the repository browser.