Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc (Version 9.3.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.28 2009/11/03 11:02:32 lgarnier Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-03-patch-01 $
 27 //                                                 29 //
 28 //                                                 30 //
 29 // Class G4OpenGLStoredQtViewer : a class deri     31 // Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and
 30 //                                G4OpenGLStor     32 //                                G4OpenGLStoredViewer.
 31                                                    33 
                                                   >>  34 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
                                                   >>  35 
 32 #include "G4OpenGLStoredQtViewer.hh"               36 #include "G4OpenGLStoredQtViewer.hh"
 33                                                    37 
 34 #include "G4OpenGLStoredSceneHandler.hh"       << 
 35 #include "G4ios.hh"                                38 #include "G4ios.hh"
 36 #include "G4Threading.hh"                      << 
 37 #include "G4UIQt.hh"                           << 
 38 #if 0x060000 <= QT_VERSION                     << 
 39 #include "G4Qt.hh"                             << 
 40 #endif                                         << 
 41                                                << 
 42 #include <qapplication.h>                      << 
 43 #include <qtabwidget.h>                        << 
 44                                                    39 
 45 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer     40 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
 46 (G4OpenGLStoredSceneHandler& sceneHandler,         41 (G4OpenGLStoredSceneHandler& sceneHandler,
 47  const G4String&  name):                           42  const G4String&  name):
 48   G4VViewer (sceneHandler, sceneHandler.Increm     43   G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
 49   G4OpenGLViewer (sceneHandler),                   44   G4OpenGLViewer (sceneHandler),
 50   G4OpenGLQtViewer (sceneHandler),                 45   G4OpenGLQtViewer (sceneHandler),
 51   G4OpenGLStoredViewer (sceneHandler),             46   G4OpenGLStoredViewer (sceneHandler),             // FIXME : gerer le pb du parent !
 52   G4QGLWidgetType()                            <<  47   QGLWidget()
 53 {                                                  48 {
 54   if (fViewId < 0) return;  // In case error i << 
 55                                                    49 
 56 #if QT_VERSION < 0x060000                      <<  50 #if QT_VERSION < 0x040000
 57   fQGLWidgetInitialiseCompleted = false;       <<  51   setFocusPolicy(QWidget::StrongFocus); // enable keybord events
 58                                                << 
 59     // Indicates that the widget has no backgr << 
 60   G4QGLWidgetType::setAttribute (Qt::WA_NoSyst << 
 61                                                << 
 62   setFocusPolicy(Qt::StrongFocus); // enable k << 
 63   fHasToRepaint = false;                       << 
 64   fPaintEventLock = false;                     << 
 65   fUpdateGLLock = false;                       << 
 66 #else                                              52 #else
 67   // Indicates that the widget has no backgrou << 
 68   G4QGLWidgetType::setAttribute (Qt::WA_NoSyst << 
 69                                                << 
 70   setFocusPolicy(Qt::StrongFocus); // enable k     53   setFocusPolicy(Qt::StrongFocus); // enable keybord events
 71 #endif                                             54 #endif
 72 }                                              <<  55   fHasToRepaint =false;
 73                                                    56 
 74 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewe <<  57   if (fViewId < 0) return;  // In case error in base class instantiation.
 75                                                <<  58 }
 76 void G4OpenGLStoredQtViewer::Initialise() {    << 
 77 #if QT_VERSION < 0x060000                      << 
 78                                                << 
 79   fQGLWidgetInitialiseCompleted = false;       << 
 80   CreateMainWindow (this,QString(GetName()));  << 
 81                                                    59 
                                                   >>  60 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
 82   makeCurrent();                                   61   makeCurrent();
 83   glDrawBuffer (GL_BACK);                      <<  62   // this is connect to the Dialog for deleting it properly
                                                   >>  63   // when close event.
                                                   >>  64   //   ((QDialog*)window())->reject();
                                                   >>  65 }
 84                                                    66 
 85    // set the good tab active                  <<  67 void G4OpenGLStoredQtViewer::Initialise() {
 86   if (G4QGLWidgetType::parentWidget()) {       <<  68 #ifdef G4DEBUG_VIS_OGL
 87     auto *parentTab = dynamic_cast<QTabWidget* <<  69   printf("G4OpenGLStoredQtViewer::Initialise 1\n");
 88     if (parentTab) {                           << 
 89       parentTab->setCurrentIndex(parentTab->co << 
 90     }                                          << 
 91   }                                            << 
 92                                                << 
 93   fQGLWidgetInitialiseCompleted = true;        << 
 94 #else                                          << 
 95   CreateMainWindow (this,QString(GetName()));  << 
 96   // Set jpg as default export format for Qt v << 
 97   setExportImageFormat("jpg");                 << 
 98 #endif                                             70 #endif
                                                   >>  71   fReadyToPaint = false;
                                                   >>  72   CreateMainWindow (this,QString(fName));
                                                   >>  73   CreateFontLists ();
                                                   >>  74   
                                                   >>  75   fReadyToPaint = true;
 99 }                                                  76 }
100                                                    77 
101 #if QT_VERSION < 0x060000                      << 
102 void G4OpenGLStoredQtViewer::initializeGL () {     78 void G4OpenGLStoredQtViewer::initializeGL () {
103                                                    79 
104   InitializeGLView ();                             80   InitializeGLView ();
105                                                    81 
                                                   >>  82 #ifdef G4DEBUG_VIS_OGL
                                                   >>  83   printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n");
                                                   >>  84 #endif
                                                   >>  85 
                                                   >>  86   // clear the buffers and window.
                                                   >>  87   ClearView ();
                                                   >>  88   FinishView ();
                                                   >>  89    
                                                   >>  90   glDepthFunc (GL_LEQUAL);
                                                   >>  91   glDepthMask (GL_TRUE);
                                                   >>  92 
106   if (fSceneHandler.GetScene() == 0) {             93   if (fSceneHandler.GetScene() == 0) {
107     fHasToRepaint =false;                          94     fHasToRepaint =false;
108   } else {                                         95   } else {
109     fHasToRepaint =true;                           96     fHasToRepaint =true;
110   }                                                97   }
111                                                << 
112    // Set the component visible                << 
113   //   setVisible(true) ;                      << 
114                                                    98 
115   // Set jpg as default export format for Qt v <<  99 #ifdef G4DEBUG_VIS_OGL
116   setExportImageFormat("jpg");                 << 100   printf("G4OpenGLStoredQtViewer::InitialiseGL  END\n");
117 }                                              << 
118 #endif                                            101 #endif
119                                                << 
120 G4bool G4OpenGLStoredQtViewer::CompareForKerne << 
121 {                                              << 
122   // Identical to G4OpenGLStoredViewer::Compar << 
123   // for checking of VisAttributesModifiers, b << 
124   // G4OpenGLStoredQtViewer keeps track of its << 
125   // modifiers (fTreeItemModels, etc.).        << 
126   if (                                         << 
127       (lastVP.GetDrawingStyle ()    != fVP.Get << 
128       (lastVP.GetNumberOfCloudPoints()  != fVP << 
129       (lastVP.IsAuxEdgeVisible ()   != fVP.IsA << 
130       (lastVP.IsCulling ()          != fVP.IsC << 
131       (lastVP.IsCullingInvisible () != fVP.IsC << 
132       (lastVP.IsDensityCulling ()   != fVP.IsD << 
133       (lastVP.IsCullingCovered ()   != fVP.IsC << 
134       (lastVP.GetCBDAlgorithmNumber() !=       << 
135        fVP.GetCBDAlgorithmNumber())            << 
136       // Note: Section and Cutaway can reveal  << 
137       // backface culling is implemented, the  << 
138       // the back-facing faces are not there.  << 
139       // (commented out) backface culling (it  << 
140       // in fact, performance seems to improve << 
141       (lastVP.IsSection ()          != fVP.IsS << 
142       // Section (DCUT) is NOT implemented loc << 
143       // (lastVP.IsCutaway ()          != fVP. << 
144       // Cutaways are implemented locally so w << 
145       (lastVP.IsExplode ()          != fVP.IsE << 
146       (lastVP.GetNoOfSides ()       != fVP.Get << 
147       (lastVP.GetGlobalMarkerScale()    != fVP << 
148       (lastVP.GetGlobalLineWidthScale() != fVP << 
149       (lastVP.IsMarkerNotHidden ()  != fVP.IsM << 
150       (lastVP.GetDefaultVisAttributes()->GetCo << 
151        fVP.GetDefaultVisAttributes()->GetColou << 
152       (lastVP.GetDefaultTextVisAttributes()->G << 
153        fVP.GetDefaultTextVisAttributes()->GetC << 
154       (lastVP.GetBackgroundColour ()!= fVP.Get << 
155       (lastVP.IsPicking ()          != fVP.IsP << 
156       (lastVP.IsSpecialMeshRendering() != fVP. << 
157       (lastVP.GetSpecialMeshRenderingOption()  << 
158     return true;                               << 
159                                                << 
160   // Don't check VisAttributesModifiers if thi << 
161   // initiated by a mouse interaction on the s << 
162   if (fMouseOnSceneTree) {                     << 
163     // Reset the flag.                         << 
164     fMouseOnSceneTree = false;                 << 
165   } else {                                     << 
166     // Not initiated by a mouse so compare for << 
167     if (lastVP.GetVisAttributesModifiers() !=  << 
168       return true;                             << 
169     }                                          << 
170   }                                            << 
171                                                << 
172   if (lastVP.IsDensityCulling () &&            << 
173       (lastVP.GetVisibleDensity () != fVP.GetV << 
174     return true;                               << 
175                                                << 
176 //  /***************************************** << 
177 //   If section (DCUT) is implemented locally, << 
178   if (lastVP.IsSection () &&                   << 
179       (lastVP.GetSectionPlane () != fVP.GetSec << 
180     return true;                               << 
181 //   ***************************************** << 
182                                                << 
183   /******************************************* << 
184    If cutaways are implemented locally, commen << 
185    if (lastVP.IsCutaway ()) {                  << 
186    if (vp.GetCutawayMode() != fVP.GetCutawayMo << 
187    if (lastVP.GetCutawayPlanes ().size () !=   << 
188    fVP.GetCutawayPlanes ().size ()) return tru << 
189    for (size_t i = 0; i < lastVP.GetCutawayPla << 
190    if (lastVP.GetCutawayPlanes()[i] != fVP.Get << 
191    return true;                                << 
192    }                                           << 
193    ******************************************* << 
194                                                << 
195   if (lastVP.GetCBDAlgorithmNumber() > 0) {    << 
196     if (lastVP.GetCBDParameters().size() != fV << 
197     else if (lastVP.GetCBDParameters() != fVP. << 
198   }                                            << 
199                                                << 
200   if (lastVP.IsExplode () &&                   << 
201       (lastVP.GetExplodeFactor () != fVP.GetEx << 
202     return true;                               << 
203                                                << 
204   if (lastVP.IsSpecialMeshRendering() &&       << 
205       (lastVP.GetSpecialMeshVolumes() != fVP.G << 
206     return true;                               << 
207                                                << 
208   return false;                                << 
209 }                                                 102 }
210                                                   103 
211 G4bool G4OpenGLStoredQtViewer::POSelected(size << 
212 {                                              << 
213   return isTouchableVisible((int)POListIndex); << 
214 }                                              << 
215                                                << 
216 G4bool G4OpenGLStoredQtViewer::TOSelected(size << 
217 {                                              << 
218   return true;                                 << 
219 }                                              << 
220                                                   104 
221 void G4OpenGLStoredQtViewer::DrawView () {        105 void G4OpenGLStoredQtViewer::DrawView () {
222 #if QT_VERSION < 0x060000                      << 106 #ifdef G4DEBUG_VIS_OGL
223 #else                                          << 107   printf("G4OpenGLStoredQtViewer::DrawView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
224   if(IsGettingPickInfos()) {                   << 
225     paintGL();                                 << 
226     return;                                    << 
227   }                                            << 
228 #endif                                            108 #endif
229 #if (QT_VERSION < 0x060000) || !defined(G4MULT << 109   // That's no the same logic as Immediate Viewer, I don't know why...
230   updateQWidget();                             << 110   // But if I send updateGL here, we go here :
231 #else                                          << 111   //  updateQWidget -> paintGL -> ComputeView
232   if (G4Threading::IsMasterThread()) {         << 112   // whih is not the same as ComputeView Directly
233     updateQWidget();                           << 113   // And we loose the redraw of things !
234   } else {                                     << 114   
235     update(); //G.Barrand: updateQWidget() ind << 115   ComputeView();
236   }                                            << 116 #ifdef G4DEBUG_VIS_OGL
                                                   >> 117   printf("G4OpenGLStoredQtViewer::DrawView  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
237 #endif                                            118 #endif
238 }                                                 119 }
239                                                   120 
240 void G4OpenGLStoredQtViewer::ComputeView () {     121 void G4OpenGLStoredQtViewer::ComputeView () {
241                                                   122 
242 #if QT_VERSION < 0x060000                      << 123 #ifdef G4DEBUG_VIS_OGL
243   makeCurrent();                               << 124   printf("G4OpenGLStoredQtViewer::ComputeView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
244 #endif                                            125 #endif
245                                                << 126   makeCurrent();
246   G4ViewParameters::DrawingStyle dstyle = GetV << 127   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
247                                                   128 
248   //Make sure current viewer is attached and c    129   //Make sure current viewer is attached and clean...
249                                                   130 
250   //See if things have changed from last time     131   //See if things have changed from last time and remake if necessary...
251   // The fNeedKernelVisit flag might have been    132   // The fNeedKernelVisit flag might have been set by the user in
252   // /vis/viewer/rebuild, but if not, make dec    133   // /vis/viewer/rebuild, but if not, make decision and set flag only
253   // if necessary...                              134   // if necessary...
254   if (!fNeedKernelVisit) {                        135   if (!fNeedKernelVisit) {
255     KernelVisitDecision ();                       136     KernelVisitDecision ();
256   }                                               137   }
257   fLastVP = fVP;                               << 
258   G4bool kernelVisitWasNeeded = fNeedKernelVis    138   G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
259   ProcessView ();                                 139   ProcessView ();
260                                                   140    
261   if (kernelVisitWasNeeded) {                  << 
262     displaySceneTreeComponent();               << 
263   }                                            << 
264                                                   141 
265   if(dstyle!=G4ViewParameters::hlr &&          << 142   if(style!=G4ViewParameters::hlr &&
266      haloing_enabled) {                           143      haloing_enabled) {
                                                   >> 144 #ifdef G4DEBUG_VIS_OGL
                                                   >> 145     printf("G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
                                                   >> 146 #endif
267                                                   147 
268     HaloingFirstPass ();                          148     HaloingFirstPass ();
269     DrawDisplayLists ();                          149     DrawDisplayLists ();
270     glFlush ();                                   150     glFlush ();
271                                                   151 
272     HaloingSecondPass ();                         152     HaloingSecondPass ();
273                                                   153 
274     DrawDisplayLists ();                          154     DrawDisplayLists ();
275     FinishView ();                                155     FinishView ();
276                                                   156 
277   } else {                                        157   } else {
278                                                   158      
279     // If kernel visit was needed, drawing and    159     // If kernel visit was needed, drawing and FinishView will already
280     // have been done, so...                      160     // have been done, so...
281     if (!kernelVisitWasNeeded) {                  161     if (!kernelVisitWasNeeded) {
                                                   >> 162 #ifdef G4DEBUG_VIS_OGL
                                                   >> 163       printf("**************************  G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
                                                   >> 164 #endif
282       DrawDisplayLists ();                        165       DrawDisplayLists ();
283       FinishView ();                              166       FinishView ();
284     } else {                                      167     } else {
                                                   >> 168 #ifdef G4DEBUG_VIS_OGL
                                                   >> 169       printf("**************************  G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
                                                   >> 170 #endif
285       // However, union cutaways are implement    171       // However, union cutaways are implemented in DrawDisplayLists, so make
286       // an extra pass...                         172       // an extra pass...
287       if (fVP.IsCutaway() &&                      173       if (fVP.IsCutaway() &&
288           fVP.GetCutawayMode() == G4ViewParame    174           fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
289         ClearView();                              175         ClearView();
290         DrawDisplayLists ();                      176         DrawDisplayLists ();
291         FinishView ();                            177         FinishView ();
                                                   >> 178 #ifdef G4DEBUG_VIS_OGL
                                                   >> 179         printf("***************************  CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
                                                   >> 180 #endif
292       } else { // ADD TO AVOID KernelVisit=1 a    181       } else { // ADD TO AVOID KernelVisit=1 and nothing to display
293         DrawDisplayLists ();                      182         DrawDisplayLists ();
294         FinishView ();                            183         FinishView ();
295       }                                           184       }
296     }                                             185     }
297   }                                               186   }
298                                                   187 
299   if (isRecording()) {                            188   if (isRecording()) {
300     savePPMToTemp();                              189     savePPMToTemp();
301   }                                               190   }
302                                                   191 
303 #if QT_VERSION < 0x060000                      << 192 #ifdef G4DEBUG_VIS_OGL
304   fHasToRepaint = true;                        << 193   printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
305 #endif                                            194 #endif
                                                   >> 195   fHasToRepaint =true;
306 }                                                 196 }
307                                                   197 
308                                                   198 
309 /**                                               199 /**
310    - Lors du resize de la fenetre, on doit non    200    - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
311 */                                                201 */
312 void G4OpenGLStoredQtViewer::resizeGL(            202 void G4OpenGLStoredQtViewer::resizeGL(
313                                       int aWid    203                                       int aWidth
314                                       ,int aHe    204                                       ,int aHeight)
315 {                                                 205 {  
316   // Set new size, it will be update when next    206   // Set new size, it will be update when next Repaint()->SetView() called
317   if ((aWidth > 0) && (aHeight > 0)) {         << 207   ResizeWindow(aWidth,aHeight);
318 #if QT_VERSION < 0x060000                      << 208   fHasToRepaint = sizeHasChanged();
319     ResizeWindow(aWidth,aHeight);              << 
320     fHasToRepaint = sizeHasChanged();          << 
321 #else                                          << 
322     ResizeWindow(devicePixelRatio()*aWidth,dev << 
323 #endif                                         << 
324   }                                            << 
325 }                                                 209 }
326                                                   210 
327                                                   211 
328 // We have to get several case :               << 
329 // - Only activate the windows (mouse click fo << 
330 // - resize window -> redraw                   << 
331 // - try to avoid recompute everything if we d << 
332                                                << 
333 void G4OpenGLStoredQtViewer::paintGL()            212 void G4OpenGLStoredQtViewer::paintGL()
334 {                                                 213 {
335 #if QT_VERSION < 0x060000                      << 214 #ifdef G4DEBUG_VIS_OGL
336   updateToolbarAndMouseContextMenu();          << 215   printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
337 #else                                          << 
338   //G.Barrand: don't do any change in the GUI  << 
339 #endif                                            216 #endif
340                                                << 217   if (!fReadyToPaint) {
341 #if QT_VERSION < 0x060000                      << 218     fReadyToPaint= true;
342   if (fPaintEventLock) {                       << 
343 //    return ;                                 << 
344   }                                            << 
345   fPaintEventLock = true;                      << 
346   if ((getWinWidth() == 0) && (getWinHeight()  << 
347     return;                                       219     return;
348   }                                               220   }
349                                                << 
350   if (!fQGLWidgetInitialiseCompleted) {        << 
351     fPaintEventLock = false;                   << 
352     return;                                    << 
353   }                                            << 
354                                                << 
355   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :       221   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
356   //    WHEN CLICK ON THE FRAME FOR EXAMPLE       222   //    WHEN CLICK ON THE FRAME FOR EXAMPLE
357   //    EXECEPT WHEN MOUSE MOVE EVENT             223   //    EXECEPT WHEN MOUSE MOVE EVENT
358   if ( !fHasToRepaint) {                          224   if ( !fHasToRepaint) {
                                                   >> 225 #if QT_VERSION < 0x040000
                                                   >> 226     if (((getWinWidth() == (unsigned int)width())) &&(getWinHeight() == (unsigned int) height())) { 
                                                   >> 227 #else
359     // L. Garnier : Trap to get the size with     228     // L. Garnier : Trap to get the size with mac OSX 10.6 and Qt 4.6(devel)
360     // Tested on Qt4.5 on mac, 4.4 on windows,    229     // Tested on Qt4.5 on mac, 4.4 on windows, 4.5 on unbuntu
361     int sw = 0;                                   230     int sw = 0;
362     int sh = 0;                                   231     int sh = 0;
363     if (!isMaximized() && !isFullScreen()) {      232     if (!isMaximized() && !isFullScreen()) {
364       sw = normalGeometry().width();              233       sw = normalGeometry().width();
365       sh = normalGeometry().height();             234       sh = normalGeometry().height();
366     } else {                                      235     } else {
367       sw = frameGeometry().width();               236       sw = frameGeometry().width();
368       sh = frameGeometry().height();              237       sh = frameGeometry().height();
369     }                                             238     }
370     if ((getWinWidth() == (unsigned int)sw) &&    239     if ((getWinWidth() == (unsigned int)sw) &&(getWinHeight() == (unsigned int)sh)) {
                                                   >> 240 #endif
371       return;                                     241       return;
372     }                                             242     }
373   }                                               243   }
374 #else                                          << 244 #ifdef G4DEBUG_VIS_OGL
375   if ((getWinWidth() == 0) && (getWinHeight()  << 245   printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
376 #endif                                            246 #endif
377                                                   247 
378 #if QT_VERSION < 0x060000                      << 
379 #else                                          << 
380   InitializeGLView ();                         << 
381 #endif                                         << 
382                                                << 
383   // Ensure that we really draw the BACK buffe << 
384   glDrawBuffer (GL_BACK);                      << 
385                                                << 
386   SetView();                                      248   SetView();
387                                                << 249           
388   ClearView (); //ok, put the background corre    250   ClearView (); //ok, put the background correct
389   ComputeView();                                  251   ComputeView();
390                                                << 252      
391 #if QT_VERSION < 0x060000                      << 253   fHasToRepaint =false;
392   fHasToRepaint = false;                       << 254      
393                                                << 255 #ifdef G4DEBUG_VIS_OGL
394   fPaintEventLock = false;                     << 256   printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
395 #endif                                         << 
396 }                                              << 
397                                                << 
398 #if QT_VERSION < 0x060000                      << 
399 void G4OpenGLStoredQtViewer::paintEvent(QPaint << 
400   if (! fQGLWidgetInitialiseCompleted) {       << 
401     return;                                    << 
402   }                                            << 
403   // Force a repaint next time if the FRAMEBUF << 
404   fHasToRepaint = isFramebufferReady();        << 
405   if ( fHasToRepaint) {                        << 
406     // Will really update the widget by callin << 
407     // The widget's rendering context will bec << 
408     // will be called if it hasn't already bee << 
409     // Copies the back buffer of a double-buff << 
410 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))   << 
411     updateGL();                                << 
412 #else                                          << 
413     // Not sure this is correct....            << 
414     paintGL();                                 << 
415 #endif                                            257 #endif
416   }                                            << 
417 }                                                 258 }
418 #endif                                         << 
419                                                   259 
420 void G4OpenGLStoredQtViewer::mousePressEvent(Q    260 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
421 {                                                 261 {
422   G4MousePressEvent(event);                       262   G4MousePressEvent(event);
423 }                                                 263 }
424                                                   264 
425 void G4OpenGLStoredQtViewer::keyPressEvent (QK    265 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event) 
426 {                                                 266 {
427   G4keyPressEvent(event);                         267   G4keyPressEvent(event);
428 }                                                 268 }
429                                                   269 
430 void G4OpenGLStoredQtViewer::keyReleaseEvent ( << 270 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event) 
431 {                                              << 
432   G4keyReleaseEvent(event);                    << 
433 }                                              << 
434                                                << 
435 void G4OpenGLStoredQtViewer::wheelEvent (QWhee << 
436 {                                                 271 {
437   G4wheelEvent(event);                            272   G4wheelEvent(event);
438 }                                                 273 }
439                                                   274 
440 #if QT_VERSION < 0x060000                      << 
441 void G4OpenGLStoredQtViewer::showEvent (QShowE << 
442 {                                              << 
443   if (fQGLWidgetInitialiseCompleted) {         << 
444     fHasToRepaint = true;                      << 
445   }                                            << 
446 }                                              << 
447 #endif                                         << 
448                                                << 
449 /**                                               275 /**
450  * This function was build in order to make a     276  * This function was build in order to make a zoom on double clic event.
451  * It was think to build a rubberband on the z    277  * It was think to build a rubberband on the zoom area, but never work fine
452  */                                               278  */
453 void G4OpenGLStoredQtViewer::mouseDoubleClickE    279 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
454 {                                                 280 {
455   G4MouseDoubleClickEvent();                      281   G4MouseDoubleClickEvent();
456 }                                                 282 }
457                                                   283 
458 void G4OpenGLStoredQtViewer::mouseReleaseEvent << 284 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *)
459 {                                                 285 {
460   G4MouseReleaseEvent(event);                  << 286   G4MouseReleaseEvent();
461 }                                                 287 }
462                                                   288 
463 void G4OpenGLStoredQtViewer::mouseMoveEvent(QM    289 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
464 {                                                 290 {
465   G4MouseMoveEvent(event);                        291   G4MouseMoveEvent(event);
466 }                                                 292 }
467                                                   293 
468                                                   294 
469 void G4OpenGLStoredQtViewer::contextMenuEvent(    295 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
470 {                                                 296 {
471   G4manageContextMenuEvent(e);                    297   G4manageContextMenuEvent(e);
472 }                                                 298 }
473                                                   299 
474 void G4OpenGLStoredQtViewer::updateQWidget() {    300 void G4OpenGLStoredQtViewer::updateQWidget() {
475 #if QT_VERSION < 0x060000                      << 
476   if (fUpdateGLLock) {                         << 
477     return;                                    << 
478   }                                            << 
479                                                << 
480   if (! isCurrentWidget()){                    << 
481     return;                                    << 
482   }                                            << 
483                                                << 
484   fUpdateGLLock = true;                        << 
485   fHasToRepaint= true;                            301   fHasToRepaint= true;
486   // Will really update the widget by calling  << 302   updateGL();
487   // The widget's rendering context will becom << 303   fHasToRepaint= false;
488   // will be called if it hasn't already been  << 
489   // Copies the back buffer of a double-buffer << 
490   repaint(); // will read scene tree state     << 
491   // updateGL() // From J.Allison picking bran << 
492   updateViewerPropertiesTableWidget();         << 
493   updateSceneTreeWidget();                     << 
494   fUpdateGLLock = false;                       << 
495 #else                                          << 
496   //if (!isCurrentWidget()) return; //G.Barran << 
497   //G.Barrand: don't do any change in the GUI  << 
498   update();                                    << 
499 #endif                                         << 
500 }                                                 304 }
501                                                   305 
502 void G4OpenGLStoredQtViewer::ShowView ()       << 306 void G4OpenGLStoredQtViewer::ShowView (
                                                   >> 307 ) 
                                                   >> 308 //////////////////////////////////////////////////////////////////////////////
                                                   >> 309 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
503 {                                                 310 {
                                                   >> 311 #if QT_VERSION < 0x040000
                                                   >> 312   setActiveWindow();
                                                   >> 313 #else
504   activateWindow();                               314   activateWindow();
505 #if 0x060000 <= QT_VERSION                     << 
506   ((QApplication*)G4Qt::getInstance ())->proce << 
507 #endif                                            315 #endif
508 }                                                 316 }
509                                                   317 
510                                                << 318 #endif
511 void G4OpenGLStoredQtViewer::DisplayTimePOColo << 
512 G4Colour& c,                                   << 
513 size_t poIndex) {                              << 
514   c = getColorForPoIndex((int)poIndex);        << 
515 }                                              << 
516                                                   319