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

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

r689@mac-90108: laurentgarnier | 2007-07-09 18:33:54 +0200
visu OpenGL en cours de debug NE MARCHE PAS

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