Geant4-11
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//
28//
29
30#include "G4OpenGL2PSAction.hh"
31
32#include <limits>
33#include <cstdlib>
34#include <cstring>
35
37)
40{
41 fFile = 0;
42 fViewport[0] = 0;
43 fViewport[1] = 0;
44 fViewport[2] = 0;
45 fViewport[3] = 0;
46 fBufferSize = 2048;
50}
51
54)
57{
58 fBufferSize = 2048;
59}
60
63 int width
64)
67{
68 gl2psLineWidth( width );
69}
70
73 int size
74)
77{
78 gl2psPointSize( size );
79}
80
83int a
84,int b
85,int winSizeX
86,int winSizeY
87)
90{
91 fViewport[0] = a;
92 fViewport[1] = b;
93 fViewport[2] = winSizeX;
94 fViewport[3] = winSizeY;
95}
96
99 const char* aFileName
100)
103{
104 fFileName = aFileName;
105}
108)
111{
112 fFile = ::fopen(fFileName,"wb");
113 if(!fFile) {
114 return false;
115 }
116
117 // No buffering for output file
118 setvbuf ( fFile , NULL , _IONBF , 2048 );
119 return G4gl2psBegin();
120}
123)
126{
127 int state = gl2psEndPage();
128 ::fclose(fFile);
129 if (state == GL2PS_OVERFLOW) {
130 return false;
131 }
132 fFile = 0;
133 return true;
134}
137)
140{
141 // extend buffer size *2
142 if (fBufferSize < (fBufferSizeLimit/2)) {
144 return true;
145 }
146 return false;
147}
148
149
150// FWJ
152{
153 fBufferSize = (newSize < int(fBufferSizeLimit))
154 ? GLint(newSize) : fBufferSizeLimit;
155}
156
157
159) const
162{
163 return (fFile?true:false);
164}
167)
170{
171 if(!fFile) return false;
172 int options =
174 int sort = GL2PS_BSP_SORT;
175
176 glGetIntegerv(GL_VIEWPORT,fViewport);
177 GLint res = gl2psBeginPage("Geant4 output","Geant4",
178 fViewport,
180 sort,
181 options,
182 GL_RGBA,0, NULL,0,0,0,
184 fFile,fFileName.c_str());
185 if (res == GL2PS_ERROR) {
186 return false;
187 }
188 // enable blending for all
190
191 return true;
192}
193
195 if(!fFile) {
196 fExportImageFormat = type;
197 } else {
198 // Could not change the file type at this step. Please change it before enableFileWriting()
199 }
200}
#define gl2psEnable
Definition: Geant4_gl2ps.h:37
#define gl2psBeginPage
Definition: Geant4_gl2ps.h:34
#define gl2psLineWidth
Definition: Geant4_gl2ps.h:40
#define gl2psPointSize
Definition: Geant4_gl2ps.h:39
#define gl2psEndPage
Definition: Geant4_gl2ps.h:35
bool enableFileWriting()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setExportImageFormat(unsigned int)
void setLineWidth(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
G4OpenGL2PSAction()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
bool disableFileWriting()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
bool fileWritingEnabled() const
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setViewport(int, int, int, int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setPointSize(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
bool G4gl2psBegin()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setFileName(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
unsigned int fExportImageFormat
bool extendBufferSize()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void resetBufferSizeParameters()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
#define GL2PS_ERROR
Definition: gl2ps.h:147
#define GL2PS_BSP_SORT
Definition: gl2ps.h:140
#define GL2PS_OVERFLOW
Definition: gl2ps.h:149
#define GL2PS_BEST_ROOT
Definition: gl2ps.h:158
#define GL2PS_DRAW_BACKGROUND
Definition: gl2ps.h:155
#define GL2PS_USE_CURRENT_VIEWPORT
Definition: gl2ps.h:164
#define GL2PS_PDF
Definition: gl2ps.h:132
#define GL2PS_BLEND
Definition: gl2ps.h:176
T max(const T t1, const T t2)
brief Return the largest of the two arguments