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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4gl2ps.cc (Version 11.3.0) and /visualization/OpenGL/src/G4gl2ps.cc (Version 9.6.p3)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 //                                                
 29                                                   
 30 #include "G4gl2ps.hh"                             
 31                                                   
 32 #include <tools/gl2ps>                            
 33                                                   
 34 #include <limits>                                 
 35 #include <cstdlib>                                
 36 #include <cstring>                                
 37                                                   
 38 G4gl2ps::G4gl2ps() {                              
 39   fContext = 0;                                   
 40   fOpenGLFuncs.m_glIsEnabled = tools_dummy_glI    
 41   fOpenGLFuncs.m_glBegin = tools_dummy_glBegin    
 42   fOpenGLFuncs.m_glEnd = tools_dummy_glEnd;       
 43   fOpenGLFuncs.m_glGetFloatv = tools_dummy_glG    
 44   fOpenGLFuncs.m_glVertex3f = tools_dummy_glVe    
 45   fOpenGLFuncs.m_glGetBooleanv = tools_dummy_g    
 46   fOpenGLFuncs.m_glGetIntegerv = tools_dummy_g    
 47   fOpenGLFuncs.m_glRenderMode = tools_dummy_gl    
 48   fOpenGLFuncs.m_glFeedbackBuffer = tools_dumm    
 49   fOpenGLFuncs.m_glPassThrough = tools_dummy_g    
 50                                                   
 51   fFile = 0;                                      
 52   fViewport[0] = 0;                               
 53   fViewport[1] = 0;                               
 54   fViewport[2] = 0;                               
 55   fViewport[3] = 0;                               
 56   fBufferSize = 2048;                             
 57   fBufferSizeLimit = (std::numeric_limits<int>    
 58   fExportImageFormat = TOOLS_GL2PS_PDF;           
 59   resetBufferSizeParameters();                    
 60 }                                                 
 61                                                   
 62 G4gl2ps::~G4gl2ps() {                             
 63   if(fFile) {                                     
 64     ::fclose(fFile);                              
 65     fFile = 0;                                    
 66   }                                               
 67   if(fContext) {                                  
 68     ::tools_gl2psDeleteContext(fContext);         
 69     fContext = 0;                                 
 70   }                                               
 71 }                                                 
 72                                                   
 73 void G4gl2ps::setOpenGLFunctions(tools_gl2ps_g    
 74   fOpenGLFuncs.m_glIsEnabled = a_funcs->m_glIs    
 75   fOpenGLFuncs.m_glBegin = a_funcs->m_glBegin;    
 76   fOpenGLFuncs.m_glEnd = a_funcs->m_glEnd;        
 77   fOpenGLFuncs.m_glGetFloatv = a_funcs->m_glGe    
 78   fOpenGLFuncs.m_glVertex3f = a_funcs->m_glVer    
 79   fOpenGLFuncs.m_glGetBooleanv = a_funcs->m_gl    
 80   fOpenGLFuncs.m_glGetIntegerv = a_funcs->m_gl    
 81   fOpenGLFuncs.m_glRenderMode = a_funcs->m_glR    
 82   fOpenGLFuncs.m_glFeedbackBuffer = a_funcs->m    
 83   fOpenGLFuncs.m_glPassThrough = a_funcs->m_gl    
 84 }                                                 
 85                                                   
 86 void G4gl2ps::resetBufferSizeParameters() {       
 87   fBufferSize = 2048;                             
 88 }                                                 
 89                                                   
 90 void G4gl2ps::setLineWidth(int width) {           
 91   if(!fContext) return;                           
 92   ::tools_gl2psLineWidth(fContext, width );       
 93 }                                                 
 94                                                   
 95 void G4gl2ps::setPointSize(int size) {            
 96   if(!fContext) return;                           
 97   ::tools_gl2psPointSize(fContext, size );        
 98 }                                                 
 99                                                   
100 void G4gl2ps::addTextOpt(const char *str, cons    
101                          tools_GLshort fontsiz    
102        tools_GLfloat angle) {                     
103   if(!fContext) return;                           
104   ::tools_gl2psTextOpt(fContext,str,fontname,f    
105 }                                                 
106                                                   
107 void G4gl2ps::setViewport(int a,int b,int winS    
108   fViewport[0] = a;                               
109   fViewport[1] = b;                               
110   fViewport[2] = winSizeX;                        
111   fViewport[3] = winSizeY;                        
112 }                                                 
113                                                   
114 void G4gl2ps::setFileName(const char* aFileNam    
115   fFileName = aFileName;                          
116 }                                                 
117                                                   
118 bool G4gl2ps::enableFileWriting() {               
119   if(fFile) {                                     
120     ::fclose(fFile);                              
121     fFile = 0;                                    
122   }                                               
123   if(fContext) {                                  
124     ::tools_gl2psDeleteContext(fContext);         
125     fContext = 0;                                 
126   }                                               
127                                                   
128   fContext = ::tools_gl2psCreateContext();        
129   if(!fContext) return false;                     
130                                                   
131   ::tools_gl2ps_set_gl_funcs(fContext,&fOpenGL    
132                                                   
133   fFile = ::fopen(fFileName,"wb");                
134   if(!fFile) {                                    
135     ::tools_gl2psDeleteContext(fContext);         
136     fContext = 0;                                 
137     return false;                                 
138   }                                               
139                                                   
140   // No buffering for output file                 
141   setvbuf ( fFile , NULL , _IONBF , 2048 );       
142                                                   
143   return true;                                    
144 }                                                 
145                                                   
146 void G4gl2ps::disableFileWriting() {              
147   if(fFile) {                                     
148     ::fclose(fFile);                              
149     fFile = 0;                                    
150   }                                               
151   if(fContext) {                                  
152     ::tools_gl2psDeleteContext(fContext);         
153     fContext = 0;                                 
154   }                                               
155 }                                                 
156                                                   
157 bool G4gl2ps::fileWritingEnabled() const {        
158   return (fContext && fFile?true:false);          
159 }                                                 
160                                                   
161 bool G4gl2ps::extendBufferSize() {                
162   // extend buffer size *2                        
163   if (fBufferSize < (fBufferSizeLimit/2)) {       
164     fBufferSize = fBufferSize*2;                  
165     return true;                                  
166   }                                               
167   return false;                                   
168 }                                                 
169                                                   
170                                                   
171 // FWJ                                            
172 void G4gl2ps::setBufferSize(int newSize)          
173 {                                                 
174   fBufferSize = (newSize < int(fBufferSizeLimi    
175 }                                                 
176                                                   
177                                                   
178 bool G4gl2ps::beginPage() {                       
179   if(!fContext) return false;                     
180   if(!fFile) return false;                        
181                                                   
182   if( (fViewport[2]<=0) || (fViewport[3]<=0) )    
183                                                   
184   int options =                                   
185     TOOLS_GL2PS_BEST_ROOT |                       
186     TOOLS_GL2PS_DRAW_BACKGROUND |                 
187     TOOLS_GL2PS_USE_CURRENT_VIEWPORT;             
188   int sort = TOOLS_GL2PS_BSP_SORT;                
189                                                   
190   tools_GLint res = ::tools_gl2psBeginPage(fCo    
191                  fViewport,                       
192                  fExportImageFormat,              
193                  sort,                            
194                  options,                         
195                  TOOLS_GL_RGBA,0, NULL,0,0,0,     
196                  fBufferSize,                     
197                  fFile,fFileName.c_str());        
198   if (res == TOOLS_GL2PS_ERROR) return false;     
199                                                   
200   // enable blending for all                      
201   ::tools_gl2psEnable(fContext,TOOLS_GL2PS_BLE    
202                                                   
203   return true;                                    
204 }                                                 
205                                                   
206 bool G4gl2ps::endPage() {                         
207   int _status = 0;                                
208   if(fContext) {                                  
209     _status = ::tools_gl2psEndPage(fContext);     
210   }                                               
211   if (_status == TOOLS_GL2PS_OVERFLOW) return     
212   return true;                                    
213 }                                                 
214                                                   
215 void G4gl2ps::setExportImageFormat(unsigned in    
216   if(fFile) return;                               
217   fExportImageFormat = type;                      
218 }                                                 
219                                                   
220