Ignore:
Timestamp:
Mar 4, 2009, 6:58:22 PM (16 years ago)
Author:
garnier
Message:

print PS marche, mais plein de msg de debug a supprimer

Location:
trunk/source/visualization/OpenGL
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/History

    r935 r938  
    2121-------------------------------------
    2222
     233rd 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
    23281st March 2009, Laurent Garnier
    24 - Remplacing glBitmap by GL_POINTS to draw marker : Speed improvment
     29 - Remplacing glBitmap by GL_POINTS to draw marker : Speed improvment
    2530  and gl2ps can now draw Markers.
    2631
  • trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r917 r938  
    144144  void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
    145145  void rescaleImage(int, int);
    146   bool generatePS_PDF(const std::string,int,QImage); 
     146  bool printPDF(const std::string,int,QImage); 
    147147  void showMovieParametersDialog();
    148148  void initMovieParameters();
  • trunk/source/visualization/OpenGL/include/G4OpenGLStoredSceneHandler.hh

    r936 r938  
    109109  G4Polymarker fLastPolymarker ;
    110110  std::vector< G4Polymarker > fLastPolymarkers ;
     111  int nbDoublons;
    111112};
    112113
  • trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh

    r924 r938  
    6868  void Pick(GLdouble x, GLdouble y);
    6969  virtual void CreateFontLists () {}
    70   virtual void printVectoredEPS();
     70  bool printVectoredEPS();
    7171  void rotateScene (G4double dx, G4double dy,G4double delta);
    7272//////////////////////////////Vectored PostScript production functions///
     
    7474                       unsigned int width,
    7575                       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);
    8181  void printBuffer(GLint, GLfloat*);
    8282  GLfloat* spewPrimitiveEPS (FILE*, GLfloat*);
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r931 r938  
    13241324    if ((exportDialog->getWidth() !=fWindow->width()) ||
    13251325        (exportDialog->getHeight() !=fWindow->height())) {
    1326       if (format != QString("eps")) {
     1326      if ((format != QString("eps")) && (format != QString("ps"))) {
    13271327      G4cerr << "Export->Change Size : This function is not implemented, to export in another size, please resize your frame to what you need" << G4endl;
    13281328     
     
    13481348    if (format == QString("eps")) {
    13491349      if (exportDialog->getVectorEPS()) {
    1350         printVectoredEPS();
    1351         res = true;
     1350        res = printVectoredEPS();
    13521351      } 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());
    13541353      }
    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
    13571365    } else if ((format == "tif") ||
    13581366               (format == "tiff") ||
     
    16541662   @param aImage : Image to print
    16551663*/
    1656 bool G4OpenGLQtViewer::generatePS_PDF (
     1664bool G4OpenGLQtViewer::printPDF (
    16571665 const std::string aFilename
    16581666,int aInColor
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc

    r936 r938  
    8383fTopPODL (0),
    8484fLastPolymarker(),
    85 fLastPolymarkers()
     85fLastPolymarkers(),
     86nbDoublons(0)
    8687{}
    8788
     
    210211{
    211212
     213  std::vector< G4Polymarker > poly;
    212214    // 40,83 N03 lancement
    213215    // 289,69 10Gev supp doublons   + bitmap 21 frame en 10 sec
    214216    // 343,45 10Gev full polymarker + bitmap 15 frame en 10 sec
    215217    // 351,67 10Gev full polymarker - bitmap 31 frame en 10 sec
    216     // 294,90 10Gev supp doublons   - bitmap 42 frame en 10 sec
     218    // 257,90 10Gev supp doublons MAX  - bitmap 42 frame en 10 sec 45757 markers et 16243 enleves
    217219  // Check
    218220  int reste = polymarker.size();
    219   for (unsigned int a=0; a< fLastPolymarkers.size();a++) {
     221  bool res = false;
     222  if (fLastPolymarkers.size() > 0 ) {
    220223    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        }
    226235      }
    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  }
    236252#define TEST_MARKER 1
    237253#ifdef TEST_MARKER
    238254  // if it is already done
    239   if (polymarker.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;
    254270  }
    255271#endif 
     
    258274  G4OpenGLSceneHandler::AddPrimitive(polymarker);
    259275  AddPrimitivePostamble();
    260   fLastPolymarker.SetPosition(polymarker[polymarker.size()-1]);
     276//  fLastPolymarker.SetPosition(polymarker[polymarker.size()-1]);
    261277}
    262278
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc

    r911 r938  
    3333//                              and G4OpenGLStoredViewer.
    3434
     35#define G4DEBUG_VIS_OGL 1
    3536#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
    3637
     
    8283
    8384void G4OpenGLStoredXmViewer::DrawView () {
     85#ifdef G4DEBUG_VIS_OGL
     86  printf("G4OpenGLStoredXmViewer::DrawView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
     87#endif
    8488
    8589  //Make sure current viewer is attached and clean...
     
    112116    // have been done, so...
    113117    if (!kernelVisitWasNeeded) {
     118#ifdef G4DEBUG_VIS_OGL
     119      printf("**************************  G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n");
     120#endif
    114121      DrawDisplayLists ();
    115122      FinishView ();
    116123    } else {
     124#ifdef G4DEBUG_VIS_OGL
     125      printf("**************************  G4OpenGLStoredXmViewer::ComputeView Need kernel Visit \n");
     126#endif
    117127    // However, union cutaways are implemented in DrawDisplayLists, so make
    118128    // an extra pass...
     
    125135    }
    126136  }
     137#ifdef G4DEBUG_VIS_OGL
     138  printf("G4OpenGLStoredXmViewer::DrawView  ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
     139#endif
    127140}
    128141
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r931 r938  
    418418}
    419419
    420 void G4OpenGLViewer::printVectoredEPS() {
     420bool G4OpenGLViewer::printVectoredEPS() {
    421421
    422422  // Print vectored PostScript
     
    439439      fclose(file);
    440440    } 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;
    442443    }
    443444  } else {
     
    446447
    447448  delete[] feedback_buffer;
     449  return true;
    448450}
    449451
     
    823825}
    824826
    825 int G4OpenGLViewer::generateEPS (const char* filnam,
    826                                 int inColour,
     827int G4OpenGLViewer::printNonVectoredEPS (int inColour,
    827828                                unsigned int width,
    828829                                unsigned int height) {
     
    832833  GLubyte* curpix;
    833834  int components, pos, i;
    834 
    835   WritePostScript("AAAAAAAAAAAAAAA.ps");
    836835
    837836  pixels = grabPixels (inColour, width, height);
     
    845844  }
    846845 
    847   fp = fopen (filnam, "w");
     846  fp = fopen (fPrintFilename.c_str(), "w");
    848847  if (fp == NULL) {
    849848    return 2;
     
    851850 
    852851  fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
    853   fprintf (fp, "%%%%Title: %s\n", filnam);
     852  fprintf (fp, "%%%%Title: %s\n", fPrintFilename.c_str());
    854853  fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
    855854  fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
     
    903902
    904903
    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");
     904bool 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();
    931917  if (fGL2PSAction->enableFileWriting()) {
     918#ifdef G4DEBUG_VIS_OGL
     919      printf("Call Need() \n");
     920#endif
    932921    NeedKernelVisit ();
     922#ifdef G4DEBUG_VIS_OGL
     923      printf("Call Process() \n");
     924#endif
    933925    ProcessView();
    934926    SetView ();
     
    937929    fGL2PSAction->disableFileWriting();
    938930  }
    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;
    998937}
    999938
  • trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc

    r924 r938  
    4949#include "G4Point3D.hh"
    5050#include "G4Normal3D.hh"
     51#include "G4StateManager.hh"
    5152
    5253#include <X11/Xatom.h>
     
    417418  if (fVectoredPs) {
    418419
    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   
    421430  } else {
    422431
     
    454463    DrawView ();
    455464   
    456     generateEPS (fPrintFilename.c_str(),
    457                  fPrintColour,
     465    printNonVectoredEPS (fPrintColour,
    458466                 fWinSize_x, fWinSize_y);
    459467   
Note: See TracChangeset for help on using the changeset viewer.