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