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