| [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 | //
|
|---|
| [1092] | 27 | // $Id: G4OpenGLStoredQtViewer.cc,v 1.26 2009/07/27 14:01:13 lgarnier Exp $
|
|---|
| [866] | 28 | // GEANT4 tag $Name: $
|
|---|
| [531] | 29 | //
|
|---|
| [564] | 30 | //
|
|---|
| [533] | 31 | // Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and
|
|---|
| [564] | 32 | // G4OpenGLStoredViewer.
|
|---|
| [531] | 33 |
|
|---|
| [533] | 34 | #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
|
|---|
| [1121] | 35 | #define QT_STORE_46_DBG 1
|
|---|
| 36 | #define QT_STORE_46_DBG_INIT 1
|
|---|
| 37 | #define QT_STORE_46_DBG_COMPUTE 1 seul ok
|
|---|
| 38 | //#define QT_STORE_46_DBG_RESIZE 1 resize et compute ok
|
|---|
| 39 | //#define QT_STORE_46_DBG_PAINT 1
|
|---|
| [531] | 40 |
|
|---|
| [1121] | 41 | #include "G4VViewer.hh"
|
|---|
| [533] | 42 | #include "G4OpenGLStoredQtViewer.hh"
|
|---|
| [1121] | 43 | #include "G4OpenGLStoredSceneHandler.hh"
|
|---|
| [531] | 44 |
|
|---|
| 45 | #include "G4ios.hh"
|
|---|
| 46 |
|
|---|
| [533] | 47 | G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
|
|---|
| [531] | 48 | (G4OpenGLStoredSceneHandler& sceneHandler,
|
|---|
| 49 | const G4String& name):
|
|---|
| [682] | 50 | G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
|
|---|
| 51 | G4OpenGLViewer (sceneHandler),
|
|---|
| 52 | G4OpenGLQtViewer (sceneHandler),
|
|---|
| [1121] | 53 | G4OpenGLStoredViewer (sceneHandler) // FIXME : gerer le pb du parent !
|
|---|
| [682] | 54 | {
|
|---|
| [863] | 55 |
|
|---|
| [709] | 56 | #if QT_VERSION < 0x040000
|
|---|
| 57 | setFocusPolicy(QWidget::StrongFocus); // enable keybord events
|
|---|
| 58 | #else
|
|---|
| [696] | 59 | setFocusPolicy(Qt::StrongFocus); // enable keybord events
|
|---|
| [709] | 60 | #endif
|
|---|
| [1040] | 61 | fHasToRepaint =false;
|
|---|
| [858] | 62 |
|
|---|
| [531] | 63 | if (fViewId < 0) return; // In case error in base class instantiation.
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| [564] | 66 | G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
|
|---|
| [682] | 67 | makeCurrent();
|
|---|
| 68 | // this is connect to the Dialog for deleting it properly
|
|---|
| 69 | // when close event.
|
|---|
| 70 | // ((QDialog*)window())->reject();
|
|---|
| [564] | 71 | }
|
|---|
| [531] | 72 |
|
|---|
| [564] | 73 | void G4OpenGLStoredQtViewer::Initialise() {
|
|---|
| [911] | 74 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [858] | 75 | printf("G4OpenGLStoredQtViewer::Initialise 1\n");
|
|---|
| [608] | 76 | #endif
|
|---|
| [1040] | 77 | fReadyToPaint = false;
|
|---|
| [866] | 78 | CreateMainWindow (this,QString(fName));
|
|---|
| [873] | 79 | CreateFontLists ();
|
|---|
| [564] | 80 |
|
|---|
| [1040] | 81 | fReadyToPaint = true;
|
|---|
| [564] | 82 | }
|
|---|
| [531] | 83 |
|
|---|
| [1121] | 84 | #ifdef QT_STORE_46_DBG_INIT
|
|---|
| [564] | 85 | void G4OpenGLStoredQtViewer::initializeGL () {
|
|---|
| [1121] | 86 | glShadeModel(GL_SMOOTH); // Enable Smooth Shading
|
|---|
| 87 | glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
|
|---|
| 88 | glClearDepth(1.0f); // Depth Buffer Setup
|
|---|
| 89 | glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
|---|
| 90 | glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
|---|
| 91 | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
|---|
| 92 |
|
|---|
| [564] | 93 |
|
|---|
| [1121] | 94 | return; // Initialization Went OK
|
|---|
| 95 |
|
|---|
| 96 | }
|
|---|
| 97 | #else
|
|---|
| 98 | void G4OpenGLStoredQtViewer::initializeGL () {
|
|---|
| 99 |
|
|---|
| [682] | 100 | InitializeGLView ();
|
|---|
| [564] | 101 |
|
|---|
| [911] | 102 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [682] | 103 | printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n");
|
|---|
| [608] | 104 | #endif
|
|---|
| [564] | 105 |
|
|---|
| [682] | 106 | // clear the buffers and window.
|
|---|
| 107 | ClearView ();
|
|---|
| 108 | FinishView ();
|
|---|
| [564] | 109 |
|
|---|
| [682] | 110 | glDepthFunc (GL_LEQUAL);
|
|---|
| 111 | glDepthMask (GL_TRUE);
|
|---|
| [1121] | 112 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 113 | printf("glDepthFunc (GL_LEQUAL) G4OpenGLStoredQtViewer\n ");
|
|---|
| 114 | printf("glDepthMask (GL_TRUE) G4OpenGLStoredQtViewer\n ");
|
|---|
| 115 | #endif
|
|---|
| [564] | 116 |
|
|---|
| [866] | 117 | if (fSceneHandler.GetScene() == 0) {
|
|---|
| [1040] | 118 | fHasToRepaint =false;
|
|---|
| [866] | 119 | } else {
|
|---|
| [1040] | 120 | fHasToRepaint =true;
|
|---|
| [866] | 121 | }
|
|---|
| [564] | 122 |
|
|---|
| [911] | 123 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [873] | 124 | printf("G4OpenGLStoredQtViewer::InitialiseGL END\n");
|
|---|
| [608] | 125 | #endif
|
|---|
| [531] | 126 | }
|
|---|
| 127 |
|
|---|
| [1121] | 128 | #endif
|
|---|
| [564] | 129 |
|
|---|
| [533] | 130 | void G4OpenGLStoredQtViewer::DrawView () {
|
|---|
| [911] | 131 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 132 | printf("G4OpenGLStoredQtViewer::DrawView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
|
|---|
| 133 | #endif
|
|---|
| 134 | // That's no the same logic as Immediate Viewer, I don't know why...
|
|---|
| 135 | // But if I send updateGL here, we go here :
|
|---|
| 136 | // updateQWidget -> paintGL -> ComputeView
|
|---|
| 137 | // whih is not the same as ComputeView Directly
|
|---|
| 138 | // And we loose the redraw of things !
|
|---|
| 139 |
|
|---|
| [1039] | 140 | ComputeView();
|
|---|
| [911] | 141 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 142 | printf("G4OpenGLStoredQtViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
|
|---|
| 143 | #endif
|
|---|
| 144 | }
|
|---|
| [682] | 145 |
|
|---|
| [1121] | 146 | #ifdef QT_STORE_46_DBG_COMPUTE
|
|---|
| [877] | 147 | void G4OpenGLStoredQtViewer::ComputeView () {
|
|---|
| [1121] | 148 | glBegin(GL_QUADS);
|
|---|
| 149 | //carré rouge
|
|---|
| 150 | glColor3ub(255,0,0);
|
|---|
| 151 | glVertex3d(9,9,0);
|
|---|
| 152 | glVertex3d(9,0,0);
|
|---|
| 153 | glVertex3d(0,0,0);
|
|---|
| 154 | glVertex3d(0,9,0);
|
|---|
| 155 | //carré vert
|
|---|
| 156 | glColor3ub(0,255,0);
|
|---|
| 157 | glVertex3d(9,9,0);
|
|---|
| 158 | glVertex3d(18,9,0);
|
|---|
| 159 | glVertex3d(18,0,0);
|
|---|
| 160 | glVertex3d(9,0,0);
|
|---|
| 161 | //carré vert
|
|---|
| 162 | glColor3ub(0,255,0);
|
|---|
| 163 | glVertex3d(0,18,0);
|
|---|
| 164 | glVertex3d(9,18,0);
|
|---|
| 165 | glVertex3d(9,9,0);
|
|---|
| 166 | glVertex3d(0,9,0);
|
|---|
| 167 | //carré bleu
|
|---|
| 168 | glColor3ub(0,0,255);
|
|---|
| 169 | glVertex3d(18,18,0);
|
|---|
| 170 | glVertex3d(18,9,0);
|
|---|
| 171 | glVertex3d(9,9,0);
|
|---|
| 172 | glVertex3d(9,18,0);
|
|---|
| 173 | //carré bleu
|
|---|
| 174 | glColor3ub(0,0,255);
|
|---|
| 175 | glVertex3d(9,0,0);
|
|---|
| 176 | glVertex3d(9,9,0);
|
|---|
| 177 | glVertex3d(9,9,9);
|
|---|
| 178 | glVertex3d(9,0,9);
|
|---|
| 179 | //carré blanc
|
|---|
| 180 | glColor3ub(255,255,255);
|
|---|
| 181 | glVertex3d(9,9,0);
|
|---|
| 182 | glVertex3d(0,9,0);
|
|---|
| 183 | glVertex3d(0,9,9);
|
|---|
| 184 | glVertex3d(9,9,9);
|
|---|
| 185 | //carré rouge
|
|---|
| 186 | glColor3ub(255,0,0);
|
|---|
| 187 | glVertex3d(9,9,9);
|
|---|
| 188 | glVertex3d(9,0,9);
|
|---|
| 189 | glVertex3d(0,0,9);
|
|---|
| 190 | glVertex3d(0,9,9);
|
|---|
| 191 | glEnd();
|
|---|
| 192 | }
|
|---|
| 193 | #else
|
|---|
| 194 | void G4OpenGLStoredQtViewer::ComputeView () {
|
|---|
| [877] | 195 |
|
|---|
| [911] | 196 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1039] | 197 | printf("G4OpenGLStoredQtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
|
|---|
| [608] | 198 | #endif
|
|---|
| [877] | 199 | makeCurrent();
|
|---|
| [682] | 200 | G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
|
|---|
| [531] | 201 |
|
|---|
| [682] | 202 | //Make sure current viewer is attached and clean...
|
|---|
| [531] | 203 |
|
|---|
| [682] | 204 | //See if things have changed from last time and remake if necessary...
|
|---|
| 205 | // The fNeedKernelVisit flag might have been set by the user in
|
|---|
| 206 | // /vis/viewer/rebuild, but if not, make decision and set flag only
|
|---|
| 207 | // if necessary...
|
|---|
| [873] | 208 | if (!fNeedKernelVisit) {
|
|---|
| [877] | 209 | KernelVisitDecision ();
|
|---|
| [873] | 210 | }
|
|---|
| [682] | 211 | G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
|
|---|
| 212 | ProcessView ();
|
|---|
| [564] | 213 |
|
|---|
| [531] | 214 |
|
|---|
| [682] | 215 | if(style!=G4ViewParameters::hlr &&
|
|---|
| 216 | haloing_enabled) {
|
|---|
| [911] | 217 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 218 | printf("G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
|
|---|
| [608] | 219 | #endif
|
|---|
| [531] | 220 |
|
|---|
| [682] | 221 | HaloingFirstPass ();
|
|---|
| 222 | DrawDisplayLists ();
|
|---|
| [1121] | 223 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 224 | printf("glFlush () G4OpenGLStoredQtViewer\n ");
|
|---|
| 225 | #endif
|
|---|
| [682] | 226 | glFlush ();
|
|---|
| [531] | 227 |
|
|---|
| [682] | 228 | HaloingSecondPass ();
|
|---|
| [531] | 229 |
|
|---|
| [682] | 230 | DrawDisplayLists ();
|
|---|
| 231 | FinishView ();
|
|---|
| [531] | 232 |
|
|---|
| [682] | 233 | } else {
|
|---|
| [564] | 234 |
|
|---|
| [682] | 235 | // If kernel visit was needed, drawing and FinishView will already
|
|---|
| 236 | // have been done, so...
|
|---|
| 237 | if (!kernelVisitWasNeeded) {
|
|---|
| [911] | 238 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 239 | printf("************************** G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
|
|---|
| [608] | 240 | #endif
|
|---|
| [682] | 241 | DrawDisplayLists ();
|
|---|
| 242 | FinishView ();
|
|---|
| 243 | } else {
|
|---|
| [911] | 244 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 245 | printf("************************** G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
|
|---|
| [608] | 246 | #endif
|
|---|
| [682] | 247 | // However, union cutaways are implemented in DrawDisplayLists, so make
|
|---|
| 248 | // an extra pass...
|
|---|
| 249 | if (fVP.IsCutaway() &&
|
|---|
| 250 | fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
|
|---|
| 251 | ClearView();
|
|---|
| 252 | DrawDisplayLists ();
|
|---|
| 253 | FinishView ();
|
|---|
| [911] | 254 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [682] | 255 | printf("*************************** CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
|
|---|
| [608] | 256 | #endif
|
|---|
| [682] | 257 | } else { // ADD TO AVOID KernelVisit=1 and nothing to display
|
|---|
| 258 | DrawDisplayLists ();
|
|---|
| 259 | FinishView ();
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| [564] | 263 |
|
|---|
| [745] | 264 | if (isRecording()) {
|
|---|
| [739] | 265 | savePPMToTemp();
|
|---|
| [724] | 266 | }
|
|---|
| 267 |
|
|---|
| [911] | 268 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1039] | 269 | printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
|
|---|
| [608] | 270 | #endif
|
|---|
| [1040] | 271 | fHasToRepaint =true;
|
|---|
| [531] | 272 | }
|
|---|
| [1121] | 273 | #endif
|
|---|
| [531] | 274 |
|
|---|
| [564] | 275 |
|
|---|
| 276 | /**
|
|---|
| [682] | 277 | - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
|
|---|
| 278 | */
|
|---|
| [1121] | 279 | #ifdef QT_STORE_46_DBG_RESIZE
|
|---|
| [564] | 280 | void G4OpenGLStoredQtViewer::resizeGL(
|
|---|
| [1039] | 281 | int aWidth
|
|---|
| 282 | ,int aHeight)
|
|---|
| [564] | 283 | {
|
|---|
| [1121] | 284 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 285 | printf("G4OpenGLStoredQtViewer::resizeGL\n");
|
|---|
| 286 | #endif
|
|---|
| [906] | 287 | // Set new size, it will be update when next Repaint()->SetView() called
|
|---|
| [1121] | 288 | if (2 == 1) {
|
|---|
| 289 | if (aHeight==0)
|
|---|
| 290 | {
|
|---|
| 291 | aHeight=1;
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | glViewport(0,0,aWidth,aHeight);
|
|---|
| 295 |
|
|---|
| 296 | glMatrixMode(GL_PROJECTION);
|
|---|
| 297 | glLoadIdentity();
|
|---|
| 298 |
|
|---|
| 299 | // Calculate The Aspect Ratio Of The Window
|
|---|
| 300 | gluPerspective(45.0f,(GLfloat)aWidth/(GLfloat)aHeight,0.1f,100.0f);
|
|---|
| 301 |
|
|---|
| 302 | glMatrixMode(GL_MODELVIEW);
|
|---|
| 303 | glLoadIdentity();
|
|---|
| 304 | } else {
|
|---|
| 305 | int side = qMin(aWidth, aHeight);
|
|---|
| 306 | glViewport((aWidth - side) / 2, (aHeight - side) / 2, side, side);
|
|---|
| 307 |
|
|---|
| 308 | glMatrixMode(GL_PROJECTION);
|
|---|
| 309 | glLoadIdentity();
|
|---|
| 310 | glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
|
|---|
| 311 | glMatrixMode(GL_MODELVIEW);
|
|---|
| 312 | }
|
|---|
| 313 | }
|
|---|
| 314 | #else
|
|---|
| 315 | void G4OpenGLStoredQtViewer::resizeGL(
|
|---|
| 316 | int aWidth
|
|---|
| 317 | ,int aHeight)
|
|---|
| 318 | {
|
|---|
| 319 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 320 | printf("G4OpenGLStoredQtViewer::resizeGL\n");
|
|---|
| 321 | #endif
|
|---|
| 322 | // Set new size, it will be update when next Repaint()->SetView() called
|
|---|
| 323 |
|
|---|
| [1039] | 324 | ResizeWindow(aWidth,aHeight);
|
|---|
| [1121] | 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | SetView(); // en test .......................
|
|---|
| 329 | // ResizeGLView(); // en test .......................
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| [1040] | 334 | fHasToRepaint = sizeHasChanged();
|
|---|
| [564] | 335 | }
|
|---|
| [1121] | 336 | #endif
|
|---|
| [564] | 337 |
|
|---|
| 338 |
|
|---|
| [1121] | 339 | #ifdef QT_STORE_46_DBG_PAINT
|
|---|
| [564] | 340 | void G4OpenGLStoredQtViewer::paintGL()
|
|---|
| [682] | 341 | {
|
|---|
| [911] | 342 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1121] | 343 | printf("G4OpenGLStoredQtViewer::paintGL\n");
|
|---|
| 344 | #endif
|
|---|
| 345 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|---|
| 346 | glMatrixMode(GL_MODELVIEW);
|
|---|
| 347 | glLoadIdentity();
|
|---|
| 348 | gluLookAt(15,15,15,0,0,0,0,0,1);
|
|---|
| 349 |
|
|---|
| 350 | glBegin(GL_QUADS);
|
|---|
| 351 | //carré rouge
|
|---|
| 352 | glColor3ub(255,0,0);
|
|---|
| 353 | glVertex3d(9,9,0);
|
|---|
| 354 | glVertex3d(9,0,0);
|
|---|
| 355 | glVertex3d(0,0,0);
|
|---|
| 356 | glVertex3d(0,9,0);
|
|---|
| 357 | //carré vert
|
|---|
| 358 | glColor3ub(0,255,0);
|
|---|
| 359 | glVertex3d(9,9,0);
|
|---|
| 360 | glVertex3d(18,9,0);
|
|---|
| 361 | glVertex3d(18,0,0);
|
|---|
| 362 | glVertex3d(9,0,0);
|
|---|
| 363 | //carré vert
|
|---|
| 364 | glColor3ub(0,255,0);
|
|---|
| 365 | glVertex3d(0,18,0);
|
|---|
| 366 | glVertex3d(9,18,0);
|
|---|
| 367 | glVertex3d(9,9,0);
|
|---|
| 368 | glVertex3d(0,9,0);
|
|---|
| 369 | //carré bleu
|
|---|
| 370 | glColor3ub(0,0,255);
|
|---|
| 371 | glVertex3d(18,18,0);
|
|---|
| 372 | glVertex3d(18,9,0);
|
|---|
| 373 | glVertex3d(9,9,0);
|
|---|
| 374 | glVertex3d(9,18,0);
|
|---|
| 375 | //carré bleu
|
|---|
| 376 | glColor3ub(0,0,255);
|
|---|
| 377 | glVertex3d(9,0,0);
|
|---|
| 378 | glVertex3d(9,9,0);
|
|---|
| 379 | glVertex3d(9,9,9);
|
|---|
| 380 | glVertex3d(9,0,9);
|
|---|
| 381 | //carré blanc
|
|---|
| 382 | glColor3ub(255,255,255);
|
|---|
| 383 | glVertex3d(9,9,0);
|
|---|
| 384 | glVertex3d(0,9,0);
|
|---|
| 385 | glVertex3d(0,9,9);
|
|---|
| 386 | glVertex3d(9,9,9);
|
|---|
| 387 | //carré rouge
|
|---|
| 388 | glColor3ub(255,0,0);
|
|---|
| 389 | glVertex3d(9,9,9);
|
|---|
| 390 | glVertex3d(9,0,9);
|
|---|
| 391 | glVertex3d(0,0,9);
|
|---|
| 392 | glVertex3d(0,9,9);
|
|---|
| 393 | glEnd();
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | #else
|
|---|
| 397 | void G4OpenGLStoredQtViewer::paintGL()
|
|---|
| 398 | {
|
|---|
| 399 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1040] | 400 | printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
|
|---|
| [873] | 401 | #endif
|
|---|
| [1040] | 402 | if (!fReadyToPaint) {
|
|---|
| 403 | fReadyToPaint= true;
|
|---|
| [682] | 404 | return;
|
|---|
| 405 | }
|
|---|
| [1039] | 406 | // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
|
|---|
| 407 | // WHEN CLICK ON THE FRAME FOR EXAMPLE
|
|---|
| 408 | // EXECEPT WHEN MOUSE MOVE EVENT
|
|---|
| [1040] | 409 | if ( !fHasToRepaint) {
|
|---|
| [1039] | 410 | if (((getWinWidth() == (unsigned int)width())) &&(getWinHeight() == (unsigned int) height())) {
|
|---|
| 411 | return;
|
|---|
| 412 | }
|
|---|
| 413 | }
|
|---|
| 414 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1040] | 415 | printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
|
|---|
| [1039] | 416 | #endif
|
|---|
| [873] | 417 |
|
|---|
| [1039] | 418 | SetView();
|
|---|
| 419 |
|
|---|
| 420 | ClearView (); //ok, put the background correct
|
|---|
| 421 | ComputeView();
|
|---|
| 422 |
|
|---|
| [1040] | 423 | fHasToRepaint =false;
|
|---|
| [1039] | 424 |
|
|---|
| [911] | 425 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1040] | 426 | printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
|
|---|
| [608] | 427 | #endif
|
|---|
| [682] | 428 | }
|
|---|
| [564] | 429 |
|
|---|
| [1121] | 430 | #endif
|
|---|
| 431 |
|
|---|
| [564] | 432 | void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
|
|---|
| 433 | {
|
|---|
| [873] | 434 | G4MousePressEvent(event);
|
|---|
| [564] | 435 | }
|
|---|
| 436 |
|
|---|
| [696] | 437 | void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
|
|---|
| 438 | {
|
|---|
| 439 | G4keyPressEvent(event);
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| [804] | 442 | void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
|
|---|
| 443 | {
|
|---|
| 444 | G4wheelEvent(event);
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| [678] | 447 | /**
|
|---|
| 448 | * This function was build in order to make a zoom on double clic event.
|
|---|
| 449 | * It was think to build a rubberband on the zoom area, but never work fine
|
|---|
| 450 | */
|
|---|
| [955] | 451 | void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
|
|---|
| [673] | 452 | {
|
|---|
| [873] | 453 | G4MouseDoubleClickEvent();
|
|---|
| [673] | 454 | }
|
|---|
| 455 |
|
|---|
| [955] | 456 | void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *)
|
|---|
| [673] | 457 | {
|
|---|
| [797] | 458 | G4MouseReleaseEvent();
|
|---|
| [673] | 459 | }
|
|---|
| 460 |
|
|---|
| [564] | 461 | void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
|
|---|
| 462 | {
|
|---|
| [873] | 463 | G4MouseMoveEvent(event);
|
|---|
| [564] | 464 | }
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 | void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
|
|---|
| 468 | {
|
|---|
| [873] | 469 | G4manageContextMenuEvent(e);
|
|---|
| [564] | 470 | }
|
|---|
| 471 |
|
|---|
| 472 | void G4OpenGLStoredQtViewer::updateQWidget() {
|
|---|
| [1040] | 473 | fHasToRepaint= true;
|
|---|
| [564] | 474 | updateGL();
|
|---|
| [1040] | 475 | fHasToRepaint= false;
|
|---|
| [564] | 476 | }
|
|---|
| 477 |
|
|---|
| [877] | 478 | void G4OpenGLStoredQtViewer::ShowView (
|
|---|
| 479 | )
|
|---|
| 480 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 481 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 482 | {
|
|---|
| 483 | #if QT_VERSION < 0x040000
|
|---|
| 484 | setActiveWindow();
|
|---|
| 485 | #else
|
|---|
| 486 | activateWindow();
|
|---|
| 487 | #endif
|
|---|
| 488 | }
|
|---|
| [673] | 489 |
|
|---|
| [531] | 490 | #endif
|
|---|