Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
visualization
externals
gl2ps
src
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
43
G4OpenGL2PSAction::G4OpenGL2PSAction
(
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;
56
resetBufferSizeParameters
();
57
}
58
60
void
G4OpenGL2PSAction::resetBufferSizeParameters
(
61
)
64
{
65
fBufferSize
= 1024;
66
fBufferSizeLimit
= 8192;
67
}
68
70
void
G4OpenGL2PSAction::setLineWidth
(
71
int
width
72
)
75
{
76
gl2psLineWidth
( width );
77
}
78
80
void
G4OpenGL2PSAction::setPointSize
(
81
int
size
82
)
85
{
86
gl2psPointSize
( size );
87
}
88
90
void
G4OpenGL2PSAction::setViewport
(
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
106
void
G4OpenGL2PSAction::setFileName
(
107
const
char
* aFileName
108
)
111
{
112
fFileName
= aFileName;
113
}
115
bool
G4OpenGL2PSAction::enableFileWriting
(
116
)
119
{
120
fFile
= ::fopen(
fFileName
,
"wb"
);
121
if
(!
fFile
) {
122
return
false
;
123
}
124
return
G4gl2psBegin
();
125
}
127
bool
G4OpenGL2PSAction::disableFileWriting
(
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
}
141
bool
G4OpenGL2PSAction::extendBufferSize
(
142
)
145
{
146
// extend buffer size *2
147
if
(
fBufferSize
*2 <=
fBufferSizeLimit
) {
148
fBufferSize
=
fBufferSize
*2;
149
return
true
;
150
}
151
return
false
;
152
}
154
bool
G4OpenGL2PSAction::fileWritingEnabled
(
155
)
const
158
{
159
return
(
fFile
?
true
:
false
);
160
}
162
bool
G4OpenGL2PSAction::G4gl2psBegin
(
163
)
166
{
167
if
(!
fFile
)
return
false
;
168
int
options =
GL2PS_OCCLUSION_CULL
|
169
GL2PS_BEST_ROOT
|
GL2PS_SILENT
|
GL2PS_DRAW_BACKGROUND
|
GL2PS_USE_CURRENT_VIEWPORT
;
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
Generated on Sat May 25 2013 14:34:13 for Geant4 by
1.8.4