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] [ 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/G4OpenGLImmediateQtViewer.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc (Version 3.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 //                                                
 29 // Class G4OpenGLImmediateQtViewer : a class d    
 30 //                                G4OpenGLImme    
 31                                                   
 32 #include "G4OpenGLImmediateQtViewer.hh"           
 33 #include "G4OpenGLImmediateSceneHandler.hh"       
 34                                                   
 35 #include "G4ios.hh"                               
 36 #include "G4Threading.hh"                         
 37 #include <qapplication.h>                         
 38 #include <qtabwidget.h>                           
 39 #if 0x060000 <= QT_VERSION                        
 40 #include "G4Qt.hh"                                
 41 #endif                                            
 42                                                   
 43 G4OpenGLImmediateQtViewer::G4OpenGLImmediateQt    
 44 (G4OpenGLImmediateSceneHandler& sceneHandler,     
 45  const G4String&  name):                          
 46   G4VViewer (sceneHandler, sceneHandler.Increm    
 47   G4OpenGLViewer (sceneHandler),                  
 48   G4OpenGLQtViewer (sceneHandler),                
 49   G4OpenGLImmediateViewer (sceneHandler)          
 50 {                                                 
 51 #if QT_VERSION < 0x060000                         
 52   fQGLWidgetInitialiseCompleted = false;          
 53                                                   
 54   setFocusPolicy(Qt::StrongFocus); // enable k    
 55   fHasToRepaint = false;                          
 56   fPaintEventLock = false;                        
 57   fUpdateGLLock = false;                          
 58                                                   
 59   if (fViewId < 0) return;  // In case error i    
 60 #else                                             
 61   setFocusPolicy(Qt::StrongFocus); // enable k    
 62 #endif                                            
 63 }                                                 
 64                                                   
 65 G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQ    
 66                                                   
 67 void G4OpenGLImmediateQtViewer::Initialise() {    
 68 #if QT_VERSION < 0x060000                         
 69                                                   
 70   fQGLWidgetInitialiseCompleted = false;          
 71   CreateMainWindow (this,QString(GetName()));     
 72                                                   
 73   makeCurrent();                                  
 74   glDrawBuffer (GL_BACK);                         
 75                                                   
 76   // set the good tab active                      
 77   if (G4QGLWidgetType::parentWidget()) {          
 78     auto *parentTab = dynamic_cast<QTabWidget*    
 79     if (parentTab) {                              
 80       parentTab->setCurrentIndex(parentTab->co    
 81     }                                             
 82   }                                               
 83                                                   
 84   fQGLWidgetInitialiseCompleted = true;           
 85 #else                                             
 86   CreateMainWindow (this,QString(GetName()));     
 87   // Set jpg as default export format for Qt v    
 88   setExportImageFormat("jpg");                    
 89 #endif                                            
 90 }                                                 
 91                                                   
 92 #if QT_VERSION < 0x060000                         
 93 void G4OpenGLImmediateQtViewer::initializeGL (    
 94                                                   
 95   InitializeGLView ();                            
 96                                                   
 97   // If a double buffer context has been force    
 98   // back buffer for this OpenGLImmediate view    
 99   //  glDrawBuffer (GL_FRONT); // FIXME : Ne m    
100                                                   
101   if (fSceneHandler.GetScene() == 0) {            
102     fHasToRepaint =false;                         
103   } else {                                        
104     fHasToRepaint =true;                          
105   }                                               
106                                                   
107   // Set the component visible                    
108                                                   
109   // and update it immediatly before wait for     
110 //  QCoreApplication::sendPostedEvents () ;       
111                                                   
112   // Set jpg as default export format for Qt v    
113   setExportImageFormat("jpg");                    
114 }                                                 
115 #endif                                            
116                                                   
117                                                   
118 void  G4OpenGLImmediateQtViewer::DrawView() {     
119 #if QT_VERSION < 0x060000                         
120 #else                                             
121   if(IsGettingPickInfos()) {                      
122     paintGL();                                    
123     return;                                       
124   }                                               
125 #endif                                            
126   if (G4Threading::IsMasterThread()) {            
127     updateQWidget();                              
128   }                                               
129 }                                                 
130                                                   
131                                                   
132 void G4OpenGLImmediateQtViewer::ComputeView ()    
133                                                   
134 #if QT_VERSION < 0x060000                         
135   makeCurrent();                                  
136   // If a double buffer context has been force    
137   // back buffer for this OpenGLImmediate view    
138   //  glDrawBuffer (GL_FRONT);                    
139 #endif                                            
140                                                   
141   G4ViewParameters::DrawingStyle dstyle = GetV    
142                                                   
143   if(dstyle!=G4ViewParameters::hlr &&             
144      haloing_enabled) {                           
145                                                   
146     HaloingFirstPass ();                          
147     NeedKernelVisit ();                           
148     ProcessView ();                               
149     FinishView();                                 
150     HaloingSecondPass ();                         
151                                                   
152   }                                               
153                                                   
154   NeedKernelVisit ();  // Always need to visit    
155   ProcessView ();                                 
156                                                   
157   if (isRecording()) {                            
158     savePPMToTemp();                              
159   }                                               
160                                                   
161 #if QT_VERSION < 0x060000                         
162   fHasToRepaint = true;                           
163 #endif                                            
164 }                                                 
165                                                   
166 /**                                               
167    - Lors du resize de la fenetre, on doit non    
168 */                                                
169 void G4OpenGLImmediateQtViewer::resizeGL(         
170  int aWidth                                       
171 ,int aHeight)                                     
172 {                                                 
173   if ((aWidth > 0) && (aHeight > 0)) {            
174 #if QT_VERSION < 0x060000                         
175     ResizeWindow(aWidth,aHeight);                 
176     fHasToRepaint = sizeHasChanged();             
177 #else                                             
178     ResizeWindow(devicePixelRatio()*aWidth,dev    
179 #endif                                            
180   }                                               
181 }                                                 
182                                                   
183                                                   
184 void G4OpenGLImmediateQtViewer::paintGL()         
185 {                                                 
186 #if QT_VERSION < 0x060000                         
187   updateToolbarAndMouseContextMenu();             
188 #else                                             
189   //G.Barrand: don't do any change in the GUI     
190 #endif                                            
191                                                   
192 #if QT_VERSION < 0x060000                         
193   if (fPaintEventLock) {                          
194 //    return ;                                    
195   }                                               
196   if (!fQGLWidgetInitialiseCompleted) {           
197     fPaintEventLock = false;                      
198     return;                                       
199   }                                               
200   if ((getWinWidth() == 0) && (getWinHeight()     
201       return;                                     
202   }                                               
203                                                   
204   // DO NOT RESIZE IF SIZE HAS NOT CHANGE         
205   if ( !fHasToRepaint) {                          
206     // L. Garnier : Trap to get the size with     
207     // Tested on Qt4.5 on mac, 4.4 on windows,    
208     int sw = 0;                                   
209     int sh = 0;                                   
210     if (!isMaximized() && !isFullScreen()) {      
211       sw = normalGeometry().width();              
212       sh = normalGeometry().height();             
213     } else {                                      
214       sw = frameGeometry().width();               
215       sh = frameGeometry().height();              
216     }                                             
217     if ((getWinWidth() == (unsigned int)sw) &&    
218       return;                                     
219                                                   
220     } else if ((sw == 0) && (sh == 0)) { // NO    
221       if (((getWinWidth() == (unsigned int)wid    
222         return;                                   
223       }                                           
224     }                                             
225   }                                               
226 #else                                             
227   if ((getWinWidth() == 0) && (getWinHeight()     
228 #endif                                            
229                                                   
230 #if QT_VERSION < 0x060000                         
231 #else                                             
232   InitializeGLView ();                            
233   glDrawBuffer (GL_BACK);                         
234 #endif                                            
235                                                   
236   SetView();                                      
237                                                   
238   ClearView (); //ok, put the background corre    
239   ComputeView();                                  
240                                                   
241 #if QT_VERSION < 0x060000                         
242   fHasToRepaint = false; // could be set to fa    
243                                                   
244   fPaintEventLock = false;                        
245 #endif                                            
246 }                                                 
247                                                   
248 void G4OpenGLImmediateQtViewer::mousePressEven    
249 {                                                 
250   G4MousePressEvent(event);                       
251 }                                                 
252                                                   
253 void G4OpenGLImmediateQtViewer::keyPressEvent     
254 {                                                 
255   G4keyPressEvent(event);                         
256 }                                                 
257                                                   
258 void G4OpenGLImmediateQtViewer::keyReleaseEven    
259 {                                                 
260   G4keyReleaseEvent(event);                       
261 }                                                 
262                                                   
263 void G4OpenGLImmediateQtViewer::wheelEvent (QW    
264 {                                                 
265   G4wheelEvent(event);                            
266 }                                                 
267                                                   
268 #if QT_VERSION < 0x060000                         
269 void G4OpenGLImmediateQtViewer::showEvent (QSh    
270 {                                                 
271   if (fQGLWidgetInitialiseCompleted) {            
272     fHasToRepaint = true;                         
273   }                                               
274 }                                                 
275 #endif                                            
276                                                   
277 /**                                               
278  * This function was build in order to make a     
279  * It was think to build a rubberband on the z    
280  */                                               
281 void G4OpenGLImmediateQtViewer::mouseDoubleCli    
282 {                                                 
283   G4MouseDoubleClickEvent();                      
284 }                                                 
285                                                   
286 void G4OpenGLImmediateQtViewer::mouseReleaseEv    
287 {                                                 
288   G4MouseReleaseEvent(event);                     
289 }                                                 
290                                                   
291 void G4OpenGLImmediateQtViewer::mouseMoveEvent    
292 {                                                 
293   G4MouseMoveEvent(event);                        
294 }                                                 
295                                                   
296                                                   
297 void G4OpenGLImmediateQtViewer::contextMenuEve    
298 {                                                 
299   G4manageContextMenuEvent(e);                    
300 }                                                 
301                                                   
302 #if QT_VERSION < 0x060000                         
303 void G4OpenGLImmediateQtViewer::paintEvent(QPa    
304   if (! fQGLWidgetInitialiseCompleted) {          
305     return;                                       
306   }                                               
307   // Force a repaint next time if the FRAMEBUF    
308   fHasToRepaint = isFramebufferReady();           
309   if ( fHasToRepaint) {                           
310 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))      
311     updateGL();                                   
312 #else                                             
313     // Not sure this is correct....               
314     paintGL();                                    
315 #endif                                            
316   }                                               
317 }                                                 
318 #endif                                            
319                                                   
320                                                   
321 void G4OpenGLImmediateQtViewer::updateQWidget(    
322 #if QT_VERSION < 0x060000                         
323   if (fUpdateGLLock) {                            
324     return;                                       
325   }                                               
326                                                   
327   if (! isCurrentWidget()){                       
328     return;                                       
329   }                                               
330                                                   
331   fUpdateGLLock = true;                           
332   fHasToRepaint= true;                            
333   repaint();                                      
334   updateViewerPropertiesTableWidget();            
335   updateSceneTreeWidget();                        
336   fUpdateGLLock= false;                           
337 #else                                             
338   //if (!isCurrentWidget()) return; //G.Barran    
339   //G.Barrand: don't do any change in the GUI     
340   update();                                       
341 #endif                                            
342 }                                                 
343                                                   
344                                                   
345 void G4OpenGLImmediateQtViewer::ShowView ()       
346 {                                                 
347 #if QT_VERSION < 0x060000                         
348   fHasToRepaint = true;                           
349   activateWindow();                               
350 #else                                             
351   activateWindow();                               
352   ((QApplication*)G4Qt::getInstance ())->proce    
353 #endif                                            
354 }                                                 
355