Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGL2PSAction.cc
이 파일의 문서화 페이지로 가기
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: G4OpenGL2PSAction.cc 110513 2018-05-28 07:37:38Z gcosmo $
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 #include <limits>
43 #include <cstdlib>
44 #include <cstring>
45 
47 )
50 {
51  fFile = 0;
52  fViewport[0] = 0;
53  fViewport[1] = 0;
54  fViewport[2] = 0;
55  fViewport[3] = 0;
56  fBufferSize = 2048;
60 }
61 
64 )
67 {
68  fBufferSize = 2048;
69 }
70 
73  int width
74 )
77 {
78  gl2psLineWidth( width );
79 }
80 
83  int size
84 )
87 {
88  gl2psPointSize( size );
89 }
90 
93 int a
94 ,int b
95 ,int winSizeX
96 ,int winSizeY
97 )
100 {
101  fViewport[0] = a;
102  fViewport[1] = b;
103  fViewport[2] = winSizeX;
104  fViewport[3] = winSizeY;
105 }
106 
109  const char* aFileName
110 )
113 {
114  fFileName = aFileName;
115 }
118 )
121 {
122  fFile = ::fopen(fFileName,"wb");
123  if(!fFile) {
124  return false;
125  }
126 
127  // No buffering for output file
128  setvbuf ( fFile , NULL , _IONBF , 2048 );
129  return G4gl2psBegin();
130 }
133 )
136 {
137  int state = gl2psEndPage();
138  ::fclose(fFile);
139  if (state == GL2PS_OVERFLOW) {
140  return false;
141  }
142  fFile = 0;
143  return true;
144 }
147 )
150 {
151  // extend buffer size *2
152  if (fBufferSize < (fBufferSizeLimit/2)) {
154  return true;
155  }
156  return false;
157 }
158 
159 
160 // FWJ
161 void G4OpenGL2PSAction::setBufferSize(int newSize)
162 {
163  fBufferSize = (newSize < int(fBufferSizeLimit))
164  ? GLint(newSize) : fBufferSizeLimit;
165 }
166 
167 
169 ) const
172 {
173  return (fFile?true:false);
174 }
177 )
180 {
181  if(!fFile) return false;
182  int options =
184  int sort = GL2PS_BSP_SORT;
185 
186  glGetIntegerv(GL_VIEWPORT,fViewport);
187  GLint res = gl2psBeginPage("Geant4 output","Geant4",
188  fViewport,
190  sort,
191  options,
192  GL_RGBA,0, NULL,0,0,0,
193  fBufferSize,
194  fFile,fFileName.c_str());
195  if (res == GL2PS_ERROR) {
196  return false;
197  }
198  // enable blending for all
200 
201  return true;
202 }
203 
204 void G4OpenGL2PSAction::setExportImageFormat(unsigned int type){
205  if(!fFile) {
206  fExportImageFormat = type;
207  } else {
208  // Could not change the file type at this step. Please change it before enableFileWriting()
209  }
210 }
211 
212 
213 
214 
215 #endif
void setLineWidth(int)
void setPointSize(int)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
bool enableFileWriting()
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
void setExportImageFormat(unsigned int)
bool disableFileWriting()
#define GL2PS_DRAW_BACKGROUND
Definition: gl2ps.h:145
void setFileName(const char *)
void setViewport(int, int, int, int)
fclose(fg1)
#define width
GL2PSDLL_API GLint gl2psEndPage(void)
#define GL2PS_ERROR
Definition: gl2ps.h:137
#define GL2PS_USE_CURRENT_VIEWPORT
Definition: gl2ps.h:154
GL2PSDLL_API GLint gl2psPointSize(GLfloat value)
#define GL2PS_BSP_SORT
Definition: gl2ps.h:130
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void resetBufferSizeParameters()
unsigned int fExportImageFormat
const G4ThreeVector const G4double const
#define GL2PS_BLEND
Definition: gl2ps.h:164
#define GL2PS_PDF
Definition: gl2ps.h:122
void setBufferSize(int)
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
#define GL2PS_BEST_ROOT
Definition: gl2ps.h:148
bool fileWritingEnabled() const
#define GL2PS_OVERFLOW
Definition: gl2ps.h:139
GL2PSDLL_API GLint gl2psEnable(GLint mode)