Changeset 938 for trunk/source/visualization/OpenGL
- Timestamp:
- Mar 4, 2009, 6:58:22 PM (16 years ago)
- Location:
- trunk/source/visualization/OpenGL
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/OpenGL/History
r935 r938 21 21 ------------------------------------- 22 22 23 3rd March 2009, Laurent Garnier 24 - G4OpenGLQtViewer: 25 - Suppress some warnings when saving file 26 - Changing size is now allowed when saving (to save with better resolution than screen size) 27 23 28 1st March 2009, Laurent Garnier 24 - Remplacing glBitmap by GL_POINTS to draw marker : Speed improvment29 - Remplacing glBitmap by GL_POINTS to draw marker : Speed improvment 25 30 and gl2ps can now draw Markers. 26 31 -
trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r917 r938 144 144 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1); 145 145 void rescaleImage(int, int); 146 bool generatePS_PDF(const std::string,int,QImage);146 bool printPDF(const std::string,int,QImage); 147 147 void showMovieParametersDialog(); 148 148 void initMovieParameters(); -
trunk/source/visualization/OpenGL/include/G4OpenGLStoredSceneHandler.hh
r936 r938 109 109 G4Polymarker fLastPolymarker ; 110 110 std::vector< G4Polymarker > fLastPolymarkers ; 111 int nbDoublons; 111 112 }; 112 113 -
trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh
r924 r938 68 68 void Pick(GLdouble x, GLdouble y); 69 69 virtual void CreateFontLists () {} 70 virtual voidprintVectoredEPS();70 bool printVectoredEPS(); 71 71 void rotateScene (G4double dx, G4double dy,G4double delta); 72 72 //////////////////////////////Vectored PostScript production functions/// … … 74 74 unsigned int width, 75 75 unsigned int height); 76 int generateEPS (const char* filnam,77 int inColour,78 unsigned int width, 79 unsigned int height); 80 void WritePostScript(const char *aFile);76 int printNonVectoredEPS (int inColour, 77 unsigned int width, 78 unsigned int height); 79 bool printGl2PS(unsigned int width, 80 unsigned int height); 81 81 void printBuffer(GLint, GLfloat*); 82 82 GLfloat* spewPrimitiveEPS (FILE*, GLfloat*); -
trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r931 r938 1324 1324 if ((exportDialog->getWidth() !=fWindow->width()) || 1325 1325 (exportDialog->getHeight() !=fWindow->height())) { 1326 if ( format != QString("eps")) {1326 if ((format != QString("eps")) && (format != QString("ps"))) { 1327 1327 G4cerr << "Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need" << G4endl; 1328 1328 … … 1348 1348 if (format == QString("eps")) { 1349 1349 if (exportDialog->getVectorEPS()) { 1350 printVectoredEPS(); 1351 res = true; 1350 res = printVectoredEPS(); 1352 1351 } else { 1353 res = generateEPS(fPrintFilename.c_str(),exportDialog->getNbColor(),(unsigned int)image.width(),(unsigned int)image.height());1352 res = printNonVectoredEPS(exportDialog->getNbColor(),(unsigned int)image.width(),(unsigned int)image.height()); 1354 1353 } 1355 } else if ((format == "ps") || (format == "pdf")) { 1356 res = generatePS_PDF(fPrintFilename,exportDialog->getNbColor(),image); 1354 } else if (format == "ps") { 1355 if ((exportDialog->getWidth() !=fWindow->width()) || 1356 (exportDialog->getHeight() !=fWindow->height())) { 1357 res = printGl2PS(exportDialog->getWidth(),exportDialog->getHeight()); 1358 } else { 1359 res = printGl2PS(fWindow->width(),fWindow->height()); 1360 } 1361 } else if (format == "pdf") { 1362 1363 res = printPDF(fPrintFilename,exportDialog->getNbColor(),image); 1364 1357 1365 } else if ((format == "tif") || 1358 1366 (format == "tiff") || … … 1654 1662 @param aImage : Image to print 1655 1663 */ 1656 bool G4OpenGLQtViewer:: generatePS_PDF (1664 bool G4OpenGLQtViewer::printPDF ( 1657 1665 const std::string aFilename 1658 1666 ,int aInColor -
trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc
r936 r938 83 83 fTopPODL (0), 84 84 fLastPolymarker(), 85 fLastPolymarkers() 85 fLastPolymarkers(), 86 nbDoublons(0) 86 87 {} 87 88 … … 210 211 { 211 212 213 std::vector< G4Polymarker > poly; 212 214 // 40,83 N03 lancement 213 215 // 289,69 10Gev supp doublons + bitmap 21 frame en 10 sec 214 216 // 343,45 10Gev full polymarker + bitmap 15 frame en 10 sec 215 217 // 351,67 10Gev full polymarker - bitmap 31 frame en 10 sec 216 // 2 94,90 10Gev supp doublons - bitmap 42 frame en 10 sec218 // 257,90 10Gev supp doublons MAX - bitmap 42 frame en 10 sec 45757 markers et 16243 enleves 217 219 // Check 218 220 int reste = polymarker.size(); 219 for (unsigned int a=0; a< fLastPolymarkers.size();a++) { 221 bool res = false; 222 if (fLastPolymarkers.size() > 0 ) { 220 223 for (unsigned int b=0; b< polymarker.size();b++) { 221 if (( fLastPolymarkers[a].GetPosition().x() == polymarker[b].x()) && 222 ( fLastPolymarkers[a].GetPosition().y() == polymarker[b].y()) && 223 ( fLastPolymarkers[a].GetPosition().z() == polymarker[b].z())) { 224 reste --; 225 printf("G4OpenGLStoredSceneHandler::AddPrimitive DOUBLON %d et pos %d reste %d ----------- point %f %f %f\n",a,b,reste,polymarker[b].x(),polymarker[b].y(),polymarker[b].z()); 224 res= false; 225 int size= fLastPolymarkers.size()-1; 226 for (unsigned int a=0; a< fLastPolymarkers.size() ;a++) { 227 if (( fLastPolymarkers[size-a].GetPosition().x() == polymarker[b].x()) && 228 ( fLastPolymarkers[size-a].GetPosition().y() == polymarker[b].y()) && 229 ( fLastPolymarkers[size-a].GetPosition().z() == polymarker[b].z())) { 230 reste --; 231 res= true; 232 nbDoublons++; 233 printf("G4OpenGLStoredSceneHandler::AddPrimitive DOUBLON %d total:%d et pos %d reste %d ----------- point %f %f %f\n",size-a,nbDoublons,b,reste,polymarker[b].x(),polymarker[b].y(),polymarker[b].z()); 234 } 226 235 } 227 } 228 } 229 // Add 230 for (unsigned int a=0; a< polymarker.size();a++) { 231 G4Polymarker tmp; 232 tmp.SetPosition(polymarker[a]); 233 fLastPolymarkers.push_back(tmp); 234 } 235 236 // Add 237 if (!res) { 238 G4Polymarker tmp; 239 tmp.SetPosition(polymarker[b]); 240 fLastPolymarkers.push_back(tmp); 241 poly.push_back(tmp); 242 } 243 } 244 } else { 245 for (unsigned int b=0; b< polymarker.size();b++) { 246 G4Polymarker tmp; 247 tmp.SetPosition(polymarker[b]); 248 fLastPolymarkers.push_back(tmp); 249 poly.push_back(tmp); 250 } 251 } 236 252 #define TEST_MARKER 1 237 253 #ifdef TEST_MARKER 238 254 // if it is already done 239 if (poly marker.size() >0) {240 if (( fLastPolymarker.GetPosition().x() == polymarker[0].x()) &&241 ( fLastPolymarker.GetPosition().y() == polymarker[0].y()) &&242 ( fLastPolymarker.GetPosition().z() == polymarker[0].z())) {243 if (fpViewer->GetViewParameters().IsPicking()) {244 glLoadName(++fPickName);245 fPickMap[fPickName] = 0;246 }247 printf("G4OpenGLStoredSceneHandler::AddPrimitive SUPPR ----------- point %f %f %f\n",polymarker[0].x(),polymarker[0].y(),polymarker[0].z());248 const G4Colour& c = GetColour (polymarker);249 glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());250 G4OpenGLSceneHandler::AddPrimitive(polymarker);251 fLastPolymarker.SetPosition(polymarker[polymarker.size()-1]);252 return;253 }255 if (poly.size() == 1 ) { 256 // if (polymarker.size() >0) { 257 // if (( fLastPolymarker.GetPosition().x() == polymarker[0].x()) && 258 // ( fLastPolymarker.GetPosition().y() == polymarker[0].y()) && 259 // ( fLastPolymarker.GetPosition().z() == polymarker[0].z())) { 260 // if (fpViewer->GetViewParameters().IsPicking()) { 261 // glLoadName(++fPickName); 262 // fPickMap[fPickName] = 0; 263 // } 264 // printf("G4OpenGLStoredSceneHandler::AddPrimitive SUPPR ----------- point %f %f %f\n",polymarker[0].x(),polymarker[0].y(),polymarker[0].z()); 265 const G4Colour& c = GetColour (polymarker); 266 glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ()); 267 G4OpenGLSceneHandler::AddPrimitive(poly[0]); 268 // fLastPolymarker.SetPosition(polymarker[poly]); 269 return; 254 270 } 255 271 #endif … … 258 274 G4OpenGLSceneHandler::AddPrimitive(polymarker); 259 275 AddPrimitivePostamble(); 260 fLastPolymarker.SetPosition(polymarker[polymarker.size()-1]);276 // fLastPolymarker.SetPosition(polymarker[polymarker.size()-1]); 261 277 } 262 278 -
trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc
r911 r938 33 33 // and G4OpenGLStoredViewer. 34 34 35 #define G4DEBUG_VIS_OGL 1 35 36 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER 36 37 … … 82 83 83 84 void G4OpenGLStoredXmViewer::DrawView () { 85 #ifdef G4DEBUG_VIS_OGL 86 printf("G4OpenGLStoredXmViewer::DrawView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); 87 #endif 84 88 85 89 //Make sure current viewer is attached and clean... … … 112 116 // have been done, so... 113 117 if (!kernelVisitWasNeeded) { 118 #ifdef G4DEBUG_VIS_OGL 119 printf("************************** G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n"); 120 #endif 114 121 DrawDisplayLists (); 115 122 FinishView (); 116 123 } else { 124 #ifdef G4DEBUG_VIS_OGL 125 printf("************************** G4OpenGLStoredXmViewer::ComputeView Need kernel Visit \n"); 126 #endif 117 127 // However, union cutaways are implemented in DrawDisplayLists, so make 118 128 // an extra pass... … … 125 135 } 126 136 } 137 #ifdef G4DEBUG_VIS_OGL 138 printf("G4OpenGLStoredXmViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); 139 #endif 127 140 } 128 141 -
trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
r931 r938 418 418 } 419 419 420 voidG4OpenGLViewer::printVectoredEPS() {420 bool G4OpenGLViewer::printVectoredEPS() { 421 421 422 422 // Print vectored PostScript … … 439 439 fclose(file); 440 440 } else { 441 printf("Could not open %s\n", fPrintFilename.c_str()); 441 G4cerr << "Could not open " <<fPrintFilename.c_str() <<" for writing"<< G4endl; 442 return false; 442 443 } 443 444 } else { … … 446 447 447 448 delete[] feedback_buffer; 449 return true; 448 450 } 449 451 … … 823 825 } 824 826 825 int G4OpenGLViewer::generateEPS (const char* filnam, 826 int inColour, 827 int G4OpenGLViewer::printNonVectoredEPS (int inColour, 827 828 unsigned int width, 828 829 unsigned int height) { … … 832 833 GLubyte* curpix; 833 834 int components, pos, i; 834 835 WritePostScript("AAAAAAAAAAAAAAA.ps");836 835 837 836 pixels = grabPixels (inColour, width, height); … … 845 844 } 846 845 847 fp = fopen (f ilnam, "w");846 fp = fopen (fPrintFilename.c_str(), "w"); 848 847 if (fp == NULL) { 849 848 return 2; … … 851 850 852 851 fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n"); 853 fprintf (fp, "%%%%Title: %s\n", f ilnam);852 fprintf (fp, "%%%%Title: %s\n", fPrintFilename.c_str()); 854 853 fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n"); 855 854 fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height); … … 903 902 904 903 905 void G4OpenGLViewer::WritePostScript(const char *aFile) { 906 907 908 if (!fGL2PSAction) return; 909 910 // FIXME : TEST 911 printf("G4OpenGLViewer::WritePostScript world size:%f\n",GetViewParameters().GetDefaultMarker().GetWorldSize()); 912 G4ViewParameters vp = GetViewParameters(); 913 G4VMarker defaultMarker = vp.GetDefaultMarker(); 914 G4VMarker myMarker = vp.GetDefaultMarker(); 915 916 myMarker.SetScreenSize(0); // before SetWorldSize 917 myMarker.SetScreenDiameter(0); // before SetWorldSize 918 myMarker.SetScreenRadius(0); // before SetWorldSize 919 920 myMarker.SetWorldSize(6.); 921 myMarker.SetWorldDiameter(4.); 922 myMarker.SetWorldRadius(3.); 923 // myMarker.SetWorldSize(defaultMarker.GetScreenSize()); 924 // myMarker.SetWorldDiameter(defaultMarker.GetScreenDiameter()); 925 // myMarker.SetWorldRadius(defaultMarker.GetScreenRadius()); 926 927 vp.SetDefaultMarker(myMarker); 928 SetViewParameters(vp); 929 930 fGL2PSAction->setFileName("PostScriptViaGL2PS.ps"); 904 bool G4OpenGLViewer::printGl2PS(unsigned int width,unsigned int height) { 905 906 if (!fGL2PSAction) return false; 907 908 909 fGL2PSAction->setFileName(fPrintFilename.c_str()); 910 // try to resize 911 int X = fWinSize_x; 912 int Y = fWinSize_y; 913 914 fWinSize_x = width; 915 fWinSize_y = height; 916 ResizeGLView(); 931 917 if (fGL2PSAction->enableFileWriting()) { 918 #ifdef G4DEBUG_VIS_OGL 919 printf("Call Need() \n"); 920 #endif 932 921 NeedKernelVisit (); 922 #ifdef G4DEBUG_VIS_OGL 923 printf("Call Process() \n"); 924 #endif 933 925 ProcessView(); 934 926 SetView (); … … 937 929 fGL2PSAction->disableFileWriting(); 938 930 } 939 vp.SetDefaultMarker(defaultMarker); 940 SetViewParameters(vp); 941 // FIXME : TEST 942 943 944 945 FILE *fFile = fopen(aFile,"w"); 946 if(!fFile) { 947 G4cout << "G4OpenGLViewer::WritePostScript. Cannot open file " <<aFile << G4endl; 948 return; 949 } 950 951 // Get the viewport 952 GLint viewport[4]; 953 glGetIntegerv(GL_VIEWPORT, viewport); 954 955 956 957 int psformat; 958 // psformat = GL2PS_PDF; 959 psformat = GL2PS_PS; 960 // psformat = GL2PS_SVG; 961 // psformat = GL2PS_EPS; 962 963 // int old_bg_gradient = CTX.bg_gradient; 964 // if(!CTX.print.eps_background) CTX.bg_gradient = 0; 965 966 // PixelBuffer buffer(width, height, GL_RGB, GL_FLOAT); 967 968 // if(CTX.print.eps_quality == 0) 969 // buffer.Fill(CTX.batch); 970 971 int pssort = GL2PS_SIMPLE_SORT; 972 // int pssort = 973 // (CTX.print.eps_quality == 3) ? GL2PS_NO_SORT : 974 // (CTX.print.eps_quality == 2) ? GL2PS_BSP_SORT : 975 // GL2PS_SIMPLE_SORT; 976 int psoptions = GL2PS_SIMPLE_LINE_OFFSET | GL2PS_DRAW_BACKGROUND; 977 // GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT | 978 // (CTX.print.eps_occlusion_culling ? GL2PS_OCCLUSION_CULL : 0) | 979 // (CTX.print.eps_best_root ? GL2PS_BEST_ROOT : 0) | 980 // (CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) | 981 // (CTX.print.eps_compress ? GL2PS_COMPRESS : 0) | 982 // (CTX.print.eps_ps3shading ? 0 : GL2PS_NO_PS3_SHADING); 983 984 GLint buffsize = 0; 985 int res = GL2PS_OVERFLOW; 986 while(res == GL2PS_OVERFLOW) { 987 buffsize += 2048 * 2048; 988 gl2psBeginPage("MyTitle", "Geant4", viewport, 989 psformat, pssort, psoptions, GL_RGBA, 0, NULL, 990 15, 20, 10, buffsize, fFile, aFile); 991 DrawView(); 992 res = gl2psEndPage(); 993 } 994 995 // CTX.bg_gradient = old_bg_gradient; 996 fclose(fFile); 997 931 932 fWinSize_x = X; 933 fWinSize_y = Y; 934 ResizeGLView(); 935 936 return true; 998 937 } 999 938 -
trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc
r924 r938 49 49 #include "G4Point3D.hh" 50 50 #include "G4Normal3D.hh" 51 #include "G4StateManager.hh" 51 52 52 53 #include <X11/Xatom.h> … … 417 418 if (fVectoredPs) { 418 419 419 G4OpenGLViewer::printVectoredEPS(); 420 420 // Set State to Idle because otherwise it won't redraw 421 G4StateManager* stateManager = G4StateManager::GetStateManager(); 422 G4ApplicationState oldState = stateManager->GetCurrentState(); 423 stateManager->SetNewState(G4State_Idle); 424 printGl2PS(fWinSize_x, fWinSize_y); 425 stateManager->SetNewState(oldState); 426 427 // fPrintFilename = fPrintFilename+"-Gl2ps.ps"; 428 // printVectoredEPS(); 429 421 430 } else { 422 431 … … 454 463 DrawView (); 455 464 456 generateEPS (fPrintFilename.c_str(), 457 fPrintColour, 465 printNonVectoredEPS (fPrintColour, 458 466 fWinSize_x, fWinSize_y); 459 467
Note: See TracChangeset
for help on using the changeset viewer.