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.4.p4)


  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.32 2010-06-23 13:29:23 lgarnier Exp $
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
 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
                                                   >>  55   fHasToRepaint = false;
                                                   >>  56   fIsRepainting = false;
                                                   >>  57 
                                                   >>  58   if (fViewId < 0) return;  // In case error in base class instantiation.
 72 }                                                  59 }
 73                                                    60 
 74 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewe <<  61 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
                                                   >>  62   makeCurrent();
                                                   >>  63   // this is connect to the Dialog for deleting it properly
                                                   >>  64   // when close event.
                                                   >>  65   //   ((QDialog*)window())->reject();
                                                   >>  66 }
 75                                                    67 
 76 void G4OpenGLStoredQtViewer::Initialise() {        68 void G4OpenGLStoredQtViewer::Initialise() {
 77 #if QT_VERSION < 0x060000                      <<  69 #ifdef G4DEBUG_VIS_OGL
 78                                                <<  70   printf("G4OpenGLStoredQtViewer::Initialise 1\n");
 79   fQGLWidgetInitialiseCompleted = false;       <<  71 #endif
                                                   >>  72   fReadyToPaint = false;
 80   CreateMainWindow (this,QString(GetName()));      73   CreateMainWindow (this,QString(GetName()));
 81                                                <<  74   CreateFontLists ();
 82   makeCurrent();                               << 
 83   glDrawBuffer (GL_BACK);                      << 
 84                                                << 
 85    // set the good tab active                  << 
 86   if (G4QGLWidgetType::parentWidget()) {       << 
 87     auto *parentTab = dynamic_cast<QTabWidget* << 
 88     if (parentTab) {                           << 
 89       parentTab->setCurrentIndex(parentTab->co << 
 90     }                                          << 
 91   }                                            << 
 92                                                    75   
 93   fQGLWidgetInitialiseCompleted = true;        <<  76   fReadyToPaint = true;
 94 #else                                          << 
 95   CreateMainWindow (this,QString(GetName()));  << 
 96   // Set jpg as default export format for Qt v << 
 97   setExportImageFormat("jpg");                 << 
 98 #endif                                         << 
 99 }                                                  77 }
100                                                    78 
101 #if QT_VERSION < 0x060000                      << 
102 void G4OpenGLStoredQtViewer::initializeGL () {     79 void G4OpenGLStoredQtViewer::initializeGL () {
103                                                    80 
104   InitializeGLView ();                             81   InitializeGLView ();
105                                                    82 
                                                   >>  83 #ifdef G4DEBUG_VIS_OGL
                                                   >>  84   printf("G4OpenGLStoredQtViewer::InitialiseGL () 1\n");
                                                   >>  85 #endif
                                                   >>  86 
                                                   >>  87   // clear the buffers and window.
                                                   >>  88   ClearView ();
                                                   >>  89   FinishView ();
                                                   >>  90    
                                                   >>  91   glDepthFunc (GL_LEQUAL);
                                                   >>  92   glDepthMask (GL_TRUE);
                                                   >>  93 
106   if (fSceneHandler.GetScene() == 0) {             94   if (fSceneHandler.GetScene() == 0) {
107     fHasToRepaint =false;                          95     fHasToRepaint =false;
108   } else {                                         96   } else {
109     fHasToRepaint =true;                           97     fHasToRepaint =true;
110   }                                                98   }
111                                                << 
112    // Set the component visible                << 
113   //   setVisible(true) ;                      << 
114                                                    99 
115   // Set jpg as default export format for Qt v << 100 #ifdef G4DEBUG_VIS_OGL
116   setExportImageFormat("jpg");                 << 101   printf("G4OpenGLStoredQtViewer::InitialiseGL  END\n");
117 }                                              << 
118 #endif                                            102 #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 }                                                 103 }
210                                                   104 
211 G4bool G4OpenGLStoredQtViewer::POSelected(size << 
212 {                                              << 
213   return isTouchableVisible((int)POListIndex); << 
214 }                                              << 
215                                                   105 
216 G4bool G4OpenGLStoredQtViewer::TOSelected(size << 106 void G4OpenGLStoredQtViewer::DrawView () {  
217 {                                              << 
218   return true;                                 << 
219 }                                              << 
220                                                << 
221 void G4OpenGLStoredQtViewer::DrawView () {     << 
222 #if QT_VERSION < 0x060000                      << 
223 #else                                          << 
224   if(IsGettingPickInfos()) {                   << 
225     paintGL();                                 << 
226     return;                                    << 
227   }                                            << 
228 #endif                                         << 
229 #if (QT_VERSION < 0x060000) || !defined(G4MULT << 
230   updateQWidget();                                107   updateQWidget();
231 #else                                          << 
232   if (G4Threading::IsMasterThread()) {         << 
233     updateQWidget();                           << 
234   } else {                                     << 
235     update(); //G.Barrand: updateQWidget() ind << 
236   }                                            << 
237 #endif                                         << 
238 }                                                 108 }
239                                                   109 
240 void G4OpenGLStoredQtViewer::ComputeView () {     110 void G4OpenGLStoredQtViewer::ComputeView () {
241                                                   111 
242 #if QT_VERSION < 0x060000                      << 112 #ifdef G4DEBUG_VIS_OGL
243   makeCurrent();                               << 113   printf("G4OpenGLStoredQtViewer::ComputeView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
244 #endif                                            114 #endif
245                                                << 115   makeCurrent();
246   G4ViewParameters::DrawingStyle dstyle = GetV << 116   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
247                                                   117 
248   //Make sure current viewer is attached and c    118   //Make sure current viewer is attached and clean...
249                                                   119 
250   //See if things have changed from last time     120   //See if things have changed from last time and remake if necessary...
251   // The fNeedKernelVisit flag might have been    121   // The fNeedKernelVisit flag might have been set by the user in
252   // /vis/viewer/rebuild, but if not, make dec    122   // /vis/viewer/rebuild, but if not, make decision and set flag only
253   // if necessary...                              123   // if necessary...
254   if (!fNeedKernelVisit) {                        124   if (!fNeedKernelVisit) {
255     KernelVisitDecision ();                       125     KernelVisitDecision ();
256   }                                               126   }
257   fLastVP = fVP;                               << 
258   G4bool kernelVisitWasNeeded = fNeedKernelVis    127   G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
259   ProcessView ();                                 128   ProcessView ();
260                                                   129    
261   if (kernelVisitWasNeeded) {                  << 
262     displaySceneTreeComponent();               << 
263   }                                            << 
264                                                   130 
265   if(dstyle!=G4ViewParameters::hlr &&          << 131   if(style!=G4ViewParameters::hlr &&
266      haloing_enabled) {                           132      haloing_enabled) {
                                                   >> 133 #ifdef G4DEBUG_VIS_OGL
                                                   >> 134     printf("G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
                                                   >> 135 #endif
267                                                   136 
268     HaloingFirstPass ();                          137     HaloingFirstPass ();
269     DrawDisplayLists ();                          138     DrawDisplayLists ();
270     glFlush ();                                   139     glFlush ();
271                                                   140 
272     HaloingSecondPass ();                         141     HaloingSecondPass ();
273                                                   142 
274     DrawDisplayLists ();                          143     DrawDisplayLists ();
275     FinishView ();                                144     FinishView ();
276                                                   145 
277   } else {                                        146   } else {
278                                                   147      
279     // If kernel visit was needed, drawing and    148     // If kernel visit was needed, drawing and FinishView will already
280     // have been done, so...                      149     // have been done, so...
281     if (!kernelVisitWasNeeded) {                  150     if (!kernelVisitWasNeeded) {
                                                   >> 151 #ifdef G4DEBUG_VIS_OGL
                                                   >> 152       printf("**************************  G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
                                                   >> 153 #endif
282       DrawDisplayLists ();                        154       DrawDisplayLists ();
283       FinishView ();                              155       FinishView ();
284     } else {                                      156     } else {
                                                   >> 157 #ifdef G4DEBUG_VIS_OGL
                                                   >> 158       printf("**************************  G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
                                                   >> 159 #endif
285       // However, union cutaways are implement    160       // However, union cutaways are implemented in DrawDisplayLists, so make
286       // an extra pass...                         161       // an extra pass...
287       if (fVP.IsCutaway() &&                      162       if (fVP.IsCutaway() &&
288           fVP.GetCutawayMode() == G4ViewParame    163           fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
289         ClearView();                              164         ClearView();
290         DrawDisplayLists ();                      165         DrawDisplayLists ();
291         FinishView ();                            166         FinishView ();
                                                   >> 167 #ifdef G4DEBUG_VIS_OGL
                                                   >> 168         printf("***************************  CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
                                                   >> 169 #endif
292       } else { // ADD TO AVOID KernelVisit=1 a    170       } else { // ADD TO AVOID KernelVisit=1 and nothing to display
293         DrawDisplayLists ();                      171         DrawDisplayLists ();
294         FinishView ();                            172         FinishView ();
295       }                                           173       }
296     }                                             174     }
297   }                                               175   }
298                                                   176 
299   if (isRecording()) {                            177   if (isRecording()) {
300     savePPMToTemp();                              178     savePPMToTemp();
301   }                                               179   }
302                                                   180 
303 #if QT_VERSION < 0x060000                      << 181 #ifdef G4DEBUG_VIS_OGL
304   fHasToRepaint = true;                        << 182   printf("G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
305 #endif                                            183 #endif
                                                   >> 184   fHasToRepaint = true;
306 }                                                 185 }
307                                                   186 
308                                                   187 
309 /**                                               188 /**
310    - Lors du resize de la fenetre, on doit non    189    - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
311 */                                                190 */
312 void G4OpenGLStoredQtViewer::resizeGL(            191 void G4OpenGLStoredQtViewer::resizeGL(
313                                       int aWid    192                                       int aWidth
314                                       ,int aHe    193                                       ,int aHeight)
315 {                                                 194 {  
316   // Set new size, it will be update when next    195   // Set new size, it will be update when next Repaint()->SetView() called
317   if ((aWidth > 0) && (aHeight > 0)) {            196   if ((aWidth > 0) && (aHeight > 0)) {
318 #if QT_VERSION < 0x060000                      << 
319     ResizeWindow(aWidth,aHeight);                 197     ResizeWindow(aWidth,aHeight);
320     fHasToRepaint = sizeHasChanged();             198     fHasToRepaint = sizeHasChanged();
321 #else                                          << 
322     ResizeWindow(devicePixelRatio()*aWidth,dev << 
323 #endif                                         << 
324   }                                               199   }
325 }                                                 200 }
326                                                   201 
327                                                   202 
328 // We have to get several case :                  203 // We have to get several case :
329 // - Only activate the windows (mouse click fo    204 // - Only activate the windows (mouse click for example) -> Do not redraw
330 // - resize window -> redraw                      205 // - resize window -> redraw
331 // - try to avoid recompute everything if we d    206 // - try to avoid recompute everything if we do not rescale picture (side is the same)
332                                                   207  
333 void G4OpenGLStoredQtViewer::paintGL()            208 void G4OpenGLStoredQtViewer::paintGL()
334 {                                                 209 {
335 #if QT_VERSION < 0x060000                      << 210 #ifdef G4DEBUG_VIS_OGL
336   updateToolbarAndMouseContextMenu();          << 211   printf("G4OpenGLStoredQtViewer::paintGL \n");
337 #else                                          << 
338   //G.Barrand: don't do any change in the GUI  << 
339 #endif                                            212 #endif
340                                                << 213   if (fIsRepainting) {
341 #if QT_VERSION < 0x060000                      << 214     //    return ;
342   if (fPaintEventLock) {                       << 
343 //    return ;                                 << 
344   }                                            << 
345   fPaintEventLock = true;                      << 
346   if ((getWinWidth() == 0) && (getWinHeight()  << 
347     return;                                    << 
348   }                                               215   }
349                                                << 216   fIsRepainting = true;
350   if (!fQGLWidgetInitialiseCompleted) {        << 217 #ifdef G4DEBUG_VIS_OGL
351     fPaintEventLock = false;                   << 218   printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
                                                   >> 219 #endif
                                                   >> 220   if (!fReadyToPaint) {
                                                   >> 221     fReadyToPaint= true;
352     return;                                       222     return;
353   }                                               223   }
354                                                << 
355   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :       224   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
356   //    WHEN CLICK ON THE FRAME FOR EXAMPLE       225   //    WHEN CLICK ON THE FRAME FOR EXAMPLE
357   //    EXECEPT WHEN MOUSE MOVE EVENT             226   //    EXECEPT WHEN MOUSE MOVE EVENT
358   if ( !fHasToRepaint) {                          227   if ( !fHasToRepaint) {
                                                   >> 228 #if QT_VERSION < 0x040000
                                                   >> 229     if (((getWinWidth() == (unsigned int)width())) &&(getWinHeight() == (unsigned int) height())) { 
                                                   >> 230 #else
359     // L. Garnier : Trap to get the size with     231     // 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,    232     // Tested on Qt4.5 on mac, 4.4 on windows, 4.5 on unbuntu
361     int sw = 0;                                   233     int sw = 0;
362     int sh = 0;                                   234     int sh = 0;
363     if (!isMaximized() && !isFullScreen()) {      235     if (!isMaximized() && !isFullScreen()) {
364       sw = normalGeometry().width();              236       sw = normalGeometry().width();
365       sh = normalGeometry().height();             237       sh = normalGeometry().height();
366     } else {                                      238     } else {
367       sw = frameGeometry().width();               239       sw = frameGeometry().width();
368       sh = frameGeometry().height();              240       sh = frameGeometry().height();
369     }                                             241     }
370     if ((getWinWidth() == (unsigned int)sw) &&    242     if ((getWinWidth() == (unsigned int)sw) &&(getWinHeight() == (unsigned int)sh)) {
                                                   >> 243 #endif
371       return;                                     244       return;
372     }                                             245     }
373   }                                               246   }
374 #else                                          << 247 #ifdef G4DEBUG_VIS_OGL
375   if ((getWinWidth() == 0) && (getWinHeight()  << 248   printf("G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
376 #endif                                         << 
377                                                << 
378 #if QT_VERSION < 0x060000                      << 
379 #else                                          << 
380   InitializeGLView ();                         << 
381 #endif                                            249 #endif
382                                                   250 
383   // Ensure that we really draw the BACK buffe << 
384   glDrawBuffer (GL_BACK);                      << 
385                                                << 
386   SetView();                                      251   SetView();
387                                                << 252 
388   ClearView (); //ok, put the background corre    253   ClearView (); //ok, put the background correct
389   ComputeView();                                  254   ComputeView();
390                                                   255 
391 #if QT_VERSION < 0x060000                      << 
392   fHasToRepaint = false;                          256   fHasToRepaint = false;
393                                                   257 
394   fPaintEventLock = false;                     << 258 #ifdef G4DEBUG_VIS_OGL
                                                   >> 259   printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
395 #endif                                            260 #endif
                                                   >> 261   fIsRepainting = false;
396 }                                                 262 }
397                                                   263 
398 #if QT_VERSION < 0x060000                      << 
399 void G4OpenGLStoredQtViewer::paintEvent(QPaint    264 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
400   if (! fQGLWidgetInitialiseCompleted) {       << 
401     return;                                    << 
402   }                                            << 
403   // Force a repaint next time if the FRAMEBUF << 
404   fHasToRepaint = isFramebufferReady();        << 
405   if ( fHasToRepaint) {                           265   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();                                   266     updateGL();
412 #else                                          << 
413     // Not sure this is correct....            << 
414     paintGL();                                 << 
415 #endif                                         << 
416   }                                               267   }
417 }                                                 268 }
418 #endif                                         << 
419                                                   269 
420 void G4OpenGLStoredQtViewer::mousePressEvent(Q    270 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
421 {                                                 271 {
422   G4MousePressEvent(event);                       272   G4MousePressEvent(event);
423 }                                                 273 }
424                                                   274 
425 void G4OpenGLStoredQtViewer::keyPressEvent (QK    275 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event) 
426 {                                                 276 {
427   G4keyPressEvent(event);                         277   G4keyPressEvent(event);
428 }                                                 278 }
429                                                   279 
430 void G4OpenGLStoredQtViewer::keyReleaseEvent ( << 280 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event) 
431 {                                              << 
432   G4keyReleaseEvent(event);                    << 
433 }                                              << 
434                                                << 
435 void G4OpenGLStoredQtViewer::wheelEvent (QWhee << 
436 {                                                 281 {
437   G4wheelEvent(event);                            282   G4wheelEvent(event);
438 }                                                 283 }
439                                                   284 
440 #if QT_VERSION < 0x060000                      << 285 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *) 
441 void G4OpenGLStoredQtViewer::showEvent (QShowE << 
442 {                                                 286 {
443   if (fQGLWidgetInitialiseCompleted) {         << 287   fHasToRepaint = true;
444     fHasToRepaint = true;                      << 
445   }                                            << 
446 }                                                 288 }
447 #endif                                         << 
448                                                   289 
449 /**                                               290 /**
450  * This function was build in order to make a     291  * 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    292  * It was think to build a rubberband on the zoom area, but never work fine
452  */                                               293  */
453 void G4OpenGLStoredQtViewer::mouseDoubleClickE    294 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
454 {                                                 295 {
455   G4MouseDoubleClickEvent();                      296   G4MouseDoubleClickEvent();
456 }                                                 297 }
457                                                   298 
458 void G4OpenGLStoredQtViewer::mouseReleaseEvent << 299 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *)
459 {                                                 300 {
460   G4MouseReleaseEvent(event);                  << 301   G4MouseReleaseEvent();
461 }                                                 302 }
462                                                   303 
463 void G4OpenGLStoredQtViewer::mouseMoveEvent(QM    304 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
464 {                                                 305 {
465   G4MouseMoveEvent(event);                        306   G4MouseMoveEvent(event);
466 }                                                 307 }
467                                                   308 
468                                                   309 
469 void G4OpenGLStoredQtViewer::contextMenuEvent(    310 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
470 {                                                 311 {
471   G4manageContextMenuEvent(e);                    312   G4manageContextMenuEvent(e);
472 }                                                 313 }
473                                                   314 
474 void G4OpenGLStoredQtViewer::updateQWidget() {    315 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;                            316   fHasToRepaint= true;
486   // Will really update the widget by calling  << 317   updateGL();
487   // The widget's rendering context will becom << 318   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 }                                                 319 }
501                                                   320 
502 void G4OpenGLStoredQtViewer::ShowView ()       << 321 void G4OpenGLStoredQtViewer::ShowView (
                                                   >> 322 ) 
                                                   >> 323 //////////////////////////////////////////////////////////////////////////////
                                                   >> 324 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
503 {                                                 325 {
                                                   >> 326 #if QT_VERSION < 0x040000
                                                   >> 327   setActiveWindow();
                                                   >> 328 #else
504   activateWindow();                               329   activateWindow();
505 #if 0x060000 <= QT_VERSION                     << 
506   ((QApplication*)G4Qt::getInstance ())->proce << 
507 #endif                                            330 #endif
508 }                                                 331 }
509                                                   332 
510                                                << 333 #endif
511 void G4OpenGLStoredQtViewer::DisplayTimePOColo << 
512 G4Colour& c,                                   << 
513 size_t poIndex) {                              << 
514   c = getColorForPoIndex((int)poIndex);        << 
515 }                                              << 
516                                                   334