33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
35 #ifndef G4OPENGLVIEWER_HH
36 #define G4OPENGLVIEWER_HH
40 #ifdef G4OPENGL_VERSION_2
44 class G4OpenGLSceneHandler;
48 class G4OpenGLViewerPickMap {
54 inline void setHitNumber(
G4int n) {
58 inline void setSubHitNumber(
G4int n) {
61 inline void setPickName(
G4int n) {
65 inline void addAttributes(
G4String att) {
66 fAttributes.push_back(att);
73 inline G4int getHitNumber() {
77 inline G4int getSubHitNumber() {
81 inline G4int getPickName() {
85 inline std::vector <G4String > getAttributes() {
96 std::vector <G4String > fAttributes;
101 class G4OpenGLViewer:
virtual public G4VViewer {
103 friend class G4OpenGLSceneHandler;
104 friend class G4OpenGLImmediateSceneHandler;
105 friend class G4OpenGLStoredSceneHandler;
106 friend class G4OpenGLFileSceneHandler;
111 void ClearViewWithoutFlush ();
114 virtual bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
116 bool setExportImageFormat(std::string format,
bool quiet =
false);
120 #ifdef G4OPENGL_VERSION_2
121 inline G4OpenGLVboDrawer* getWtDrawer() {
return fVboDrawer;}
124 void setVboDrawer(G4OpenGLVboDrawer* drawer);
125 G4OpenGLVboDrawer* fVboDrawer;
128 return fGlViewInitialized;
133 G4OpenGLViewer (G4OpenGLSceneHandler& scene);
134 virtual ~G4OpenGLViewer ();
137 G4OpenGLViewer(
const G4OpenGLViewer&);
138 G4OpenGLViewer& operator= (
const G4OpenGLViewer&);
144 virtual void DrawText(
const G4Text&);
145 void ChangePointSize(
G4double size);
147 void HaloingFirstPass ();
148 void HaloingSecondPass ();
149 void HLRFirstPass ();
150 void HLRSecondPass ();
151 void HLRThirdPass ();
152 void InitializeGLView ();
154 void ResizeWindow(
unsigned int,
unsigned int);
155 virtual G4String Pick(GLdouble
x, GLdouble
y);
156 const std::vector < G4OpenGLViewerPickMap* > & GetPickDetails(GLdouble
x, GLdouble
y);
157 virtual void CreateFontLists () {}
172 std::string getRealPrintFilename();
173 unsigned int getWinWidth()
const;
174 unsigned int getWinHeight()
const;
177 GLdouble getSceneNearWidth();
178 GLdouble getSceneFarWidth();
179 GLdouble getSceneDepth();
180 void addExportImageFormat(std::string format);
183 G4bool isFramebufferReady();
185 void g4GluPickMatrix(GLdouble
x, GLdouble
y, GLdouble
width, GLdouble height,
189 void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
190 GLdouble centerx, GLdouble centery, GLdouble
192 GLdouble upx, GLdouble upy, GLdouble upz );
194 void g4GlOrtho (GLdouble
left, GLdouble
right,
195 GLdouble bottom, GLdouble top,
196 GLdouble near, GLdouble far);
198 void g4GlFrustum (GLdouble
left, GLdouble
right,
199 GLdouble bottom, GLdouble top,
200 GLdouble near, GLdouble far);
206 G4OpenGLSceneHandler& fOpenGLSceneHandler;
209 transparency_enabled,
210 antialiasing_enabled,
216 unsigned int fWinSize_x;
217 unsigned int fWinSize_y;
218 std::vector < std::string > fExportImageFormatVector;
219 std::string fDefaultExportImageFormat;
220 std::string fExportImageFormat;
221 int fExportFilenameIndex;
231 int fGl2psDefaultLineWith;
232 int fGl2psDefaultPointSize;
233 bool fGlViewInitialized;
239 G4int getRealExportWidth();
240 G4int getRealExportHeight();
241 GLubyte* grabPixels (
int inColor,
243 unsigned int height);
244 bool printNonVectoredEPS ();
247 bool printVectoredEPS();
250 bool fIsGettingPickInfos;
253 #ifdef G4OPENGL_VERSION_2
255 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
256 inline Wt::WGLWidget::Program getShaderProgram() {
257 return fShaderProgram;
259 inline Wt::WGLWidget::UniformLocation getShaderProjectionMatrix() {
260 return fpMatrixUniform;
262 inline Wt::WGLWidget::UniformLocation getShaderTransformMatrix() {
263 return ftMatrixUniform;
266 inline GLuint getShaderProgram() {
267 return fShaderProgram;
269 inline GLuint getShaderProjectionMatrix() {
270 return fpMatrixUniform;
272 inline GLuint getShaderTransformMatrix() {
273 return ftMatrixUniform;
275 inline GLuint getShaderViewModelMatrix() {
276 return fmvMatrixUniform;
283 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
284 #define Shader Wt::WGLWidget::Shader
286 #define Shader GLuint
290 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
291 Wt::WGLWidget::Program fShaderProgram;
294 Wt::WGLWidget::AttribLocation fVertexPositionAttribute;
295 Wt::WGLWidget::AttribLocation fVertexNormalAttribute;
296 Wt::WGLWidget::UniformLocation fpMatrixUniform;
297 Wt::WGLWidget::UniformLocation fcMatrixUniform;
298 Wt::WGLWidget::UniformLocation fmvMatrixUniform;
299 Wt::WGLWidget::UniformLocation fnMatrixUniform;
300 Wt::WGLWidget::UniformLocation ftMatrixUniform;
302 GLuint fShaderProgram;
305 GLuint fVertexPositionAttribute;
306 GLuint fVertexNormalAttribute;
307 GLuint fpMatrixUniform;
308 GLuint fcMatrixUniform;
309 GLuint fmvMatrixUniform;
310 GLuint fnMatrixUniform;
311 GLuint ftMatrixUniform;
void print(G4double elem)
virtual void ClearView()=0
std::string getName(const ParticleType t)
Get the native INCL name of the particle.