[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: G4OpenGLStoredQtViewer.cc,v 1.18 2007/06/25 12:07:59 $ |
---|
[531] | 28 | // GEANT4 tag $Name: geant4-08-02-patch-01 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
[533] | 31 | // Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and |
---|
[531] | 32 | // G4OpenGLStoredViewer. |
---|
| 33 | |
---|
[533] | 34 | #ifdef G4VIS_BUILD_OPENGLQT_DRIVER |
---|
[531] | 35 | |
---|
[533] | 36 | #include "G4OpenGLStoredQtViewer.hh" |
---|
[531] | 37 | |
---|
| 38 | #include "G4ios.hh" |
---|
| 39 | |
---|
[533] | 40 | G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer |
---|
[531] | 41 | (G4OpenGLStoredSceneHandler& sceneHandler, |
---|
| 42 | const G4String& name): |
---|
| 43 | G4OpenGLViewer (sceneHandler), |
---|
[533] | 44 | G4OpenGLQtViewer (sceneHandler), |
---|
[531] | 45 | G4OpenGLStoredViewer (sceneHandler), |
---|
| 46 | G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) { |
---|
| 47 | |
---|
| 48 | if (fViewId < 0) return; // In case error in base class instantiation. |
---|
| 49 | } |
---|
| 50 | |
---|
[533] | 51 | void G4OpenGLStoredQtViewer::Initialise () { |
---|
[531] | 52 | |
---|
[533] | 53 | //Check that G4OpenGLQtViewer got a double buffered colour visual |
---|
[531] | 54 | |
---|
[533] | 55 | CreateGLQtContext (); |
---|
[531] | 56 | CreateMainWindow (); |
---|
| 57 | CreateFontLists (); |
---|
| 58 | |
---|
| 59 | // clear the buffers and window. |
---|
| 60 | ClearView (); |
---|
| 61 | FinishView (); |
---|
| 62 | |
---|
| 63 | glDepthFunc (GL_LEQUAL); |
---|
| 64 | glDepthMask (GL_TRUE); |
---|
| 65 | } |
---|
| 66 | |
---|
[533] | 67 | void G4OpenGLStoredQtViewer::DrawView () { |
---|
[531] | 68 | |
---|
| 69 | //Make sure current viewer is attached and clean... |
---|
[533] | 70 | //Qt version needed |
---|
[531] | 71 | // glXMakeCurrent (dpy, win, cx); |
---|
| 72 | glViewport (0, 0, WinSize_x, WinSize_y); |
---|
| 73 | |
---|
| 74 | G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); |
---|
| 75 | |
---|
| 76 | //See if things have changed from last time and remake if necessary... |
---|
| 77 | // The fNeedKernelVisit flag might have been set by the user in |
---|
| 78 | // /vis/viewer/rebuild, but if not, make decision and set flag only |
---|
| 79 | // if necessary... |
---|
| 80 | if (!fNeedKernelVisit) KernelVisitDecision (); |
---|
| 81 | G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets). |
---|
| 82 | ProcessView (); |
---|
| 83 | |
---|
| 84 | if(style!=G4ViewParameters::hlr && |
---|
| 85 | haloing_enabled) { |
---|
| 86 | |
---|
| 87 | HaloingFirstPass (); |
---|
| 88 | DrawDisplayLists (); |
---|
| 89 | glFlush (); |
---|
| 90 | |
---|
| 91 | HaloingSecondPass (); |
---|
| 92 | |
---|
| 93 | DrawDisplayLists (); |
---|
| 94 | FinishView (); |
---|
| 95 | |
---|
| 96 | } else { |
---|
| 97 | |
---|
| 98 | // If kernel visit was needed, drawing and FinishView will already |
---|
| 99 | // have been done, so... |
---|
| 100 | if (!kernelVisitWasNeeded) { |
---|
| 101 | DrawDisplayLists (); |
---|
| 102 | FinishView (); |
---|
| 103 | } else { |
---|
| 104 | // However, union cutaways are implemented in DrawDisplayLists, so make |
---|
| 105 | // an extra pass... |
---|
| 106 | if (fVP.IsCutaway() && |
---|
| 107 | fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) { |
---|
| 108 | ClearView(); |
---|
| 109 | DrawDisplayLists (); |
---|
| 110 | FinishView (); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | ////////////////////////////////////////////////////////////////////////////// |
---|
[533] | 117 | void G4OpenGLStoredQtViewer::FinishView ( |
---|
[531] | 118 | ) |
---|
| 119 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 120 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 121 | { |
---|
[555] | 122 | printf("................G4OpenGLStoredQtViewer::FinishView"); |
---|
[536] | 123 | if(!fWindow) return; |
---|
[531] | 124 | |
---|
| 125 | glFlush (); |
---|
[536] | 126 | fWindow->swapBuffers (); |
---|
[555] | 127 | printf("................G4OpenGLStoredQtViewer::FinishView END"); |
---|
[531] | 128 | } |
---|
| 129 | |
---|
| 130 | #endif |
---|