Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/SoGL2PSAction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/OpenInventor/src/SoGL2PSAction.cc (Version 11.3.0) and /visualization/OpenInventor/src/SoGL2PSAction.cc (Version 11.2.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26                                                    26 
 27 /*----------------------------HEPVis----------     27 /*----------------------------HEPVis----------------------------------------*/
 28 /*                                                 28 /*                                                                          */
 29 /* Node:             SoGL2PSAction                 29 /* Node:             SoGL2PSAction                                          */
 30 /* Author:           Guy Barrand                   30 /* Author:           Guy Barrand                                            */
 31 /*                                                 31 /*                                                                          */
 32 /*--------------------------------------------     32 /*--------------------------------------------------------------------------*/
 33                                                    33 
 34 // this :                                          34 // this :
 35 #include <HEPVis/actions/SoGL2PSAction.h>          35 #include <HEPVis/actions/SoGL2PSAction.h>
 36                                                    36 
 37 // Inventor :                                      37 // Inventor :
 38 #include <Inventor/elements/SoViewportRegionEl     38 #include <Inventor/elements/SoViewportRegionElement.h>
 39 #include <Inventor/errors/SoDebugError.h>          39 #include <Inventor/errors/SoDebugError.h>
 40                                                    40 
 41 #include <Inventor/system/gl.h>                    41 #include <Inventor/system/gl.h>
 42                                                    42 
 43 #include <stdio.h>                                 43 #include <stdio.h>
 44                                                    44 
 45 SO_ACTION_SOURCE(SoGL2PSAction)                    45 SO_ACTION_SOURCE(SoGL2PSAction)
 46 //////////////////////////////////////////////     46 //////////////////////////////////////////////////////////////////////////////
 47 void SoGL2PSAction::initClass(                     47 void SoGL2PSAction::initClass(
 48 )                                                  48 )
 49 //////////////////////////////////////////////     49 //////////////////////////////////////////////////////////////////////////////
 50 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     50 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 51 {                                                  51 {
 52   static bool first = true;                        52   static bool first = true;
 53   if (first) {                                     53   if (first) {
 54     first = false;                                 54     first = false;
 55     SO_ACTION_INIT_CLASS(SoGL2PSAction,SoGLRen     55     SO_ACTION_INIT_CLASS(SoGL2PSAction,SoGLRenderAction);
 56   }                                                56   }
 57 }                                                  57 }
 58 //////////////////////////////////////////////     58 //////////////////////////////////////////////////////////////////////////////
 59 SoGL2PSAction::SoGL2PSAction(                      59 SoGL2PSAction::SoGL2PSAction(
 60  const SbViewportRegion& aViewPortRegion           60  const SbViewportRegion& aViewPortRegion
 61 )                                                  61 )
 62 :SoGLRenderAction(aViewPortRegion)                 62 :SoGLRenderAction(aViewPortRegion)
 63 ,fContext(0)                                       63 ,fContext(0)
 64 ,fFile(0)                                          64 ,fFile(0)
 65 ,fFileName("out.pdf")                              65 ,fFileName("out.pdf")
 66 ,fTitle("title")                                   66 ,fTitle("title")
 67 ,fProducer("HEPVis::SoGL2PSAction")                67 ,fProducer("HEPVis::SoGL2PSAction")
 68 ,fFormat(TOOLS_GL2PS_PDF)                          68 ,fFormat(TOOLS_GL2PS_PDF)
 69 //////////////////////////////////////////////     69 //////////////////////////////////////////////////////////////////////////////
 70 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     70 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 71 {                                                  71 {
 72   SO_ACTION_CONSTRUCTOR(SoGL2PSAction);            72   SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
 73 }                                                  73 }
 74                                                    74 
 75 //////////////////////////////////////////////     75 //////////////////////////////////////////////////////////////////////////////
 76 SoGL2PSAction::~SoGL2PSAction()                    76 SoGL2PSAction::~SoGL2PSAction()
 77 //////////////////////////////////////////////     77 //////////////////////////////////////////////////////////////////////////////
 78 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     78 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 79 {                                                  79 {
 80   closeFile();                                     80   closeFile();
 81 }                                                  81 }
 82                                                    82 
 83 //////////////////////////////////////////////     83 //////////////////////////////////////////////////////////////////////////////
 84 void SoGL2PSAction::setFileName(const std::str     84 void SoGL2PSAction::setFileName(const std::string& aFileName)
 85 //////////////////////////////////////////////     85 //////////////////////////////////////////////////////////////////////////////
 86 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     86 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 87 {                                                  87 {
 88   fFileName = aFileName;                           88   fFileName = aFileName;
 89 }                                                  89 }
 90                                                    90 
 91 //////////////////////////////////////////////     91 //////////////////////////////////////////////////////////////////////////////
 92 void SoGL2PSAction::setTitleAndProducer(const      92 void SoGL2PSAction::setTitleAndProducer(const std::string& aTitle,const std::string& aProducer)
 93 //////////////////////////////////////////////     93 //////////////////////////////////////////////////////////////////////////////
 94 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     94 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 95 {                                                  95 {
 96   fTitle = aTitle;                                 96   fTitle = aTitle;
 97   fProducer = aProducer;                           97   fProducer = aProducer;
 98 }                                                  98 }
 99                                                    99 
100 void SoGL2PSAction::setExportImageFormat_PS()     100 void SoGL2PSAction::setExportImageFormat_PS()  {fFormat = TOOLS_GL2PS_PS;}
101 void SoGL2PSAction::setExportImageFormat_EPS()    101 void SoGL2PSAction::setExportImageFormat_EPS() {fFormat = TOOLS_GL2PS_EPS;}
102 void SoGL2PSAction::setExportImageFormat_TEX()    102 void SoGL2PSAction::setExportImageFormat_TEX() {fFormat = TOOLS_GL2PS_TEX;}
103 void SoGL2PSAction::setExportImageFormat_PDF()    103 void SoGL2PSAction::setExportImageFormat_PDF() {fFormat = TOOLS_GL2PS_PDF;}
104 void SoGL2PSAction::setExportImageFormat_SVG()    104 void SoGL2PSAction::setExportImageFormat_SVG() {fFormat = TOOLS_GL2PS_SVG;}
105 void SoGL2PSAction::setExportImageFormat_PGF()    105 void SoGL2PSAction::setExportImageFormat_PGF() {fFormat = TOOLS_GL2PS_PGF;}
106                                                   106 
107 //////////////////////////////////////////////    107 //////////////////////////////////////////////////////////////////////////////
108 bool SoGL2PSAction::enableFileWriting()           108 bool SoGL2PSAction::enableFileWriting()
109 //////////////////////////////////////////////    109 //////////////////////////////////////////////////////////////////////////////
110 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    110 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
111 {                                                 111 {
112   if(!openFile()) {                               112   if(!openFile()) {
113     SoDebugError::post("SoGL2PSAction::enableF    113     SoDebugError::post("SoGL2PSAction::enableFileWriting",
114                        "openFile() failed for     114                        "openFile() failed for fil %s",
115                        fFileName.c_str());        115                        fFileName.c_str());
116     return false;                                 116     return false;
117   }                                               117   }
118 #ifdef __COIN__                                   118 #ifdef __COIN__
119 #else //SGI                                       119 #else //SGI
120   const SbViewportRegion& vpr = getViewportReg    120   const SbViewportRegion& vpr = getViewportRegion();
121   SoViewportRegionElement::set(getState(),vpr)    121   SoViewportRegionElement::set(getState(),vpr);
122   SbVec2s origin = vpr.getViewportOriginPixels    122   SbVec2s origin = vpr.getViewportOriginPixels();
123   SbVec2s size = vpr.getViewportSizePixels();     123   SbVec2s size = vpr.getViewportSizePixels();
124   if(!beginPage(origin[0],origin[1],size[0],si    124   if(!beginPage(origin[0],origin[1],size[0],size[1])) {
125     SoDebugError::post("SoGL2PSAction::enableF    125     SoDebugError::post("SoGL2PSAction::enableFileWriting","beginPage() failed");
126     return false;                                 126     return false;
127   }                                               127   }
128 #endif                                            128 #endif
129   return true;                                    129   return true;
130 }                                                 130 }
131 //////////////////////////////////////////////    131 //////////////////////////////////////////////////////////////////////////////
132 void SoGL2PSAction::disableFileWriting(           132 void SoGL2PSAction::disableFileWriting(
133 )                                                 133 )
134 //////////////////////////////////////////////    134 //////////////////////////////////////////////////////////////////////////////
135 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    135 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
136 {                                                 136 {
137 #ifdef __COIN__                                   137 #ifdef __COIN__
138 #else //SGI                                       138 #else //SGI
139   endPage();                                      139   endPage();
140 #endif                                            140 #endif
141   closeFile();                                    141   closeFile();
142 }                                                 142 }
143                                                   143 
144 //////////////////////////////////////////////    144 //////////////////////////////////////////////////////////////////////////////
145 void SoGL2PSAction::beginTraversal(               145 void SoGL2PSAction::beginTraversal(
146  SoNode* aNode                                    146  SoNode* aNode
147 )                                                 147 )
148 //////////////////////////////////////////////    148 //////////////////////////////////////////////////////////////////////////////
149 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    149 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
150 {                                                 150 {
151   if(fContext && fFile) {                         151   if(fContext && fFile) {
152 #ifdef __COIN__                                   152 #ifdef __COIN__
153     const SbViewportRegion& vpr = getViewportR    153     const SbViewportRegion& vpr = getViewportRegion();
154     SoViewportRegionElement::set(getState(),vp    154     SoViewportRegionElement::set(getState(),vpr);
155     SbVec2s origin = vpr.getViewportOriginPixe    155     SbVec2s origin = vpr.getViewportOriginPixels();
156     SbVec2s size = vpr.getViewportSizePixels()    156     SbVec2s size = vpr.getViewportSizePixels();
157     if(!beginPage(origin[0],origin[1],size[0],    157     if(!beginPage(origin[0],origin[1],size[0],size[1])) {
158       SoDebugError::post("SoGL2PSAction::begin    158       SoDebugError::post("SoGL2PSAction::beginTraversal","beginPage() failed");
159       return;                                     159       return;
160     }                                             160     }
161     traverse(aNode);                              161     traverse(aNode);
162     if(!endPage()) {                              162     if(!endPage()) {
163       SoDebugError::post("SoGL2PSAction::begin    163       SoDebugError::post("SoGL2PSAction::beginTraversal","endPage() failed");
164       return;                                     164       return;
165     }                                             165     }
166 #else //SGI                                       166 #else //SGI
167     SoGLRenderAction::beginTraversal(aNode);      167     SoGLRenderAction::beginTraversal(aNode);
168 #endif                                            168 #endif
169   } else {                                        169   } else {
170     SoGLRenderAction::beginTraversal(aNode);      170     SoGLRenderAction::beginTraversal(aNode);
171   }                                               171   }
172 }                                                 172 }
173                                                   173 
174 #include <tools/gl2ps>                            174 #include <tools/gl2ps>
175                                                   175 
176 //////////////////////////////////////////////    176 //////////////////////////////////////////////////////////////////////////////
177 bool SoGL2PSAction::openFile()                    177 bool SoGL2PSAction::openFile()
178 //////////////////////////////////////////////    178 //////////////////////////////////////////////////////////////////////////////
179 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    179 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
180 {                                                 180 {
181   if(fFile) {                                     181   if(fFile) {
182     ::fclose(fFile);                              182     ::fclose(fFile);
183     fFile = 0;                                    183     fFile = 0;
184   }                                               184   }
185   if(fContext) {                                  185   if(fContext) {
186     ::tools_gl2psDeleteContext(fContext);         186     ::tools_gl2psDeleteContext(fContext);
187     fContext = 0;                                 187     fContext = 0;
188   }                                               188   }
189                                                   189 
190   fContext = ::tools_gl2psCreateContext();        190   fContext = ::tools_gl2psCreateContext();
191   if(!fContext) return false;                     191   if(!fContext) return false;
192                                                   192 
193   tools_gl2ps_gl_funcs_t _funcs = {               193   tools_gl2ps_gl_funcs_t _funcs = {
194     (tools_glIsEnabled_func)glIsEnabled,          194     (tools_glIsEnabled_func)glIsEnabled,
195     (tools_glBegin_func)glBegin,                  195     (tools_glBegin_func)glBegin,
196     (tools_glEnd_func)glEnd,                      196     (tools_glEnd_func)glEnd,
197     (tools_glGetFloatv_func)glGetFloatv,          197     (tools_glGetFloatv_func)glGetFloatv,
198     (tools_glVertex3f_func)glVertex3f,            198     (tools_glVertex3f_func)glVertex3f,
199     (tools_glGetBooleanv_func)glGetBooleanv,      199     (tools_glGetBooleanv_func)glGetBooleanv,
200     (tools_glGetIntegerv_func)glGetIntegerv,      200     (tools_glGetIntegerv_func)glGetIntegerv,
201     (tools_glRenderMode_func)glRenderMode,        201     (tools_glRenderMode_func)glRenderMode,
202     (tools_glFeedbackBuffer_func)glFeedbackBuf    202     (tools_glFeedbackBuffer_func)glFeedbackBuffer,
203     (tools_glPassThrough_func)glPassThrough       203     (tools_glPassThrough_func)glPassThrough
204   };                                              204   };
205   ::tools_gl2ps_set_gl_funcs(fContext,&_funcs)    205   ::tools_gl2ps_set_gl_funcs(fContext,&_funcs);
206                                                   206   
207   fFile = ::fopen(fFileName.c_str(),"wb");        207   fFile = ::fopen(fFileName.c_str(),"wb");
208   if(!fFile) {                                    208   if(!fFile) {
209     ::tools_gl2psDeleteContext(fContext);         209     ::tools_gl2psDeleteContext(fContext);
210     fContext = 0;                                 210     fContext = 0;
211     return false;                                 211     return false;
212   }                                               212   }
213                                                   213 
214   return true;                                    214   return true;
215 }                                                 215 }
216                                                   216 
217 //////////////////////////////////////////////    217 //////////////////////////////////////////////////////////////////////////////
218 void SoGL2PSAction::closeFile()                   218 void SoGL2PSAction::closeFile()
219 //////////////////////////////////////////////    219 //////////////////////////////////////////////////////////////////////////////
220 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    220 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
221 {                                                 221 {
222   if(fFile) {                                     222   if(fFile) {
223     ::fclose(fFile);                              223     ::fclose(fFile);
224     fFile = 0;                                    224     fFile = 0;
225   }                                               225   }
226   if(fContext) {                                  226   if(fContext) {
227     ::tools_gl2psDeleteContext(fContext);         227     ::tools_gl2psDeleteContext(fContext);
228     fContext = 0;                                 228     fContext = 0;
229   }                                               229   }    
230 }                                                 230 }
231                                                   231 
232 //////////////////////////////////////////////    232 //////////////////////////////////////////////////////////////////////////////
233 bool SoGL2PSAction::beginPage(int a_x,int a_y,    233 bool SoGL2PSAction::beginPage(int a_x,int a_y,int a_w,int a_h)
234 //////////////////////////////////////////////    234 //////////////////////////////////////////////////////////////////////////////
235 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    235 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
236 {                                                 236 {
237   if(!fContext) return false;                     237   if(!fContext) return false;
238   if(!fFile) return false;                        238   if(!fFile) return false;
239                                                   239 
240   if( (a_w<=0) || (a_h<=0) ) return false;        240   if( (a_w<=0) || (a_h<=0) ) return false;
241                                                   241 
242   int options =                                   242   int options = 
243     TOOLS_GL2PS_BEST_ROOT |                       243     TOOLS_GL2PS_BEST_ROOT |
244     TOOLS_GL2PS_DRAW_BACKGROUND |                 244     TOOLS_GL2PS_DRAW_BACKGROUND |
245     TOOLS_GL2PS_USE_CURRENT_VIEWPORT;             245     TOOLS_GL2PS_USE_CURRENT_VIEWPORT;
246   int sort = TOOLS_GL2PS_BSP_SORT;                246   int sort = TOOLS_GL2PS_BSP_SORT;
247                                                   247 
248   int vp[4];                                      248   int vp[4];
249   vp[0] = a_x;                                    249   vp[0] = a_x;
250   vp[1] = a_y;                                    250   vp[1] = a_y;
251   vp[2] = a_w;                                    251   vp[2] = a_w;
252   vp[3] = a_h;                                    252   vp[3] = a_h;
253                                                   253 
254   int bufferSize = 0;                             254   int bufferSize = 0;
255                                                   255   
256   tools_GLint res = ::tools_gl2psBeginPage        256   tools_GLint res = ::tools_gl2psBeginPage
257     (fContext,fTitle.c_str(),fProducer.c_str()    257     (fContext,fTitle.c_str(),fProducer.c_str(),
258      vp,fFormat,sort,options,TOOLS_GL_RGBA,0,     258      vp,fFormat,sort,options,TOOLS_GL_RGBA,0, NULL,0,0,0,
259      bufferSize,fFile,fFileName.c_str());         259      bufferSize,fFile,fFileName.c_str());
260   if (res == TOOLS_GL2PS_ERROR) return false;     260   if (res == TOOLS_GL2PS_ERROR) return false;
261                                                   261 
262   // enable blending for all                      262   // enable blending for all
263   ::tools_gl2psEnable(fContext,TOOLS_GL2PS_BLE    263   ::tools_gl2psEnable(fContext,TOOLS_GL2PS_BLEND);
264                                                   264   
265   return true;                                    265   return true;
266 }                                                 266 }
267                                                   267 
268 //////////////////////////////////////////////    268 //////////////////////////////////////////////////////////////////////////////
269 bool SoGL2PSAction::endPage()                     269 bool SoGL2PSAction::endPage()
270 //////////////////////////////////////////////    270 //////////////////////////////////////////////////////////////////////////////
271 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    271 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
272 {                                                 272 {
273   int _status = 0;                                273   int _status = 0;
274   if(fContext) {                                  274   if(fContext) {
275     _status = ::tools_gl2psEndPage(fContext);     275     _status = ::tools_gl2psEndPage(fContext);
276   }                                               276   }
277   if (_status == TOOLS_GL2PS_OVERFLOW) return     277   if (_status == TOOLS_GL2PS_OVERFLOW) return false;
278   return true;                                    278   return true;
279 }                                                 279 }
280                                                   280 
281 //////////////////////////////////////////////    281 //////////////////////////////////////////////////////////////////////////////
282 bool SoGL2PSAction::addBitmap(                    282 bool SoGL2PSAction::addBitmap(
283  int aWidth                                       283  int aWidth
284 ,int aHeight                                      284 ,int aHeight
285 ,float aXorig                                     285 ,float aXorig
286 ,float aYorig                                     286 ,float aYorig
287 ,float aXmove                                     287 ,float aXmove
288 ,float aYmove                                     288 ,float aYmove
289 )                                                 289 )
290 //////////////////////////////////////////////    290 /////////////////////////////////////////////////////////////////////////////
291 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    291 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
292 {                                                 292 {
293   if(!fContext) return false;                     293   if(!fContext) return false;
294   GLboolean valid;                                294   GLboolean valid;
295   ::glGetBooleanv(GL_CURRENT_RASTER_POSITION_V    295   ::glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
296   if(!valid) return false;                        296   if(!valid) return false;
297   float pos[4];                                   297   float pos[4];
298   ::glGetFloatv(GL_CURRENT_RASTER_POSITION,pos    298   ::glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
299   int xoff = -(int)(aXmove + aXorig);             299   int xoff = -(int)(aXmove + aXorig);
300   int yoff = -(int)(aYmove + aYorig);             300   int yoff = -(int)(aYmove + aYorig);
301   int x = (int)(pos[0] + xoff);                   301   int x = (int)(pos[0] + xoff);
302   int y = (int)(pos[1] + yoff);                   302   int y = (int)(pos[1] + yoff);
303   // Should clip against viewport area :          303   // Should clip against viewport area :
304   GLint vp[4];                                    304   GLint vp[4];
305   ::glGetIntegerv(GL_VIEWPORT,vp);                305   ::glGetIntegerv(GL_VIEWPORT,vp);
306   GLsizei w = aWidth;                             306   GLsizei w = aWidth;
307   GLsizei h = aHeight;                            307   GLsizei h = aHeight;
308   if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;        308   if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
309   if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;        309   if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;
310   int s = 3 * w * h;                              310   int s = 3 * w * h;
311   if(s<=0) return false;                          311   if(s<=0) return false;
312   float* image = (float*)::malloc(s * sizeof(f    312   float* image = (float*)::malloc(s * sizeof(float));
313   if(!image) return false;                        313   if(!image) return false;
314   ::glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image    314   ::glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
315   GLint status = ::tools_gl2psDrawPixels(fCont    315   GLint status = ::tools_gl2psDrawPixels(fContext,w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
316   ::free(image);                                  316   ::free(image);
317   return (status!=TOOLS_GL2PS_SUCCESS ? false     317   return (status!=TOOLS_GL2PS_SUCCESS ? false : true);
318 }                                                 318 }
319                                                   319 
320                                                   320