Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
SoGL2PSAction Class Reference

#include <SoGL2PSAction.h>

Inheritance diagram for SoGL2PSAction:
G4OpenGL2PSAction

Public Member Functions

bool addBitmap (int, int, float=0, float=0, float=0, float=0)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void disableFileWriting ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
bool enableFileWriting ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
bool extendBufferSize ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
bool fileWritingEnabled () const
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void resetBufferSizeParameters ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void setBufferSize (int)
 
void setExportImageFormat (unsigned int)
 
void setFileName (const char *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void setLineWidth (int)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void setPointSize (int)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
void setViewport (int, int, int, int)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
 SoGL2PSAction (const SbViewportRegion &)
 

Static Public Member Functions

static void initClass ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 

Protected Member Functions

virtual void beginTraversal (SoNode *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 
bool G4gl2psBegin ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// More...
 

Protected Attributes

GLint fBufferSize
 
GLint fBufferSizeLimit
 
FILE * fFile
 
G4String fFileName
 
GLint fViewport [4]
 

Private Member Functions

 SO_ACTION_HEADER (SoGL2PSAction)
 

Private Attributes

unsigned int fExportImageFormat
 

Detailed Description

Definition at line 40 of file SoGL2PSAction.h.

Constructor & Destructor Documentation

◆ SoGL2PSAction()

SoGL2PSAction::SoGL2PSAction ( const SbViewportRegion &  aViewPortRegion)

Definition at line 59 of file SoGL2PSAction.cc.

62:SoGLRenderAction(aViewPortRegion)
66{
67 setFileName("out.ps");
68 SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
69}
G4OpenGL2PSAction()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setFileName(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

References G4OpenGL2PSAction::setFileName().

Member Function Documentation

◆ addBitmap()

bool SoGL2PSAction::addBitmap ( int  aWidth,
int  aHeight,
float  aXorig = 0,
float  aYorig = 0,
float  aXmove = 0,
float  aYmove = 0 
)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 105 of file SoGL2PSAction.cc.

115{
116 if(!fFile) return false;
117 GLboolean valid;
118 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
119 if(!valid) return false;
120 float pos[4];
121 glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
122 int xoff = -(int)(aXmove + aXorig);
123 int yoff = -(int)(aYmove + aYorig);
124 int x = (int)(pos[0] + xoff);
125 int y = (int)(pos[1] + yoff);
126 // Should clip against viewport area :
127 GLint vp[4];
128 glGetIntegerv(GL_VIEWPORT,vp);
129 GLsizei w = aWidth;
130 GLsizei h = aHeight;
131 if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
132 if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;
133 int s = 3 * w * h;
134 if(s<=0) return false;
135 float* image = (float*)::malloc(s * sizeof(float));
136 if(!image) return false;
137 glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
138 GLint status = gl2psDrawPixels(w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
139 ::free(image);
140 return (status!=GL2PS_SUCCESS ? false : true);
141}
static const G4double pos
static constexpr double s
Definition: G4SIunits.hh:154
#define gl2psDrawPixels
Definition: Geant4_gl2ps.h:41
#define GL2PS_SUCCESS
Definition: gl2ps.h:144

References G4OpenGL2PSAction::fFile, free, GL2PS_SUCCESS, gl2psDrawPixels, pos, and s.

◆ beginTraversal()

void SoGL2PSAction::beginTraversal ( SoNode *  aNode)
protectedvirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 143 of file SoGL2PSAction.cc.

148{
149 if(fFile) {
150#ifdef __COIN__
151 const SbViewportRegion& vpr = getViewportRegion();
152 SoViewportRegionElement::set(getState(),vpr);
153 G4gl2psBegin();
154 traverse(aNode);
155 gl2psEndPage();
156#else //SGI
157 // Should have already do G4gl2psBegin() before
158 SoGLRenderAction::beginTraversal(aNode);
159 // Should do gl2psEndPage() after
160#endif
161 } else {
162 SoGLRenderAction::beginTraversal(aNode);
163 }
164}
#define gl2psEndPage
Definition: Geant4_gl2ps.h:35
bool G4gl2psBegin()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

References G4OpenGL2PSAction::fFile, G4OpenGL2PSAction::G4gl2psBegin(), and gl2psEndPage.

◆ disableFileWriting()

void SoGL2PSAction::disableFileWriting ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 91 of file SoGL2PSAction.cc.

95{
96#ifdef __COIN__
97#else //SGI
98 gl2psEndPage();
99#endif
100 ::fclose(fFile);
101 fFile = 0;
102}

References G4OpenGL2PSAction::fFile, and gl2psEndPage.

◆ enableFileWriting()

bool SoGL2PSAction::enableFileWriting ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 71 of file SoGL2PSAction.cc.

75{
76 fFile = ::fopen(fFileName,"w");
77 if(!fFile) {
78 SoDebugError::post("SoGL2PSAction::enableFileWriting",
79 "Cannot open file %s",fFileName.c_str());
80 return false;
81 }
82#ifdef __COIN__
83#else //SGI
84 const SbViewportRegion& vpr = getViewportRegion();
85 SoViewportRegionElement::set(getState(),vpr);
87#endif
88 return true;
89}

References G4OpenGL2PSAction::fFile, G4OpenGL2PSAction::fFileName, and G4OpenGL2PSAction::G4gl2psBegin().

◆ extendBufferSize()

bool G4OpenGL2PSAction::extendBufferSize ( )
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 136 of file G4OpenGL2PSAction.cc.

140{
141 // extend buffer size *2
142 if (fBufferSize < (fBufferSizeLimit/2)) {
144 return true;
145 }
146 return false;
147}

References G4OpenGL2PSAction::fBufferSize, and G4OpenGL2PSAction::fBufferSizeLimit.

Referenced by G4OpenGLViewer::printGl2PS().

◆ fileWritingEnabled()

bool G4OpenGL2PSAction::fileWritingEnabled ( ) const
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 158 of file G4OpenGL2PSAction.cc.

162{
163 return (fFile?true:false);
164}

References G4OpenGL2PSAction::fFile.

Referenced by G4OpenGLViewer::isGl2psWriting(), and G4OpenGLViewer::printGl2PS().

◆ G4gl2psBegin()

bool G4OpenGL2PSAction::G4gl2psBegin ( )
protectedinherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 166 of file G4OpenGL2PSAction.cc.

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}
#define gl2psEnable
Definition: Geant4_gl2ps.h:37
#define gl2psBeginPage
Definition: Geant4_gl2ps.h:34
unsigned int fExportImageFormat
#define GL2PS_ERROR
Definition: gl2ps.h:147
#define GL2PS_BSP_SORT
Definition: gl2ps.h:140
#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_BLEND
Definition: gl2ps.h:176

References G4OpenGL2PSAction::fBufferSize, G4OpenGL2PSAction::fExportImageFormat, G4OpenGL2PSAction::fFile, G4OpenGL2PSAction::fFileName, G4OpenGL2PSAction::fViewport, GL2PS_BEST_ROOT, GL2PS_BLEND, GL2PS_BSP_SORT, GL2PS_DRAW_BACKGROUND, GL2PS_ERROR, GL2PS_USE_CURRENT_VIEWPORT, gl2psBeginPage, and gl2psEnable.

Referenced by beginTraversal(), G4OpenGL2PSAction::enableFileWriting(), and enableFileWriting().

◆ initClass()

void SoGL2PSAction::initClass ( void  )
static

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 47 of file SoGL2PSAction.cc.

51{
52 static bool first = true;
53 if (first) {
54 first = false;
55 SO_ACTION_INIT_CLASS(SoGL2PSAction,SoGLRenderAction);
56 }
57}

Referenced by G4OpenInventor::InitNodes().

◆ resetBufferSizeParameters()

void G4OpenGL2PSAction::resetBufferSizeParameters ( )
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 53 of file G4OpenGL2PSAction.cc.

57{
58 fBufferSize = 2048;
59}

References G4OpenGL2PSAction::fBufferSize.

Referenced by G4OpenGL2PSAction::G4OpenGL2PSAction(), and G4OpenGLViewer::printGl2PS().

◆ setBufferSize()

void G4OpenGL2PSAction::setBufferSize ( int  newSize)
inherited

Definition at line 151 of file G4OpenGL2PSAction.cc.

152{
153 fBufferSize = (newSize < int(fBufferSizeLimit))
154 ? GLint(newSize) : fBufferSizeLimit;
155}

References G4OpenGL2PSAction::fBufferSize, and G4OpenGL2PSAction::fBufferSizeLimit.

◆ setExportImageFormat()

void G4OpenGL2PSAction::setExportImageFormat ( unsigned int  type)
inherited

Definition at line 194 of file G4OpenGL2PSAction.cc.

194 {
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}

References G4OpenGL2PSAction::fExportImageFormat, and G4OpenGL2PSAction::fFile.

Referenced by G4OpenGLViewer::exportImage().

◆ setFileName()

void G4OpenGL2PSAction::setFileName ( const char *  aFileName)
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 98 of file G4OpenGL2PSAction.cc.

103{
104 fFileName = aFileName;
105}

References G4OpenGL2PSAction::fFileName.

Referenced by G4OpenGLViewer::printGl2PS(), and SoGL2PSAction().

◆ setLineWidth()

void G4OpenGL2PSAction::setLineWidth ( int  width)
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 62 of file G4OpenGL2PSAction.cc.

67{
68 gl2psLineWidth( width );
69}
#define gl2psLineWidth
Definition: Geant4_gl2ps.h:40

References gl2psLineWidth.

Referenced by G4OpenGLViewer::ChangeLineWidth(), and G4OpenGLViewer::printGl2PS().

◆ setPointSize()

void G4OpenGL2PSAction::setPointSize ( int  size)
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 72 of file G4OpenGL2PSAction.cc.

77{
78 gl2psPointSize( size );
79}
#define gl2psPointSize
Definition: Geant4_gl2ps.h:39

References gl2psPointSize.

Referenced by G4OpenGLViewer::ChangePointSize(), and G4OpenGLViewer::printGl2PS().

◆ setViewport()

void G4OpenGL2PSAction::setViewport ( int  a,
int  b,
int  winSizeX,
int  winSizeY 
)
inherited

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Definition at line 82 of file G4OpenGL2PSAction.cc.

90{
91 fViewport[0] = a;
92 fViewport[1] = b;
93 fViewport[2] = winSizeX;
94 fViewport[3] = winSizeY;
95}

References G4OpenGL2PSAction::fViewport.

◆ SO_ACTION_HEADER()

SoGL2PSAction::SO_ACTION_HEADER ( SoGL2PSAction  )
private

Field Documentation

◆ fBufferSize

GLint G4OpenGL2PSAction::fBufferSize
protectedinherited

◆ fBufferSizeLimit

GLint G4OpenGL2PSAction::fBufferSizeLimit
protectedinherited

◆ fExportImageFormat

unsigned int G4OpenGL2PSAction::fExportImageFormat
privateinherited

◆ fFile

FILE* G4OpenGL2PSAction::fFile
protectedinherited

◆ fFileName

G4String G4OpenGL2PSAction::fFileName
protectedinherited

◆ fViewport

GLint G4OpenGL2PSAction::fViewport[4]
protectedinherited

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