Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGL2PSAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id$
28 //
29 //
30 
31 #ifdef G4VIS_BUILD_OPENGL_DRIVER
32  #define G4VIS_BUILD_OPENGL_GL2PS
33 #endif
34 #ifdef G4VIS_BUILD_OI_DRIVER
35  #define G4VIS_BUILD_OPENGL_GL2PS
36 #endif
37 
38 #ifdef G4VIS_BUILD_OPENGL_GL2PS
39 
40 #include "G4OpenGL2PSAction.hh"
41 
42 
44 )
47 {
48  fFileName = "";
49  fFile = 0;
50  fViewport[0] = 0;
51  fViewport[1] = 0;
52  fViewport[2] = 0;
53  fViewport[3] = 0;
54  fBufferSize = 1024;
55  fBufferSizeLimit = 8192;
57 }
58 
61 )
64 {
65  fBufferSize = 1024;
66  fBufferSizeLimit = 8192;
67 }
68 
71  int width
72 )
75 {
76  gl2psLineWidth( width );
77 }
78 
81  int size
82 )
85 {
86  gl2psPointSize( size );
87 }
88 
91 int a
92 ,int b
93 ,int winSizeX
94 ,int winSizeY
95 )
98 {
99  fViewport[0] = a;
100  fViewport[1] = b;
101  fViewport[2] = winSizeX;
102  fViewport[3] = winSizeY;
103 }
104 
107  const char* aFileName
108 )
111 {
112  fFileName = aFileName;
113 }
116 )
119 {
120  fFile = ::fopen(fFileName,"wb");
121  if(!fFile) {
122  return false;
123  }
124  return G4gl2psBegin();
125 }
128 )
131 {
132  int state = gl2psEndPage();
133  ::fclose(fFile);
134  if (state == GL2PS_OVERFLOW) {
135  return false;
136  }
137  fFile = 0;
138  return true;
139 }
142 )
145 {
146  // extend buffer size *2
147  if (fBufferSize*2 <= fBufferSizeLimit) {
149  return true;
150  }
151  return false;
152 }
155 ) const
158 {
159  return (fFile?true:false);
160 }
163 )
166 {
167  if(!fFile) return false;
168  int options = GL2PS_OCCLUSION_CULL |
170 // int options = GL2PS_OCCLUSION_CULL |
171 // GL2PS_BEST_ROOT | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND;
172  int sort = GL2PS_BSP_SORT;
173  // int sort = GL2PS_SIMPLE_SORT;
174  GLint buffsize = 0;
175  buffsize += fBufferSize*fBufferSize;
176 
177  glGetIntegerv(GL_VIEWPORT,fViewport);
178 
179  GLint res = gl2psBeginPage("title","HEPVis::G4OpenGL2PSAction",
180  fViewport,
181  GL2PS_EPS,
182  sort,
183  options,
184  GL_RGBA,0, NULL,0,0,0,
185  buffsize,
186  fFile,fFileName);
187  if (res == GL2PS_ERROR) {
188  return false;
189  }
190  return true;
191 
192 }
193 
194 
195 
196 
197 #endif