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