Ignore:
Timestamp:
Mar 19, 2009, 11:04:17 AM (15 years ago)
Author:
garnier
Message:

en OGLIX ca marche...

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

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/include/G4OpenGLViewer.hh

    r941 r946  
    7070  void rotateScene (G4double dx, G4double dy,G4double delta);
    7171//////////////////////////////Vectored PostScript production functions///
    72   GLubyte* grabPixels (int inColor,
    73                        unsigned int width,
    74                        unsigned int height);
    75   bool printNonVectoredEPS ();
    76   bool printVectoredEPS();
    7772  void printEPS();
     73  // print EPS file. Depending of fVectoredPs, it will print Vectored or not
     74 
    7875  GLdouble getSceneNearWidth();
    7976  GLdouble getSceneFarWidth();
     
    108105  G4float                           fPointSize;
    109106  bool printGl2PS();
     107  GLubyte* grabPixels (int inColor,
     108                       unsigned int width,
     109                       unsigned int height);
     110  bool printNonVectoredEPS ();
     111  // print non vectored EPS files
     112
     113  bool printVectoredEPS();
     114  // print vectored EPS files
    110115};
    111116
  • trunk/source/visualization/OpenGL/include/G4OpenGLXViewer.hh

    r945 r946  
    6363  virtual void CreateMainWindow ();
    6464  virtual void CreateFontLists ();
    65   void print();
     65  void printEPS();
    6666
    6767  static int snglBuf_RGBA[12];
     
    105105  G4OpenGLXViewer (const G4OpenGLXViewer&);
    106106  G4OpenGLXViewer& operator = (const G4OpenGLXViewer&);
     107  GLXContext                        tmp_cx;
    107108};
    108109
  • trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc

    r935 r946  
    372372
    373373   } else { // Size specified in screen (window) coordinates.
    374      glPointSize (size);       
     374     glPointSize (size*centre.x());       
    375375     glBegin (GL_POINTS);
    376376     glVertex3f(centre.x(),centre.y(),centre.z());
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc

    r945 r946  
    281281  }
    282282#endif 
    283   printf("G4OpenGLStoredSceneHandler::AddPrimitive Cree une nouvelle liste de markers\n");
     283  printf("G4OpenGLStoredSceneHandler::AddPrimitive new marker list\n");
    284284  AddPrimitivePreamble(polymarker);
    285285  G4OpenGLSceneHandler::AddPrimitive(polymarker);
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredViewer.cc

    r945 r946  
    133133    fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion;
    134134  size_t nPasses = cutawayUnion? cutaways.size(): 1;
     135#ifdef G4DEBUG_VIS_OGL
     136  printf("G4OpenGLStoredViewer::DrawDisplayLists %d",nPasses);
     137#endif
    135138  for (size_t i = 0; i < nPasses; ++i) {
    136139#ifdef G4DEBUG_VIS_OGL
    137     printf("G4OpenGLStoredViewer::DrawDisplayLists cutaway %d/%d\n",i,nPasses);
     140    printf("+");
    138141#endif
    139142
     
    153156    for (size_t i = 0; i < fG4OpenGLStoredSceneHandler.fTOList.size(); ++i) {
    154157#ifdef G4DEBUG_VIS_OGL
    155       printf("+");
     158      printf("-");
    156159#endif
    157160      G4OpenGLStoredSceneHandler::TO& to =
     
    175178    if (cutawayUnion) glDisable (GL_CLIP_PLANE2);
    176179  }
     180#ifdef G4DEBUG_VIS_OGL
     181      printf("\n");
     182#endif
    177183
    178184  // Display time at "head" of time range, which is fEndTime...
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredXViewer.cc

    r945 r946  
    7777void G4OpenGLStoredXViewer::DrawView () {
    7878
     79  printf("G4OpenGLStoredXViewer::DrawView\n");
    7980  //Make sure current viewer is attached and clean...
    8081  glXMakeCurrent (dpy, fGLXWin, cx);
     
    107108    // have been done, so...
    108109    if (!kernelVisitWasNeeded) {
     110      printf("G4OpenGLStoredXViewer::DrawView NO need kernel visit\n");
    109111      DrawDisplayLists ();
    110112      FinishView ();
    111113    } else {
     114      printf("G4OpenGLStoredXViewer::DrawView NEED kernel visit\n");
    112115    // However, union cutaways are implemented in DrawDisplayLists, so make
    113116    // an extra pass...
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc

    r945 r946  
    8383void G4OpenGLStoredXmViewer::DrawView () {
    8484#ifdef G4DEBUG_VIS_OGL
    85   printf("G4OpenGLStoredXmViewer::DrawView  VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
     85  printf("G4OpenGLStoredXmViewer::DrawView  context:%d old winGL:%d \n",cx,fGLXWin);
    8686#endif
    8787
     
    116116    if (!kernelVisitWasNeeded) {
    117117#ifdef G4DEBUG_VIS_OGL
    118       printf("**************************  G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n");
     118      printf("G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n");
    119119#endif
    120120      DrawDisplayLists ();
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r945 r946  
    587587
    588588    // FIXME : How to get the point size.... ?
    589     fGL2PSAction->setLineWidth(1);
     589    //    fGL2PSAction->setLineWidth(1);
    590590    // FIXME : How to get the line width.... ?
    591     fGL2PSAction->setPointSize(30);
     591    //    fGL2PSAction->setPointSize(30);
    592592
    593593    DrawView ();
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewerMessenger.cc

    r941 r946  
    177177  fpCommandFade->SetDefaultValue(0.);
    178178
     179
    179180  fpCommandPrintMode = new G4UIcmdWithAString
    180181    ("/vis/ogl/set/printMode",this);
     
    228229(G4UIcommand* command, G4String newValue)
    229230{
     231 
    230232  G4VisManager* pVisManager = G4VisManager::GetInstance();
     233
    231234
    232235  G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
     
    250253  }
    251254
    252   if (command == fpCommandPrintEPS)
     255  if (command == fpCommandPrintEPS)  
    253256    {
    254257      // Keep copy of fPrintFilename to preserve Xm behaviour...
     
    261264      pOGLViewer->fPrintFilename = std::string(oss.str().c_str());
    262265      // Print eps file...
     266      printf("G4OpenGLViewerMessenger : Call printEPS \n");
    263267      pOGLViewer->printEPS();
    264268      // Restore fPrintFilename for Xm...
    265269      pOGLViewer->fPrintFilename = tmp_string;
    266270      return;
     271    }
     272
     273  if (command == fpCommandPrintMode)
     274    {
     275      if (newValue == "vectored") pOGLViewer->fVectoredPs = true;
     276      if (newValue == "pixmap") pOGLViewer->fVectoredPs = false;
    267277    }
    268278
     
    343353    }
    344354
    345   if (command == fpCommandPrintMode)
    346     {
    347       if (newValue == "vectored") pViewer->fVectoredPs = true;
    348       if (newValue == "pixmap") pViewer->fVectoredPs = false;
    349     }
    350 
    351355  if (command == fpCommandStartTime)
    352356    {
  • trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc

    r945 r946  
    410410}
    411411
    412 void G4OpenGLXViewer::print() {
    413  
     412void G4OpenGLXViewer::printEPS() {
     413 
     414    printf("G4OpenGLXViewer::print \n");
     415
    414416  //using namespace std;
    415417  //cout << "print_col_callback requested with file name: " << fPrintFilename << G4endl;
     
    419421    printf("G4OpenGLXViewer::print Vectored\n");
    420422#endif
    421     printEPS();   
     423    G4OpenGLViewer::printEPS();   
    422424  } else {
    423425#ifdef G4DEBUG_VIS_OGL
    424426    printf("G4OpenGLXViewer::print non Vectored\n");
    425427#endif
    426     //    printEPS ();
    427     //    return;
    428 
     428//     G4StateManager* stateManager = G4StateManager::GetStateManager();
     429//     G4ApplicationState oldState = stateManager->GetCurrentState();
     430//     stateManager->SetNewState(G4State_Idle); 
     431
     432//     printEPS ();
     433
     434//     stateManager->SetNewState(oldState); 
     435   
     436//     //    fPrintFilename =   fPrintFilename+"-Gl2ps.ps";
     437//     return;
     438
     439// save context before
     440    tmp_cx = cx;
    429441    XVisualInfo* pvi;
    430442    GLXContext pcx = create_GL_print_context(pvi);
    431 
     443//     cmap = XCreateColormap (dpy,
     444//                          XRootWindow(dpy, pvi -> screen),
     445//                          pvi -> visual,
     446//                          AllocNone);
     447//     if (!cmap) {
     448//       fViewId = -1;  // This flags an error.
     449//       G4cerr << "G4OpenGLViewer::G4OpenGLViewer failed to allocate a Colormap."
     450//              << G4endl;
     451//       return;
     452//     }
     453//     swa.colormap = cmap;
    432454    if (!pcx) {
    433455      G4cout << "Unable to create print context." << G4endl;
     
    435457    }
    436458
    437     GLXContext tmp_cx;
    438     tmp_cx = cx;
     459#ifdef G4DEBUG_VIS_OGL
     460    printf("G4OpenGLXViewer::print Create pixmap old context:%d new context %d old winGL:%d \n",cx,pcx,fGLXWin);
     461#endif
    439462    cx=pcx;
    440463   
     
    444467                                 pvi->depth);
    445468   
     469
     470    if (!pmap) {
     471      G4cout << "Unable to create pixmap." << G4endl;
     472      return;
     473    }
    446474    GLXPixmap glxpmap = glXCreateGLXPixmap (dpy,
    447475                                            pvi,
    448476                                            pmap);
    449477   
     478    if (!glxpmap) {
     479      G4cout << "Unable to create glx pixmap." << G4endl;
     480      return;
     481    }
    450482    GLXDrawable tmp_win;
    451483    tmp_win=fGLXWin;
    452484    fGLXWin=glxpmap;
    453485   
    454     // This won't work because fGLXWin is not known in G4OpenGLViewer...
    455 
    456     glXMakeCurrent (dpy,
    457                     fGLXWin,
    458                     cx);
     486    bool er1 = glXMakeCurrent (dpy,
     487                               fGLXWin,  // pixmap win Id
     488                               cx); // pixmap context Id
    459489       
    460490    glViewport (0, 0, fWinSize_x, fWinSize_y);
     
    462492    ClearView ();
    463493    SetView ();
     494#ifdef G4DEBUG_VIS_OGL
     495    printf("G4OpenGLXViewer::print Call DrawView context:%d old winGL:%d \n",cx,fGLXWin);
     496#endif
    464497    DrawView ();
    465498   
     
    472505    cx=tmp_cx;
    473506   
    474     glXMakeCurrent (dpy,
    475                     fGLXWin,
    476                     cx);
     507    bool er2 = glXMakeCurrent (dpy,
     508                    fGLXWin,
     509                    cx);
     510    printf("G4OpenGLXViewer::print Restored context:%d old winGL:%d \n",cx,fGLXWin);
     511    printf("Error 1:%d 2:%d\n",er1,er2);
    477512   
    478513  }
     
    493528  }
    494529
     530//    GLXFBConfig *fbc;
     531//    XVisualInfo *vi;
     532//    Colormap cmap;
     533//    XSetWindowAttributes swa;
     534//    Window win;
     535//    GLXContext cx;
     536//    GLXWindow gwin;
     537//    XEvent event;
     538//    int nelements;
     539 
     540//    /* Find a FBConfig that uses RGBA.  Note that no attribute list is */
     541//    /* needed since GLX_RGBA_BIT is a default attribute.               */
     542//    fbc = glXChooseFBConfig(dpy,XRootWindow (dpy, pvi->screen), 0, &nelements);
     543//    vi = glXGetVisualFromFBConfig(dpy, fbc[0]);
     544 
     545//    /* Create a GLX context using the first FBConfig in the list. */
     546//    return  glXCreateNewContext(dpy, fbc[0], GLX_RGBA_TYPE, 0, GL_FALSE);
     547 
     548
     549 
    495550  return glXCreateContext (dpy,
    496551                           pvi,
    497                            NULL,
     552                           tmp_cx,
    498553                           False);
    499554}
     
    501556
    502557GLubyte* G4OpenGLXViewer::grabPixelsX (int inColor, unsigned int width, unsigned int height) {
     558#ifdef G4DEBUG_VIS_OGL
     559  printf("G4OpenGLXViewer::grabPixelsX\n");
     560#endif
    503561         
    504562  GLubyte* buffer;
     
    538596  glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, format, GL_UNSIGNED_BYTE, (GLvoid*) buffer);
    539597       
     598//   glXWaitGL (); //Wait for effects of all previous OpenGL commands to
     599//                 //be propagated before progressing.
     600//   glFlush ();
     601   for (int i = 0; i<size; i++) {
     602     if (buffer[i] != 0)
     603       printf("%d",buffer[i]);
     604     //     else
     605     //       printf(".");
     606   }
     607
     608//   printf("-----------\n-----------\n-----------\n-----------\n-----------\n%d %d %d\n",width, height,size);
     609//   char * pixels = new char [3 * width * height];
     610//   glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, GL_DEPTH_COMPONENT, GL_FLOAT, pixels);
     611 
     612//   for (int i = 0; i<size; i++) {
     613//     if (pixels[i] != 0)
     614//       printf("%d ",pixels[i]);
     615//     else
     616//       printf(" ");
     617//   }
     618
     619//   printf("-----------\n-----------\n-----------\n-----------\n-----------\n");
     620
    540621  glPixelStorei (GL_UNPACK_SWAP_BYTES, swapbytes);
    541622  glPixelStorei (GL_UNPACK_LSB_FIRST, lsbfirst);
     
    546627  glPixelStorei (GL_UNPACK_ALIGNMENT, alignment);
    547628         
     629 
    548630  return buffer;
    549631}
     
    559641  int components, pos, i;
    560642       
     643#ifdef G4DEBUG_VIS_OGL
     644    printf("G4OpenGLXViewer::generateEPSX\n");
     645#endif
     646
    561647  pixels = grabPixelsX (inColour, width, height);
     648#ifdef G4DEBUG_VIS_OGL
     649    printf("--\n--\n--\n");
     650#endif
    562651       
    563652  if (pixels == NULL)
  • trunk/source/visualization/OpenGL/src/G4OpenGLXmWindowHandlingCallbacks.cc

    r931 r946  
    7474{
    7575  G4OpenGLXViewer* pView = (G4OpenGLXmViewer*) clientData;
    76   pView->print();
     76  pView->printEPS();
    7777}
    7878
Note: See TracChangeset for help on using the changeset viewer.