Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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#ifdef G4VIS_BUILD_OPENGL_DRIVER
31 #define G4VIS_BUILD_OPENGL_GL2PS
32#endif
33#ifdef G4VIS_BUILD_OI_DRIVER
34 #define G4VIS_BUILD_OPENGL_GL2PS
35#endif
36
37#ifdef G4VIS_BUILD_OPENGL_GL2PS
38
39#include "G4OpenGL2PSAction.hh"
40
41#include <limits>
42#include <cstdlib>
43#include <cstring>
44
46)
47//////////////////////////////////////////////////////////////////////////////
48//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
49{
50 fFile = 0;
51 fViewport[0] = 0;
52 fViewport[1] = 0;
53 fViewport[2] = 0;
54 fViewport[3] = 0;
55 fBufferSize = 2048;
56 fBufferSizeLimit = (std::numeric_limits<GLint>::max)();
57 fExportImageFormat = GL2PS_PDF;
59}
60
61//////////////////////////////////////////////////////////////////////////////
63)
64//////////////////////////////////////////////////////////////////////////////
65//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
66{
67 fBufferSize = 2048;
68}
69
70//////////////////////////////////////////////////////////////////////////////
72 int width
73)
74//////////////////////////////////////////////////////////////////////////////
75//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
76{
77 gl2psLineWidth( width );
78}
79
80//////////////////////////////////////////////////////////////////////////////
82 int size
83)
84//////////////////////////////////////////////////////////////////////////////
85//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
86{
87 gl2psPointSize( size );
88}
89
90//////////////////////////////////////////////////////////////////////////////
92int a
93,int b
94,int winSizeX
95,int winSizeY
96)
97//////////////////////////////////////////////////////////////////////////////
98//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
99{
100 fViewport[0] = a;
101 fViewport[1] = b;
102 fViewport[2] = winSizeX;
103 fViewport[3] = winSizeY;
104}
105
106//////////////////////////////////////////////////////////////////////////////
108 const char* aFileName
109)
110//////////////////////////////////////////////////////////////////////////////
111//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
112{
113 fFileName = aFileName;
114}
115//////////////////////////////////////////////////////////////////////////////
117)
118//////////////////////////////////////////////////////////////////////////////
119//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
120{
121 fFile = ::fopen(fFileName,"wb");
122 if(!fFile) {
123 return false;
124 }
125
126 // No buffering for output file
127 setvbuf ( fFile , NULL , _IONBF , 2048 );
128 return G4gl2psBegin();
129}
130//////////////////////////////////////////////////////////////////////////////
132)
133//////////////////////////////////////////////////////////////////////////////
134//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
135{
136 int state = gl2psEndPage();
137 ::fclose(fFile);
138 if (state == GL2PS_OVERFLOW) {
139 return false;
140 }
141 fFile = 0;
142 return true;
143}
144//////////////////////////////////////////////////////////////////////////////
146)
147//////////////////////////////////////////////////////////////////////////////
148//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
149{
150 // extend buffer size *2
151 if (fBufferSize < (fBufferSizeLimit/2)) {
153 return true;
154 }
155 return false;
156}
157
158
159// FWJ
160void G4OpenGL2PSAction::setBufferSize(int newSize)
161{
162 fBufferSize = (newSize < int(fBufferSizeLimit))
163 ? GLint(newSize) : fBufferSizeLimit;
164}
165
166
168) const
169//////////////////////////////////////////////////////////////////////////////
170//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
171{
172 return (fFile?true:false);
173}
174//////////////////////////////////////////////////////////////////////////////
176)
177//////////////////////////////////////////////////////////////////////////////
178//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
179{
180 if(!fFile) return false;
181 int options =
183 int sort = GL2PS_BSP_SORT;
184
185 glGetIntegerv(GL_VIEWPORT,fViewport);
186 GLint res = gl2psBeginPage("Geant4 output","Geant4",
187 fViewport,
188 fExportImageFormat,
189 sort,
190 options,
191 GL_RGBA,0, NULL,0,0,0,
193 fFile,fFileName.c_str());
194 if (res == GL2PS_ERROR) {
195 return false;
196 }
197 // enable blending for all
199
200 return true;
201}
202
203void G4OpenGL2PSAction::setExportImageFormat(unsigned int type){
204 if(!fFile) {
205 fExportImageFormat = type;
206 } else {
207 // Could not change the file type at this step. Please change it before enableFileWriting()
208 }
209}
210
211
212
213
214#endif
#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)
bool disableFileWriting()
bool fileWritingEnabled() const
void setViewport(int, int, int, int)
void setPointSize(int)
void setFileName(const char *)
void setBufferSize(int)
void resetBufferSizeParameters()
#define GL2PS_ERROR
Definition: gl2ps.h:145
#define GL2PS_BSP_SORT
Definition: gl2ps.h:138
#define GL2PS_OVERFLOW
Definition: gl2ps.h:147
#define GL2PS_BEST_ROOT
Definition: gl2ps.h:156
#define GL2PS_DRAW_BACKGROUND
Definition: gl2ps.h:153
#define GL2PS_USE_CURRENT_VIEWPORT
Definition: gl2ps.h:162
#define GL2PS_PDF
Definition: gl2ps.h:130
#define GL2PS_BLEND
Definition: gl2ps.h:173