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 10.7.p3)


  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 //                                                 27 //
 28 //                                                 28 //
 29 // Class G4OpenGLStoredQtViewer : a class deri     29 // Class G4OpenGLStoredQtViewer : a class derived from G4OpenGLQtViewer and
 30 //                                G4OpenGLStor     30 //                                G4OpenGLStoredViewer.
 31                                                    31 
                                                   >>  32 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
                                                   >>  33 
 32 #include "G4OpenGLStoredQtViewer.hh"               34 #include "G4OpenGLStoredQtViewer.hh"
 33                                                    35 
 34 #include "G4OpenGLStoredSceneHandler.hh"           36 #include "G4OpenGLStoredSceneHandler.hh"
 35 #include "G4ios.hh"                                37 #include "G4ios.hh"
                                                   >>  38 #ifdef G4MULTITHREADED
 36 #include "G4Threading.hh"                          39 #include "G4Threading.hh"
 37 #include "G4UIQt.hh"                           << 
 38 #if 0x060000 <= QT_VERSION                     << 
 39 #include "G4Qt.hh"                             << 
 40 #endif                                             40 #endif
 41                                                    41 
 42 #include <qapplication.h>                          42 #include <qapplication.h>
 43 #include <qtabwidget.h>                            43 #include <qtabwidget.h>
 44                                                    44 
 45 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer     45 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
 46 (G4OpenGLStoredSceneHandler& sceneHandler,         46 (G4OpenGLStoredSceneHandler& sceneHandler,
 47  const G4String&  name):                           47  const G4String&  name):
 48   G4VViewer (sceneHandler, sceneHandler.Increm     48   G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
 49   G4OpenGLViewer (sceneHandler),                   49   G4OpenGLViewer (sceneHandler),
 50   G4OpenGLQtViewer (sceneHandler),                 50   G4OpenGLQtViewer (sceneHandler),
 51   G4OpenGLStoredViewer (sceneHandler),             51   G4OpenGLStoredViewer (sceneHandler),             // FIXME : gerer le pb du parent !
 52   G4QGLWidgetType()                            <<  52   QGLWidget()
 53 {                                                  53 {
 54   if (fViewId < 0) return;  // In case error i << 
 55                                                << 
 56 #if QT_VERSION < 0x060000                      << 
 57   fQGLWidgetInitialiseCompleted = false;           54   fQGLWidgetInitialiseCompleted = false;
 58                                                    55 
 59     // Indicates that the widget has no backgr     56     // Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted. Note: Unlike WA_OpaquePaintEvent, newly exposed areas are never filled with the background (e.g., after showing a window for the first time the user can see "through" it until the application processes the paint events). This flag is set or cleared by the widget's author.
 60   G4QGLWidgetType::setAttribute (Qt::WA_NoSyst <<  57   QGLWidget::setAttribute (Qt::WA_NoSystemBackground);
 61                                                    58 
 62   setFocusPolicy(Qt::StrongFocus); // enable k     59   setFocusPolicy(Qt::StrongFocus); // enable keybord events
 63   fHasToRepaint = false;                           60   fHasToRepaint = false;
 64   fPaintEventLock = false;                         61   fPaintEventLock = false;
 65   fUpdateGLLock = false;                           62   fUpdateGLLock = false;
 66 #else                                          << 
 67   // Indicates that the widget has no backgrou << 
 68   G4QGLWidgetType::setAttribute (Qt::WA_NoSyst << 
 69                                                    63 
 70   setFocusPolicy(Qt::StrongFocus); // enable k <<  64   if (fViewId < 0) return;  // In case error in base class instantiation.
 71 #endif                                         << 
 72 }                                                  65 }
 73                                                    66 
 74 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewe <<  67 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
                                                   >>  68   makeCurrent();
                                                   >>  69   // this is connect to the Dialog for deleting it properly
                                                   >>  70   // when close event.
                                                   >>  71   //   ((QDialog*)window())->reject();
                                                   >>  72 }
 75                                                    73 
 76 void G4OpenGLStoredQtViewer::Initialise() {        74 void G4OpenGLStoredQtViewer::Initialise() {
 77 #if QT_VERSION < 0x060000                      <<  75   makeCurrent();
 78                                                    76 
 79   fQGLWidgetInitialiseCompleted = false;           77   fQGLWidgetInitialiseCompleted = false;
 80   CreateMainWindow (this,QString(GetName()));      78   CreateMainWindow (this,QString(GetName()));
 81                                                    79 
 82   makeCurrent();                               << 
 83   glDrawBuffer (GL_BACK);                          80   glDrawBuffer (GL_BACK);
 84                                                    81 
 85    // set the good tab active                      82    // set the good tab active
 86   if (G4QGLWidgetType::parentWidget()) {       <<  83   if (QGLWidget::parentWidget()) {
 87     auto *parentTab = dynamic_cast<QTabWidget* <<  84     QTabWidget *parentTab = dynamic_cast<QTabWidget*> (QGLWidget::parentWidget()->parent()) ;
 88     if (parentTab) {                               85     if (parentTab) {
 89       parentTab->setCurrentIndex(parentTab->co     86       parentTab->setCurrentIndex(parentTab->count()-1);
 90     }                                              87     }
 91   }                                                88   }
 92                                                    89   
 93   fQGLWidgetInitialiseCompleted = true;            90   fQGLWidgetInitialiseCompleted = true;
 94 #else                                          << 
 95   CreateMainWindow (this,QString(GetName()));  << 
 96   // Set jpg as default export format for Qt v << 
 97   setExportImageFormat("jpg");                 << 
 98 #endif                                         << 
 99 }                                                  91 }
100                                                    92 
101 #if QT_VERSION < 0x060000                      << 
102 void G4OpenGLStoredQtViewer::initializeGL () {     93 void G4OpenGLStoredQtViewer::initializeGL () {
103                                                    94 
104   InitializeGLView ();                             95   InitializeGLView ();
105                                                    96 
106   if (fSceneHandler.GetScene() == 0) {             97   if (fSceneHandler.GetScene() == 0) {
107     fHasToRepaint =false;                          98     fHasToRepaint =false;
108   } else {                                         99   } else {
109     fHasToRepaint =true;                          100     fHasToRepaint =true;
110   }                                               101   }
111                                                   102   
112    // Set the component visible                   103    // Set the component visible
113   //   setVisible(true) ;                         104   //   setVisible(true) ;
114                                                   105 
115   // Set jpg as default export format for Qt v << 
116   setExportImageFormat("jpg");                 << 
117 }                                                 106 }
118 #endif                                         << 
119                                                   107 
120 G4bool G4OpenGLStoredQtViewer::CompareForKerne    108 G4bool G4OpenGLStoredQtViewer::CompareForKernelVisit(G4ViewParameters& lastVP)
121 {                                                 109 {
122   // Identical to G4OpenGLStoredViewer::Compar    110   // Identical to G4OpenGLStoredViewer::CompareForKernelVisit except
123   // for checking of VisAttributesModifiers, b    111   // for checking of VisAttributesModifiers, because
124   // G4OpenGLStoredQtViewer keeps track of its    112   // G4OpenGLStoredQtViewer keeps track of its own touchable
125   // modifiers (fTreeItemModels, etc.).           113   // modifiers (fTreeItemModels, etc.).
126   if (                                            114   if (
127       (lastVP.GetDrawingStyle ()    != fVP.Get    115       (lastVP.GetDrawingStyle ()    != fVP.GetDrawingStyle ())    ||
128       (lastVP.GetNumberOfCloudPoints()  != fVP    116       (lastVP.GetNumberOfCloudPoints()  != fVP.GetNumberOfCloudPoints())  ||
129       (lastVP.IsAuxEdgeVisible ()   != fVP.IsA    117       (lastVP.IsAuxEdgeVisible ()   != fVP.IsAuxEdgeVisible ())   ||
130       (lastVP.IsCulling ()          != fVP.IsC    118       (lastVP.IsCulling ()          != fVP.IsCulling ())          ||
131       (lastVP.IsCullingInvisible () != fVP.IsC    119       (lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
132       (lastVP.IsDensityCulling ()   != fVP.IsD    120       (lastVP.IsDensityCulling ()   != fVP.IsDensityCulling ())   ||
133       (lastVP.IsCullingCovered ()   != fVP.IsC    121       (lastVP.IsCullingCovered ()   != fVP.IsCullingCovered ())   ||
134       (lastVP.GetCBDAlgorithmNumber() !=          122       (lastVP.GetCBDAlgorithmNumber() !=
135        fVP.GetCBDAlgorithmNumber())               123        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    124       (lastVP.IsSection ()          != fVP.IsSection ())          ||
142       // Section (DCUT) is NOT implemented loc << 125       // Section (DCUT) implemented locally.  But still need to visit
143       // (lastVP.IsCutaway ()          != fVP. << 126       // kernel if status changes so that back plane culling can be
144       // Cutaways are implemented locally so w << 127       // switched.
                                                   >> 128       (lastVP.IsCutaway ()          != fVP.IsCutaway ())          ||
                                                   >> 129       // Cutaways implemented locally.  But still need to visit kernel
                                                   >> 130       // if status changes so that back plane culling can be switched.
145       (lastVP.IsExplode ()          != fVP.IsE    131       (lastVP.IsExplode ()          != fVP.IsExplode ())          ||
146       (lastVP.GetNoOfSides ()       != fVP.Get    132       (lastVP.GetNoOfSides ()       != fVP.GetNoOfSides ())       ||
147       (lastVP.GetGlobalMarkerScale()    != fVP    133       (lastVP.GetGlobalMarkerScale()    != fVP.GetGlobalMarkerScale())    ||
148       (lastVP.GetGlobalLineWidthScale() != fVP    134       (lastVP.GetGlobalLineWidthScale() != fVP.GetGlobalLineWidthScale()) ||
149       (lastVP.IsMarkerNotHidden ()  != fVP.IsM    135       (lastVP.IsMarkerNotHidden ()  != fVP.IsMarkerNotHidden ())  ||
150       (lastVP.GetDefaultVisAttributes()->GetCo    136       (lastVP.GetDefaultVisAttributes()->GetColour() !=
151        fVP.GetDefaultVisAttributes()->GetColou    137        fVP.GetDefaultVisAttributes()->GetColour())                ||
152       (lastVP.GetDefaultTextVisAttributes()->G    138       (lastVP.GetDefaultTextVisAttributes()->GetColour() !=
153        fVP.GetDefaultTextVisAttributes()->GetC    139        fVP.GetDefaultTextVisAttributes()->GetColour())            ||
154       (lastVP.GetBackgroundColour ()!= fVP.Get    140       (lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
155       (lastVP.IsPicking ()          != fVP.IsP << 141       (lastVP.IsPicking ()          != fVP.IsPicking ()))
156       (lastVP.IsSpecialMeshRendering() != fVP. << 
157       (lastVP.GetSpecialMeshRenderingOption()  << 
158     return true;                                  142     return true;
159                                                   143 
160   // Don't check VisAttributesModifiers if thi    144   // Don't check VisAttributesModifiers if this comparison has been
161   // initiated by a mouse interaction on the s    145   // initiated by a mouse interaction on the scene tree.
162   if (fMouseOnSceneTree) {                        146   if (fMouseOnSceneTree) {
163     // Reset the flag.                            147     // Reset the flag.
164     fMouseOnSceneTree = false;                    148     fMouseOnSceneTree = false;
165   } else {                                        149   } else {
166     // Not initiated by a mouse so compare for    150     // Not initiated by a mouse so compare for kernel visit.
167     if (lastVP.GetVisAttributesModifiers() !=     151     if (lastVP.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) {
168       return true;                                152       return true;
169     }                                             153     }
170   }                                               154   }
171                                                   155 
172   if (lastVP.IsDensityCulling () &&               156   if (lastVP.IsDensityCulling () &&
173       (lastVP.GetVisibleDensity () != fVP.GetV    157       (lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ()))
174     return true;                                  158     return true;
175                                                   159 
176 //  /*****************************************    160 //  /**************************************************************
177 //   If section (DCUT) is implemented locally,    161 //   If section (DCUT) is implemented locally, comment this out.
178   if (lastVP.IsSection () &&                      162   if (lastVP.IsSection () &&
179       (lastVP.GetSectionPlane () != fVP.GetSec    163       (lastVP.GetSectionPlane () != fVP.GetSectionPlane ()))
180     return true;                                  164     return true;
181 //   *****************************************    165 //   ***************************************************************/
182                                                   166 
183   /*******************************************    167   /**************************************************************
184    If cutaways are implemented locally, commen    168    If cutaways are implemented locally, comment this out.
185    if (lastVP.IsCutaway ()) {                     169    if (lastVP.IsCutaway ()) {
186    if (vp.GetCutawayMode() != fVP.GetCutawayMo << 
187    if (lastVP.GetCutawayPlanes ().size () !=      170    if (lastVP.GetCutawayPlanes ().size () !=
188    fVP.GetCutawayPlanes ().size ()) return tru    171    fVP.GetCutawayPlanes ().size ()) return true;
189    for (size_t i = 0; i < lastVP.GetCutawayPla    172    for (size_t i = 0; i < lastVP.GetCutawayPlanes().size(); ++i)
190    if (lastVP.GetCutawayPlanes()[i] != fVP.Get    173    if (lastVP.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
191    return true;                                   174    return true;
192    }                                              175    }
193    *******************************************    176    ***************************************************************/
194                                                   177 
195   if (lastVP.GetCBDAlgorithmNumber() > 0) {       178   if (lastVP.GetCBDAlgorithmNumber() > 0) {
196     if (lastVP.GetCBDParameters().size() != fV    179     if (lastVP.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
197     else if (lastVP.GetCBDParameters() != fVP.    180     else if (lastVP.GetCBDParameters() != fVP.GetCBDParameters()) return true;
198   }                                               181   }
199                                                   182 
200   if (lastVP.IsExplode () &&                      183   if (lastVP.IsExplode () &&
201       (lastVP.GetExplodeFactor () != fVP.GetEx    184       (lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
202     return true;                                  185     return true;
203                                                   186 
204   if (lastVP.IsSpecialMeshRendering() &&       << 
205       (lastVP.GetSpecialMeshVolumes() != fVP.G << 
206     return true;                               << 
207                                                << 
208   return false;                                   187   return false;
209 }                                                 188 }
210                                                   189 
211 G4bool G4OpenGLStoredQtViewer::POSelected(size    190 G4bool G4OpenGLStoredQtViewer::POSelected(size_t POListIndex)
212 {                                                 191 {
213   return isTouchableVisible((int)POListIndex); << 192   return isTouchableVisible(POListIndex);
214 }                                                 193 }
215                                                   194 
216 G4bool G4OpenGLStoredQtViewer::TOSelected(size    195 G4bool G4OpenGLStoredQtViewer::TOSelected(size_t)
217 {                                                 196 {
218   return true;                                    197   return true;
219 }                                                 198 }
220                                                   199 
221 void G4OpenGLStoredQtViewer::DrawView () {        200 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();                                201   updateQWidget();
231 #else                                          << 
232   if (G4Threading::IsMasterThread()) {         << 
233     updateQWidget();                           << 
234   } else {                                     << 
235     update(); //G.Barrand: updateQWidget() ind << 
236   }                                            << 
237 #endif                                         << 
238 }                                                 202 }
239                                                   203 
240 void G4OpenGLStoredQtViewer::ComputeView () {     204 void G4OpenGLStoredQtViewer::ComputeView () {
241                                                   205 
242 #if QT_VERSION < 0x060000                      << 
243   makeCurrent();                                  206   makeCurrent();
244 #endif                                         << 
245                                                << 
246   G4ViewParameters::DrawingStyle dstyle = GetV    207   G4ViewParameters::DrawingStyle dstyle = GetViewParameters().GetDrawingStyle();
247                                                   208 
248   //Make sure current viewer is attached and c    209   //Make sure current viewer is attached and clean...
249                                                   210 
250   //See if things have changed from last time     211   //See if things have changed from last time and remake if necessary...
251   // The fNeedKernelVisit flag might have been    212   // The fNeedKernelVisit flag might have been set by the user in
252   // /vis/viewer/rebuild, but if not, make dec    213   // /vis/viewer/rebuild, but if not, make decision and set flag only
253   // if necessary...                              214   // if necessary...
254   if (!fNeedKernelVisit) {                        215   if (!fNeedKernelVisit) {
255     KernelVisitDecision ();                       216     KernelVisitDecision ();
256   }                                               217   }
257   fLastVP = fVP;                                  218   fLastVP = fVP;
258   G4bool kernelVisitWasNeeded = fNeedKernelVis    219   G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
259   ProcessView ();                                 220   ProcessView ();
260                                                   221    
261   if (kernelVisitWasNeeded) {                     222   if (kernelVisitWasNeeded) {
262     displaySceneTreeComponent();                  223     displaySceneTreeComponent();
263   }                                               224   }
264                                                   225 
265   if(dstyle!=G4ViewParameters::hlr &&             226   if(dstyle!=G4ViewParameters::hlr &&
266      haloing_enabled) {                           227      haloing_enabled) {
267                                                   228 
268     HaloingFirstPass ();                          229     HaloingFirstPass ();
269     DrawDisplayLists ();                          230     DrawDisplayLists ();
270     glFlush ();                                   231     glFlush ();
271                                                   232 
272     HaloingSecondPass ();                         233     HaloingSecondPass ();
273                                                   234 
274     DrawDisplayLists ();                          235     DrawDisplayLists ();
275     FinishView ();                                236     FinishView ();
276                                                   237 
277   } else {                                        238   } else {
278                                                   239      
279     // If kernel visit was needed, drawing and    240     // If kernel visit was needed, drawing and FinishView will already
280     // have been done, so...                      241     // have been done, so...
281     if (!kernelVisitWasNeeded) {                  242     if (!kernelVisitWasNeeded) {
282       DrawDisplayLists ();                        243       DrawDisplayLists ();
283       FinishView ();                              244       FinishView ();
284     } else {                                      245     } else {
285       // However, union cutaways are implement    246       // However, union cutaways are implemented in DrawDisplayLists, so make
286       // an extra pass...                         247       // an extra pass...
287       if (fVP.IsCutaway() &&                      248       if (fVP.IsCutaway() &&
288           fVP.GetCutawayMode() == G4ViewParame    249           fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
289         ClearView();                              250         ClearView();
290         DrawDisplayLists ();                      251         DrawDisplayLists ();
291         FinishView ();                            252         FinishView ();
292       } else { // ADD TO AVOID KernelVisit=1 a    253       } else { // ADD TO AVOID KernelVisit=1 and nothing to display
293         DrawDisplayLists ();                      254         DrawDisplayLists ();
294         FinishView ();                            255         FinishView ();
295       }                                           256       }
296     }                                             257     }
297   }                                               258   }
298                                                   259 
299   if (isRecording()) {                            260   if (isRecording()) {
300     savePPMToTemp();                              261     savePPMToTemp();
301   }                                               262   }
302                                                   263 
303 #if QT_VERSION < 0x060000                      << 
304   fHasToRepaint = true;                           264   fHasToRepaint = true;
305 #endif                                         << 
306 }                                                 265 }
307                                                   266 
308                                                   267 
309 /**                                               268 /**
310    - Lors du resize de la fenetre, on doit non    269    - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
311 */                                                270 */
312 void G4OpenGLStoredQtViewer::resizeGL(            271 void G4OpenGLStoredQtViewer::resizeGL(
313                                       int aWid    272                                       int aWidth
314                                       ,int aHe    273                                       ,int aHeight)
315 {                                                 274 {  
316   // Set new size, it will be update when next    275   // Set new size, it will be update when next Repaint()->SetView() called
317   if ((aWidth > 0) && (aHeight > 0)) {            276   if ((aWidth > 0) && (aHeight > 0)) {
318 #if QT_VERSION < 0x060000                      << 
319     ResizeWindow(aWidth,aHeight);                 277     ResizeWindow(aWidth,aHeight);
320     fHasToRepaint = sizeHasChanged();             278     fHasToRepaint = sizeHasChanged();
321 #else                                          << 
322     ResizeWindow(devicePixelRatio()*aWidth,dev << 
323 #endif                                         << 
324   }                                               279   }
325 }                                                 280 }
326                                                   281 
327                                                   282 
328 // We have to get several case :                  283 // We have to get several case :
329 // - Only activate the windows (mouse click fo    284 // - Only activate the windows (mouse click for example) -> Do not redraw
330 // - resize window -> redraw                      285 // - resize window -> redraw
331 // - try to avoid recompute everything if we d    286 // - try to avoid recompute everything if we do not rescale picture (side is the same)
332                                                   287  
333 void G4OpenGLStoredQtViewer::paintGL()            288 void G4OpenGLStoredQtViewer::paintGL()
334 {                                                 289 {
335 #if QT_VERSION < 0x060000                      << 
336   updateToolbarAndMouseContextMenu();             290   updateToolbarAndMouseContextMenu();
337 #else                                          << 
338   //G.Barrand: don't do any change in the GUI  << 
339 #endif                                         << 
340                                                   291 
341 #if QT_VERSION < 0x060000                      << 
342   if (fPaintEventLock) {                          292   if (fPaintEventLock) {
343 //    return ;                                    293 //    return ;
344   }                                               294   }
345   fPaintEventLock = true;                         295   fPaintEventLock = true;
346   if ((getWinWidth() == 0) && (getWinHeight()     296   if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
347     return;                                       297     return;
348   }                                               298   }
349                                                   299 
350   if (!fQGLWidgetInitialiseCompleted) {           300   if (!fQGLWidgetInitialiseCompleted) {
351     fPaintEventLock = false;                      301     fPaintEventLock = false;
352     return;                                       302     return;
353   }                                               303   }
354                                                << 
355   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :       304   // DO NOT RESIZE IF SIZE HAS NOT CHANGE :
356   //    WHEN CLICK ON THE FRAME FOR EXAMPLE       305   //    WHEN CLICK ON THE FRAME FOR EXAMPLE
357   //    EXECEPT WHEN MOUSE MOVE EVENT             306   //    EXECEPT WHEN MOUSE MOVE EVENT
358   if ( !fHasToRepaint) {                          307   if ( !fHasToRepaint) {
359     // L. Garnier : Trap to get the size with     308     // 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,    309     // Tested on Qt4.5 on mac, 4.4 on windows, 4.5 on unbuntu
361     int sw = 0;                                   310     int sw = 0;
362     int sh = 0;                                   311     int sh = 0;
363     if (!isMaximized() && !isFullScreen()) {      312     if (!isMaximized() && !isFullScreen()) {
364       sw = normalGeometry().width();              313       sw = normalGeometry().width();
365       sh = normalGeometry().height();             314       sh = normalGeometry().height();
366     } else {                                      315     } else {
367       sw = frameGeometry().width();               316       sw = frameGeometry().width();
368       sh = frameGeometry().height();              317       sh = frameGeometry().height();
369     }                                             318     }
370     if ((getWinWidth() == (unsigned int)sw) &&    319     if ((getWinWidth() == (unsigned int)sw) &&(getWinHeight() == (unsigned int)sh)) {
371       return;                                     320       return;
372     }                                             321     }
373   }                                               322   }
374 #else                                          << 
375   if ((getWinWidth() == 0) && (getWinHeight()  << 
376 #endif                                         << 
377                                                << 
378 #if QT_VERSION < 0x060000                      << 
379 #else                                          << 
380   InitializeGLView ();                         << 
381 #endif                                         << 
382                                                << 
383   // Ensure that we really draw the BACK buffe    323   // Ensure that we really draw the BACK buffer
384   glDrawBuffer (GL_BACK);                         324   glDrawBuffer (GL_BACK);
385                                                   325 
386   SetView();                                      326   SetView();
387                                                   327   
388   ClearView (); //ok, put the background corre    328   ClearView (); //ok, put the background correct
389   ComputeView();                                  329   ComputeView();
390                                                   330 
391 #if QT_VERSION < 0x060000                      << 
392   fHasToRepaint = false;                          331   fHasToRepaint = false;
393                                                   332 
394   fPaintEventLock = false;                        333   fPaintEventLock = false;
395 #endif                                         << 
396 }                                                 334 }
397                                                   335 
398 #if QT_VERSION < 0x060000                      << 
399 void G4OpenGLStoredQtViewer::paintEvent(QPaint    336 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
400   if (! fQGLWidgetInitialiseCompleted) {          337   if (! fQGLWidgetInitialiseCompleted) {
401     return;                                       338     return;
402   }                                               339   }
403   // Force a repaint next time if the FRAMEBUF    340   // Force a repaint next time if the FRAMEBUFFER is not READY
404   fHasToRepaint = isFramebufferReady();           341   fHasToRepaint = isFramebufferReady();
405   if ( fHasToRepaint) {                           342   if ( fHasToRepaint) {
406     // Will really update the widget by callin    343     // Will really update the widget by calling CGLFlushDrawable
407     // The widget's rendering context will bec    344     // The widget's rendering context will become the current context and initializeGL()
408     // will be called if it hasn't already bee    345     // will be called if it hasn't already been called.
409     // Copies the back buffer of a double-buff    346     // Copies the back buffer of a double-buffered context to the front buffer.
410 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))   << 
411     updateGL();                                   347     updateGL();
412 #else                                          << 
413     // Not sure this is correct....            << 
414     paintGL();                                 << 
415 #endif                                         << 
416   }                                               348   }
417 }                                                 349 }
418 #endif                                         << 
419                                                   350 
420 void G4OpenGLStoredQtViewer::mousePressEvent(Q    351 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
421 {                                                 352 {
422   G4MousePressEvent(event);                       353   G4MousePressEvent(event);
423 }                                                 354 }
424                                                   355 
425 void G4OpenGLStoredQtViewer::keyPressEvent (QK    356 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event) 
426 {                                                 357 {
427   G4keyPressEvent(event);                         358   G4keyPressEvent(event);
428 }                                                 359 }
429                                                   360 
430 void G4OpenGLStoredQtViewer::keyReleaseEvent (    361 void G4OpenGLStoredQtViewer::keyReleaseEvent (QKeyEvent * event)
431 {                                                 362 {
432   G4keyReleaseEvent(event);                       363   G4keyReleaseEvent(event);
433 }                                                 364 }
434                                                   365 
435 void G4OpenGLStoredQtViewer::wheelEvent (QWhee    366 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
436 {                                                 367 {
437   G4wheelEvent(event);                            368   G4wheelEvent(event);
438 }                                                 369 }
439                                                   370 
440 #if QT_VERSION < 0x060000                      << 
441 void G4OpenGLStoredQtViewer::showEvent (QShowE    371 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
442 {                                                 372 {
443   if (fQGLWidgetInitialiseCompleted) {            373   if (fQGLWidgetInitialiseCompleted) {
444     fHasToRepaint = true;                         374     fHasToRepaint = true;
445   }                                               375   }
446 }                                                 376 }
447 #endif                                         << 
448                                                   377 
449 /**                                               378 /**
450  * This function was build in order to make a     379  * 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    380  * It was think to build a rubberband on the zoom area, but never work fine
452  */                                               381  */
453 void G4OpenGLStoredQtViewer::mouseDoubleClickE    382 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
454 {                                                 383 {
455   G4MouseDoubleClickEvent();                      384   G4MouseDoubleClickEvent();
456 }                                                 385 }
457                                                   386 
458 void G4OpenGLStoredQtViewer::mouseReleaseEvent    387 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *event)
459 {                                                 388 {
460   G4MouseReleaseEvent(event);                     389   G4MouseReleaseEvent(event);
461 }                                                 390 }
462                                                   391 
463 void G4OpenGLStoredQtViewer::mouseMoveEvent(QM    392 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
464 {                                                 393 {
465   G4MouseMoveEvent(event);                        394   G4MouseMoveEvent(event);
466 }                                                 395 }
467                                                   396 
468                                                   397 
469 void G4OpenGLStoredQtViewer::contextMenuEvent(    398 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
470 {                                                 399 {
471   G4manageContextMenuEvent(e);                    400   G4manageContextMenuEvent(e);
472 }                                                 401 }
473                                                   402 
474 void G4OpenGLStoredQtViewer::updateQWidget() {    403 void G4OpenGLStoredQtViewer::updateQWidget() {
475 #if QT_VERSION < 0x060000                      << 
476   if (fUpdateGLLock) {                            404   if (fUpdateGLLock) {
477     return;                                       405     return;
478   }                                               406   }
479                                                   407   
480   if (! isCurrentWidget()){                       408   if (! isCurrentWidget()){
481     return;                                       409     return;
482   }                                               410   }
483                                                   411 
484   fUpdateGLLock = true;                           412   fUpdateGLLock = true;
485   fHasToRepaint= true;                            413   fHasToRepaint= true;
486   // Will really update the widget by calling     414   // Will really update the widget by calling CGLFlushDrawable
487   // The widget's rendering context will becom    415   // The widget's rendering context will become the current context and initializeGL()
488   // will be called if it hasn't already been     416   // will be called if it hasn't already been called.
489   // Copies the back buffer of a double-buffer    417   // Copies the back buffer of a double-buffered context to the front buffer.
490   repaint(); // will read scene tree state        418   repaint(); // will read scene tree state
491   // updateGL() // From J.Allison picking bran    419   // updateGL() // From J.Allison picking branch
492   updateViewerPropertiesTableWidget();            420   updateViewerPropertiesTableWidget();
493   updateSceneTreeWidget();                        421   updateSceneTreeWidget();
494   fUpdateGLLock = false;                          422   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 }                                                 423 }
501                                                   424 
502 void G4OpenGLStoredQtViewer::ShowView ()       << 425 void G4OpenGLStoredQtViewer::ShowView (
                                                   >> 426 ) 
                                                   >> 427 //////////////////////////////////////////////////////////////////////////////
                                                   >> 428 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
503 {                                                 429 {
                                                   >> 430   //  glFlush ();  // Tentativley offered by JA 29/04/16.
                                                   >> 431   
                                                   >> 432   // Some X servers fail to draw all trajectories, particularly Mac
                                                   >> 433   // XQuartz.  Revisit this at a future date.  Meanwhile, issue an
                                                   >> 434   // extra...
                                                   >> 435   //  ClearView();  // Necessary?  JA 29/04/16 
                                                   >> 436   //  DrawView();   // Necessary?  JA 29/04/16
504   activateWindow();                               437   activateWindow();
505 #if 0x060000 <= QT_VERSION                     << 438   //  glFlush(); // NO NEED and as drawView will already cause a flush
506   ((QApplication*)G4Qt::getInstance ())->proce << 439   // that could do a double flush
507 #endif                                         << 440   
508 }                                                 441 }
509                                                   442 
510                                                   443 
511 void G4OpenGLStoredQtViewer::DisplayTimePOColo    444 void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
512 G4Colour& c,                                      445 G4Colour& c,
513 size_t poIndex) {                                 446 size_t poIndex) {
514   c = getColorForPoIndex((int)poIndex);        << 447   c = getColorForPoIndex(poIndex);
515 }                                                 448 }
                                                   >> 449 
                                                   >> 450 #endif
516                                                   451