ATLAS Offline Software
Loading...
Searching...
No Matches
SoGL2PSAction Class Reference

SoGL2PSAction inherits Inventor/SoGLRenderAction. More...

#include <SoGL2PSAction.h>

Inheritance diagram for SoGL2PSAction:
Collaboration diagram for SoGL2PSAction:

Public Types

enum  Format {
  PS = 0 , EPS = 1 , TEX = 2 , PDF = 3 ,
  SVG = 4 , PGF = 5
}

Public Member Functions

 SoGL2PSAction (const SbViewportRegion &)
void setFileFormat (Format)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setFileName (const char *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
SbBool setPageOptions (const SbString &options)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void enableFileWriting ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void disableFileWriting ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
SbBool fileWritingEnabled () const
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
SbBool addBitmap (int, int, float=0, float=0, float=0, float=0)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void beginViewport (SbBool draw_back=TRUE)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void endViewport ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Static Public Member Functions

static void initClass ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Protected Member Functions

virtual void beginTraversal (SoNode *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Private Member Functions

 SO_ACTION_HEADER (SoGL2PSAction)
void gl2psBegin ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Static Private Member Functions

static void separatorAction (SoAction *, SoNode *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
static void drawStyleAction (SoAction *, SoNode *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

Private Attributes

Format m_fileFormat
SbString m_fileName
FILE * m_file
int m_pageOptions

Detailed Description

SoGL2PSAction inherits Inventor/SoGLRenderAction.

It uses the gl2ps software to produce vector PostScript of a scene graph. See applications/DetectorTreeKit, Polyhedron for examples.

Definition at line 17 of file SoGL2PSAction.h.

Member Enumeration Documentation

◆ Format

Enumerator
PS 
EPS 
TEX 
PDF 
SVG 
PGF 

Definition at line 30 of file SoGL2PSAction.h.

30 {
31 PS = 0,
32 EPS = 1,
33 TEX = 2,
34 PDF = 3,
35 SVG = 4,
36 PGF = 5
37 };

Constructor & Destructor Documentation

◆ SoGL2PSAction()

SoGL2PSAction::SoGL2PSAction ( const SbViewportRegion & aViewPortRegion)

Definition at line 37 of file SoGL2PSAction.cxx.

40:SoGLRenderAction(aViewPortRegion)
42,m_fileName("out.ps")
43,m_file(0)
47{
48 SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
49
54}
SbString m_fileName
SoGL2PSAction(const SbViewportRegion &)
Format m_fileFormat
#define GL2PS_OCCLUSION_CULL
Definition gl2ps.h:124
#define GL2PS_SILENT
Definition gl2ps.h:122
#define GL2PS_BEST_ROOT
Definition gl2ps.h:123
#define GL2PS_DRAW_BACKGROUND
Definition gl2ps.h:120

Member Function Documentation

◆ addBitmap()

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

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

Definition at line 188 of file SoGL2PSAction.cxx.

198{
199 if(!m_file) return FALSE;
200 GLboolean valid;
201 glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
202 if(valid==GL_FALSE) return FALSE;
203 float pos[4];
204 glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
205 int xoff = -(int)(aXmove + aXorig);
206 int yoff = -(int)(aYmove + aYorig);
207 int x = (int)(pos[0] + xoff);
208 int y = (int)(pos[1] + yoff);
209 // Should clip against viewport area :
210 GLint vp[4];
211 glGetIntegerv(GL_VIEWPORT,vp);
212 GLsizei w = aWidth;
213 GLsizei h = aHeight;
214 if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
215 if(y+h>(vp[1]+vp[3])) h = vp[1]+vp[3]-y;
216 int s = 3 * w * h;
217 if(s<=0) return FALSE;
218 float* image = new float[s];
219 glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
220 GLint status = gl2psDrawPixels(w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
221 delete [] image;
222 return (status!=GL2PS_SUCCESS ? FALSE : TRUE);
223}
#define y
#define x
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
Definition gl2ps.cxx:5817
#define GL2PS_SUCCESS
Definition gl2ps.h:109
str image
Definition MyPlots.py:40
list valid
Definition calibdata.py:44
status
Definition merge.py:16

◆ beginTraversal()

void SoGL2PSAction::beginTraversal ( SoNode * aNode)
protectedvirtual

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

Definition at line 254 of file SoGL2PSAction.cxx.

259{
260
261 if(m_file) {
262 const SbViewportRegion& vpr = getViewportRegion();
263 SoViewportRegionElement::set(getState(),vpr);
264
265 gl2psBegin();
266 traverse(aNode);
268 gl2psEndPage();
269 } else {
270 SoGLRenderAction::beginTraversal(aNode);
271 }
272}
void gl2psBegin()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
GL2PSDLL_API GLint gl2psEndViewport(void)
Definition gl2ps.cxx:5787
GL2PSDLL_API GLint gl2psEndPage(void)
Definition gl2ps.cxx:5751
traverse(graph, root, reverse=False, maxdepth=None, nodegetter=lambda n:n)

◆ beginViewport()

void SoGL2PSAction::beginViewport ( SbBool draw_back = TRUE)

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

Definition at line 225 of file SoGL2PSAction.cxx.

230{
231 if(!m_file) return;
232 GLint vp[4];
233 glGetIntegerv(GL_VIEWPORT,vp);
234 if(aDrawBack) {
236 } else {
237 GLint opts = 0;
238 gl2psGetOptions(&opts);
241 gl2psSetOptions(opts);
242 }
243}
GL2PSDLL_API GLint gl2psSetOptions(GLint options)
Definition gl2ps.cxx:6017
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4])
Definition gl2ps.cxx:5778
GL2PSDLL_API GLint gl2psGetOptions(GLint *options)
Definition gl2ps.cxx:6026

◆ disableFileWriting()

void SoGL2PSAction::disableFileWriting ( )

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

Definition at line 171 of file SoGL2PSAction.cxx.

175{
176 ::fclose(m_file);
177 m_file = 0;
178}

◆ drawStyleAction()

void SoGL2PSAction::drawStyleAction ( SoAction * aThis,
SoNode * aNode )
staticprivate

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

Definition at line 325 of file SoGL2PSAction.cxx.

331{
332 SoNode::GLRenderS(aThis,aNode);
333 SoGL2PSAction* This = static_cast<SoGL2PSAction*>(aThis);
334 if(This->m_file) {
335 SoDrawStyle* soDrawStyle = static_cast<SoDrawStyle*>(aNode);
336 if(soDrawStyle->style.getValue()==SoDrawStyle::LINES) {
337 float w = soDrawStyle->lineWidth.getValue();
340
341 /* LD HEPVis specific
342 unsigned short pattern = soDrawStyle->linePattern.getValue();
343 if(pattern==SbLinePattern_solid)
344 gl2psDisable(GL2PS_LINE_STIPPLE);
345 else
346 gl2psEnable(GL2PS_LINE_STIPPLE);
347 */
348 }
349 }
350}
GL2PSDLL_API GLint gl2psDisable(GLint mode)
Definition gl2ps.cxx:5957
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
Definition gl2ps.cxx:5992
#define GL2PS_LINE_STIPPLE
Definition gl2ps.h:138

◆ enableFileWriting()

void SoGL2PSAction::enableFileWriting ( )

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

Definition at line 154 of file SoGL2PSAction.cxx.

158{
160 m_file = ::fopen(m_fileName.getString(),"wb");
161 } else {
162 m_file = ::fopen(m_fileName.getString(),"w");
163 }
164 if(!m_file) {
165 SoDebugError::post("SoGL2PSAction::enableFileWriting",
166 "Cannot open file %s",m_fileName.getString());
167 return;
168 }
169}
#define GL2PS_PDF
Definition gl2ps.h:97

◆ endViewport()

void SoGL2PSAction::endViewport ( )

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

Definition at line 245 of file SoGL2PSAction.cxx.

249{
250 if(!m_file) return;
252}

◆ fileWritingEnabled()

SbBool SoGL2PSAction::fileWritingEnabled ( ) const

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

Definition at line 180 of file SoGL2PSAction.cxx.

184{
185 return (m_file?TRUE:FALSE);
186}

◆ gl2psBegin()

void SoGL2PSAction::gl2psBegin ( )
private

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

Definition at line 274 of file SoGL2PSAction.cxx.

278{
279 if(!m_file) return;
280
281 int sort = GL2PS_BSP_SORT;
282 //int sort = GL2PS_SIMPLE_SORT;
283
284 const SbViewportRegion& vpr = getViewportRegion();
285 SoViewportRegionElement::set(getState(),vpr);
286
287 const SbVec2s& win = vpr.getWindowSize();
288 GLint vp[4];
289 vp[0] = 0;
290 vp[1] = 0;
291 vp[2] = win[0];
292 vp[3] = win[1];
293
294 int bufsize = 0;
295 gl2psBeginPage("title","HEPVis::SoGL2PSAction",
296 vp,
298 sort,
300 GL_RGBA,0, NULL,0,0,0,
301 bufsize,
302 m_file,m_fileName.getString());
303
305}
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
Definition gl2ps.cxx:5584
#define GL2PS_BSP_SORT
Definition gl2ps.h:105

◆ initClass()

void SoGL2PSAction::initClass ( )
static

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

Definition at line 24 of file SoGL2PSAction.cxx.

28{
29 [[maybe_unused]] static const bool didInit = [&]() {
30 SO_ACTION_INIT_CLASS(SoGL2PSAction,SoGLRenderAction);
31 SO_ACTION_ADD_METHOD(SoSeparator,separatorAction);
32 SO_ACTION_ADD_METHOD(SoDrawStyle,drawStyleAction);
33 return true;
34 }();
35}
static void separatorAction(SoAction *, SoNode *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
static void drawStyleAction(SoAction *, SoNode *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

◆ separatorAction()

void SoGL2PSAction::separatorAction ( SoAction * aThis,
SoNode * aNode )
staticprivate

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

Definition at line 309 of file SoGL2PSAction.cxx.

315{
316 SoGL2PSAction* This = static_cast<SoGL2PSAction*>(aThis);
317 if(This->m_file) {
318 //SoSeparator may use render caching.
319 aNode->doAction(aThis);
320 } else {
321 SoNode::GLRenderS(aThis,aNode);
322 }
323}

◆ setFileFormat()

void SoGL2PSAction::setFileFormat ( Format aFileFormat)

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

Definition at line 56 of file SoGL2PSAction.cxx.

61{
62 m_fileFormat = aFileFormat;
63}

◆ setFileName()

void SoGL2PSAction::setFileName ( const char * aFileName)

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

Definition at line 145 of file SoGL2PSAction.cxx.

150{
151 m_fileName = aFileName;
152}

◆ setPageOptions()

SbBool SoGL2PSAction::setPageOptions ( const SbString & options)

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

Definition at line 65 of file SoGL2PSAction.cxx.

70{
71 SbPList words = SbStringGetWords(aOptions,";");
72 int wordn = words.getLength();
73 for(int wordi=0;wordi<wordn;wordi++) {
74 SbString& word = *((SbString*)words[wordi]);
75 if(!word.getLength()) continue;
76
77 SbString option("");
78 SbBool value = FALSE;
79 {SbPList o_v = SbStringGetWords(word,"=");
80 if(o_v.getLength()==2) {
81 option = *((SbString*)o_v[0]);
82 SbString svalue = *((SbString*)o_v[1]);
83 if(SbStringConvertToBool(svalue,value)==FALSE) {
84 SoDebugError::postInfo("SoGL2PSAction::setPageOptions",
85 "value \"%s\" not a bool.\n",svalue.getString());
86 }
87 } else {
88 option = word;
89 value = TRUE;
90 }
91 SbStringDelete(o_v);}
92
93#define SET_OPT(a_opt) \
94 if(value==TRUE) {\
95 m_pageOptions |= a_opt;\
96 } else {\
97 m_pageOptions &= ~a_opt;\
98 }
99
100 if(option=="DEFAULTS") {
105 } else if(option=="NONE") {
106 m_pageOptions = 0;
107 } else if(option=="DRAW_BACKGROUND") {
109 } else if(option=="SIMPLE_LINE_OFFSET") {
111 } else if(option=="SILENT") {
113 } else if(option=="BEST_ROOT") {
115 } else if(option=="OCCLUSION_CULL") {
117 } else if(option=="NO_TEXT") {
119 } else if(option=="LANDSCAPE") {
121 } else if(option=="NO_PS3_SHADING") {
123 } else if(option=="NO_PIXMAP") {
125 } else if(option=="USE_CURRENT_VIEWPORT") {
127 } else if(option=="COMPRESS") {
129 } else if(option=="NO_BLENDING") {
131 } else if(option=="TIGHT_BOUNDING_BOX") {
133 } else {
134 SoDebugError::postInfo("SoGL2PSAction::setPageOptions",
135 "bad option \"%s\".\n",option.getString());
136 }
137 }
138 SbStringDelete(words);
139
140 //::printf("debug : SoGL2PSAction::setPageOptions : %d\n",m_pageOptions);
141
142 return TRUE;
143}
SbPList SbStringGetWords(const SbString &aString, const char *aLimiter)
SbBool SbStringConvertToBool(const SbString &aString, SbBool &aValue)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void SbStringDelete(SbPList &aList)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
#define SET_OPT(a_opt)
#define GL2PS_TIGHT_BOUNDING_BOX
Definition gl2ps.h:132
#define GL2PS_NO_BLENDING
Definition gl2ps.h:131
#define GL2PS_SIMPLE_LINE_OFFSET
Definition gl2ps.h:121
#define GL2PS_LANDSCAPE
Definition gl2ps.h:126
#define GL2PS_NO_PS3_SHADING
Definition gl2ps.h:127
#define GL2PS_COMPRESS
Definition gl2ps.h:130
#define GL2PS_NO_PIXMAP
Definition gl2ps.h:128
#define GL2PS_USE_CURRENT_VIEWPORT
Definition gl2ps.h:129
#define GL2PS_NO_TEXT
Definition gl2ps.h:125

◆ SO_ACTION_HEADER()

SoGL2PSAction::SO_ACTION_HEADER ( SoGL2PSAction )
private

Member Data Documentation

◆ m_file

FILE* SoGL2PSAction::m_file
private

Definition at line 58 of file SoGL2PSAction.h.

◆ m_fileFormat

Format SoGL2PSAction::m_fileFormat
private

Definition at line 56 of file SoGL2PSAction.h.

◆ m_fileName

SbString SoGL2PSAction::m_fileName
private

Definition at line 57 of file SoGL2PSAction.h.

◆ m_pageOptions

int SoGL2PSAction::m_pageOptions
private

Definition at line 59 of file SoGL2PSAction.h.


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