Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4gl2ps Class Reference

#include <G4gl2ps.hh>

Public Member Functions

 G4gl2ps ()
 
 ~G4gl2ps ()
 
void setOpenGLFunctions (tools_gl2ps_gl_funcs_t *)
 
void setFileName (const char *)
 
void setExportImageFormat (unsigned int)
 
void setExportImageFormat_PS ()
 
void setExportImageFormat_EPS ()
 
void setExportImageFormat_TEX ()
 
void setExportImageFormat_PDF ()
 
void setExportImageFormat_SVG ()
 
void setExportImageFormat_PGF ()
 
bool enableFileWriting ()
 
void disableFileWriting ()
 
bool fileWritingEnabled () const
 
bool beginPage ()
 
bool endPage ()
 
void setLineWidth (int)
 
void setPointSize (int)
 
void addTextOpt (const char *, const char *, tools_GLshort, tools_GLint, tools_GLfloat)
 
void setViewport (int, int, int, int)
 
bool extendBufferSize ()
 
void resetBufferSizeParameters ()
 
void setBufferSize (int)
 
tools_GL2PScontextPointer context () const
 

Protected Attributes

tools_gl2ps_gl_funcs_t fOpenGLFuncs
 
tools_GL2PScontextPointer fContext
 
FILE * fFile
 
G4String fFileName
 
int fViewport [4]
 
int fBufferSize
 
int fBufferSizeLimit
 

Detailed Description

Definition at line 35 of file G4gl2ps.hh.

Constructor & Destructor Documentation

◆ G4gl2ps()

G4gl2ps::G4gl2ps ( )

Definition at line 38 of file G4gl2ps.cc.

38 {
39 fContext = 0;
40 fOpenGLFuncs.m_glIsEnabled = tools_dummy_glIsEnabled;
41 fOpenGLFuncs.m_glBegin = tools_dummy_glBegin;
42 fOpenGLFuncs.m_glEnd = tools_dummy_glEnd;
43 fOpenGLFuncs.m_glGetFloatv = tools_dummy_glGetFloatv;
44 fOpenGLFuncs.m_glVertex3f = tools_dummy_glVertex3f;
45 fOpenGLFuncs.m_glGetBooleanv = tools_dummy_glGetBooleanv;
46 fOpenGLFuncs.m_glGetIntegerv = tools_dummy_glGetIntegerv;
47 fOpenGLFuncs.m_glRenderMode = tools_dummy_glRenderMode;
48 fOpenGLFuncs.m_glFeedbackBuffer = tools_dummy_glFeedbackBuffer;
49 fOpenGLFuncs.m_glPassThrough = tools_dummy_glPassThrough;
50
51 fFile = 0;
52 fViewport[0] = 0;
53 fViewport[1] = 0;
54 fViewport[2] = 0;
55 fViewport[3] = 0;
56 fBufferSize = 2048;
57 fBufferSizeLimit = (std::numeric_limits<int>::max)();
58 fExportImageFormat = TOOLS_GL2PS_PDF;
60}
int fViewport[4]
Definition: G4gl2ps.hh:74
tools_GL2PScontextPointer fContext
Definition: G4gl2ps.hh:71
void resetBufferSizeParameters()
Definition: G4gl2ps.cc:86
int fBufferSize
Definition: G4gl2ps.hh:75
FILE * fFile
Definition: G4gl2ps.hh:72
tools_gl2ps_gl_funcs_t fOpenGLFuncs
Definition: G4gl2ps.hh:70
int fBufferSizeLimit
Definition: G4gl2ps.hh:76
#define TOOLS_GL2PS_PDF
Definition: gl2ps_def.h:37
tools_glPassThrough_func m_glPassThrough
Definition: gl2ps_def.h:209
tools_glIsEnabled_func m_glIsEnabled
Definition: gl2ps_def.h:200
tools_glRenderMode_func m_glRenderMode
Definition: gl2ps_def.h:207
tools_glGetIntegerv_func m_glGetIntegerv
Definition: gl2ps_def.h:206
tools_glGetFloatv_func m_glGetFloatv
Definition: gl2ps_def.h:203
tools_glEnd_func m_glEnd
Definition: gl2ps_def.h:202
tools_glBegin_func m_glBegin
Definition: gl2ps_def.h:201
tools_glGetBooleanv_func m_glGetBooleanv
Definition: gl2ps_def.h:205
tools_glVertex3f_func m_glVertex3f
Definition: gl2ps_def.h:204
tools_glFeedbackBuffer_func m_glFeedbackBuffer
Definition: gl2ps_def.h:208

◆ ~G4gl2ps()

G4gl2ps::~G4gl2ps ( )

Definition at line 62 of file G4gl2ps.cc.

62 {
63 if(fFile) {
64 ::fclose(fFile);
65 fFile = 0;
66 }
67 if(fContext) {
68 ::tools_gl2psDeleteContext(fContext);
69 fContext = 0;
70 }
71}

Member Function Documentation

◆ addTextOpt()

void G4gl2ps::addTextOpt ( const char *  str,
const char *  fontname,
tools_GLshort  fontsize,
tools_GLint  alignment,
tools_GLfloat  angle 
)

Definition at line 100 of file G4gl2ps.cc.

102 {
103 if(!fContext) return;
104 ::tools_gl2psTextOpt(fContext,str,fontname,fontsize,alignment,angle);
105}

Referenced by G4OpenGLViewer::DrawText().

◆ beginPage()

bool G4gl2ps::beginPage ( )

Definition at line 178 of file G4gl2ps.cc.

178 {
179 if(!fContext) return false;
180 if(!fFile) return false;
181
182 if( (fViewport[2]<=0) || (fViewport[3]<=0) ) return false;
183
184 int options =
188 int sort = TOOLS_GL2PS_BSP_SORT;
189
190 tools_GLint res = ::tools_gl2psBeginPage(fContext,"Geant4 output","Geant4",
191 fViewport,
192 fExportImageFormat,
193 sort,
194 options,
195 TOOLS_GL_RGBA,0, NULL,0,0,0,
197 fFile,fFileName.c_str());
198 if (res == TOOLS_GL2PS_ERROR) return false;
199
200 // enable blending for all
201 ::tools_gl2psEnable(fContext,TOOLS_GL2PS_BLEND);
202
203 return true;
204}
G4String fFileName
Definition: G4gl2ps.hh:73
#define TOOLS_GL2PS_USE_CURRENT_VIEWPORT
Definition: gl2ps_def.h:69
#define TOOLS_GL2PS_ERROR
Definition: gl2ps_def.h:52
#define TOOLS_GL2PS_BEST_ROOT
Definition: gl2ps_def.h:63
#define TOOLS_GL2PS_BSP_SORT
Definition: gl2ps_def.h:45
int tools_GLint
Definition: gl2ps_def.h:7
#define TOOLS_GL_RGBA
Definition: gl2ps_def.h:145
#define TOOLS_GL2PS_BLEND
Definition: gl2ps_def.h:82
#define TOOLS_GL2PS_DRAW_BACKGROUND
Definition: gl2ps_def.h:60

◆ context()

tools_GL2PScontextPointer G4gl2ps::context ( ) const
inline

Definition at line 68 of file G4gl2ps.hh.

68{return fContext;}

◆ disableFileWriting()

void G4gl2ps::disableFileWriting ( )

Definition at line 146 of file G4gl2ps.cc.

146 {
147 if(fFile) {
148 ::fclose(fFile);
149 fFile = 0;
150 }
151 if(fContext) {
152 ::tools_gl2psDeleteContext(fContext);
153 fContext = 0;
154 }
155}

◆ enableFileWriting()

bool G4gl2ps::enableFileWriting ( )

Definition at line 118 of file G4gl2ps.cc.

118 {
119 if(fFile) {
120 ::fclose(fFile);
121 fFile = 0;
122 }
123 if(fContext) {
124 ::tools_gl2psDeleteContext(fContext);
125 fContext = 0;
126 }
127
128 fContext = ::tools_gl2psCreateContext();
129 if(!fContext) return false;
130
131 ::tools_gl2ps_set_gl_funcs(fContext,&fOpenGLFuncs);
132
133 fFile = ::fopen(fFileName,"wb");
134 if(!fFile) {
135 ::tools_gl2psDeleteContext(fContext);
136 fContext = 0;
137 return false;
138 }
139
140 // No buffering for output file
141 setvbuf ( fFile , NULL , _IONBF , 2048 );
142
143 return true;
144}

◆ endPage()

bool G4gl2ps::endPage ( )

Definition at line 206 of file G4gl2ps.cc.

206 {
207 int _status = 0;
208 if(fContext) {
209 _status = ::tools_gl2psEndPage(fContext);
210 }
211 if (_status == TOOLS_GL2PS_OVERFLOW) return false;
212 return true;
213}
#define TOOLS_GL2PS_OVERFLOW
Definition: gl2ps_def.h:54

◆ extendBufferSize()

bool G4gl2ps::extendBufferSize ( )

Definition at line 161 of file G4gl2ps.cc.

161 {
162 // extend buffer size *2
163 if (fBufferSize < (fBufferSizeLimit/2)) {
165 return true;
166 }
167 return false;
168}

◆ fileWritingEnabled()

bool G4gl2ps::fileWritingEnabled ( ) const

Definition at line 157 of file G4gl2ps.cc.

157 {
158 return (fContext && fFile?true:false);
159}

Referenced by G4OpenGLViewer::isGl2psWriting().

◆ resetBufferSizeParameters()

void G4gl2ps::resetBufferSizeParameters ( )

Definition at line 86 of file G4gl2ps.cc.

86 {
87 fBufferSize = 2048;
88}

Referenced by G4gl2ps().

◆ setBufferSize()

void G4gl2ps::setBufferSize ( int  newSize)

Definition at line 172 of file G4gl2ps.cc.

173{
174 fBufferSize = (newSize < int(fBufferSizeLimit)) ? newSize : fBufferSizeLimit;
175}

◆ setExportImageFormat()

void G4gl2ps::setExportImageFormat ( unsigned int  type)

Definition at line 215 of file G4gl2ps.cc.

215 {
216 if(fFile) return;
217 fExportImageFormat = type;
218}

Referenced by setExportImageFormat_EPS(), setExportImageFormat_PDF(), setExportImageFormat_PGF(), setExportImageFormat_PS(), setExportImageFormat_SVG(), and setExportImageFormat_TEX().

◆ setExportImageFormat_EPS()

void G4gl2ps::setExportImageFormat_EPS ( )
inline

Definition at line 46 of file G4gl2ps.hh.

void setExportImageFormat(unsigned int)
Definition: G4gl2ps.cc:215
#define TOOLS_GL2PS_EPS
Definition: gl2ps_def.h:35

Referenced by G4OpenGLViewer::exportImage().

◆ setExportImageFormat_PDF()

void G4gl2ps::setExportImageFormat_PDF ( )
inline

Definition at line 48 of file G4gl2ps.hh.

Referenced by G4OpenGLViewer::exportImage().

◆ setExportImageFormat_PGF()

void G4gl2ps::setExportImageFormat_PGF ( )
inline

Definition at line 50 of file G4gl2ps.hh.

#define TOOLS_GL2PS_PGF
Definition: gl2ps_def.h:39

◆ setExportImageFormat_PS()

void G4gl2ps::setExportImageFormat_PS ( )
inline

Definition at line 45 of file G4gl2ps.hh.

#define TOOLS_GL2PS_PS
Definition: gl2ps_def.h:34

Referenced by G4OpenGLViewer::exportImage().

◆ setExportImageFormat_SVG()

void G4gl2ps::setExportImageFormat_SVG ( )
inline

Definition at line 49 of file G4gl2ps.hh.

#define TOOLS_GL2PS_SVG
Definition: gl2ps_def.h:38

Referenced by G4OpenGLViewer::exportImage().

◆ setExportImageFormat_TEX()

void G4gl2ps::setExportImageFormat_TEX ( )
inline

Definition at line 47 of file G4gl2ps.hh.

#define TOOLS_GL2PS_TEX
Definition: gl2ps_def.h:36

◆ setFileName()

void G4gl2ps::setFileName ( const char *  aFileName)

Definition at line 114 of file G4gl2ps.cc.

114 {
115 fFileName = aFileName;
116}

◆ setLineWidth()

void G4gl2ps::setLineWidth ( int  width)

Definition at line 90 of file G4gl2ps.cc.

90 {
91 if(!fContext) return;
92 ::tools_gl2psLineWidth(fContext, width );
93}

Referenced by G4OpenGLViewer::ChangeLineWidth().

◆ setOpenGLFunctions()

◆ setPointSize()

void G4gl2ps::setPointSize ( int  size)

Definition at line 95 of file G4gl2ps.cc.

95 {
96 if(!fContext) return;
97 ::tools_gl2psPointSize(fContext, size );
98}

Referenced by G4OpenGLViewer::ChangePointSize().

◆ setViewport()

void G4gl2ps::setViewport ( int  a,
int  b,
int  winSizeX,
int  winSizeY 
)

Definition at line 107 of file G4gl2ps.cc.

107 {
108 fViewport[0] = a;
109 fViewport[1] = b;
110 fViewport[2] = winSizeX;
111 fViewport[3] = winSizeY;
112}

Member Data Documentation

◆ fBufferSize

int G4gl2ps::fBufferSize
protected

◆ fBufferSizeLimit

int G4gl2ps::fBufferSizeLimit
protected

Definition at line 76 of file G4gl2ps.hh.

Referenced by extendBufferSize(), G4gl2ps(), and setBufferSize().

◆ fContext

◆ fFile

FILE* G4gl2ps::fFile
protected

◆ fFileName

G4String G4gl2ps::fFileName
protected

Definition at line 73 of file G4gl2ps.hh.

Referenced by beginPage(), enableFileWriting(), and setFileName().

◆ fOpenGLFuncs

tools_gl2ps_gl_funcs_t G4gl2ps::fOpenGLFuncs
protected

Definition at line 70 of file G4gl2ps.hh.

Referenced by enableFileWriting(), G4gl2ps(), and setOpenGLFunctions().

◆ fViewport

int G4gl2ps::fViewport[4]
protected

Definition at line 74 of file G4gl2ps.hh.

Referenced by beginPage(), G4gl2ps(), and setViewport().


The documentation for this class was generated from the following files: