| [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 |
|
|---|
| [1122] | 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
|
|---|
| [1121] | 143 |
|
|---|
| 144 | }
|
|---|
| 145 | #else
|
|---|
| 146 | void G4OpenGLStoredQtViewer::initializeGL () {
|
|---|
| 147 |
|
|---|
| [682] | 148 | InitializeGLView ();
|
|---|
| [564] | 149 |
|
|---|
| [911] | 150 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [682] | 151 | printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n");
|
|---|
| [608] | 152 | #endif
|
|---|
| [564] | 153 |
|
|---|
| [682] | 154 | // clear the buffers and window.
|
|---|
| 155 | ClearView ();
|
|---|
| 156 | FinishView ();
|
|---|
| [564] | 157 |
|
|---|
| [682] | 158 | glDepthFunc (GL_LEQUAL);
|
|---|
| 159 | glDepthMask (GL_TRUE);
|
|---|
| [1121] | 160 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 161 | printf("glDepthFunc (GL_LEQUAL) G4OpenGLStoredQtViewer\n ");
|
|---|
| 162 | printf("glDepthMask (GL_TRUE) G4OpenGLStoredQtViewer\n ");
|
|---|
| 163 | #endif
|
|---|
| [564] | 164 |
|
|---|
| [866] | 165 | if (fSceneHandler.GetScene() == 0) {
|
|---|
| [1040] | 166 | fHasToRepaint =false;
|
|---|
| [866] | 167 | } else {
|
|---|
| [1040] | 168 | fHasToRepaint =true;
|
|---|
| [866] | 169 | }
|
|---|
| [564] | 170 |
|
|---|
| [911] | 171 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [873] | 172 | printf("G4OpenGLStoredQtViewer::InitialiseGL END\n");
|
|---|
| [608] | 173 | #endif
|
|---|
| [531] | 174 | }
|
|---|
| 175 |
|
|---|
| [1121] | 176 | #endif
|
|---|
| [564] | 177 |
|
|---|
| [533] | 178 | void G4OpenGLStoredQtViewer::DrawView () {
|
|---|
| [911] | 179 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 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 |
|
|---|
| [1039] | 188 | ComputeView();
|
|---|
| [911] | 189 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 190 | printf("G4OpenGLStoredQtViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
|
|---|
| 191 | #endif
|
|---|
| 192 | }
|
|---|
| [682] | 193 |
|
|---|
| [1121] | 194 | #ifdef QT_STORE_46_DBG_COMPUTE
|
|---|
| [877] | 195 | void G4OpenGLStoredQtViewer::ComputeView () {
|
|---|
| [1122] | 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
|
|---|
| [1121] | 204 | }
|
|---|
| 205 | #else
|
|---|
| 206 | void G4OpenGLStoredQtViewer::ComputeView () {
|
|---|
| [877] | 207 |
|
|---|
| [911] | 208 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1039] | 209 | printf("G4OpenGLStoredQtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
|
|---|
| [608] | 210 | #endif
|
|---|
| [877] | 211 | makeCurrent();
|
|---|
| [682] | 212 | G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
|
|---|
| [531] | 213 |
|
|---|
| [682] | 214 | //Make sure current viewer is attached and clean...
|
|---|
| [531] | 215 |
|
|---|
| [682] | 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...
|
|---|
| [873] | 220 | if (!fNeedKernelVisit) {
|
|---|
| [877] | 221 | KernelVisitDecision ();
|
|---|
| [873] | 222 | }
|
|---|
| [682] | 223 | G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
|
|---|
| 224 | ProcessView ();
|
|---|
| [564] | 225 |
|
|---|
| [531] | 226 |
|
|---|
| [682] | 227 | if(style!=G4ViewParameters::hlr &&
|
|---|
| 228 | haloing_enabled) {
|
|---|
| [911] | 229 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 230 | printf("G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
|
|---|
| [608] | 231 | #endif
|
|---|
| [531] | 232 |
|
|---|
| [682] | 233 | HaloingFirstPass ();
|
|---|
| 234 | DrawDisplayLists ();
|
|---|
| [1121] | 235 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 236 | printf("glFlush () G4OpenGLStoredQtViewer\n ");
|
|---|
| 237 | #endif
|
|---|
| [682] | 238 | glFlush ();
|
|---|
| [531] | 239 |
|
|---|
| [682] | 240 | HaloingSecondPass ();
|
|---|
| [531] | 241 |
|
|---|
| [682] | 242 | DrawDisplayLists ();
|
|---|
| 243 | FinishView ();
|
|---|
| [531] | 244 |
|
|---|
| [682] | 245 | } else {
|
|---|
| [564] | 246 |
|
|---|
| [682] | 247 | // If kernel visit was needed, drawing and FinishView will already
|
|---|
| 248 | // have been done, so...
|
|---|
| 249 | if (!kernelVisitWasNeeded) {
|
|---|
| [911] | 250 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 251 | printf("************************** G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
|
|---|
| [608] | 252 | #endif
|
|---|
| [682] | 253 | DrawDisplayLists ();
|
|---|
| 254 | FinishView ();
|
|---|
| 255 | } else {
|
|---|
| [911] | 256 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [877] | 257 | printf("************************** G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
|
|---|
| [608] | 258 | #endif
|
|---|
| [682] | 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 ();
|
|---|
| [911] | 266 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [682] | 267 | printf("*************************** CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
|
|---|
| [608] | 268 | #endif
|
|---|
| [682] | 269 | } else { // ADD TO AVOID KernelVisit=1 and nothing to display
|
|---|
| 270 | DrawDisplayLists ();
|
|---|
| 271 | FinishView ();
|
|---|
| 272 | }
|
|---|
| 273 | }
|
|---|
| 274 | }
|
|---|
| [564] | 275 |
|
|---|
| [745] | 276 | if (isRecording()) {
|
|---|
| [739] | 277 | savePPMToTemp();
|
|---|
| [724] | 278 | }
|
|---|
| 279 |
|
|---|
| [911] | 280 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1039] | 281 | printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
|
|---|
| [608] | 282 | #endif
|
|---|
| [1040] | 283 | fHasToRepaint =true;
|
|---|
| [531] | 284 | }
|
|---|
| [1121] | 285 | #endif
|
|---|
| [531] | 286 |
|
|---|
| [564] | 287 |
|
|---|
| 288 | /**
|
|---|
| [682] | 289 | - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
|
|---|
| 290 | */
|
|---|
| [1121] | 291 | #ifdef QT_STORE_46_DBG_RESIZE
|
|---|
| [564] | 292 | void G4OpenGLStoredQtViewer::resizeGL(
|
|---|
| [1039] | 293 | int aWidth
|
|---|
| 294 | ,int aHeight)
|
|---|
| [564] | 295 | {
|
|---|
| [1121] | 296 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 297 | printf("G4OpenGLStoredQtViewer::resizeGL\n");
|
|---|
| 298 | #endif
|
|---|
| [906] | 299 | // Set new size, it will be update when next Repaint()->SetView() called
|
|---|
| [1121] | 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 |
|
|---|
| [1039] | 336 | ResizeWindow(aWidth,aHeight);
|
|---|
| [1121] | 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 | SetView(); // en test .......................
|
|---|
| 341 | // ResizeGLView(); // en test .......................
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| [1040] | 346 | fHasToRepaint = sizeHasChanged();
|
|---|
| [564] | 347 | }
|
|---|
| [1121] | 348 | #endif
|
|---|
| [564] | 349 |
|
|---|
| 350 |
|
|---|
| [1121] | 351 | #ifdef QT_STORE_46_DBG_PAINT
|
|---|
| [564] | 352 | void G4OpenGLStoredQtViewer::paintGL()
|
|---|
| [682] | 353 | {
|
|---|
| [911] | 354 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1122] | 355 | printf("G4OpenGLStoredQtViewer::paintGL Immediate\n");
|
|---|
| [1121] | 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
|
|---|
| [1040] | 412 | printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
|
|---|
| [873] | 413 | #endif
|
|---|
| [1040] | 414 | if (!fReadyToPaint) {
|
|---|
| 415 | fReadyToPaint= true;
|
|---|
| [682] | 416 | return;
|
|---|
| 417 | }
|
|---|
| [1039] | 418 | // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
|
|---|
| 419 | // WHEN CLICK ON THE FRAME FOR EXAMPLE
|
|---|
| 420 | // EXECEPT WHEN MOUSE MOVE EVENT
|
|---|
| [1040] | 421 | if ( !fHasToRepaint) {
|
|---|
| [1039] | 422 | if (((getWinWidth() == (unsigned int)width())) &&(getWinHeight() == (unsigned int) height())) {
|
|---|
| 423 | return;
|
|---|
| 424 | }
|
|---|
| 425 | }
|
|---|
| 426 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1040] | 427 | printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
|
|---|
| [1039] | 428 | #endif
|
|---|
| [873] | 429 |
|
|---|
| [1039] | 430 | SetView();
|
|---|
| 431 |
|
|---|
| 432 | ClearView (); //ok, put the background correct
|
|---|
| 433 | ComputeView();
|
|---|
| 434 |
|
|---|
| [1040] | 435 | fHasToRepaint =false;
|
|---|
| [1039] | 436 |
|
|---|
| [911] | 437 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| [1040] | 438 | printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
|
|---|
| [608] | 439 | #endif
|
|---|
| [682] | 440 | }
|
|---|
| [564] | 441 |
|
|---|
| [1121] | 442 | #endif
|
|---|
| 443 |
|
|---|
| [564] | 444 | void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
|
|---|
| 445 | {
|
|---|
| [873] | 446 | G4MousePressEvent(event);
|
|---|
| [564] | 447 | }
|
|---|
| 448 |
|
|---|
| [696] | 449 | void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
|
|---|
| 450 | {
|
|---|
| 451 | G4keyPressEvent(event);
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| [804] | 454 | void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
|
|---|
| 455 | {
|
|---|
| 456 | G4wheelEvent(event);
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| [678] | 459 | /**
|
|---|
| 460 | * This function was build in order to make a zoom on double clic event.
|
|---|
| 461 | * It was think to build a rubberband on the zoom area, but never work fine
|
|---|
| 462 | */
|
|---|
| [955] | 463 | void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
|
|---|
| [673] | 464 | {
|
|---|
| [873] | 465 | G4MouseDoubleClickEvent();
|
|---|
| [673] | 466 | }
|
|---|
| 467 |
|
|---|
| [955] | 468 | void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *)
|
|---|
| [673] | 469 | {
|
|---|
| [797] | 470 | G4MouseReleaseEvent();
|
|---|
| [673] | 471 | }
|
|---|
| 472 |
|
|---|
| [564] | 473 | void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
|
|---|
| 474 | {
|
|---|
| [873] | 475 | G4MouseMoveEvent(event);
|
|---|
| [564] | 476 | }
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 | void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
|
|---|
| 480 | {
|
|---|
| [873] | 481 | G4manageContextMenuEvent(e);
|
|---|
| [564] | 482 | }
|
|---|
| 483 |
|
|---|
| 484 | void G4OpenGLStoredQtViewer::updateQWidget() {
|
|---|
| [1040] | 485 | fHasToRepaint= true;
|
|---|
| [1122] | 486 | #ifdef G4DEBUG_VIS_OGL
|
|---|
| 487 | printf("G4OpenGLStoredQtViewer::updateQWidget\n");
|
|---|
| 488 | #endif
|
|---|
| [564] | 489 | updateGL();
|
|---|
| [1040] | 490 | fHasToRepaint= false;
|
|---|
| [564] | 491 | }
|
|---|
| 492 |
|
|---|
| [877] | 493 | void G4OpenGLStoredQtViewer::ShowView (
|
|---|
| 494 | )
|
|---|
| 495 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 496 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 497 | {
|
|---|
| 498 | #if QT_VERSION < 0x040000
|
|---|
| 499 | setActiveWindow();
|
|---|
| 500 | #else
|
|---|
| 501 | activateWindow();
|
|---|
| 502 | #endif
|
|---|
| 503 | }
|
|---|
| [673] | 504 |
|
|---|
| [531] | 505 | #endif
|
|---|