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

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

r709@mac-90108: laurentgarnier | 2007-07-11 17:47:06 +0200
pas mal, sauf que le gun ne fait aucun effet. Suppression de glwisget en test

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