Ignore:
Timestamp:
Feb 16, 2009, 10:14:30 AM (15 years ago)
Author:
garnier
Message:

en test de gl2ps. Problemes de libraries

Location:
trunk/source/visualization/OpenInventor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenInventor/GNUmakefile

    r529 r921  
    1818include $(G4INSTALL)/config/interactivity.gmk
    1919
     20ifdef G4VIS_BUILD_OPENGL_DRIVER
     21CPPFLAGS += -I$(G4BASE)/visualization/externals/gl2ps/include
     22endif
     23ifdef G4VIS_BUILD_OI_DRIVER
     24CPPFLAGS += -I$(G4BASE)/visualization/externals/gl2ps/include
     25endif
     26
    2027CPPFLAGS += -I$(G4BASE)/visualization/management/include
    2128CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
     
    3340CPPFLAGS += -I$(G4BASE)/digits_hits/hits/include
    3441
     42INTYLIBS += -L$(G4LIBDIR) -lG4gl2ps
     43
    3544include $(G4INSTALL)/config/common.gmk
    3645
  • trunk/source/visualization/OpenInventor/include/HEPVis/actions/SoGL2PSAction.h

    r529 r921  
    2828
    2929#include <Inventor/actions/SoGLRenderAction.h>
     30#include "G4OpenGL2PSAction.hh"
    3031
    3132/**
     
    3738#define SoGL2PSAction Geant4_SoGL2PSAction
    3839
    39 class SoGL2PSAction : public SoGLRenderAction {
     40class SoGL2PSAction : public SoGLRenderAction, public G4OpenGL2PSAction {
    4041  SO_ACTION_HEADER(SoGL2PSAction);
    4142public:
    4243  SoGL2PSAction(const SbViewportRegion&);
    43   void setFileName(const char*);
    44   void enableFileWriting();
    45   void disableFileWriting();
    46   SbBool fileWritingEnabled() const;
    47   SbBool addBitmap(int,int,float=0,float=0,float=0,float=0);
    48   void beginViewport();
    49   void endViewport();
    5044public: /*SoINTERNAL*/
    5145  static void initClass();
    5246protected:
    5347  virtual void beginTraversal(SoNode*);
    54 private:
    55   void gl2psBegin();
    56 private:
    57   SbString fFileName;
    58   FILE* fFile;
     48  void setViewport();
    5949};
    6050
  • trunk/source/visualization/OpenInventor/src/G4OpenInventorViewer.cc

    r850 r921  
    5050#include "G4Scene.hh"
    5151#include "Geant4_SoPolyhedron.h"
    52 #include "G4AttValue.hh"
    53 #include "G4AttDef.hh"
     52#include "G4AttValue.hh"#include "G4AttDef.hh"
    5453#include "G4AttCheck.hh"
    5554#include "G4AttHolder.hh"
     
    480479  fGL2PSAction->setFileName(aFile.c_str());
    481480  G4cout << "Produce " << aFile << "..." << G4endl;
    482   fGL2PSAction->enableFileWriting();
    483   ViewerRender();
    484   fGL2PSAction->disableFileWriting();
     481  if (fGL2PSAction->enableFileWriting()) {
     482    ViewerRender();
     483    fGL2PSAction->disableFileWriting();
     484  }
    485485}
    486486
  • trunk/source/visualization/OpenInventor/src/SoGL2PSAction.cc

    r529 r921  
    3333/*--------------------------------------------------------------------------*/
    3434
     35
    3536// this :
    3637#include <HEPVis/actions/SoGL2PSAction.h>
     
    4041#include <Inventor/errors/SoDebugError.h>
    4142
    42 #include "Geant4_gl2ps.h"
     43//#include "Geant4_gl2ps.h"
    4344
    4445#include <stdio.h>
     
    5859)
    5960:SoGLRenderAction(aViewPortRegion)
    60 ,fFileName("out.ps")
    61 ,fFile(0)
     61,G4OpenGL2PSAction()
    6262//////////////////////////////////////////////////////////////////////////////
    6363//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    6464{
     65  setFileName("out.ps");
    6566  SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
    6667}
    6768//////////////////////////////////////////////////////////////////////////////
    68 void SoGL2PSAction::setFileName(
    69  const char* aFileName
     69void SoGL2PSAction::setViewport(
    7070)
    7171//////////////////////////////////////////////////////////////////////////////
    7272//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    7373{
    74   fFileName = aFileName;
    75 }
    76 //////////////////////////////////////////////////////////////////////////////
    77 void SoGL2PSAction::enableFileWriting(
    78 )
    79 //////////////////////////////////////////////////////////////////////////////
    80 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    81 {
    82   fFile = ::fopen(fFileName.getString(),"w");
    83   if(!fFile) {
    84     SoDebugError::post("SoGL2PSAction::enableFileWriting",
    85                        "Cannot open file %s",fFileName.getString());
    86     return;
    87   }
     74  // FIXME Useful ??
     75
    8876#ifdef __COIN__
    8977#else //SGI
    9078  const SbViewportRegion& vpr = getViewportRegion();
    9179  SoViewportRegionElement::set(getState(),vpr);
    92   gl2psBegin();
     80 
     81  const SbVec2s& win = vpr.getWindowSize();
     82  fViewport[0] = 0;
     83  fViewport[1] = 0;
     84  fViewport[2] = win[0];
     85  fViewport[3] = win[1];
    9386#endif
    94 }
    95 //////////////////////////////////////////////////////////////////////////////
    96 void SoGL2PSAction::disableFileWriting(
    97 )
    98 //////////////////////////////////////////////////////////////////////////////
    99 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    100 {
    101 #ifdef __COIN__
    102 #else //SGI
    103   gl2psEndPage();       
    104 #endif
    105   ::fclose(fFile);
    106   fFile = 0;
    107 }
    108 //////////////////////////////////////////////////////////////////////////////
    109 SbBool SoGL2PSAction::fileWritingEnabled(
    110 ) const
    111 //////////////////////////////////////////////////////////////////////////////
    112 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    113 {
    114   return (fFile?TRUE:FALSE);
    115 }
    116 //////////////////////////////////////////////////////////////////////////////
    117 SbBool SoGL2PSAction::addBitmap(
    118  int aWidth
    119 ,int aHeight
    120 ,float aXorig
    121 ,float aYorig
    122 ,float aXmove
    123 ,float aYmove
    124 )
    125 /////////////////////////////////////////////////////////////////////////////
    126 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    127 {
    128   if(!fFile) return FALSE;
    129   GLboolean valid;
    130   glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
    131   if(valid==GL_FALSE) return FALSE;
    132   float pos[4];
    133   glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
    134   int xoff = -(int)(aXmove + aXorig);
    135   int yoff = -(int)(aYmove + aYorig);
    136   int x = (int)(pos[0] + xoff);
    137   int y = (int)(pos[1] + yoff);
    138   // Should clip against viewport area :
    139   GLint vp[4];
    140   glGetIntegerv(GL_VIEWPORT,vp);
    141   GLsizei w = aWidth;
    142   GLsizei h = aHeight;
    143   if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
    144   if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;
    145   int s = 3 * w * h;
    146   if(s<=0) return FALSE;
    147   float* image = (float*)::malloc(s * sizeof(float));
    148   if(!image) return FALSE;
    149   glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
    150   GLint status = gl2psDrawPixels(w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
    151   ::free(image);
    152   return (status!=GL2PS_SUCCESS ? FALSE : TRUE);
    153 }
    154 //////////////////////////////////////////////////////////////////////////////
    155 void SoGL2PSAction::beginViewport(
    156 )
    157 /////////////////////////////////////////////////////////////////////////////
    158 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    159 {
    160   if(!fFile) return;
    161   GLint vp[4];
    162   glGetIntegerv(GL_VIEWPORT,vp);
    163   gl2psBeginViewport(vp);
    164 }
    165 //////////////////////////////////////////////////////////////////////////////
    166 void SoGL2PSAction::endViewport(
    167 )
    168 /////////////////////////////////////////////////////////////////////////////
    169 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    170 {
    171   if(!fFile) return;
    172   gl2psEndViewport();
    17387}
    17488//////////////////////////////////////////////////////////////////////////////
     
    18397    const SbViewportRegion& vpr = getViewportRegion();
    18498    SoViewportRegionElement::set(getState(),vpr);
    185     gl2psBegin();
     99    Geant4_gl2psBegin();
    186100    traverse(aNode);
    187     gl2psEndPage();       
     101    Geant4_gl2psEndPage();       
    188102#else //SGI
    189103    SoGLRenderAction::beginTraversal(aNode);
     
    193107  }
    194108}
    195 //////////////////////////////////////////////////////////////////////////////
    196 void SoGL2PSAction::gl2psBegin(
    197 )
    198 //////////////////////////////////////////////////////////////////////////////
    199 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    200 {
    201   if(!fFile) return;
    202   int options = GL2PS_OCCLUSION_CULL |
    203      GL2PS_BEST_ROOT | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND;
    204   int sort = GL2PS_BSP_SORT;
    205   //int sort = GL2PS_SIMPLE_SORT;
    206    
    207   const SbViewportRegion& vpr = getViewportRegion();
    208   SoViewportRegionElement::set(getState(),vpr);
    209  
    210   const SbVec2s& win = vpr.getWindowSize();
    211   GLint vp[4];
    212   vp[0] = 0;
    213   vp[1] = 0;
    214   vp[2] = win[0];
    215   vp[3] = win[1];
    216 
    217   int bufsize = 0;
    218   gl2psBeginPage("title","HEPVis::SoGL2PSAction",
    219                  vp,
    220                  GL2PS_EPS,
    221                  sort,
    222                  options,
    223                  GL_RGBA,0, NULL,0,0,0,
    224                  bufsize,
    225                  fFile,fFileName.getString());   
    226 }
    227109
    228110#endif
Note: See TracChangeset for help on using the changeset viewer.