Changeset 1242 for trunk/source
- Timestamp:
- Apr 12, 2010, 5:20:43 PM (14 years ago)
- Location:
- trunk/source/visualization
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/GNUmakefile
r1228 r1242 26 26 27 27 # For Debug mode 28 #CPPFLAGS += -DG4DEBUG_VIS_OGL28 CPPFLAGS += -DG4DEBUG_VIS_OGL 29 29 # CPPFLAGS += -DG4DEBUG_VIS_OI 30 30 # CPPFLAGS += -DG4DEBUG_VIS_MANAGEMENT 31 31 32 32 33 ifdef G4VIS_BUILD -
trunk/source/visualization/OpenGL/GNUmakefile
r1233 r1242 12 12 # For debug mode 13 13 CPPFLAGS += -DG4DEBUG_VIS_OGL 14 15 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1 16 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2 17 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_3 14 18 15 19 GLOBLIBS = libG4vis_management.lib libG4modeling.lib libG4gl2ps.lib -
trunk/source/visualization/OpenGL/History
r1240 r1242 1 $Id: History,v 1.16 3 2010/01/28 09:19:04 gcosmoExp $1 $Id: History,v 1.164 2010/03/10 11:03:46 lgarnier Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 17 17 * Reverse chronological order (last date on top), please * 18 18 ---------------------------------------------------------- 19 9th March 2010 Laurent Garnier 20 - G4OpenGLViewer : Fix clipping when resizing non square size windows 21 Remove error message when no scene present. 22 - G4OpenGLImmediateQtViewer, G4OpenGLStoredQtViewer : 23 - Add some protections if viewer is in tab 24 - fix some redraw probems when focus was outside frame 25 - Add ShowView() and paintEvent() methods 26 - DrawView method is now the same in Store and Immediate mode 27 - G4OpenGLQtViewer : Add things for viewer in tabs 28 19 29 3rd March 2010 Laurent Garnier 20 30 - G4OpenGLViewer : Add protection against null pointer scene -
trunk/source/visualization/OpenGL/include/G4OpenGLImmediateQtViewer.hh
r1240 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLImmediateQtViewer.hh,v 1. 6 2009/10/14 13:27:30lgarnier Exp $27 // $Id: G4OpenGLImmediateQtViewer.hh,v 1.7 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 56 56 void initializeGL (); 57 57 void DrawView (); 58 // void FinishView ();59 58 void resizeGL(int width,int height); 60 59 void paintGL(); -
trunk/source/visualization/OpenGL/include/G4OpenGLSceneHandler.hh
r1140 r1242 64 64 void AddPrimitive (const G4Circle&); 65 65 void AddPrimitive (const G4Square&); 66 void AddPrimitives (std::vector <G4VMarker>); 66 67 void AddPrimitive (const G4Scale&); 67 68 void AddPrimitive (const G4Polyhedron&); … … 105 106 106 107 void AddCircleSquare (const G4VMarker&, G4OpenGLBitMapStore::Shape); 108 void AddCircleSquares (std::vector <G4VMarker>, G4OpenGLBitMapStore::Shape); 107 109 108 110 void DrawXYPolygon -
trunk/source/visualization/OpenGL/include/G4OpenGLStoredQtViewer.hh
r1240 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLStoredQtViewer.hh,v 1. 9 2009/10/14 13:27:30lgarnier Exp $27 // $Id: G4OpenGLStoredQtViewer.hh,v 1.10 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // -
trunk/source/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc
r1240 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLImmediateQtViewer.cc,v 1.1 7 2009/11/03 11:02:32lgarnier Exp $27 // $Id: G4OpenGLImmediateQtViewer.cc,v 1.18 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 67 67 #endif 68 68 fReadyToPaint = false; 69 #ifdef G4DEBUG_VIS_OGL70 printf("G4OpenGLImmediateQtViewer::Initialise VVVVVVVVVVVVVVVV \n");71 #endif72 69 CreateMainWindow (this,QString(fName)); 73 #ifdef G4DEBUG_VIS_OGL74 printf("G4OpenGLImmediateQtViewer::Initialise ^^^^^^^^^^^^^^^^\n");75 #endif76 70 CreateFontLists (); 77 71 78 72 fReadyToPaint = true; 79 #ifdef G4DEBUG_VIS_OGL80 printf("G4OpenGLImmediateQtViewer::InitialiseGLView * \n");81 #endif82 83 // L.Garnier 01/2010 Force a update in order to Init GL84 // updateGL();85 #ifdef G4DEBUG_VIS_OGL86 printf("G4OpenGLImmediateQtViewer::InitialiseGLView end * \n");87 #endif88 73 } 89 74 90 75 void G4OpenGLImmediateQtViewer::initializeGL () { 91 #ifdef G4DEBUG_VIS_OGL92 printf("G4OpenGLImmediateQtViewer::InitialiseGL * \n");93 #endif94 76 95 77 InitializeGLView (); … … 115 97 116 98 117 /** To ensure compatibility with DrawView method118 */119 99 void G4OpenGLImmediateQtViewer::DrawView() { 120 #ifdef G4DEBUG_VIS_OGL121 printf("G4OpenGLImmediateQtViewer::DrawView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");122 #endif123 // That's no the same logic as Stored Viewer, I don't know why...124 // see G4OpenGLStoredQtViewer::DrawView for more informations125 126 100 updateQWidget(); 127 128 #ifdef G4DEBUG_VIS_OGL129 printf("G4OpenGLImmediateQtViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");130 #endif131 101 } 132 102 … … 135 105 136 106 #ifdef G4DEBUG_VIS_OGL 137 printf("G4OpenGLImmediateQtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());107 printf("G4OpenGLImmediateQtViewer::ComputeView %d %d &:%d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight(),this); 138 108 #endif 139 109 makeCurrent(); … … 166 136 167 137 #ifdef G4DEBUG_VIS_OGL 168 printf("G4OpenGLImmediateQtViewer::ComputeView %d %d hasTo:%d^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight(),fHasToRepaint);138 printf("G4OpenGLImmediateQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight()); 169 139 #endif 170 140 fHasToRepaint = true; 171 141 } 172 173 142 174 143 /** … … 179 148 ,int aHeight) 180 149 { 181 #ifdef G4DEBUG_VIS_OGL182 printf("\n\nG4OpenGLImmediateQtViewer::resizeGL VVVV recu : W:%d H:%d\n",aWidth,aHeight);183 #endif184 150 ResizeWindow(aWidth,aHeight); 185 151 fHasToRepaint = sizeHasChanged(); 186 #ifdef G4DEBUG_VIS_OGL187 printf("\n\nG4OpenGLImmediateQtViewer::resizeGL ^^^^^\n");188 #endif189 152 } 190 153 … … 193 156 { 194 157 #ifdef G4DEBUG_VIS_OGL 195 printf("\n\nG4OpenGLImmediateQtViewer::paintGL ?? %d W:%d H:%d \n",fHasToRepaint,getWinWidth(),getWinHeight());158 printf("\n\nG4OpenGLImmediateQtViewer::paintGL &: %d??\n",this); 196 159 #endif 197 160 if (!fReadyToPaint) { … … 294 257 295 258 void G4OpenGLImmediateQtViewer::paintEvent(QPaintEvent *event) { 296 // fHasToRepaint= false;297 #ifdef G4DEBUG_VIS_OGL298 printf("\n\nG4OpenGLImmediateQtViewer::paintEvent VVVVVVVVV %d\n",fHasToRepaint);299 #endif300 259 if ( fHasToRepaint) { 301 260 updateGL(); 302 261 } 303 #ifdef G4DEBUG_VIS_OGL304 printf("\n\nG4OpenGLImmediateQtViewer::paintEvent ^^^^^^^^^ %d\n",fHasToRepaint);305 #endif306 262 } 307 263 … … 309 265 void G4OpenGLImmediateQtViewer::updateQWidget() { 310 266 fHasToRepaint= true; 311 #ifdef G4DEBUG_VIS_OGL312 printf("\n\nG4OpenGLImmediateQtViewer::updateQWidget VVVVVVVVV HasTo:%d\n",fHasToRepaint);313 #endif314 267 updateGL(); 315 268 repaint(); 316 #ifdef G4DEBUG_VIS_OGL317 printf("\n\nG4OpenGLImmediateQtViewer::updateQWidget ^^^^^^^^^\n");318 #endif319 269 fHasToRepaint= false; 320 270 } … … 326 276 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 327 277 { 328 #ifdef G4DEBUG_VIS_OGL329 printf("\n\nG4OpenGLImmediateQtViewer::ShowView VVVV\n");330 #endif331 278 fHasToRepaint = true; 332 279 #if QT_VERSION < 0x040000 … … 335 282 activateWindow(); 336 283 #endif 337 #ifdef G4DEBUG_VIS_OGL 338 printf("\n\nG4OpenGLImmediateQtViewer::ShowView ^^^^^\n"); 339 #endif 340 } 341 #endif 284 } 285 #endif -
trunk/source/visualization/OpenGL/src/G4OpenGLImmediateSceneHandler.cc
r1241 r1242 157 157 158 158 // See all primitives immediately... 159 //glFlush ();159 glFlush (); 160 160 161 161 G4OpenGLSceneHandler::EndPrimitives (); -
trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r1240 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLQtViewer.cc,v 1.4 7 2010/01/27 15:49:22 gcosmoExp $27 // $Id: G4OpenGLQtViewer.cc,v 1.48 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 165 165 YPos = offset; 166 166 } 167 #ifdef G4DEBUG_VIS_OGL168 printf("G4OpenGLQtViewer::CreateMainWindow :: before resizing to %d %d vvvvvvvvvvvvvvvvvvv\n",getWinWidth(), getWinHeight());169 #endif170 167 fGLWindow->resize(getWinWidth(), getWinHeight()); 171 168 #ifdef G4DEBUG_VIS_OGL 172 printf("G4OpenGLQtViewer::CreateMainWindow :: after resizing to %d %d ^^^^^^^^^^^^^^^^^^^^\n",getWinWidth(), getWinHeight());169 printf("G4OpenGLQtViewer::CreateMainWindow :: resizing to %d %d \n",getWinWidth(), getWinHeight()); 173 170 #endif 174 171 fGLWindow->move(fVP.GetWindowAbsoluteLocationHintX(QApplication::desktop()->width()),YPos); 175 172 fGLWindow->show(); 176 #ifdef G4DEBUG_VIS_OGL 177 printf("G4OpenGLQtViewer::CreateMainWindow :: after show to %d %d --------------------\n",getWinWidth(), getWinHeight()); 178 #endif 179 } else { 180 #ifdef G4DEBUG_VIS_OGL 181 printf("G4OpenGLQtViewer::AddTab VVVVVVVVVVVVVV\n"); 182 #endif 173 } else { 183 174 fGLWindow = fWindow; 184 #ifdef G4DEBUG_VIS_OGL185 printf("G4OpenGLQtViewer::AddTab ->resize : %d %d\n",getWinWidth(), getWinHeight());186 #endif187 175 fGLWindow->resize(getWinWidth(), getWinHeight()); 188 #ifdef G4DEBUG_VIS_OGL189 printf("G4OpenGLQtViewer::AddTab ^^^^^^^^^^^^^^\n");190 #endif191 176 } 192 177 … … 196 181 createPopupMenu(); 197 182 198 #ifdef G4DEBUG_VIS_OGL199 printf("G4OpenGLQtViewer::CreateMainWindow :: END\n");200 #endif201 183 } 202 184 … … 1436 1418 void G4OpenGLQtViewer::FinishView() 1437 1419 { 1438 #ifdef G4DEBUG_VIS_OGL1439 printf("G4OpenGLQtViewer::FinishView() flush \n");1440 #endif1441 1420 glFlush (); 1442 1421 -
trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc
r1238 r1242 234 234 // printf(" circle "); 235 235 #endif 236 #ifdef G4VIS_BUILD_OPTIMISE_3 237 std::vector <G4VMarker> circleV; 238 // FIXME, must check attribute before doing a list 239 #endif 236 240 for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) { 237 241 G4Circle circle (polymarker); 242 // If not already drawn 238 243 circle.SetPosition (polymarker[iPoint]); 239 G4OpenGLSceneHandler::AddPrimitive (circle); 240 } 244 #ifdef G4VIS_BUILD_OPTIMISE_3 245 circleV.push_back(circle); 246 #endif 247 } 248 #ifdef G4VIS_BUILD_OPTIMISE_3 249 G4OpenGLSceneHandler::AddPrimitives (circleV); 250 #endif 241 251 } 242 252 break; … … 246 256 // printf(" square "); 247 257 #endif 258 #ifdef G4VIS_BUILD_OPTIMISE_3 259 std::vector <G4VMarker> squareV; 260 // FIXME, must check attribute before doing a list 261 #endif 248 262 for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) { 249 263 G4Square square (polymarker); 250 264 square.SetPosition (polymarker[iPoint]); 251 G4OpenGLSceneHandler::AddPrimitive (square); 252 } 265 #ifdef G4VIS_BUILD_OPTIMISE_3 266 squareV.push_back(square); 267 #endif 268 } 269 #ifdef G4VIS_BUILD_OPTIMISE_3 270 G4OpenGLSceneHandler::AddPrimitives (squareV); 271 #endif 253 272 } 254 273 break; … … 319 338 } 320 339 340 void G4OpenGLSceneHandler::AddPrimitives (std::vector <G4VMarker> square) { 341 glDisable (GL_POINT_SMOOTH); 342 AddCircleSquares (square, G4OpenGLBitMapStore::square); 343 } 344 321 345 void G4OpenGLSceneHandler::AddCircleSquare 322 346 (const G4VMarker& marker, … … 398 422 glBegin (GL_POINTS); 399 423 glVertex3f(centre.x(),centre.y(),centre.z()); 424 glEnd(); 425 //Antialiasing 426 glEnable (GL_POINT_SMOOTH); 427 //Transparency 428 glEnable(GL_BLEND); 429 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 430 431 // L. GARNIER 1 March 2009 432 // Old method, we draw a bitmap instead of a GL_POINT. 433 // I remove it because it cost in term of computing performances 434 // and gl2ps can't draw bitmaps 435 436 // glRasterPos3d(centre.x(),centre.y(),centre.z()); 437 // const GLubyte* marker = 438 // G4OpenGLBitMapStore::GetBitMap(shape, size, filled); 439 // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 440 // glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker); 441 } 442 } 443 444 void G4OpenGLSceneHandler::AddCircleSquares 445 (std::vector <G4VMarker> marker, 446 G4OpenGLBitMapStore::Shape shape) { 447 448 if (marker.size() == 0) { 449 return; 450 } 451 452 if (!fProcessingPolymarker) { // Polymarker has already loaded atts. 453 // Loads G4Atts for picking... 454 if (fpViewer->GetViewParameters().IsPicking()) { 455 G4AttHolder* holder = new G4AttHolder; 456 LoadAtts(marker[0], holder); 457 fPickMap[fPickName] = holder; 458 } 459 } 460 461 // Note: colour treated in sub-class. 462 463 if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) { 464 #ifdef G4DEBUG_VIS_OGL 465 // printf("+"); 466 #endif 467 glDisable (GL_DEPTH_TEST); 468 } else { 469 #ifdef G4DEBUG_VIS_OGL 470 // printf("-"); 471 #endif 472 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);} 473 474 glDisable (GL_LIGHTING); 475 476 // Get vis attributes - pick up defaults if none. 477 const G4VisAttributes* pVA = 478 fpViewer -> GetApplicableVisAttributes (marker[0].GetVisAttributes ()); 479 480 G4double lineWidth = GetLineWidth(pVA); 481 glLineWidth(lineWidth); 482 483 G4VMarker::FillStyle style = marker[0].GetFillStyle(); 484 485 G4bool filled = false; 486 static G4bool hashedWarned = false; 487 488 switch (style) { 489 case G4VMarker::noFill: 490 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 491 filled = false; 492 break; 493 494 case G4VMarker::hashed: 495 if (!hashedWarned) { 496 G4cout << "Hashed fill style in G4OpenGLSceneHandler." 497 << "\n Not implemented. Using G4VMarker::filled." 498 << G4endl; 499 hashedWarned = true; 500 } 501 // Maybe use 502 //glPolygonStipple (fStippleMaskHashed); 503 // Drop through to filled... 504 505 case G4VMarker::filled: 506 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 507 filled = true; 508 break; 509 510 } 511 512 513 514 MarkerSizeType sizeType; 515 G4double size = GetMarkerSize(marker[0], sizeType); 516 517 // Draw... 518 if (sizeType == world) { // Size specified in world coordinates. 519 520 for (unsigned int a=0;a<marker.size();a++) { 521 G4Point3D centre = marker[a].GetPosition(); 522 // A few useful quantities... 523 DrawXYPolygon (shape, size, centre, pVA); 524 } 525 } else { // Size specified in screen (window) coordinates. 526 // A few useful quantities... 527 glPointSize (size); 528 glBegin (GL_POINTS); 529 for (unsigned int a=0;a<marker.size();a++) { 530 G4Point3D centre = marker[a].GetPosition(); 531 glVertex3f(centre.x(),centre.y(),centre.z()); 532 } 400 533 glEnd(); 401 534 //Antialiasing -
trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc
r1240 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.2 8 2009/11/03 11:02:32lgarnier Exp $27 // $Id: G4OpenGLStoredQtViewer.cc,v 1.29 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 103 103 104 104 105 void G4OpenGLStoredQtViewer::DrawView () { 106 #ifdef G4DEBUG_VIS_OGL 107 printf("G4OpenGLStoredQtViewer::DrawView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); 108 #endif 109 // That's no the same logic as Immediate Viewer, I don't know why... 110 // But if I send updateGL here, we go here : 111 // updateQWidget -> paintGL -> ComputeView 112 // whih is not the same as ComputeView Directly 113 // And we loose the redraw of things ! 114 115 // ComputeView(); 116 #ifdef G4DEBUG_VIS_OGL 117 printf("G4OpenGLStoredQtViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ llllllllllllllllllllllllllllllll\n"); 118 #endif 105 void G4OpenGLStoredQtViewer::DrawView () { 119 106 updateQWidget(); 120 107 } … … 219 206 { 220 207 #ifdef G4DEBUG_VIS_OGL 221 printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d?? context:%d\n",fReadyToPaint,fHasToRepaint,context());208 printf("G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint); 222 209 #endif 223 210 if (!fReadyToPaint) { … … 253 240 254 241 SetView(); 255 242 256 243 ClearView (); //ok, put the background correct 257 244 ComputeView(); 258 245 259 246 fHasToRepaint =false; 260 247 261 248 #ifdef G4DEBUG_VIS_OGL 262 249 printf("G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint); … … 265 252 266 253 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *event) { 267 #ifdef G4DEBUG_VIS_OGL268 printf("\n\nG4OpenGLStoredQtViewer::paintEvent VVVVVVVVV %d context : %d\n",fHasToRepaint,context());269 #endif270 254 if ( fHasToRepaint) { 271 255 updateGL(); 272 256 } 273 #ifdef G4DEBUG_VIS_OGL274 printf("\n\nG4OpenGLStoredQtViewer::paintEvent ^^^^^^^^^\n");275 #endif276 257 } 277 258 -
trunk/source/visualization/OpenGL/src/G4OpenGLStoredViewer.cc
r1125 r1242 126 126 void G4OpenGLStoredViewer::DrawDisplayLists () { 127 127 #ifdef G4DEBUG_VIS_OGL 128 printf("G4OpenGLStoredViewer::DrawDisplayLists \n");128 // printf("G4OpenGLStoredViewer::DrawDisplayLists \n"); 129 129 #endif 130 130 … … 134 134 size_t nPasses = cutawayUnion? cutaways.size(): 1; 135 135 #ifdef G4DEBUG_VIS_OGL 136 printf("G4OpenGLStoredViewer::DrawDisplayLists");136 // printf("G4OpenGLStoredViewer::DrawDisplayLists"); 137 137 #endif 138 138 for (size_t i = 0; i < nPasses; ++i) { 139 139 #ifdef G4DEBUG_VIS_OGL 140 printf("+");140 // printf("+"); 141 141 #endif 142 142 … … 156 156 for (size_t i = 0; i < fG4OpenGLStoredSceneHandler.fTOList.size(); ++i) { 157 157 #ifdef G4DEBUG_VIS_OGL 158 printf("-");158 // printf("-"); 159 159 #endif 160 160 G4OpenGLStoredSceneHandler::TO& to = … … 179 179 } 180 180 #ifdef G4DEBUG_VIS_OGL 181 printf("\n");181 // printf("\n"); 182 182 #endif 183 183 -
trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
r1241 r1242 25 25 // 26 26 // 27 // $Id: G4OpenGLViewer.cc,v 1. 59 2009/10/20 12:47:45lgarnier Exp $27 // $Id: G4OpenGLViewer.cc,v 1.60 2010/03/10 11:03:46 lgarnier Exp $ 28 28 // GEANT4 tag $Name: $ 29 29 // … … 100 100 // glDisable (GL_LINE_SMOOTH); 101 101 // glDisable (GL_POLYGON_SMOOTH); 102 } 103 104 G4OpenGLViewer::~G4OpenGLViewer () { 105 #ifdef G4DEBUG_VIS_OGL 106 printf("G4OpenGLViewer::~G4OpenGLViewer DELETING \n"); 107 #endif 108 } 102 103 } 104 105 G4OpenGLViewer::~G4OpenGLViewer () {} 109 106 110 107 void G4OpenGLViewer::InitializeGLView () … … 118 115 fWinSize_x = fVP.GetWindowSizeHintX(); 119 116 fWinSize_y = fVP.GetWindowSizeHintY(); 120 #ifdef G4DEBUG_VIS_OGL121 printf("G4OpenGLViewer::InitializeGLView to W:%d H:%d pt:%d\n",fWinSize_x,fWinSize_y,this);122 #endif123 117 } 124 118 125 119 void G4OpenGLViewer::ClearView () { 126 120 #ifdef G4DEBUG_VIS_OGL 127 printf("G4OpenGLViewer::ClearView \n");121 printf("G4OpenGLViewer::ClearView &:%d\n",this); 128 122 #endif 129 123 glClearColor (background.GetRed(), … … 152 146 fSizeHasChanged = false; 153 147 } 154 #ifdef G4DEBUG_VIS_OGL155 printf("G4OpenGLViewer::ResizeWindow :W:%d H:%d changed?:%d set:W:%d H:%d pt:%d\n",fWinSize_x,fWinSize_y,fSizeHasChanged,aWidth,aHeight,this);156 #endif157 148 } 158 149 … … 166 157 { 167 158 #ifdef G4DEBUG_VIS_OGL 168 printf("G4OpenGLViewer::ResizeGLView %d %d pt:%d\n",fWinSize_x,fWinSize_y,this);159 printf("G4OpenGLViewer::ResizeGLView %d %d &:%d\n",fWinSize_x,fWinSize_y,this); 169 160 #endif 170 161 // Check size … … 172 163 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims); 173 164 174 // L.Garnier 01-2010: Some problems with mac 10.6175 165 if ((dims[0] !=0 ) && (dims[1] !=0)) { 176 166 177 #ifdef G4DEBUG_VIS_OGL178 GLenum err = glGetError();179 if (err != GL_NO_ERROR) { \180 printf("%s: %s at %s:%d\n", \181 __FUNCTION__, \182 gluErrorString(err), \183 __FILE__, __LINE__); \184 printf("G4OpenGLViewer::ResizeGLView ERRRRR\n");185 }186 printf("G4OpenGLViewer::ResizeGLView DIM X:%d Y:%d\n",dims[0],dims[1]);187 #endif188 167 if (fWinSize_x > (unsigned)dims[0]) { 189 168 G4cerr << "Try to resize view greater than max X viewport dimension. Desired size "<<dims[0] <<" is resize to "<< dims[0] << G4endl; … … 195 174 } 196 175 } 197 // GLsizei side = fWinSize_x; 198 // if (fWinSize_y < fWinSize_x) side = fWinSize_y; 199 200 // SPECIAL CASE if fWinSize_x is even (69 for example) 201 // Ex : X: 69 Y: 26 202 // side = 26 203 // width / 2 = 21,5 204 // height / 2 = 0 205 // Should be fixed to closed : 21 0 for ex 206 // Then size must by change to : 207 // X:68 Y: 26 208 209 // SPECIAL CASE 210 // if ((fWinSize_x - side)%2) { 211 // // fWinSize_x --; 212 213 // side = fWinSize_x; 214 // if (fWinSize_y < fWinSize_x) side = fWinSize_y; 215 // } 216 // if ((fWinSize_y - side)%2) { 217 // // fWinSize_y --; 218 219 // side = fWinSize_x; 220 // if (fWinSize_y < fWinSize_x) side = fWinSize_y; 221 // } 222 223 // GLint X = (fWinSize_x - side) / 2; 224 // GLint Y = (fWinSize_y - side) / 2; 225 226 #ifdef G4DEBUG_VIS_OGL 227 // printf("G4OpenGLViewer::ResizeGLView X:%d Y:%d W:%d H:%d --side%d\n",(fWinSize_x - side) / 2,(fWinSize_y - side) / 2,fWinSize_x,fWinSize_y,side); 228 #endif 229 230 // glViewport(X, Y, side, side); 176 231 177 glViewport(0, 0, fWinSize_x,fWinSize_y); 232 233 234 178 } 235 179 … … 284 228 285 229 // FIXME 286 #ifdef G4DEBUG_VIS_OGL287 printf("G4OpenGLViewer::SetView Call ResizeGLView VVVVVV sizeX:%d sizeY:%d ratioX:%f ratioY:%f\n",fWinSize_x,fWinSize_y,ratioX,ratioY);288 #endif289 230 ResizeGLView(); 290 #ifdef G4DEBUG_VIS_OGL291 printf("G4OpenGLViewer::SetView Call ResizeGLView ^^^^^^\n");292 #endif293 231 //SHOULD SetWindowsSizeHint()... 294 232 … … 301 239 if (fVP.GetFieldHalfAngle() == 0.) { 302 240 glOrtho (left, right, bottom, top, pnear, pfar); 303 #ifdef G4DEBUG_VIS_OGL304 printf("G4OpenGLViewer::SetView glOrtho %f %f %f %f %f %f\n",left, right, bottom, top, pnear, pfar);305 #endif306 241 } 307 242 else { … … 567 502 } 568 503 504 #ifdef G4DEBUG_VIS_OGL 505 printf("G4OpenGLViewer::printEPS END\n"); 506 #endif 569 507 } 570 508 … … 575 513 bool G4OpenGLViewer::printNonVectoredEPS () { 576 514 515 577 516 int width = getRealPrintSizeX(); 578 517 int height = getRealPrintSizeY(); 579 518 580 519 #ifdef G4DEBUG_VIS_OGL 581 printf("G4OpenGLViewer::printNonVectoredEPS file:%s Vec:%d X:%d Y:%d col:%d \n",getRealPrintFilename().c_str(),fVectoredPs,width,height,fPrintColour);520 printf("G4OpenGLViewer::printNonVectoredEPS file:%s Vec:%d X:%d Y:%d col:%d fWinX:%d fWinY:%d\n",getRealPrintFilename().c_str(),fVectoredPs,width,height,fPrintColour,fWinSize_x,fWinSize_y); 582 521 #endif 583 522 FILE* fp; … … 671 610 fGL2PSAction->setFileName(getRealPrintFilename().c_str()); 672 611 // try to resize 673 int X = fWinSize_x; 674 int Y = fWinSize_y; 675 676 fWinSize_x = width; 677 fWinSize_y = height; 612 int X = fWinSize_x; 613 int Y = fWinSize_y; 614 615 fWinSize_x = width; 616 fWinSize_y = height; 617 #ifdef G4DEBUG_VIS_OGL 618 printf("G4OpenGLViewer::printgl2PS VVVV %d %d\n",getRealPrintSizeX(),getRealPrintSizeY()); 619 #endif 620 // Laurent G. 16/03/10 : Not the good way to do. 621 // We should draw in a new offscreen context instead of 622 // resizing and drawing in current window... 623 // This should be solve when we will do an offscreen method 624 // to render OpenGL 625 // See : 626 // http://developer.apple.com/Mac/library/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_offscreen/opengl_offscreen.html 627 // http://www.songho.ca/opengl/gl_fbo.html 628 678 629 ResizeGLView(); 679 630 if (fGL2PSAction->enableFileWriting()) { 680 631 632 // Set the viewport 633 // fGL2PSAction->setViewport(0, 0, getRealPrintSizeX(),getRealPrintSizeY()); 681 634 // By default, we choose the line width (trajectories...) 682 635 fGL2PSAction->setLineWidth(1); 683 636 // By default, we choose the point size (markers...) 684 685 #ifdef G4DEBUG_VIS_OGL 686 // printf("G4OpenGLViewer::printGl2PS marker size:%f\n", GetSceneHandler()->GetMarkerSize()); 687 #endif 688 #ifdef G4DEBUG_VIS_OGL 689 // printf("G4OpenGLViewer::printGl2PS marker2 size:%f\n",fpViewer -> GetViewParameters ()->GetDefaultMarker ().GetScreenSize()); 690 #endif 691 // if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) { 692 // fGL2PSAction->setPointSize(fpViewer -> GetViewParameters ()->GetDefaultMarker ().GetScreenSize()); 693 // } else { 694 fGL2PSAction->setPointSize(2); 695 // } 637 fGL2PSAction->setPointSize(2); 638 696 639 DrawView (); 697 640 fGL2PSAction->disableFileWriting(); … … 700 643 fWinSize_x = X; 701 644 fWinSize_y = Y; 645 #ifdef G4DEBUG_VIS_OGL 646 printf("G4OpenGLViewer::printgl2PS 22222 %d %d \n",fWinSize_x,fWinSize_y); 647 #endif 702 648 ResizeGLView(); 649 DrawView (); 650 #ifdef G4DEBUG_VIS_OGL 651 printf("G4OpenGLViewer::printgl2PS ^^^^\n"); 652 #endif 703 653 704 654 // Reset for next time (useful is size change) -
trunk/source/visualization/externals/gl2ps/include/G4OpenGL2PSAction.hh
r1038 r1242 49 49 void setLineWidth(int); 50 50 void setPointSize(int); 51 void setViewport(int,int,int,int); 52 51 53 52 54 protected: -
trunk/source/visualization/externals/gl2ps/src/G4OpenGL2PSAction.cc
r1228 r1242 76 76 77 77 ////////////////////////////////////////////////////////////////////////////// 78 void G4OpenGL2PSAction::setViewport( 79 int a 80 ,int b 81 ,int winSizeX 82 ,int winSizeY 83 ) 84 ////////////////////////////////////////////////////////////////////////////// 85 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// 86 { 87 fViewport[0] = a; 88 fViewport[1] = b; 89 fViewport[2] = winSizeX; 90 fViewport[3] = winSizeY; 91 } 92 93 ////////////////////////////////////////////////////////////////////////////// 78 94 void G4OpenGL2PSAction::setFileName( 79 95 const char* aFileName -
trunk/source/visualization/management/GNUmakefile
r1241 r1242 11 11 # For debug mode 12 12 # CPPFLAGS += -DG4DEBUG_VIS_MANAGEMENT 13 CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1 14 CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2 15 13 16 14 17 GLOBLIBS = libG4modeling.lib -
trunk/source/visualization/management/History
r1241 r1242 26 26 History file for visualization management sub-category 27 27 ------------------------------------------------------ 28 9th March 2010 Laurent Garnier 29 - G4OpenGLViewer : Fix clipping when resizing non square size windows 30 28 31 8th March 2010 Laurent Garnier 29 32 -G4VisManager.cc : Add protection against null pointer -
trunk/source/visualization/management/src/G4VisManager.cc
r1241 r1242 477 477 fpSceneHandler -> BeginPrimitives (objectTransform); 478 478 fpSceneHandler -> AddPrimitive (line); 479 #ifndef G4VIS_BUILD_OPTIMISE_2 479 480 fpSceneHandler -> EndPrimitives (); 481 #endif 480 482 } 481 483 } … … 485 487 if (IsValidView ()) { 486 488 ClearTransientStoreIfMarked(); 489 #ifndef G4VIS_BUILD_OPTIMISE_2 490 // FIXME : test 487 491 fpSceneHandler -> BeginPrimitives (objectTransform); 492 #endif 488 493 fpSceneHandler -> AddPrimitive (polymarker); 494 // FIXME : test 495 #ifndef G4VIS_BUILD_OPTIMISE_2 489 496 fpSceneHandler -> EndPrimitives (); 497 #endif 490 498 } 491 499 } … … 515 523 if (IsValidView ()) { 516 524 ClearTransientStoreIfMarked(); 525 // FIXME : test 526 #ifndef G4VIS_BUILD_OPTIMISE_2 517 527 fpSceneHandler -> BeginPrimitives (objectTransform); 518 528 fpSceneHandler -> AddPrimitive (text); 529 #endif 519 530 fpSceneHandler -> EndPrimitives (); 520 531 } -
trunk/source/visualization/modeling/GNUmakefile
r1171 r1242 17 17 18 18 include $(G4INSTALL)/config/architecture.gmk 19 20 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_1 21 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_2 22 #CPPFLAGS += -DG4VIS_BUILD_OPTIMISE_3 19 23 20 24 CPPFLAGS += -I$(G4BASE)/global/management/include -
trunk/source/visualization/modeling/src/G4TrajectoryDrawerUtils.cc
r1171 r1242 33 33 #include "G4Polyline.hh" 34 34 #include "G4Polymarker.hh" 35 #include "G4Text.hh" 35 36 #include "G4VTrajectory.hh" 36 37 #include "G4VTrajectoryPoint.hh" … … 56 57 for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) { 57 58 const G4ThreeVector pos((*auxiliaries)[iAux]); 58 trajectoryLine.push_back(pos); 59 auxiliaryPoints.push_back(pos); 60 } 59 #ifdef G4VIS_BUILD_OPTIMISE_1 60 if (trajectoryLine.size() >0) { 61 if (pos != trajectoryLine[trajectoryLine.size()-1]) { 62 trajectoryLine.push_back(pos); 63 auxiliaryPoints.push_back(pos); 64 } 65 } else { 66 #endif 67 trajectoryLine.push_back(pos); 68 auxiliaryPoints.push_back(pos); 69 #ifdef G4VIS_BUILD_OPTIMISE_1 70 } 71 #endif 72 } 61 73 } 62 74 const G4ThreeVector pos(aTrajectoryPoint->GetPosition()); 63 trajectoryLine.push_back(pos); 64 stepPoints.push_back(pos); 65 } 75 #ifdef G4VIS_BUILD_OPTIMISE_1 76 if (trajectoryLine.size() >0) { 77 if (pos != trajectoryLine[trajectoryLine.size()-1]) { 78 trajectoryLine.push_back(pos); 79 stepPoints.push_back(pos); 80 } 81 } else { 82 #endif 83 trajectoryLine.push_back(pos); 84 stepPoints.push_back(pos); 85 #ifdef G4VIS_BUILD_OPTIMISE_1 86 } 87 #endif 88 } 66 89 } 67 90 … … 274 297 275 298 pVVisManager->Draw(stepPoints); 299 #ifdef G4VIS_BUILD_OPTIMISE_2 300 G4Text text = G4Text(""); 301 pVVisManager->Draw(text); 302 #endif 276 303 } 277 304 }
Note: See TracChangeset
for help on using the changeset viewer.