ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4OpenGL2PSAction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file 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
//
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
45
G4OpenGL2PSAction::G4OpenGL2PSAction
(
46
)
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
;
58
resetBufferSizeParameters
();
59
}
60
62
void
G4OpenGL2PSAction::resetBufferSizeParameters
(
63
)
66
{
67
fBufferSize
= 2048;
68
}
69
71
void
G4OpenGL2PSAction::setLineWidth
(
72
int
width
73
)
76
{
77
gl2psLineWidth
( width );
78
}
79
81
void
G4OpenGL2PSAction::setPointSize
(
82
int
size
83
)
86
{
87
gl2psPointSize
( size );
88
}
89
91
void
G4OpenGL2PSAction::setViewport
(
92
int
a
93
,
int
b
94
,
int
winSizeX
95
,
int
winSizeY
96
)
99
{
100
fViewport
[0] =
a
;
101
fViewport
[1] =
b
;
102
fViewport
[2] = winSizeX;
103
fViewport
[3] = winSizeY;
104
}
105
107
void
G4OpenGL2PSAction::setFileName
(
108
const
char
* aFileName
109
)
112
{
113
fFileName
= aFileName;
114
}
116
bool
G4OpenGL2PSAction::enableFileWriting
(
117
)
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
}
131
bool
G4OpenGL2PSAction::disableFileWriting
(
132
)
135
{
136
int
state =
gl2psEndPage
();
137
::fclose
(
fFile
);
138
if
(state ==
GL2PS_OVERFLOW
) {
139
return
false
;
140
}
141
fFile
= 0;
142
return
true
;
143
}
145
bool
G4OpenGL2PSAction::extendBufferSize
(
146
)
149
{
150
// extend buffer size *2
151
if
(
fBufferSize
< (
fBufferSizeLimit
/2)) {
152
fBufferSize
=
fBufferSize
*2;
153
return
true
;
154
}
155
return
false
;
156
}
157
158
159
// FWJ
160
void
G4OpenGL2PSAction::setBufferSize
(
int
newSize)
161
{
162
fBufferSize
= (newSize <
int
(
fBufferSizeLimit
))
163
? GLint(newSize) :
fBufferSizeLimit
;
164
}
165
166
167
bool
G4OpenGL2PSAction::fileWritingEnabled
(
168
) const
171
{
172
return
(
fFile
?
true
:
false
);
173
}
175
bool
G4OpenGL2PSAction::G4gl2psBegin
(
176
)
179
{
180
if
(!
fFile
)
return
false
;
181
int
options =
182
GL2PS_BEST_ROOT
|
GL2PS_DRAW_BACKGROUND
|
GL2PS_USE_CURRENT_VIEWPORT
;
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,
192
fBufferSize
,
193
fFile
,
fFileName
.c_str());
194
if
(res ==
GL2PS_ERROR
) {
195
return
false
;
196
}
197
// enable blending for all
198
gl2psEnable
(
GL2PS_BLEND
);
199
200
return
true
;
201
}
202
203
void
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
geant4
tree
geant4-10.6-release
source
visualization
externals
gl2ps
src
G4OpenGL2PSAction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:54
using
1.8.2 with
ECCE GitHub integration