G4OpenGL2PSAction.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 
00031 #ifdef G4VIS_BUILD_OPENGL_DRIVER
00032  #define G4VIS_BUILD_OPENGL_GL2PS 
00033 #endif
00034 #ifdef G4VIS_BUILD_OI_DRIVER
00035  #define G4VIS_BUILD_OPENGL_GL2PS 
00036 #endif
00037 
00038 #ifdef G4VIS_BUILD_OPENGL_GL2PS
00039 
00040 #include "G4OpenGL2PSAction.hh"
00041 
00042 
00043 G4OpenGL2PSAction::G4OpenGL2PSAction(
00044 )
00047 {
00048   fFileName = "";
00049   fFile = 0;
00050   fViewport[0] = 0;
00051   fViewport[1] = 0;
00052   fViewport[2] = 0;
00053   fViewport[3] = 0;
00054   fBufferSize = 1024;
00055   fBufferSizeLimit = 8192;
00056   resetBufferSizeParameters();
00057 }
00058 
00060 void G4OpenGL2PSAction::resetBufferSizeParameters(
00061 )
00064 {
00065   fBufferSize = 1024;
00066   fBufferSizeLimit = 8192;
00067 }
00068 
00070 void G4OpenGL2PSAction::setLineWidth(
00071  int width
00072 )
00075 {
00076   gl2psLineWidth( width );
00077 }
00078 
00080 void G4OpenGL2PSAction::setPointSize(
00081  int size
00082 )
00085 {
00086   gl2psPointSize( size );
00087 }
00088 
00090 void G4OpenGL2PSAction::setViewport(
00091 int a
00092 ,int b
00093 ,int winSizeX
00094 ,int winSizeY
00095 )
00098 {
00099   fViewport[0] = a;
00100   fViewport[1] = b;
00101   fViewport[2] = winSizeX;
00102   fViewport[3] = winSizeY;
00103 }
00104 
00106 void G4OpenGL2PSAction::setFileName(
00107  const char* aFileName
00108 )
00111 {
00112   fFileName = aFileName;
00113 }
00115 bool G4OpenGL2PSAction::enableFileWriting(
00116 )
00119 {
00120   fFile = ::fopen(fFileName,"wb");
00121   if(!fFile) {
00122     return false;
00123   }
00124   return G4gl2psBegin();
00125 }
00127 bool G4OpenGL2PSAction::disableFileWriting(
00128 )
00131 {
00132   int state = gl2psEndPage();
00133   ::fclose(fFile);
00134   if (state == GL2PS_OVERFLOW) {
00135     return false;
00136   }
00137   fFile = 0;
00138   return true;
00139 }
00141 bool G4OpenGL2PSAction::extendBufferSize(
00142 )
00145 {
00146   // extend buffer size *2
00147   if (fBufferSize*2 <= fBufferSizeLimit) {
00148     fBufferSize = fBufferSize*2;
00149     return true;
00150   }
00151   return false;
00152 }
00154 bool G4OpenGL2PSAction::fileWritingEnabled(
00155 ) const
00158 {
00159   return (fFile?true:false);
00160 }
00162 bool G4OpenGL2PSAction::G4gl2psBegin(
00163 )
00166 {
00167   if(!fFile) return false;
00168   int options = GL2PS_OCCLUSION_CULL | 
00169     GL2PS_BEST_ROOT | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT;
00170 //   int options = GL2PS_OCCLUSION_CULL | 
00171 //      GL2PS_BEST_ROOT | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND;
00172   int sort = GL2PS_BSP_SORT;
00173   //  int sort = GL2PS_SIMPLE_SORT;
00174   GLint buffsize = 0;
00175   buffsize += fBufferSize*fBufferSize;
00176   
00177   glGetIntegerv(GL_VIEWPORT,fViewport);
00178 
00179   GLint res = gl2psBeginPage("title","HEPVis::G4OpenGL2PSAction", 
00180                  fViewport,
00181                  GL2PS_EPS, 
00182                  sort, 
00183                  options, 
00184                  GL_RGBA,0, NULL,0,0,0,
00185                  buffsize, 
00186                  fFile,fFileName);    
00187   if (res == GL2PS_ERROR) {
00188     return false;
00189   }
00190   return true;
00191 
00192 }
00193 
00194 
00195 
00196 
00197 #endif

Generated on Mon May 27 17:49:09 2013 for Geant4 by  doxygen 1.4.7