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

#include <SoImageWriter.h>

+ Inheritance diagram for SoImageWriter:

Public Member Functions

 SoImageWriter ()
 
void enable ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 
void disable ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 
SbBool getStatus () const
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 
virtual void GLRender (SoGLRenderAction *)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 

Static Public Member Functions

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

Public Attributes

SoSFString fileName
 

Protected Member Functions

virtual ~SoImageWriter ()
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 

Detailed Description

Definition at line 42 of file SoImageWriter.h.

Constructor & Destructor Documentation

◆ SoImageWriter()

SoImageWriter::SoImageWriter ( )

Definition at line 76 of file SoImageWriter.cc.

79,fStatus(FALSE)
80//////////////////////////////////////////////////////////////////////////////
81//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
82{
83 SO_NODE_CONSTRUCTOR(SoImageWriter);
84 //SO_NODE_ADD_FIELD(format,(POST_SCRIPT));
85 SO_NODE_ADD_FIELD(fileName,("out.ps"));
86
87 //SO_NODE_DEFINE_ENUM_VALUE(Format,POST_SCRIPT);
88 //SO_NODE_DEFINE_ENUM_VALUE(Format,GIF);
89
90 //SO_NODE_SET_SF_ENUM_TYPE(format,Format);
91}
#define FALSE
Definition globals.hh:38

Referenced by SoImageWriter().

◆ ~SoImageWriter()

SoImageWriter::~SoImageWriter ( )
protectedvirtual

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

Definition at line 93 of file SoImageWriter.cc.

97{
98}

Referenced by ~SoImageWriter().

Member Function Documentation

◆ disable()

void SoImageWriter::disable ( )

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

Definition at line 108 of file SoImageWriter.cc.

112{
113 fEnabled = FALSE;
114}

Referenced by disable().

◆ enable()

void SoImageWriter::enable ( )

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

Definition at line 100 of file SoImageWriter.cc.

104{
105 fEnabled = TRUE;
106}
#define TRUE
Definition globals.hh:41

Referenced by enable().

◆ getStatus()

SbBool SoImageWriter::getStatus ( ) const

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

Definition at line 116 of file SoImageWriter.cc.

120{
121 return fStatus;
122}

Referenced by getStatus().

◆ GLRender()

void SoImageWriter::GLRender ( SoGLRenderAction * aAction)
virtual

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

Definition at line 124 of file SoImageWriter.cc.

129{
130 fStatus = FALSE;
131 //printf("debug : SoImageWriter::GLRender : enabled : %d\n",fEnabled);
132 if(!fEnabled) return;
133 SbViewportRegion vpr = SoViewportRegionElement::get(aAction->getState());
134 const SbVec2s& win = vpr.getWindowSize();
135 int w = win[0];
136 int h = win[1];
137 if((w*h)<=0) {
138 SoDebugError::postInfo("SoImageWriter::GLRender","null area window !");
139 return;
140 }
141
142 int x = 0;
143 int y = 0;
144 int s = 3 * w * h;
145 float* image = new float[s];
146 if(!image) return;
147
148 //printf("debug : SoImageWriter::GLRender : %d %d %d %d\n",x,y,w,h);
149
150 //glReadPixels(x,y,w,h,GL_RGB,GL_UNSIGNED_BYTE,image); Don't work !
151 glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
152
153 //Format fm = (Format)format.getValue();
154 //if(fm==GIF) {
155/*
156 FILE* file = fopen(fileName.getValue().getString(),"wb");
157 if(!file) {
158 SoDebugError::postInfo("SoImageWriter::GLRender",
159 "can't open file \"%s\".",fileName.getValue().getString());
160 } else {
161 int coln;
162 Uchar* rs;
163 Uchar* gs;
164 Uchar* bs;
165 Uchar* data;
166 getImagePixels(w,h,image,coln,rs,gs,bs,data);
167
168 SbGIF::putBytesInStream(file,data,w,h,coln,rs,gs,bs);
169
170 delete [] data;
171
172 if(rs) free(rs);
173 if(gs) free(gs);
174 if(bs) free(bs);
175
176 fclose(file);
177
178 fStatus = TRUE;
179 }
180 } else {
181*/
182
183 SbPainterPS painterPS;
184 painterPS.openFileForWriting(fileName.getValue().getString());
185 if(!painterPS.getStream()) {
186 SoDebugError::postInfo("SoImageWriter::GLRender",
187 "can't open file \"%s\".",fileName.getValue().getString());
188 } else {
189 painterPS.setWindowSize(w,h);
190 //painterPS.setBitsPerPixel(8);
191 painterPS.setBitsPerPixel(4);
192 painterPS.beginTraversal();
193 painterPS.clearColorBuffer(1.,1.,1.);
194
195 sWidth = w;
196 sHeight = h;
197 sImage = image;
198 painterPS.putImageInStream((unsigned int)w,(unsigned int)h,getRGB);
199
200 painterPS.endTraversal();
201
202 painterPS.closeStream();
203
204 fStatus = TRUE;
205 }
206 //}
207 delete [] image;
208
209}
void endTraversal()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void beginTraversal()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putImageInStream(unsigned int, unsigned int, GetRGB_Function)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setBitsPerPixel(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void clearColorBuffer(float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void openFileForWriting(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void * getStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void closeStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setWindowSize(int, int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
Definition SbPainter.cc:58
SoSFString fileName

Referenced by GLRender().

◆ initClass()

void SoImageWriter::initClass ( )
static

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

Definition at line 64 of file SoImageWriter.cc.

68{
69 static bool first = true;
70 if (first) {
71 first = false;
72 SO_NODE_INIT_CLASS(SoImageWriter,SoNode,"Node");
73 }
74}

Member Data Documentation

◆ fileName

SoSFString SoImageWriter::fileName

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