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

Last change on this file since 545 was 543, checked in by garnier, 18 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
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//
[533]27// $Id: G4OpenGLImmediateQtViewer.cc,v 1.16 2007/06/25 16:38:13 $
[531]28// GEANT4 tag $Name: geant4-08-02-patch-01 $
29//
[539]30//
[533]31// Class G4OpenGLImmediateQtViewer : a class derived from G4OpenGLQtViewer and
[531]32// G4OpenGLImmediateViewer.
33
[533]34#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
[531]35
[533]36#include "G4OpenGLImmediateQtViewer.hh"
[531]37
38#include "G4ios.hh"
39
[533]40G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer
[531]41(G4OpenGLImmediateSceneHandler& sceneHandler,
42 const G4String& name):
43G4OpenGLViewer (sceneHandler),
[533]44G4OpenGLQtViewer (sceneHandler),
[531]45G4OpenGLImmediateViewer (sceneHandler),
46G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) {
47
48 if (fViewId < 0) return; // In case error in base class instantiation.
49}
50
[543]51void G4OpenGLImmediateQtViewer::Initialise() {
[531]52
[541]53 readyToPaint = false;
54
[531]55// ensure a suitable window was found
56
[539]57 printf("G4OpenGLImmediateQtViewer::Initialise () 1\n");
[533]58 CreateGLQtContext ();
[543]59 printf("G4OpenGLImmediateQtViewer::Initialise () 2\n");
[541]60
[539]61 CreateMainWindow (this);
[543]62 printf("G4OpenGLImmediateQtViewer::Initialise () 3\n");
[531]63 CreateFontLists ();
[543]64 printf("G4OpenGLImmediateQtViewer::Initialise () 4\n");
65 readyToPaint = true;
[531]66
[543]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
[531]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);
[543]83 printf("G4OpenGLImmediateQtViewer::Initialise () 8\n");
[541]84
[531]85}
86
[543]87void G4OpenGLImmediateQtViewer::InitialiseGL () {
88 printf("G4OpenGLImmediateQtViewer::Initialise ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
89 printf("G4OpenGLImmediateQtViewer::Initialise -------------------------------------------------------------------------------------\n");
90}
91
92
[533]93void G4OpenGLImmediateQtViewer::DrawView () {
[531]94
[542]95 printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
[531]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...
[533]103 //Qt version needed
[531]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 ();
[542]122 printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
[531]123
124}
125
[539]126
[531]127//////////////////////////////////////////////////////////////////////////////
[533]128void G4OpenGLImmediateQtViewer::FinishView (
[531]129)
130//////////////////////////////////////////////////////////////////////////////
131//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
132{
[542]133 printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
[536]134 // if(!fHDC) return;
[531]135
136 glFlush ();
[542]137 printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[531]138
139 // Empty the Windows message queue :
[536]140// MSG event;
141// while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
142// ::TranslateMessage(&event);
143// ::DispatchMessage (&event);
144// }
[531]145}
146
[539]147
148void G4OpenGLImmediateQtViewer::resizeGL(
149 int width
150,int height)
151{
[542]152 printf("G4OpenGLImmediateQtViewer::resizeGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");
[543]153 /*
[539]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);
[543]160 */
[542]161 printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[539]162}
163
164void G4OpenGLImmediateQtViewer::paintGL()
165 {
[542]166 printf("G4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n");
[543]167 float b=3;
[541]168 if (!readyToPaint)
169 return;
170
[543]171 // WinSize_x = (G4int) width();
172 // WinSize_y = (G4int) height();
[541]173
[543]174 // glViewport (0, 0, width(), height());
[541]175
[543]176 // SetView();
177 printf("before ClearView\n");
178 // makeCurrent();
[542]179 for (int a=0;a<100000000;a++) {b = b/3.1456;}
[543]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
[542]186 printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
[539]187 // FIXME
[540]188 // FinishView();
[539]189 // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
190 // glLoadIdentity();
191 // glTranslated(0.0, 0.0, -10.0);
[543]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();
[539]208 }
[531]209#endif
Note: See TracBrowser for help on using the repository browser.