Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
+1 -12
View File
@@ -1,14 +1,3 @@
#------------------------------------------------------------------------------
# Module : G4OpenGL
# Package: Geant4.src.G4visualization.G4OpenGL
#------------------------------------------------------------------------------
# - G4OpenGL category build
geant4_global_library_target(COMPONENTS sources.cmake)
if(GEANT4_USE_QT)
foreach(__target G4OpenGL G4OpenGL-static)
if(TARGET ${__target})
set_target_properties(${__target} PROPERTIES AUTOMOC 1)
endif()
endforeach()
endif()
+66
View File
@@ -16,6 +16,72 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
07 June 2021 John Allison (opengl-V10-07-09)
- Requires greps-V10-07-07 (new method AddCompound (const G4Mesh&)).
- Requires modeling-V10-07-09 (new class G4Mesh).
- Requires visman-V10-07-10 (new default method and new commands).
- G4OpenGLSceneHandler:
o Implement AddCompound (const G4Mesh&):
Turns nested parameterisations into polymarkers of dots - much
improved speed.
- G4OpenGLStoredViewer.cc and G4OpenGLStoredQtViewer.cc:
o Force kernel visit if special mesh rendering parameters change.
28 May 2021 Ben Morgan (opengl-V10-07-08)
- Migrate to modular CMake build
15 April 2021 Guy Barrand (opengl-V10-07-07)
- G4OpenGLWin32Viewer: fixed occasional crash with G4UIWin32 when creating
viewer from UI command: avoid indirect call to DrawView() while still within
CreateMainWindow().
12 April 2021 John Allison (opengl-V10-07-06)
- Comment out makeCurrent in ~G4OpenGLImmediate/StoredQtViewer:
o Prevents red-button crash.
29 March 2021 John Allison (opengl-V10-07-05)
- G4OpenGLQtViewer::addNonPVSceneTreeElement:
Special case for markers - use Info() if non-empty for modelShortName,
the name that appears in Qt's scene tree. This allows the user to design
markers, e.g., a list of points, and give them a name that relates to the
providence of the points, e.g., a particular material or geometry component.
11 March 2021 Gabriele Cosmo (opengl-V10-07-04)
- Enable extended WIN32 window in G4OpenGLWin32Viewer.
Based on contribution by O.Pena-Rodrigues in GitHub PR#23.
- Removed [commented out] DrawView() implementation in G4OpenGLWin32Viewer.
09 March 2021 John Allison (opengl-V10-07-03)
- Removed Wt.
- G4OpenGLStoredQtViewer.cc:
o Move fViewId<0 check to top of constructor to pick up errors in
base class construction.
04 March 2021 Gabriele Cosmo (opengl-V10-07-02)
- Implemented WindowProc() function in G4OpenGLWin32Viewer for the Win32
OpenGL driver (function that was commented out). It is now possible to
change the Zoom and the orientation using the mouse (like in the Qt driver).
Based on GitHub PR#20, contributed by Ovidio Pena Rodriguez.
- Added [commented out] DrawView() implementation in G4OpenGLWin32Viewer.
06 January 2021 John Allison (opengl-V10-07-01)
- Remove deprecated /vis/ogl/set/ commands. These have been deprecated
since 2016. Since that time they have all printed a message, giving the
new command. All examples have been checked for use of the deprecated
commands, which have been replaced with the new ones. The commands
involved are:
o All commands connected with a time window. Use equivalent
/vis/viewer/set/timeWindow commands.
o "/vis/ogl/set/eventsDrawInterval <N> is replaced by
"/vis/ogl/flushAt NthPrimitive <N>".
30 December 2020 John Allison (openGL-V10-07-00)
- G4OpenGLViewerMessenger: Remove deprecated /vis/ogl/set commands.
o /vis/ogl/set/eventsDrawInterval: use /vis/ogl/flushAt
o /vis/ogl/set/<time-interval-related-command>: use related
/vis/viewer/set/timeWindow command.
o All above commands have been deprecated (with a message) since 2017.
16 November 2020 Gabriele Cosmo (OpenGL-V10-06-13)
- Fixed typos in printed-out text. Addressing problem report #2285.
@@ -68,10 +68,6 @@
//# Do NOT include glx Here ! It has to be done, after all <Qxx...> includes
//# include <GL/glx.h>
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
# include <Wt/WGLWidget>
# define G4OPENGL_VERSION_2 1
#endif
#if defined (G4VIS_BUILD_OPENGLQT_DRIVER) || defined (G4VIS_USE_OPENGLQT)
#if defined (G4VIS_BUILD_OPENGLX_DRIVER) || defined (G4VIS_USE_OPENGLX)
#else
@@ -1,50 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// OpenGLImmediateWt graphics system factory.
#ifndef G4OPENGLIMMEDIATEWT_HH
#define G4OPENGLIMMEDIATEWT_HH
#include "G4VGraphicsSystem.hh"
namespace Wt {
class WContainerWidget;
}
class G4OpenGLImmediateWt: public G4VGraphicsSystem {
public:
G4OpenGLImmediateWt ();
G4VSceneHandler* CreateSceneHandler (const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
private:
Wt::WContainerWidget* fWGLContainer;
};
#endif
@@ -1,91 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Class G4OpenGLImmediateWtViewer : a class derived from
// G4OpenGLWtViewer and G4OpenGLImmediateViewer.
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
#ifndef G4OPENGLIMMEDIATEWTVIEWER_HH
#define G4OPENGLIMMEDIATEWTVIEWER_HH
#include "G4OpenGLImmediateViewer.hh"
#include "G4OpenGLWtViewer.hh"
#include <Wt/WEvent>
#include "globals.hh"
class G4OpenGLImmediateSceneHandler;
class G4OpenGLImmediateWtViewer :
public G4OpenGLWtViewer, public G4OpenGLImmediateViewer, public Wt::WGLWidget {
public:
G4OpenGLImmediateWtViewer (G4OpenGLImmediateSceneHandler& scene, Wt::WContainerWidget*, const G4String& name = "");
~G4OpenGLImmediateWtViewer ();
void Initialise ();
void resizeGL(int, int);
void paintGL();
void initializeGL ();
void DrawView();
void ShowView();
//
void popMatrix();
void pushMatrix();
void multMatrixd(const GLdouble*);
void setMatrixUniforms();
void loadIdentity();
void ComputeView ();
void FinishView();
private:
// void showEvent(QShowEvent event );
void mousePressEvent(Wt::WMouseEvent *event);
void mouseMoveEvent(Wt::WMouseEvent *event);
void mouseDoubleClickEvent(Wt::WMouseEvent *event);
void mouseReleaseEvent(Wt::WMouseEvent event);
// void WtContextMenuEvent(QContextMenuEvent e);
void keyPressEvent (Wt::WKeyEvent *event);
void paintEvent(Wt::WPaintDevice * event);
void updateWWidget();
// A client-side JavaScript matrix variable
JavaScriptMatrix4x4 jsMatrix_;
// void ComputeView ();
// implements G4VViewer::SetView() and ClearView()
// void SetView ();
// void ClearView ();
};
#endif
#endif
@@ -85,7 +85,8 @@ public:
void AddCompound (const G4VDigi&);
void AddCompound (const G4THitsMap<G4double>&);
void AddCompound (const G4THitsMap<G4StatDouble>&);
void AddCompound (const G4Mesh&);
// enum for /vis/ogl/flushAt.
enum FlushAction {
endOfEvent,
@@ -124,13 +125,8 @@ public:
void drawVBOArray(std::vector<double> vertices);
// Buffers used to access vertex and indices elements
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
Wt::WGLWidget::Buffer fVertexBufferObject;
Wt::WGLWidget::Buffer fIndicesBufferObject;
#else
GLuint fVertexBufferObject;
GLuint fIndicesBufferObject;
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
#endif //G4OPENGL_VERSION_2
@@ -28,6 +28,7 @@
//
// G4OpenGLVboDrawer : Class to provide Wt and Qt specific
// functionality for OpenGL in GEANT4
// All references to Wt removed - 1/3/21 JA
#ifndef G4OpenGLVboDrawer_HH
#define G4OpenGLVboDrawer_HH
@@ -88,183 +89,6 @@
#define glReadPixels(a,b,c,d,e,f,g) fVboDrawer->empty()
#define glTranslatef(a,b,c) fVboDrawer->empty() // TO BE FIXED
// +--------------------------------+
// + WT (OpenGL ES) case +
// +--------------------------------+
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
class G4OpenGLImmediateWtViewer;
// specific definition for WT :
// WARNING fVboDrawer should be the exact name of the object!
#define glGetError() Wt::WGLWidget::NONE
#define glOrtho fVboDrawer->vboGlOrtho
#define glFrustum fVboDrawer->vboGlFrustum
#define glViewport fVboDrawer->vboGlViewport
#define glEnable fVboDrawer->vboGlEnable
#define glDisable fVboDrawer->vboGlDisable
#define glBlendFunc fVboDrawer->vboGlBlendFunc
#define glClear fVboDrawer->vboGlClear
#define glClearColor fVboDrawer->vboGlClearColor
#define glClearDepth fVboDrawer->vboGlClearDepth
#define glDepthFunc fVboDrawer->vboGlDepthFunc
#define glDepthMask fVboDrawer->vboGlDepthMask
#define glFlush fVboDrawer->vboGlFlush
#define glColorMask fVboDrawer->vboGlColorMask
#define glLineWidth fVboDrawer->vboGlLineWidth
#define glUniformMatrix4 fVboDrawer->vboGlUniformMatrix4
#define glDrawArrays fVboDrawer->vboGlDrawArrays
#define glCreateBuffer fVboDrawer->vboGlCreateBuffer
#define glVertexPointer fVboDrawer->vboGlVertexPointer
#define glBindBuffer fVboDrawer->vboGlBindBuffer
#define glDeleteBuffer fVboDrawer->vboGlDeleteBuffer
#define glBufferDatafv fVboDrawer->vboGlBufferDatafv
#define glBufferDataiv fVboDrawer->vboGlBufferDataiv
#define glGetAttribLocation fVboDrawer->vboGlGetAttribLocation
#define glEnableVertexAttribArray fVboDrawer->vboGlEnableVertexAttribArray
#define glDisableVertexAttribArray fVboDrawer->vboGlDisableVertexAttribArray
#define glShaderSource fVboDrawer->vboGlShaderSource
#define glCompileShader fVboDrawer->vboGlCompileShader
#define glCreateShader fVboDrawer->vboGlCreateShader
#define glCreateProgram fVboDrawer->vboGlCreateProgram
#define glAttachShader fVboDrawer->vboGlAttachShader
#define glLinkProgram fVboDrawer->vboGlLinkProgram
#define glUseProgram fVboDrawer->vboGlUseProgram
#define glDrawElements fVboDrawer->vboGlDrawElements
#define glVertexAttribPointer fVboDrawer->vboGlVertexAttribPointer
#define glGetUniformLocation fVboDrawer->vboGlGetUniformLocation
#define glPointSize fVboDrawer->vboGlPointSize
#define glColor3d fVboDrawer->vboGlColor3d
#define glColor4d fVboDrawer->vboGlColor4d
#define glColor4fv fVboDrawer->vboGlColor4fv
#define glMultMatrixd fVboDrawer->vboGlMultMatrixd
#define glMultMatrixf fVboDrawer->vboGlMultMatrixf
#define glGetUniformLocation fVboDrawer->vboGlGetUniformLocation
#define glGetAttribLocation fVboDrawer->vboGlGetAttribLocation
#define glMatrixMode fVboDrawer->vboGlMatrixMode
// Only used in fvboDrawer->VboDrawer to be compatible between Wt and Qt framework
#define glUniform1f fVboViewer->uniform1f
#define glUniform4fv fVboViewer->uniform4fv
#define glUniformMatrix4dv fVboDrawer->vboGlUniformMatrix4;
#define glUniformMatrix4fv fVboDrawer->vboGlUniformMatrix4fv;
#define GL_VIEWPORT Wt::WGLWidget::VIEWPORT
#define GL_RGBA Wt::WGLWidget::RGBA
#define GL_ONE_MINUS_SRC_ALPHA Wt::WGLWidget::ONE_MINUS_SRC_ALPHA
#define GL_BLEND Wt::WGLWidget::BLEND
#define GL_SRC_ALPHA Wt::WGLWidget::SRC_ALPHA
#define GL_LEQUAL Wt::WGLWidget::LEQUAL
#define GL_FALSE false
#define GL_LESS Wt::WGLWidget::LESS
#define GL_SELECT Wt::WGLWidget::SELECT
#define GL_TRUE true
#define GL_RGB Wt::WGLWidget::RGB
#define GL_CURRENT_RASTER_POSITION_VALID Wt::WGLWidget::CURRENT_RASTER_POSITION_VALID
#define GL_ONE Wt::WGLWidget::ONE
#define GL_ZERO Wt::WGLWidget::ZERO
#define GL_COLOR_INDEX Wt::WGLWidget::COLOR_INDEX
#define GL_LINE_TOKEN Wt::WGLWidget::LINE_TOKEN
#define GL_LINE_RESET_TOKEN Wt::WGLWidget::LINE_RESET_TOKEN
#define GL_POLYGON_TOKEN Wt::WGLWidget::POLYGON_TOKEN
#define GL_FEEDBACK Wt::WGLWidget::FEEDBACK
#define GL_COLOR_CLEAR_VALUE Wt::WGLWidget::COLOR_CLEAR_VALUE
#define GL_BITMAP_TOKEN Wt::WGLWidget::BITMAP_TOKEN
#define GL_DRAW_PIXEL_TOKEN Wt::WGLWidget::DRAW_PIXEL_TOKEN
#define GL_COPY_PIXEL_TOKEN Wt::WGLWidget::COPY_PIXEL_TOKEN
#define GL_PASS_THROUGH_TOKEN Wt::WGLWidget::PASS_THROUGH_TOKEN
#define GL_3D_COLOR Wt::WGLWidget::3D_COLOR
#define GL_DEPTH_TEST Wt::WGLWidget::DEPTH_TEST
#define GL_FRONT Wt::WGLWidget::FRONT
#define GL_BACK Wt::WGLWidget::BACK
#define GL_FRONT_AND_BACK Wt::WGLWidget::FRONT_AND_BACK
#define GL_OUT_OF_MEMORY Wt::WGLWidget::OUT_OF_MEMORY
#define GL_LINE_STRIP Wt::WGLWidget::LINE_STRIP
#define GL_QUADS Wt::WGLWidget::QUADS
#define GL_LINE_LOOP Wt::WGLWidget::LINE_LOOP
#define GL_LINES Wt::WGLWidget::LINES
#define GL_POINTS Wt::WGLWidget::POINTS
#define GL_TRIANGLES Wt::WGLWidget::TRIANGLES
#define GL_TRIANGLE_STRIP Wt::WGLWidget::TRIANGLE_STRIP
#define GL_TRIANGLE_FAN Wt::WGLWidget::TRIANGLE_FAN
#define GL_FLOAT Wt::WGLWidget::FLOAT
#define GL_STENCIL_TEST Wt::WGLWidget::STENCIL_TEST
#define GL_ALWAYS Wt::WGLWidget::ALWAYS
#define GL_INVERT Wt::WGLWidget::INVERT
#define GL_COMPILE_AND_EXECUTE Wt::WGLWidget::COMPILE_AND_EXECUTE
#define GL_COMPILE Wt::WGLWidget::COMPILE
#define GL_COLOR_BUFFER_BIT Wt::WGLWidget::COLOR_BUFFER_BIT
#define GL_DEPTH_BUFFER_BIT Wt::WGLWidget::DEPTH_BUFFER_BIT
#define GL_STENCIL_BUFFER_BIT Wt::WGLWidget::STENCIL_BUFFER_BIT
#define GL_UNSIGNED_BYTE Wt::WGLWidget::UNSIGNED_BYTE
#define GL_ARRAY_BUFFER Wt::WGLWidget::ARRAY_BUFFER
#define GL_ELEMENT_ARRAY_BUFFER Wt::WGLWidget::ELEMENT_ARRAY_BUFFER
#define GL_RENDER Wt::WGLWidget::RENDER
#define GL_LUMINANCE Wt::WGLWidget::LUMINANCE
#define GL_STATIC_DRAW Wt::WGLWidget::STATIC_DRAW
#define GL_FRAGMENT_SHADER Wt::WGLWidget::FRAGMENT_SHADER
#define GL_VERTEX_SHADER Wt::WGLWidget::VERTEX_SHADER
#define GL_UNSIGNED_INT Wt::WGLWidget::UNSIGNED_INT
#define GL_UNSIGNED_SHORT Wt::WGLWidget::UNSIGNED_SHORT
#define GL_CULL_FACE Wt::WGLWidget::CULL_FACE
#define GL_MAX_VIEWPORT_DIMS Wt::WGLWidget::MAX_VIEWPORT_DIMS
#define GL_PROJECTION Wt::WGLWidget::FRAGMENT_SHADER // Not the good value, but should be ok, work together with GL_MODELVIEW
#define GL_MODELVIEW Wt::WGLWidget::VERTEX_SHADER // Not the good value, but should be ok, work together with GL_PROJECTION
// to be implemented
#define GL_LINE 0
#define GL_FILL 0
#define GL_PROJECTION_MATRIX 0
#define GL_UNPACK_SWAP_BYTES 0
#define GL_UNPACK_LSB_FIRST 0
#define GL_UNPACK_SKIP_ROWS 0
#define GL_UNPACK_LOW_LENGHT 0
#define GL_UNPACK_SKIP_PIXELS 0
#define GL_UNPACK_ALIGNMENT 0
#define GL_UNPACK_ROW_LENGTH 0
#define GL_CLIP_PLANE0 Wt::WGLWidget::NONE
#define GL_CLIP_PLANE1 Wt::WGLWidget::NONE
#define GL_CLIP_PLANE2 Wt::WGLWidget::NONE
#define GL_CLIP_PLANE3 Wt::WGLWidget::NONE
#define GL_CLIP_PLANE4 Wt::WGLWidget::NONE
#define GL_COLOR_MATERIAL Wt::WGLWidget::NONE
#define GL_AMBIENT_AND_DIFFUSE Wt::WGLWidget::NONE
#define GL_POLYGON 0
#define GL_LIGHTING Wt::WGLWidget::NONE
#define GL_POINT_SMOOTH Wt::WGLWidget::NONE
#define GL_LINE_SMOOTH Wt::WGLWidget::NONE
#define GL_POLYGON_SMOOTH Wt::WGLWidget::NONE
#define GL_LIGHT0 Wt::WGLWidget::NONE
#define GL_AMBIENT Wt::WGLWidget::NONE
#define GL_DIFFUSE Wt::WGLWidget::NONE
#define GL_POSITION Wt::WGLWidget::NONE
#define GLenum Wt::WGLWidget::GLenum
#define GLchar char
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef void GLvoid;
typedef char GLbyte;
typedef short GLshort;
typedef int GLint;
typedef unsigned char GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef int GLsizei;
typedef float GLfloat;
typedef float GLclampf;
typedef double GLdouble;
typedef double GLclampd;
#else
// +--------------------------------+
// + QT (OpenGL ES) case +
// +--------------------------------+
@@ -282,9 +106,6 @@ class G4OpenGLImmediateQtViewer;
#define glColor4fv fVboDrawer->vboGlColor4fv
#endif // G4VIS_BUILD_OPENGLQT_DRIVER
class G4OpenGLViewer;
class G4OpenGLVboDrawer {
@@ -295,49 +116,8 @@ public:
virtual ~G4OpenGLVboDrawer ();
// WT specific
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
void vboGlClear(Wt::WFlags< GLenum > mask);
void vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WMatrix4x4 &mat);
void vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const double* matrix);
void vboGlUniformMatrix4fv(const Wt::WGLWidget::UniformLocation &location, const float* matrix);
void vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WGLWidget::JavaScriptMatrix4x4 &mat);
Wt::WGLWidget::Buffer vboGlCreateBuffer();
void vboGlBindBuffer(GLenum target, Wt::WGLWidget::Buffer buffer);
void vboGlDeleteBuffer(Wt::WGLWidget::Buffer buffer);
void vboGlVertexAttribPointer(Wt::WGLWidget::AttribLocation location, int size, GLenum type, bool normalized, unsigned stride, unsigned offset);
void vboGlShaderSource(Wt::WGLWidget::Shader shader, GLsizei , const GLchar **src, const GLint *);
void vboGlCompileShader(Wt::WGLWidget::Shader shader);
Wt::WGLWidget::Shader vboGlCreateShader(GLenum shader);
Wt::WGLWidget::Program vboGlCreateProgram();
void vboGlAttachShader(Wt::WGLWidget::Program program, Wt::WGLWidget::Shader shader);
void vboGlLinkProgram(Wt::WGLWidget::Program program);
void vboGlUseProgram(Wt::WGLWidget::Program program);
void vboGlEnableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer);
void vboGlDisableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer);
Wt::WGLWidget::UniformLocation vboGlGetUniformLocation(Wt::WGLWidget::Program programm,const std::string &src);
Wt::WGLWidget::AttribLocation vboGlGetAttribLocation(Wt::WGLWidget::Program shader,const std::string &src);
void vboGlClearColor (double r, double g, double b, double a);
void vboGlClearDepth(double depth);
void vboGlViewport(int x, int y, unsigned width, unsigned height);
void vboGlEnable(GLenum cap);
void vboGlDisable(GLenum cap);
void vboGlBlendFunc (GLenum sfactor, GLenum dfactor);
void vboGlDepthFunc (GLenum func);
void vboGlDepthMask(bool flag);
void vboGlColorMask (bool red, bool green, bool blue, bool alpha);
void vboGlLineWidth(double width);
void vboGlDrawArrays(GLenum mode, int first, unsigned count);
void vboGlBufferDatafv(GLenum target, const std::vector<double>::iterator begin, const std::vector<double>::iterator end, GLenum usage);
void vboGlBufferDataiv(GLenum target, const std::vector<unsigned short>::iterator begin, const std::vector<unsigned short>::iterator end, GLenum usage, GLenum type);
void vboGlDrawElements(GLenum mode, unsigned count, GLenum type, unsigned offset);
void vboGlMultMatrixf( const GLfloat *m );
void vboGlMultMatrixd( const GLdouble *m );
#else
void vboGlMultMatrixf( const GLfloat *m );
void vboGlMultMatrixd( const GLdouble *m );
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
void vboGlFlush();
void vboGlOrtho(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
@@ -372,11 +152,7 @@ private:
std::string fOGLType;
GLenum fMatrixMode;
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
G4OpenGLImmediateWtViewer* fVboViewer;
#else
G4OpenGLImmediateQtViewer* fVboViewer;
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
};
#endif // G4OPENGL_VERSION_2
@@ -115,11 +115,8 @@ public:
bool setExportImageFormat(std::string format,bool quiet = false);
// change the export image format according to thoses available for the current viewer
// Special case for Wt, we want to have acces to the drawer
#ifdef G4OPENGL_VERSION_2
inline G4OpenGLVboDrawer* getWtDrawer() {return fVboDrawer;}
// Associate the Wt drawer to the OpenGLViewer and the OpenGLSceneHandler
void setVboDrawer(G4OpenGLVboDrawer* drawer);
G4OpenGLVboDrawer* fVboDrawer;
@@ -251,17 +248,6 @@ private :
#ifdef G4OPENGL_VERSION_2
public:
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
inline Wt::WGLWidget::Program getShaderProgram() {
return fShaderProgram;
}
inline Wt::WGLWidget::UniformLocation getShaderProjectionMatrix() {
return fpMatrixUniform;
}
inline Wt::WGLWidget::UniformLocation getShaderTransformMatrix() {
return ftMatrixUniform;
}
#else
inline GLuint getShaderProgram() {
return fShaderProgram;
}
@@ -274,30 +260,13 @@ public:
inline GLuint getShaderViewModelMatrix() {
return fmvMatrixUniform;
}
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
protected :
// define the keyword shader to handle it in a better way for OpenGL and WebGL
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
#define Shader Wt::WGLWidget::Shader
#else
#define Shader GLuint
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
// define some attributes and variables for OpenGL and WebGL
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
Wt::WGLWidget::Program fShaderProgram;
// Program and related variables
Wt::WGLWidget::AttribLocation fVertexPositionAttribute;
Wt::WGLWidget::AttribLocation fVertexNormalAttribute;
Wt::WGLWidget::UniformLocation fpMatrixUniform;
Wt::WGLWidget::UniformLocation fcMatrixUniform;
Wt::WGLWidget::UniformLocation fmvMatrixUniform;
Wt::WGLWidget::UniformLocation fnMatrixUniform;
Wt::WGLWidget::UniformLocation ftMatrixUniform;
#else
GLuint fShaderProgram;
// Program and related variables
@@ -308,7 +277,6 @@ protected :
GLuint fmvMatrixUniform;
GLuint fnMatrixUniform;
GLuint ftMatrixUniform;
#endif // G4VIS_BUILD_OPENGLWT_DRIVER
#endif
};
@@ -56,17 +56,11 @@ private:
G4UIcmdWithoutParameter* fpCommandPrintEPS;
G4UIdirectory* fpDirectorySet;
G4UIcommand* fpCommandDisplayHeadTime;
G4UIcommand* fpCommandDisplayLightFront;
G4UIcmdWithAnInteger* fpCommandDisplayListLimit;
G4UIcommand* fpCommandEndTime;
G4UIcmdWithAnInteger* fpCommandEventsDrawInterval;
G4UIcommand* fpCommandExportFormat;
G4UIcmdWithADouble* fpCommandFade;
G4UIcommand* fpCommandPrintFilename;
G4UIcmdWithAString* fpCommandPrintMode;
G4UIcommand* fpCommandPrintSize;
G4UIcommand* fpCommandStartTime;
G4UIcmdWithABool* fpCommandTransparency;
};
@@ -53,12 +53,24 @@ protected:
void CreateGLWin32Context ();
virtual void CreateMainWindow ();
HDC fHDC;
G4bool fMouseHovered;
G4bool fMousePressed;
G4int fMousePressedX, fMousePressedY;
private:
static LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);
static bool SetWindowPixelFormat(HDC);
private:
static G4bool SetWindowPixelFormat(HDC);
void TrackMouse(G4int, G4int);
void ReleaseMouse();
void SetShift(G4int, G4int);
void SetRotation(G4int, G4int);
void SetZoom(G4int);
HWND fWindow;
HGLRC fHGLRC;
G4bool fInCreateWindow;
};
#endif
@@ -1,271 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4OpenGLWtViewer : Class to provide WindowsNT specific
// functionality for OpenGL in GEANT4
#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
#ifndef G4OPENGLWTVIEWER_HH
#define G4OPENGLWTVIEWER_HH
#include "globals.hh"
#include "G4OpenGLViewer.hh"
#include <Wt/WObject>
#include <Wt/WPoint>
#include <Wt/WTime>
#include <Wt/WContainerWidget>
#include <Wt/WMatrix4x4>
class G4OpenGLSceneHandler;
class G4UImanager;
class WDialog;
#ifdef _A_FINIR_FIXME
class WContextMenuEvent;
#endif
class WMenu;
class WImage;
#ifdef _A_FINIR_FIXME
class WWheelEvent;
#endif
class WProcess;
class G4UIWt;
class G4OpenGLSceneHandler;
class G4OpenGLWtMovieDialog;
class G4OpenGLWtViewer: virtual public G4OpenGLViewer {
public:
G4OpenGLWtViewer (G4OpenGLSceneHandler& scene);
virtual ~G4OpenGLWtViewer ();
virtual void updateWWidget()=0;
Wt::WMatrix4x4 mMatrix;
#ifdef _A_FINIR_FIXME
Wt::WString setEncoderPath(Wt::WString path);
Wt::WString getEncoderPath();
Wt::WString setTempFolderPath(Wt::WString path);
Wt::WString getTempFolderPath();
Wt::WString setSaveFileName(Wt::WString path);
Wt::WString getSaveFileName();
bool isRecording();
bool isStopped();
bool isPaused();
bool isEncoding();
bool isWaiting();
bool isFailed();
void setWaiting();
bool isBadEncoder();
bool isBadOutput();
bool isBadTmp();
bool isSuccess();
void setBadTmp();
void setBadOutput();
void setBadEncoder();
bool isReadyToEncode();
void resetRecording();
void encodeVideo();
void stopVideo();
void saveVideo();
bool generateMpegEncoderParameters();
void displayRecordingStatus();
#endif
void drawText(const char * ,int x,int y,int z, int size);
protected:
void CreateGLWtContext ();
virtual void CreateMainWindow (Wt::WGLWidget*,Wt::WString);
#ifdef _A_FINIR_FIXME
void G4manageContextMenuEvent(Wt::WContextMenuEvent *e);
#endif
void G4MousePressEvent(Wt::WMouseEvent *event);
void G4MouseReleaseEvent();
void G4MouseDoubleClickEvent();
void G4MouseMoveEvent(Wt::WMouseEvent *event);
// void G4wheelEvent (Wt::WWheelEvent * event);
void G4keyPressEvent (Wt::WKeyEvent * event);
void rotateWtScene(float, float);
void rotateWtSceneToggle(float, float);
void moveScene(float, float, float,bool);
#ifdef _A_FINIR_FIXME
void updateKeyModifierState(Wt::KeyboardModifiers);
#endif
inline Wt::WGLWidget* getGLWindow() {
return fWindow;
}
protected:
Wt::WGLWidget* fWindow;
Wt::WWidget* fGLWindow;
bool hasPendingEvents();
void resizeGL(int width, int height);
#ifdef _A_FINIR_FIXME
void savePPMToTemp();
#endif
int fRecordFrameNumber;
bool fHasToRepaint;
bool fReadyToPaint;
bool fIsRepainting;
private:
enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
#ifdef _A_FINIR_FIXME
void createPopupMenu();
void createRadioAction(Wt::WAction *,Wt::WAction *, const std::string&,unsigned int a=1);
#endif
void rescaleImage(int, int);
#ifdef _A_FINIR_FIXME
bool printPDF(const std::string,int,WImage);
void showMovieParametersDialog();
void initMovieParameters();
Wt::WString createTempFolder();
Wt::WString removeTempFolder();
void setRecordingStatus(RECORDING_STEP);
void setRecordingInfos(Wt::WString);
Wt::WString getProcessErrorMsg();
WMenu *fContextMenu;
#endif
mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
Wt::WPoint fLastPos1;
Wt::WPoint fLastPos2;
Wt::WPoint fLastPos3;
/** delta of scene rotation. This delta is put in degree */
G4double fDeltaRotation;
/** delta of scene translation. This delta is put in % of the scene view */
G4double fDeltaSceneTranslation;
/** delta of depth move. This delta is put in % of the scene view */
G4double fDeltaDepth;
/** delta of zoom move. This delta is put in % of the scene view */
G4double fDeltaZoom;
/** delta of auto move/rotation. This delta is put in % of the move/rotation param */
G4double fDeltaMove;
/** To ensure key event are keep one by one */
bool fHoldKeyEvent;
/** To ensure move event are keep one by one */
bool fHoldMoveEvent;
/** To ensure rotate event are keep one by one */
bool fHoldRotateEvent;
bool fAutoMove;
Wt::WString fEncoderPath;
Wt::WString fTempFolderPath;
Wt::WString fMovieTempFolderPath;
Wt::WString fSaveFileName;
Wt::WString fParameterFileName;
#ifdef _A_FINIR_FIXME
WAction *fRotateAction;
WAction *fMoveAction;
WAction *fPickAction;
WAction *fFullScreenOn;
WAction *fFullScreenOff;
WAction *fDrawingWireframe;
WAction *fDrawingLineRemoval;
WAction *fDrawingSurfaceRemoval;
WAction *fDrawingLineSurfaceRemoval;
#endif
G4OpenGLWtMovieDialog* fMovieParametersDialog;
RECORDING_STEP fRecordingStep;
WProcess *fProcess;
Wt::WTime *fLastEventTime;
int fSpinningDelay;
int fNbMaxFramesPerSec;
float fNbMaxAnglePerSec;
int fLaunchSpinDelay;
Wt::WTabWidget* fUISceneTreeComponentsTBWidget;
G4double fXRot;
G4double fYRot;
bool fNoKeyPress;
bool fAltKeyPress;
bool fControlKeyPress;
bool fShiftKeyPress;
bool fBatchMode;
G4UIWt* fUiWt;
#ifdef _A_FINIR_FIXME
void rotateTheta(int);
void rotatePhi(int);
void moveX(int);
void moveY(int);
void moveZ(int);
#endif
public :
void startPauseVideo();
private :
#ifdef _A_FINIR_FIXME
void actionMouseRotate();
void actionMouseMove();
void actionMousePick();
void actionDrawingWireframe();
void actionDrawingLineRemoval();
void actionDrawingSurfaceRemoval();
void actionDrawingLineSurfaceRemoval();
void actionSaveImage();
void actionChangeBackgroundColor();
void actionChangeTextColor();
void actionChangeDefaultColor();
void actionMovieParameters();
#endif
void showShortcuts();
#ifdef _A_FINIR_FIXME
void toggleDrawingAction(int);
void toggleMouseAction(mouseActions);
void toggleRepresentation(bool);
void toggleProjection(bool);
void toggleTransparency(bool);
void toggleAntialiasing(bool);
void toggleHaloing(bool);
void toggleAux(bool);
void toggleFullScreen(bool);
#endif
void processEncodeFinished();
void processLookForFinished();
void processEncodeStdout();
// Only use for Wt>4.0
// void dialogClosed();
};
#endif
#endif
@@ -40,7 +40,5 @@ G4String G4VisFeaturesOfOpenGLIWin32 ();
G4String G4VisFeaturesOfOpenGLSWin32 ();
G4String G4VisFeaturesOfOpenGLIQt ();
G4String G4VisFeaturesOfOpenGLSQt ();
G4String G4VisFeaturesOfOpenGLIWt ();
//G4String G4VisFeaturesOfOpenGLSWt ();
#endif
+16 -53
View File
@@ -1,14 +1,8 @@
#------------------------------------------------------------------------------
# Module : G4OpenGL
# Package: Geant4.src.G4visualization.G4OpenGL
#------------------------------------------------------------------------------
# - G4OpenGL module build definition
#
# Module has optional sources
#
# Define the core sources, includes and libraries which all Geant4
# OpenGL implementations use
#
set(G4VIS_MODULE_OPENGL_HEADERS
G4OpenGL.hh
G4OpenGLImmediateViewer.hh
@@ -215,54 +209,23 @@ list(REMOVE_DUPLICATES G4VIS_MODULE_OPENGL_LINK_LIBRARIES)
#----------------------------------------------------------------------------
# Define the Geant4 Module.
#
geant4_define_module(NAME G4OpenGL
HEADERS
${G4VIS_MODULE_OPENGL_HEADERS}
SOURCES
${G4VIS_MODULE_OPENGL_SOURCES}
GRANULAR_DEPENDENCIES
G4UIbasic
G4UIcommon
G4csg
G4event
G4run
G4tasking
G4particles
G4processes
G4track
G4materials
G4geometrymng
G4gl2ps
geant4_add_module(G4OpenGL
PUBLIC_HEADERS ${G4VIS_MODULE_OPENGL_HEADERS}
SOURCES ${G4VIS_MODULE_OPENGL_SOURCES})
geant4_module_link_libraries(G4OpenGL
PUBLIC
G4globman
G4graphics_reps
G4digits
G4hits
G4intercoms
G4modeling
G4specsolids
G4tracking
G4graphics_reps
G4hepgeometry
G4intercoms
G4vis_management
GLOBAL_DEPENDENCIES
G4digits_hits
G4event
${G4VIS_MODULE_OPENGL_LINK_LIBRARIES}
PRIVATE
G4geometrymng
G4UIcommon
G4UIbasic
G4run
G4tasking
G4particles
G4processes
G4track
G4materials
G4geometry
G4gl2ps
G4global
G4graphics_reps
G4intercoms
G4interfaces
G4modeling
G4tracking
G4vis_management
LINK_LIBRARIES
${G4VIS_MODULE_OPENGL_LINK_LIBRARIES}
)
# List any source specific properties here
G4gl2ps)
@@ -72,7 +72,7 @@ G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer
}
G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQtViewer() {
makeCurrent();
// makeCurrent(); // Not sure why this - commented out 12-Apr-2021 JA
}
void G4OpenGLImmediateQtViewer::Initialise() {
@@ -131,8 +131,6 @@ void G4OpenGLImmediateQtViewer::initializeGL () {
glUseProgram(fShaderProgram);
setInitialized(); // Should be removed when fuse Wt and Qt
#endif
// If a double buffer context has been forced upon us, ignore the
@@ -1,104 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// OpenGLImmediateWt graphics system factory.
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
#include "G4VisFeaturesOfOpenGL.hh"
#include "G4VSceneHandler.hh"
#include "G4OpenGLSceneHandler.hh"
#include "G4OpenGLViewer.hh"
#include "G4OpenGLImmediateWt.hh"
#include "G4OpenGLImmediateWtViewer.hh"
#include "G4OpenGLViewerMessenger.hh"
#include "G4OpenGLImmediateSceneHandler.hh"
#include "G4UIWt.hh"
#include "G4UImanager.hh"
#include <Wt/WLabel>
#include <Wt/WContainerWidget>
G4OpenGLImmediateWt::G4OpenGLImmediateWt ():
G4VGraphicsSystem ("OpenGLImmediateWt",
"OGLIWt",
G4VisFeaturesOfOpenGLIWt (),
G4VGraphicsSystem::threeD)
{
G4OpenGLViewerMessenger::GetInstance();
}
G4VSceneHandler* G4OpenGLImmediateWt::CreateSceneHandler
(const G4String& name) {
G4VSceneHandler* pScene = new G4OpenGLImmediateSceneHandler (*this, name);
return pScene;
}
G4VViewer* G4OpenGLImmediateWt::CreateViewer
(G4VSceneHandler& scene, const G4String& name) {
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWt::CreateViewer \n");
#endif
G4VViewer* pView = 0;
// G4VisManager::CreateViewer
// -> G4OpenGLImmediateWt::CreateViewer
// -> G4OpenGLImmediateWtViewer
// !! ImmediateWtViewer should be the container
// G4VisManager::CreateViewer
// G4OpenGLImmediateQtViewer::Initialise()
// ->G4OpenGLQtViewer::CreateMainWindow(container, name)
// fUiQt->AddTabWidget (container fWindow)
// Create a container for the widget
fWGLContainer = new Wt::WContainerWidget();
pView = new G4OpenGLImmediateWtViewer
((G4OpenGLImmediateSceneHandler&) scene, fWGLContainer, name);
if (pView) {
if (pView -> GetViewId () < 0) {
G4cerr << "G4OpenGLImmediateWt::CreateViewer: error flagged by negative"
" view id in G4OpenGLImmediateWtViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = 0;
}
}
else {
G4cerr << "G4OpenGLImmediateWt::CreateViewer: null pointer on"
" new G4OpenGLImmediateWtViewer." << G4endl;
}
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWt::CreateViewer END \n");
#endif
return pView;
}
#endif
@@ -1,422 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Class G4OpenGLImmediateWtViewer : a class derived from G4OpenGLWtViewer and
// G4OpenGLImmediateViewer.
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
#include "G4OpenGLImmediateWtViewer.hh"
#include "G4OpenGLImmediateSceneHandler.hh"
#include "G4ios.hh"
#define G4DEBUG_VIS_OGL 1
G4OpenGLImmediateWtViewer::G4OpenGLImmediateWtViewer
(G4OpenGLImmediateSceneHandler& sceneHandler,
Wt::WContainerWidget* aParent,
const G4String& name):
G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
G4OpenGLViewer (sceneHandler),
G4OpenGLWtViewer (sceneHandler),
G4OpenGLImmediateViewer (sceneHandler),
Wt::WGLWidget(aParent)
{
// Create a new drawer
// register the WtDrawer to the OpenGLViewer
setVboDrawer(new G4OpenGLVboDrawer(this,"OGL-ES"));
// Add the GL Widget to its parent
aParent->addWidget(this);
fHasToRepaint = false;
fIsRepainting = false;
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer INIT\n");
#endif
if (fViewId < 0) return; // In case error in base class instantiation.
}
G4OpenGLImmediateWtViewer::~G4OpenGLImmediateWtViewer() {
}
void G4OpenGLImmediateWtViewer::Initialise() {
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer::Initialise \n");
#endif
fReadyToPaint = false;
CreateMainWindow (this,Wt::WString(fName));
CreateFontLists ();
fReadyToPaint = true;
}
void G4OpenGLImmediateWtViewer::initializeGL () {
InitializeGLView ();
// If a double buffer context has been forced upon us, ignore the
// back buffer for this OpenGLImmediate view.
// glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
if (fSceneHandler.GetScene() == 0) {
fHasToRepaint =false;
} else {
fHasToRepaint =true;
}
// In order to know where to look at, calculate the centerpoint of the
// scene
double cx, cy, cz;
cx = cy = cz = 0.;
// Transform the world so that we look at the centerpoint of the scene
Wt::WMatrix4x4 worldTransform;
worldTransform.lookAt(
cx, cy, cz + 10, // camera position
cx, cy, cz, // looking at
0, 1, 0); // 'up' vector
// We want to be able to change the camera position client-side. In
// order to do so, the world transformation matrix must be stored in
// a matrix that can be manipulated from JavaScript.
jsMatrix_ = createJavaScriptMatrix4();
setJavaScriptMatrix4(jsMatrix_, worldTransform);
// This installs a client-side mouse handler that modifies the
// world transformation matrix. Like WMatrix4x4::lookAt, this works
// by specifying a center point and an up direction; mouse movements
// will allow the camera to be moved around the center point.
setClientSideLookAtHandler(jsMatrix_, // the name of the JS matrix
cx, cy, cz, // the center point
0, 1, 0, // the up direction
0.005, 0.005); // 'speed' factors
// Alternative: this installs a client-side mouse handler that allows
// to 'walk' around: go forward, backward, turn left, turn right, ...
//setClientSideWalkHandler(jsMatrix_, 0.05, 0.005);
// Set the clear color to a transparant background
glClearColor(0, 0, 0, 0);
// Reset Z-buffer, enable Z-buffering
glClearDepth(1);
glEnable(DEPTH_TEST);
glDepthFunc(LEQUAL);
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLWtViewer initializeGL END\n");
#endif
// Set the component visible
show() ;
}
void G4OpenGLImmediateWtViewer::DrawView() {
updateWWidget();
}
void G4OpenGLImmediateWtViewer::ComputeView () {
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLWtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
#endif
// If a double buffer context has been forced upon us, ignore the
// back buffer for this OpenGL view.
// glDrawBuffer (GL_FRONT);
G4ViewParameters::DrawingStyle dstyle = GetViewParameters().GetDrawingStyle();
if(dstyle!=G4ViewParameters::hlr &&
haloing_enabled) {
HaloingFirstPass ();
NeedKernelVisit ();
ProcessView ();
FinishView();
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLWtViewer::ComputeView First ProcessView ok\n");
#endif
HaloingSecondPass ();
}
NeedKernelVisit (); // Always need to visit G4 kernel.
ProcessView ();
/* FIXME
if (isRecording()) {
savePPMToTemp();
}
*/
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLWtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
#endif
fHasToRepaint = true;
}
/**
- Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
*/
void G4OpenGLImmediateWtViewer::resizeGL(
int width
,int height)
{
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer resizeGL %d %d\n",width,height);
#endif
G4OpenGLWtViewer::resizeGL(width,height);
// Set the viewport size.
glViewport(0, 0, width, height);
// Set projection matrix to some fixed values
/* Wt::WMatrix4x4 proj;
proj.perspective(45, ((double)width)/height, 1, 40);
glUniformMatrix4(fpMatrixUniform, proj);
*/
SetView();
// updateWWidget();
}
void G4OpenGLImmediateWtViewer::paintGL() {
if (fIsRepainting) {
// return ;
}
if (!fReadyToPaint) {
fReadyToPaint= true;
return;
}
if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
return;
}
// DO NOT RESIZE IF SIZE HAS NOT CHANGE
if ( !fHasToRepaint) {
double sw = 0;
double sh = 0;
// if (!isMaximized() && !isFullScreen()) {
sw = width().value();
sh = height().value();
// } else {
// sw = frameGeometry().width();
// sh = frameGeometry().height();
// }
if ((getWinWidth() == sw) &&(getWinHeight() == sh)) {
return;
} else if ((sw == 0) && (sh == 0)) { // NOT A TOP LEVEL WIDGET
if (((getWinWidth() == width().value())) &&(getWinHeight() == height().value())) {
return;
}
}
}
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
#endif
SetView();
ClearView(); //ok, put the background correct
// SHOULD BE REMOVED
// Configure the shader: set the uniforms
// Uniforms are 'configurable constants' in a shader: they are
// identical for every point that has to be drawn.
// Set the camera transformation to the value of a client-side JS matrix
glUniformMatrix4(fcMatrixUniform, jsMatrix_);
// Often, a model matrix is used to move the model around. We're happy
// with the location of the model, so we leave it as the unit matrix
Wt::WMatrix4x4 modelMatrix;
glUniformMatrix4(fmvMatrixUniform, modelMatrix);
// The next one is a bit complicated. In desktop OpenGL, a shader
// has the gl_NormalMatrix matrix available in the shader language,
// a matrix that is used to transform normals to e.g. implement proper
// Phong shading (google will help you to find a detailed explanation
// of why you need it). It is the transposed inverse of the model view
// matrix. Unfortunately, this matrix is not available in WebGL, so if
// you want to do phong shading, you must calculate it yourself.
// Wt provides methods to calculate the transposed inverse of a matrix,
// when client-side JS matrices are involved. Here, we inverse-transpose
// the product of the client-side camera matrix and the model matrix.
glUniformMatrix4(fnMatrixUniform, (jsMatrix_ * modelMatrix).inverted().transposed());
// Create a new Buffer
Buffer objBuffer_2 = glCreateBuffer(); //glGenBuffers(1,&objBuffer_2)
// Bind this buffer
glBindBuffer(GL_ARRAY_BUFFER, objBuffer_2);
// SHOULD BE REMOVED END
ComputeView();
fHasToRepaint = false; // could be set to false by ComputeView
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n\n\n",fReadyToPaint);
#endif
fIsRepainting = false;
}
void G4OpenGLImmediateWtViewer::mousePressEvent(Wt::WMouseEvent *event)
{
// boutons et position
G4MousePressEvent(event);
}
void G4OpenGLImmediateWtViewer::keyPressEvent (Wt::WKeyEvent *event)
{
G4keyPressEvent(event);
}
/**
void G4OpenGLImmediateWtViewer::showEvent (QShowEvent *)
{
fHasToRepaint = true;
}
*/
/**
* This function was build in order to make a zoom on double clic event.
* It was think to build a rubberband on the zoom area, but never work fine
*/
void G4OpenGLImmediateWtViewer::mouseDoubleClickEvent(Wt::WMouseEvent *)
{
G4MouseDoubleClickEvent();
}
void G4OpenGLImmediateWtViewer::mouseReleaseEvent(Wt::WMouseEvent )
{
G4MouseReleaseEvent();
}
void G4OpenGLImmediateWtViewer::mouseMoveEvent(Wt::WMouseEvent *event)
{
G4MouseMoveEvent(event);
}
/**
void G4OpenGLImmediateWtViewer::contextMenuEvent(QContextMenuEvent *e)
{
G4manageContextMenuEvent(e);
}
*/
void G4OpenGLImmediateWtViewer::paintEvent(Wt::WPaintDevice * /* painter */) {
if ( fHasToRepaint) {
updateGL();
}
}
void G4OpenGLImmediateWtViewer::FinishView()
{
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLWtViewer::FinishView() \n");
#endif
flush ();
// L. Garnier 10/2009 : Not necessary and cause problems on mac OS X 10.6
// fWindow->swapBuffers ();
}
void G4OpenGLImmediateWtViewer::popMatrix() {
}
void G4OpenGLImmediateWtViewer::pushMatrix() {
}
void G4OpenGLImmediateWtViewer::multMatrixd(const GLdouble* /* m */) {
// mMatrix = mMatrix * m;
}
void G4OpenGLImmediateWtViewer::loadIdentity() {
mMatrix.setToIdentity ();
}
void G4OpenGLImmediateWtViewer::setMatrixUniforms() {
/*
UniformLocation pUniform = getUniformLocation(shaderProgram, "uPMatrix");
uniformMatrix4fv(pUniform, false, new Float32Array(perspectiveMatrix.flatten()));
UniformLocation mvUniform = getUniformLocation(shaderProgram, "uMVMatrix");
uniformMatrix4fv(mvUniform, false, new Float32Array(mvMatrix.flatten()));
*/
}
void G4OpenGLImmediateWtViewer::ShowView (
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer ShowView\n");
#endif
repaintSlot();
// activateWindow();
}
void G4OpenGLImmediateWtViewer::updateWWidget() {
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer updateWWidget\n");
#endif
fHasToRepaint= true;
// updateGL();
repaintGL(PAINT_GL | RESIZE_GL);
// paintGL() ;
fHasToRepaint= false;
#ifdef G4DEBUG_VIS_OGL
printf("G4OpenGLImmediateWtViewer updateWWidget END\n");
#endif
}
#endif
@@ -3352,6 +3352,16 @@ void G4OpenGLQtViewer::addNonPVSceneTreeElement(
catch (const std::bad_cast&) {
color = fSceneHandler.GetColour();
}
// Special case for marker
try {
const G4VMarker& g4Marker = dynamic_cast<const G4VMarker&>(visible);
if (g4Marker.GetInfo() != "") {
modelShortName = g4Marker.GetInfo();
}
}
catch (const std::bad_cast&) {}
if (modelShortName == "") {
return ;
}
@@ -58,6 +58,9 @@
# include "G4RunManager.hh"
# include "G4Run.hh"
# include "G4RunManagerFactory.hh"
# include "G4Mesh.hh"
# include "G4PseudoScene.hh"
# include "G4VisManager.hh"
const GLubyte G4OpenGLSceneHandler::fStippleMaskHashed [128] = {
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
@@ -1026,6 +1029,118 @@ void G4OpenGLSceneHandler::AddCompound(const G4THitsMap<G4StatDouble>& hits) {
G4VSceneHandler::AddCompound(hits); // For now.
}
void G4OpenGLSceneHandler::AddCompound(const G4Mesh& mesh)
{
// Special mesh rendering for OpenGL drivers
// Limited to rectangular 3-deep meshes
if (mesh.GetMeshType() != G4Mesh::rectangle ||
mesh.GetMeshDepth() != 3) {
G4VSceneHandler::AddCompound(mesh);
}
auto container = mesh.GetContainerVolume();
static G4bool firstPrint = true;
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
G4bool print = firstPrint && verbosity >= G4VisManager::confirmations;
if (print) {
G4cout
<< "Special case drawing of G4VNestedParameterisation in G4OpenGLSceneHandler"
<< '\n' << mesh
<< G4endl;
}
// Instantiate a temporary G4PhysicalVolumeModel
G4ModelingParameters tmpMP;
tmpMP.SetCulling(true); // This avoids drawing transparent...
tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
const G4bool useFullExtent = true; // To avoid calculating the extent
G4PhysicalVolumeModel tmpPVModel
(container,
G4PhysicalVolumeModel::UNLIMITED,
G4Transform3D(),
&tmpMP,
useFullExtent);
// Instantiate a pseudo scene so that we can make a "private" descent
// into the nested parameterisation and fill a multimap...
std::multimap<const G4Colour,G4ThreeVector> positionByColour;
G4double halfX = 0., halfY = 0., halfZ = 0.;
struct PseudoScene: public G4PseudoScene {
PseudoScene
(G4PhysicalVolumeModel* pvModel // input...the following are outputs
, std::multimap<const G4Colour,G4ThreeVector>& positionByColour
, G4double& halfX, G4double& halfY, G4double& halfZ)
: fpPVModel(pvModel)
, fPositionByColour(positionByColour)
, fHalfX(halfX), fHalfY(halfY), fHalfZ(halfZ)
{}
using G4PseudoScene::AddSolid; // except for...
void AddSolid(const G4Box& box) {
const G4Colour& colour = fpPVModel->GetCurrentLV()->GetVisAttributes()->GetColour();
const G4ThreeVector& position = fpCurrentObjectTransformation->getTranslation();
fPositionByColour.insert(std::make_pair(colour,position));
fHalfX = box.GetXHalfLength();
fHalfY = box.GetYHalfLength();
fHalfZ = box.GetZHalfLength();
}
G4PhysicalVolumeModel* fpPVModel;
std::multimap<const G4Colour,G4ThreeVector>& fPositionByColour;
G4double &fHalfX, &fHalfY, &fHalfZ;
}
pseudoScene(&tmpPVModel,positionByColour,halfX,halfY,halfZ);
// Make private descent into the nested parameterisation
tmpPVModel.DescribeYourselfTo(pseudoScene);
// Make list of found colours
std::set<G4Colour> setOfColours;
for (const auto& entry: positionByColour) {
setOfColours.insert(entry.first);
}
if (print) {
for (const auto& colour: setOfColours) {
G4cout << "setOfColours: " << colour << G4endl;
}
}
// Draw as dots
BeginPrimitives (mesh.GetTransform());
G4int nDotsTotal = 0;
for (const auto& colour: setOfColours) {
G4int nDots = 0;
G4Polymarker dots;
dots.SetVisAttributes(G4Colour(colour));
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
dots.SetInfo(container->GetName());
const auto range = positionByColour.equal_range(colour);
for (auto posByCol = range.first; posByCol != range.second; ++posByCol) {
const G4double x = posByCol->second.getX() + (2.*G4UniformRand()-1.)*halfX;
const G4double y = posByCol->second.getY() + (2.*G4UniformRand()-1.)*halfY;
const G4double z = posByCol->second.getZ() + (2.*G4UniformRand()-1.)*halfZ;
dots.push_back(G4ThreeVector(x,y,z));
++nDots;
}
AddPrimitive(dots);
if (print) {
G4cout
<< "Number of dots for colour " << colour
<< ": " << nDots << G4endl;
}
nDotsTotal += nDots;
}
if (print) {
G4cout << "Total number of dots: " << nDotsTotal << G4endl;
}
EndPrimitives ();
firstPrint = false;
return;
}
#ifdef G4OPENGL_VERSION_2
@@ -1124,13 +1239,8 @@ void G4OpenGLSceneHandler::OptimizeVBOForCons(G4int aNoFaces){
void G4OpenGLSceneHandler::glBeginVBO(GLenum type) {
fDrawArrayType = type;
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glGenBuffers(1,&fVertexBufferObject);
glGenBuffers(1,&fIndicesBufferObject);
#else
fVertexBufferObject = glCreateBuffer(); //glGenBuffer(1,fVertexBufferObject_2)
fIndicesBufferObject = glCreateBuffer(); //glGenBuffer(1,fIndicesBufferObject_2)
#endif
// clear data and indices for OpenGL
fOglVertex.clear();
@@ -1208,26 +1318,18 @@ void G4OpenGLSceneHandler::glEndVBO() {
glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
// Load fOglVertex into VBO
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
int sizeV = fOglVertex.size();
// FIXME : perhaps a problem withBufferData in OpenGL other than WebGL ?
// void glBufferData( GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
glBufferData(GL_ARRAY_BUFFER, sizeof(double)*sizeV, &fOglVertex[0], GL_STATIC_DRAW);
#else
glBufferDatafv(GL_ARRAY_BUFFER, fOglVertex.begin(), fOglVertex.end(), GL_STATIC_DRAW);
#endif
// Bind IBO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fIndicesBufferObject);
// Load fOglVertex into VBO
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
int sizeI = fOglIndices.size();
glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(int)*sizeI, &fOglIndices[0], GL_STATIC_DRAW);
#else
glBufferDataiv(GL_ELEMENT_ARRAY_BUFFER, fOglIndices.begin(), fOglIndices.end(), GL_STATIC_DRAW, GL_UNSIGNED_BYTE);
#endif
//----------------------------
// Draw VBO
//----------------------------
@@ -1261,33 +1363,20 @@ void G4OpenGLSceneHandler::glEndVBO() {
}
// delete the buffer
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glDeleteBuffers(1,&fVertexBufferObject);
#else
glDeleteBuffer(fVertexBufferObject);
#endif
}
}
void G4OpenGLSceneHandler::drawVBOArray(std::vector<double> vertices) {
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glGenBuffers(1,&fVertexBufferObject);
glGenBuffers(1,&fIndicesBufferObject);
#else
fVertexBufferObject = glCreateBuffer(); //glGenBuffer(1,fVertexBufferObject_2)
fIndicesBufferObject = glCreateBuffer(); //glGenBuffer(1,fIndicesBufferObject_2)
#endif
// Bind this buffer
glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
// Load oglData into VBO
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
int s = vertices.size();
glBufferData(GL_ARRAY_BUFFER, sizeof(double)*s, &vertices[0], GL_STATIC_DRAW);
#else
glBufferDatafv(GL_ARRAY_BUFFER, vertices.begin(), vertices.end(), GL_STATIC_DRAW);
#endif
//----------------------------
// Draw VBO
//----------------------------
@@ -1306,7 +1395,6 @@ void G4OpenGLSceneHandler::drawVBOArray(std::vector<double> vertices) {
glLoadMatrixd, glRotated and any other function that have to do with the double type. Most GPUs don't support GL_DOUBLE (double) so the driver will convert the data to GL_FLOAT (float) and send to the GPU. If you put GL_DOUBLE data in a VBO, the performance might even be much worst than immediate mode (immediate mode means glBegin, glVertex, glEnd). GL doesn't offer any better way to know what the GPU prefers.
*/
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glVertexAttribPointer(pGLViewer->fVertexPositionAttribute,
3, // size: Every vertex has an X, Y anc Z component
GL_DOUBLE, // type: They are double
@@ -1316,35 +1404,16 @@ void G4OpenGLSceneHandler::drawVBOArray(std::vector<double> vertices) {
// vx, vy, vz, nx, ny, nz and every element is a
// Float32, hence 4 bytes large
0); // offset: The byte position of the first vertex in the buffer
#else
glVertexAttribPointer(pGLViewer->fVertexPositionAttribute,
3, // size: Every vertex has an X, Y anc Z component
GL_FLOAT, // type: They are floats
GL_FALSE, // normalized: Please, do NOT normalize the vertices
2*3*4, // stride: The first byte of the next vertex is located this
// amount of bytes further. The format of the VBO is
// vx, vy, vz, nx, ny, nz and every element is a
// Float32, hence 4 bytes large
0); // offset: The byte position of the first vertex in the buffer
#endif
}
glDrawArrays(fDrawArrayType, // GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, and GL_TRIANGLES
0, vertices.size()/6);
if (pGLViewer) {
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glDisableClientState( GL_VERTEX_ARRAY );
#else
glDisableVertexAttribArray(pGLViewer->fVertexPositionAttribute);
#endif
}
// delete the buffer
#ifndef G4VIS_BUILD_OPENGLWT_DRIVER
glDeleteBuffers(1,&fVertexBufferObject);
#else
glDeleteBuffer(fVertexBufferObject);
#endif
}
#endif
@@ -51,6 +51,8 @@ G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
G4OpenGLStoredViewer (sceneHandler), // FIXME : gerer le pb du parent !
QGLWidget()
{
if (fViewId < 0) return; // In case error in base class instantiation.
fQGLWidgetInitialiseCompleted = false;
// Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted. Note: Unlike WA_OpaquePaintEvent, newly exposed areas are never filled with the background (e.g., after showing a window for the first time the user can see "through" it until the application processes the paint events). This flag is set or cleared by the widget's author.
@@ -60,12 +62,10 @@ G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
fHasToRepaint = false;
fPaintEventLock = false;
fUpdateGLLock = false;
if (fViewId < 0) return; // In case error in base class instantiation.
}
G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
makeCurrent();
// makeCurrent(); // Not sure why this - commented out 12-Apr-2021 JA
// this is connect to the Dialog for deleting it properly
// when close event.
// ((QDialog*)window())->reject();
@@ -138,7 +138,8 @@ G4bool G4OpenGLStoredQtViewer::CompareForKernelVisit(G4ViewParameters& lastVP)
(lastVP.GetDefaultTextVisAttributes()->GetColour() !=
fVP.GetDefaultTextVisAttributes()->GetColour()) ||
(lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
(lastVP.IsPicking () != fVP.IsPicking ()))
(lastVP.IsPicking () != fVP.IsPicking ()) ||
(lastVP.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()))
return true;
// Don't check VisAttributesModifiers if this comparison has been
@@ -184,6 +185,10 @@ G4bool G4OpenGLStoredQtViewer::CompareForKernelVisit(G4ViewParameters& lastVP)
(lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
return true;
if (lastVP.IsSpecialMeshRendering() &&
(lastVP.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
return true;
return false;
}
@@ -97,7 +97,9 @@ G4bool G4OpenGLStoredViewer::CompareForKernelVisit(G4ViewParameters& lastVP) {
(lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
(lastVP.IsPicking () != fVP.IsPicking ()) ||
(lastVP.GetVisAttributesModifiers() !=
fVP.GetVisAttributesModifiers())
fVP.GetVisAttributesModifiers()) ||
(lastVP.IsSpecialMeshRendering() !=
fVP.IsSpecialMeshRendering())
)
return true;
@@ -132,6 +134,10 @@ G4bool G4OpenGLStoredViewer::CompareForKernelVisit(G4ViewParameters& lastVP) {
(lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
return true;
if (lastVP.IsSpecialMeshRendering() &&
(lastVP.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
return true;
// Time window parameters operate on the existing database so no need
// to rebuild even if they change.
@@ -26,20 +26,15 @@
//
//
//
// G4OpenGLWtViewer : Class to provide Vertex Buffer Object (VBO) specific
// functionality for OpenGL > 2.0 in GEANT4
//
// Class to provide Vertex Buffer Object (VBO) specific
// functionality for OpenGL > 2.0 in GEANT4
#include "G4OpenGLViewer.hh"
#ifdef G4OPENGL_VERSION_2
#include "G4OpenGLVboDrawer.hh"
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
#include "G4OpenGLImmediateWtViewer.hh"
#else
#include "G4OpenGLImmediateQtViewer.hh"
#endif
//////////////////////////////////////////////////////////////////////////////
@@ -51,11 +46,7 @@ fOGLType(type)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
G4OpenGLImmediateWtViewer* v = dynamic_cast<G4OpenGLImmediateWtViewer*>(viewer);
#else
G4OpenGLImmediateQtViewer* v = dynamic_cast<G4OpenGLImmediateQtViewer*>(viewer);
#endif
if (v) {
fVboViewer = v;
}
@@ -74,38 +65,6 @@ fOGLType(type)
"}\n";
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVertexShaderSrc =
"attribute vec3 aVertexPosition;\n"
"attribute vec3 aVertexNormal;\n"
"\n"
"uniform mat4 uMVMatrix; // [M]odel[V]iew matrix\n"
"uniform mat4 uCMatrix; // Client-side manipulated [C]amera matrix\n"
"uniform mat4 uPMatrix; // Perspective [P]rojection matrix\n"
"uniform mat4 uNMatrix; // [N]ormal transformation\n"
"// uNMatrix is the transpose of the inverse of uCMatrix * uMVMatrix\n"
"uniform mat4 uTMatrix; // [T]ransformation matrix\n"
"uniform float uPointSize; // Point size\n"
"\n"
"varying vec3 vLightWeighting;\n"
"\n"
"void main(void) {\n"
" // Calculate the position of this vertex\n"
" gl_Position = uPMatrix * uCMatrix * uMVMatrix * uTMatrix * vec4(aVertexPosition, 1.0);\n"
"\n"
" // Phong shading\n"
" vec3 transformedNormal = normalize((uNMatrix * vec4(normalize(aVertexNormal), 0)).xyz);\n"
" vec3 lightingDirection = normalize(vec3(1, 1, 1));\n"
" float directionalLightWeighting = max(dot(transformedNormal, lightingDirection), 0.0);\n"
" vec3 uAmbientLightColor = vec3(0.2, 0.2, 0.2);\n"
" vec3 uDirectionalColor = vec3(0.8, 0.8, 0.8);\n"
" gl_PointSize = uPointSize;\n"
" vLightWeighting = uAmbientLightColor + uDirectionalColor * directionalLightWeighting;\n"
"}\n";
#else
fVertexShaderSrc =
"attribute highp vec4 aVertexPosition;\n"
"attribute vec3 aVertexNormal;\n"
@@ -126,9 +85,6 @@ fOGLType(type)
" gl_PointSize = uPointSize;\n"
// " vLightWeighting = uAmbientLightColor + uDirectionalColor * directionalLightWeighting;\n"
"}";
#endif
}
//////////////////////////////////////////////////////////////////////////////
@@ -138,338 +94,6 @@ G4OpenGLVboDrawer::~G4OpenGLVboDrawer (
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
}
// +--------------------------------+
// + WT (OpenGL ES) case +
// +--------------------------------+
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
void G4OpenGLVboDrawer:: vboGlClear(Wt::WFlags< GLenum > mask) {
if (fVboViewer->isInitialized()) {
fVboViewer->clear(mask);
}
}
void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WMatrix4x4 &m) {
if (fVboViewer) {
vboGlUseProgram(fVboViewer->getShaderProgram());
fVboViewer->uniformMatrix4(location, m);
}
}
void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const double* matrix) {
if (fVboViewer) {
Wt::WMatrix4x4 mat(
(double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
(double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
(double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
(double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
fVboViewer->uniformMatrix4(location, mat);
}
}
void G4OpenGLVboDrawer:: vboGlUniformMatrix4fv(const Wt::WGLWidget::UniformLocation &location, const float* matrix) {
if (fVboViewer) {
Wt::WMatrix4x4 mat(
(double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
(double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
(double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
(double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
fVboViewer->uniformMatrix4(location, mat);
}
}
void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WGLWidget::JavaScriptMatrix4x4 &m) {
if (fVboViewer->isInitialized()) {
fVboViewer->uniformMatrix4(location, m);
}
}
Wt::WGLWidget::Buffer G4OpenGLVboDrawer:: vboGlCreateBuffer(){
if (fVboViewer) {
return fVboViewer->createBuffer();
}
return Wt::WGLWidget::Buffer();
}
void G4OpenGLVboDrawer:: vboGlBindBuffer(GLenum target, Wt::WGLWidget::Buffer buffer){
if (fVboViewer) {
fVboViewer->bindBuffer(target,buffer);
}
}
void G4OpenGLVboDrawer:: vboGlDeleteBuffer(Wt::WGLWidget::Buffer buffer){
if (fVboViewer == NULL) return;
fVboViewer->deleteBuffer(buffer);
}
void G4OpenGLVboDrawer:: vboGlVertexAttribPointer(Wt::WGLWidget::AttribLocation location, int size, GLenum type, bool normalized, unsigned stride, unsigned offset){
if (fVboViewer->isInitialized()) {
fVboViewer->vertexAttribPointer(location, size,type, normalized, stride, offset);
}
}
Wt::WGLWidget::Program G4OpenGLVboDrawer:: vboGlCreateProgram(){
if (fVboViewer) {
return fVboViewer->createProgram();
}
return Wt::WGLWidget::Program();
}
void G4OpenGLVboDrawer:: vboGlAttachShader(Wt::WGLWidget::Program program, Shader shader){
if (fVboViewer) {
fVboViewer->attachShader(program,shader);
}
}
void G4OpenGLVboDrawer:: vboGlLinkProgram(Wt::WGLWidget::Program program){
if (fVboViewer) {
fVboViewer->linkProgram(program);
}
}
void G4OpenGLVboDrawer:: vboGlUseProgram(Wt::WGLWidget::Program program){
if (fVboViewer) {
fVboViewer->useProgram(program);
}
}
void G4OpenGLVboDrawer:: vboGlEnableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
if (fVboViewer) {
fVboViewer->enableVertexAttribArray(pointer);
}
}
void G4OpenGLVboDrawer:: vboGlDisableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
if (fVboViewer) {
fVboViewer->disableVertexAttribArray(pointer);
}
}
Wt::WGLWidget::UniformLocation G4OpenGLVboDrawer:: vboGlGetUniformLocation(Wt::WGLWidget::Program programm,const std::string &src){
if (fVboViewer) {
return fVboViewer->getUniformLocation(programm, src);
}
return Wt::WGLWidget::UniformLocation();
}
Wt::WGLWidget::AttribLocation G4OpenGLVboDrawer:: vboGlGetAttribLocation(Wt::WGLWidget::Program shader,const std::string &src){
if (fVboViewer) {
return fVboViewer->getAttribLocation(shader, src);
}
return Wt::WGLWidget::AttribLocation();
}
void G4OpenGLVboDrawer::vboGlClearColor (double r, double g, double b, double a) {
if (fVboViewer->isInitialized() ) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->clearColor(r,g,b,a);
#else
#endif
}
}
void G4OpenGLVboDrawer::vboGlClearDepth(double depth) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->clearDepth(depth);
#else
glClearDepth(depth);
#endif
}
}
void G4OpenGLVboDrawer::vboGlFlush() {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->flush();
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlViewport(int x, int y, unsigned width, unsigned height) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->viewport(x,y,width,height);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlEnable(GLenum cap) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
if (cap != Wt::WGLWidget::NONE) {
fVboViewer->enable(cap);
}
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlDisable(GLenum cap) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
if (cap != Wt::WGLWidget::NONE) {
fVboViewer->disable(cap);
}
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlBlendFunc (GLenum sfactor, GLenum dfactor) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->blendFunc(sfactor, dfactor);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlDepthFunc (GLenum func) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->depthFunc(func);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlDepthMask(bool flag) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->depthMask(flag);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlColorMask (bool red, bool green, bool blue, bool alpha) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->colorMask(red,green,blue,alpha);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlLineWidth(double width) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->lineWidth(width);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlDrawArrays(GLenum mode, int first, unsigned count){
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->drawArrays(mode,first, count);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlDrawElements(GLenum mode, unsigned count, GLenum type, unsigned offset){
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
fVboViewer->drawElements(mode,count,type,offset);
#else
#endif
}
}
void G4OpenGLVboDrawer:: vboGlBufferDatafv(GLenum target, const std::vector<double>::iterator begin, const std::vector<double>::iterator end, GLenum usage){
if (fVboViewer) {
if (fVboViewer->isInitialized()) {
fVboViewer->bufferDatafv(target,begin,end,usage);
}
}
}
void G4OpenGLVboDrawer:: vboGlBufferDataiv(GLenum target, const std::vector<unsigned short>::iterator begin, const std::vector<unsigned short>::iterator end, GLenum usage, GLenum type){
if (fVboViewer) {
if (fVboViewer->isInitialized()) {
fVboViewer->bufferDataiv(target,begin,end,usage,type);
}
}
}
void G4OpenGLVboDrawer:: vboGlMultMatrixd(const GLdouble *matrix){
if (fVboViewer) {
if (fVboViewer->isInitialized()) {
Wt::WMatrix4x4 mat(
(double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
(double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
(double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
(double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
// FIXME !
fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
if (fMatrixMode == GL_MODELVIEW) {
// fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
} else {
G4cerr << "glMultMatrixd could only be used in GL_MODELVIEW mode" << G4endl;
}
}
}
}
void G4OpenGLVboDrawer:: vboGlMultMatrixf(const GLfloat *matrix){
if (fVboViewer) {
if (fVboViewer->isInitialized()) {
Wt::WMatrix4x4 mat(
matrix[0], matrix[4], matrix[8], matrix[12],
matrix[1], matrix[5], matrix[9], matrix[13],
matrix[2], matrix[6], matrix[10], matrix[14],
matrix[3], matrix[7], matrix[11], matrix[15]);
if (fMatrixMode == GL_MODELVIEW) {
fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
} else {
G4cerr << "glMultMatrixf could only be used in GL_MODELVIEW mode" << G4endl;
}
}
}
}
void G4OpenGLVboDrawer:: vboGlShaderSource(Shader shader, GLsizei , const GLchar **src, const GLint *){
if (fVboViewer) {
std::string s = *src;
fVboViewer->shaderSource(shader, s);
}
}
void G4OpenGLVboDrawer:: vboGlCompileShader(Shader shader){
if (fVboViewer) {
fVboViewer->compileShader(shader);
}
}
Shader G4OpenGLVboDrawer:: vboGlCreateShader(GLenum shader){
if (fVboViewer) {
return fVboViewer->createShader(shader);
}
return Shader();
}
#else
// +--------------------------------+
// + QT (OpenGL ES) case +
@@ -518,7 +142,6 @@ void G4OpenGLVboDrawer:: vboGlMultMatrixd(const GLdouble *matrix){
#endif
// +--------------------------------+
// + All case +
// +--------------------------------+
@@ -548,11 +171,7 @@ void G4OpenGLVboDrawer::vboGlOrtho(GLdouble left, GLdouble right, GLdouble botto
// Error: GL_INVALID_OPERATION
if (fMatrixMode == GL_PROJECTION) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
vboGlUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), ortho);
#else
glUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), 1, 0, ortho);
#endif
} else {
G4cerr << "glFrustum could only be used in GL_PROJECTION mode" << G4endl;
}
@@ -583,11 +202,7 @@ void G4OpenGLVboDrawer::vboGlFrustum(GLdouble left, GLdouble right, GLdouble bot
};
if (fMatrixMode == GL_PROJECTION) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
vboGlUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), proj);
#else
glUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), 1, 0, proj);
#endif
} else {
G4cerr << "glFrustrum could only be used in GL_PROJECTION mode" << G4endl;
}
@@ -611,13 +226,8 @@ void G4OpenGLVboDrawer::vboGlColor4d(int red,int green,int blue,int alpha) {
if (fVboViewer->isInitialized()) {
// double color [] = { red, green, blue, alpha };
// FIXME : REMOVE /2 , used to render transparents for testing purpose
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
double color [] = { red, green, blue, 0.7 };
glUniform4fv (fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color);
#else
alpha = 0.7;
glUniform4f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),red, green, blue, alpha);
#endif
}
}
}
@@ -627,11 +237,7 @@ void G4OpenGLVboDrawer:: vboGlColor4fv(const GLfloat* data) {
if (fVboViewer->isInitialized()) {
double color [] = { (data[0]), (data[1]), (data[2]), 0.7};
// FIXME : REMOVE /2 , used to render transparents for testing purpose
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
glUniform4fv (fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color);
#else
glUniform4f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color[0],color[1],color[2], color[3]);
#endif
}
}
}
@@ -639,11 +245,7 @@ void G4OpenGLVboDrawer:: vboGlColor4fv(const GLfloat* data) {
void G4OpenGLVboDrawer:: vboGlPointSize(float size) {
if (fVboViewer) {
if (fVboViewer->isInitialized()) {
#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
glUniform1f(fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointSize"),size);
#else
glUniform1f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointSize"),size);
#endif
}
}
}
@@ -50,7 +50,6 @@
#include "G4Text.hh"
#ifdef G4OPENGL_VERSION_2
// We need to have a Wt gl drawer because we will draw inside the WtGL component (ImmediateWtViewer)
#include "G4OpenGLVboDrawer.hh"
#endif
@@ -129,90 +129,6 @@ G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/");
fpDirectorySet->SetGuidance("G4OpenGLViewer set commands.");
G4UIparameter* parameter;
fpCommandDisplayHeadTime =
new G4UIcommand("/vis/ogl/set/displayHeadTime", this);
fpCommandDisplayHeadTime->SetGuidance
("DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
"\n Display head time of range in 2D text.");
parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
parameter->SetDefaultValue(false);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("screenX", 'd', omitable = true);
parameter->SetGuidance("-1 < screenX < 1");
parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
parameter->SetDefaultValue(-0.9);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("screenY", 'd', omitable = true);
parameter->SetGuidance("-1 < screenY < 1");
parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
parameter->SetDefaultValue(-0.9);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
parameter->SetDefaultValue(24.);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("red", 'd', omitable = true);
parameter->SetParameterRange("red >= 0. && red <= 1.");
parameter->SetDefaultValue(0.);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("green", 'd', omitable = true);
parameter->SetParameterRange("green >= 0. && green <= 1.");
parameter->SetDefaultValue(1.);
fpCommandDisplayHeadTime->SetParameter(parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter->SetParameterRange("blue >= 0. && blue <= 1.");
parameter->SetDefaultValue(1.);
fpCommandDisplayHeadTime->SetParameter(parameter);
fpCommandDisplayLightFront =
new G4UIcommand("/vis/ogl/set/displayLightFront", this);
fpCommandDisplayLightFront->SetGuidance
("DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
"\n Display the light front at head time.");
fpCommandDisplayLightFront->SetGuidance
("Tip: The trajectories can appear of jump ahead of the light front"
"\nbecause their time range overlaps the viewer's time range. To"
"\naverage out this discrete time effect, advance the light front by"
"\nhalf the trajectories interval. E.g., if the trajectory time slice"
"\ninterval is 0.01 ns:"
"\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns"
"\nTo prevent them beating the light front at all:"
"\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns");
parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
parameter->SetDefaultValue(false);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("originX", 'd', omitable = true);
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("originY", 'd', omitable = true);
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("originZ", 'd', omitable = true);
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("space_unit", 's', omitable = true);
parameter->SetDefaultValue("m");
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("originT", 'd', omitable = true);
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("time_unit", 's', omitable = true);
parameter->SetDefaultValue("s");
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("red", 'd', omitable = true);
parameter->SetParameterRange("red >= 0. && red <= 1.");
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("green", 'd', omitable = true);
parameter->SetParameterRange("green >= 0. && green <= 1.");
parameter->SetDefaultValue(1.);
fpCommandDisplayLightFront->SetParameter(parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter->SetParameterRange("blue >= 0. && blue <= 1.");
parameter->SetDefaultValue(0.);
fpCommandDisplayLightFront->SetParameter(parameter);
fpCommandDisplayListLimit =
new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this);
fpCommandDisplayListLimit->SetGuidance
@@ -221,33 +137,6 @@ G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
fpCommandDisplayListLimit->SetDefaultValue(50000);
fpCommandDisplayListLimit->SetRange("limit>=10000");
fpCommandEndTime =
new G4UIcommand("/vis/ogl/set/endTime", this);
fpCommandEndTime->SetGuidance
("DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
"\n Set end and range of time window.");
parameter = new G4UIparameter ("end-time", 'd', omitable = false);
parameter->SetDefaultValue(G4VisAttributes::fVeryLongTime);
fpCommandEndTime->SetParameter(parameter);
parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
parameter->SetDefaultValue("ns");
fpCommandEndTime->SetParameter(parameter);
parameter = new G4UIparameter ("time-range", 'd', omitable = true);
parameter->SetDefaultValue(-1.);
fpCommandEndTime->SetParameter(parameter);
parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
parameter->SetDefaultValue("ns");
fpCommandEndTime->SetParameter(parameter);
fpCommandEventsDrawInterval =
new G4UIcmdWithAnInteger("/vis/ogl/set/eventsDrawInterval", this);
fpCommandEventsDrawInterval->SetGuidance
("Deprecated. Use /vis/ogl/flushAt.");
fpCommandEventsDrawInterval->SetGuidance
("(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\"");
fpCommandEventsDrawInterval->SetParameterName("N", omitable = true);
fpCommandEventsDrawInterval->SetDefaultValue(1);
fpCommandExportFormat =
new G4UIcommand("/vis/ogl/set/exportFormat", this);
fpCommandExportFormat->SetGuidance ("Set export format");
@@ -259,14 +148,6 @@ G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
parameterExportFormat->SetDefaultValue("");
fpCommandExportFormat->SetParameter(parameterExportFormat);
fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this);
fpCommandFade->SetGuidance
("DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
"\n 0: no fade; 1: maximum fade with time within range.");
fpCommandFade->SetParameterName("fadefactor", omitable = false);
fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1.");
fpCommandFade->SetDefaultValue(0.);
fpCommandPrintFilename =
new G4UIcommand("/vis/ogl/set/printFilename", this);
fpCommandPrintFilename->SetGuidance ("Set print filename");
@@ -298,24 +179,6 @@ G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
parameterPrintSize->SetDefaultValue(-1);
fpCommandPrintSize->SetParameter(parameterPrintSize);
fpCommandStartTime =
new G4UIcommand("/vis/ogl/set/startTime", this);
fpCommandStartTime->SetGuidance
("DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
"\n Set start and range of time window.");
parameter = new G4UIparameter ("start-time", 'd', omitable = false);
parameter->SetDefaultValue(-G4VisAttributes::fVeryLongTime);
fpCommandStartTime->SetParameter(parameter);
parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
parameter->SetDefaultValue("ns");
fpCommandStartTime->SetParameter(parameter);
parameter = new G4UIparameter ("time-range", 'd', omitable = true);
parameter->SetDefaultValue(-1.);
fpCommandStartTime->SetParameter(parameter);
parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
parameter->SetDefaultValue("ns");
fpCommandStartTime->SetParameter(parameter);
fpCommandTransparency =
new G4UIcmdWithABool("/vis/ogl/set/transparency", this);
fpCommandTransparency->SetGuidance
@@ -328,17 +191,11 @@ G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
G4OpenGLViewerMessenger::~G4OpenGLViewerMessenger ()
{
delete fpCommandTransparency;
delete fpCommandStartTime;
delete fpCommandPrintSize;
delete fpCommandPrintMode;
delete fpCommandPrintFilename;
delete fpCommandFade;
delete fpCommandExportFormat;
delete fpCommandEventsDrawInterval;
delete fpCommandEndTime;
delete fpCommandDisplayListLimit;
delete fpCommandDisplayLightFront;
delete fpCommandDisplayHeadTime;
delete fpDirectorySet;
delete fpCommandPrintEPS;
delete fpCommandFlushAt;
@@ -420,15 +277,6 @@ void G4OpenGLViewerMessenger::SetNewValue
return;
}
if (command == fpCommandEventsDrawInterval)
{
G4int entitiesFlushInterval =
fpCommandEventsDrawInterval->GetNewIntValue(newValue);
pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive);
pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval);
return;
}
if (command == fpCommandFlushAt)
{
static G4bool firstTime = true;
@@ -513,112 +361,6 @@ void G4OpenGLViewerMessenger::SetNewValue
return;
}
if (command == fpCommandDisplayHeadTime)
{
G4String display;
G4double screenX, screenY, screenSize, red, green, blue;
std::istringstream iss(newValue);
iss >> display >> screenX >> screenY
>> screenSize >> red >> green >> blue;
pOGLSViewer->fVP.SetDisplayHeadTime(command->ConvertToBool(display));
pOGLSViewer->fVP.SetDisplayHeadTimeX(screenX);
pOGLSViewer->fVP.SetDisplayHeadTimeY(screenY);
pOGLSViewer->fVP.SetDisplayHeadTimeSize(screenSize);
pOGLSViewer->fVP.SetDisplayHeadTimeRed(red);
pOGLSViewer->fVP.SetDisplayHeadTimeGreen(green);
pOGLSViewer->fVP.SetDisplayHeadTimeBlue(blue);
G4cout
<< "DEPRECATED. Use /vis/viewer/set/timeWindow/displayHeadTime."
<< G4endl;
return;
}
if (command == fpCommandDisplayLightFront)
{
G4String display, originX, originY, originZ, unitS, originT, unitT;
G4double red, green, blue;
std::istringstream iss(newValue);
iss >> display
>> originX >> originY >> originZ >> unitS
>> originT >> unitT
>> red >> green >> blue;
pOGLSViewer->fVP.SetDisplayLightFront(command->ConvertToBool(display));
pOGLSViewer->fVP.SetDisplayLightFrontX
(command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)));
pOGLSViewer->fVP.SetDisplayLightFrontY
(command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)));
pOGLSViewer->fVP.SetDisplayLightFrontZ
(command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)));
pOGLSViewer->fVP.SetDisplayLightFrontT
(command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)));
pOGLSViewer->fVP.SetDisplayLightFrontRed(red);
pOGLSViewer->fVP.SetDisplayLightFrontGreen(green);
pOGLSViewer->fVP.SetDisplayLightFrontBlue(blue);
G4cout
<< "DEPRECATED. Use /vis/viewer/set/timeWindow/displayLightFront."
<< G4endl;
return;
}
if (command == fpCommandEndTime)
{
G4String end_time_string, end_time_unit,
time_range_string, time_range_unit;
std::istringstream iss(newValue);
iss >> end_time_string >> end_time_unit
>> time_range_string >> time_range_unit;
pOGLSViewer->fVP.SetEndTime
(command->ConvertToDimensionedDouble
(G4String(end_time_string + ' ' + end_time_unit)));
G4double timeRange = command->ConvertToDimensionedDouble
(G4String(time_range_string + ' ' + time_range_unit));
if (timeRange > 0.) {
pOGLSViewer->fVP.SetStartTime
(pOGLSViewer->fVP.GetEndTime() - timeRange);
}
if (pOGLSViewer->fVP.IsAutoRefresh())
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
G4cout
<< "DEPRECATED. Use /vis/viewer/set/timeWindow/endTime."
<< G4endl;
return;
}
if (command == fpCommandFade)
{
pOGLSViewer->fVP.SetFadeFactor(command->ConvertToDouble(newValue));
if (pOGLSViewer->fVP.IsAutoRefresh())
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
G4cout
<< "DEPRECATED. Use /vis/viewer/set/timeWindow/fadeFactor."
<< G4endl;
return;
}
if (command == fpCommandStartTime)
{
G4String start_time_string, start_time_unit,
time_range_string, time_range_unit;
std::istringstream iss(newValue);
iss >> start_time_string >> start_time_unit
>> time_range_string >> time_range_unit;
pOGLSViewer->fVP.SetStartTime
(command->ConvertToDimensionedDouble
(G4String(start_time_string + ' ' + start_time_unit)));
G4double timeRange = command->ConvertToDimensionedDouble
(G4String(time_range_string + ' ' + time_range_unit));
if (timeRange > 0.) {
pOGLSViewer->fVP.SetEndTime
(pOGLSViewer->fVP.GetStartTime() + timeRange);
}
if (pOGLSViewer->fVP.IsAutoRefresh())
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
G4cout
<< "DEPRECATED. Use /vis/viewer/set/timeWindow/startTime."
<< G4endl;
return;
}
// Scene handler commands
G4OpenGLStoredSceneHandler* pOGLSSceneHandler =
dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler());
@@ -22,12 +22,9 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4OpenGLWin32Viewer : Class to provide WindowsNT specific
// functionality for OpenGL in GEANT4
// G4OpenGLWin32Viewer : Class to provide Windows specific
// functionality for OpenGL
//
// 27/06/2003 : G.Barrand : implementation (at last !).
@@ -37,6 +34,7 @@
#include "G4VViewer.hh"
#include "G4VSceneHandler.hh"
#include "G4OpenGLSceneHandler.hh"
#include "G4Scene.hh"
#include "G4ios.hh"
#include "G4VisExtent.hh"
@@ -45,6 +43,7 @@
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
#include "G4SystemOfUnits.hh"
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::SetView (
@@ -100,7 +99,7 @@ void G4OpenGLWin32Viewer::CreateMainWindow (
// Bill Gates stuff...
static const char className[] = "G4OpenGLWin32";
static bool done = false;
static G4bool done = false;
if(done==false) {
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
@@ -119,11 +118,11 @@ void G4OpenGLWin32Viewer::CreateMainWindow (
ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
int x_res=GetSystemMetrics(SM_CXSCREEN);
int y_res=GetSystemMetrics(SM_CYSCREEN);
G4int x_res=GetSystemMetrics(SM_CXSCREEN);
G4int y_res=GetSystemMetrics(SM_CYSCREEN);
//FIXME : NOT tested !
fWindow = ::CreateWindow(className,fName.c_str(),
fWindow = ::CreateWindowEx(0, className,fName.c_str(),
WS_OVERLAPPEDWINDOW,
//WS_CHILD | WS_VISIBLE,
// 0,0,
@@ -147,10 +146,17 @@ void G4OpenGLWin32Viewer::CreateMainWindow (
::wglMakeCurrent(fHDC,fHGLRC);
}
//G.Barrand : avoid to indirectly pass in
// WindowProc/[WM_SIZE,WM_PAINT]/This->DrawView()
// from this method. Else we have crash.
fInCreateWindow = true;
::SetForegroundWindow(fWindow);
::ShowWindow(fWindow,SW_SHOWDEFAULT);
::UpdateWindow(fWindow);
::DrawMenuBar(fWindow);
fInCreateWindow = false;
}
//////////////////////////////////////////////////////////////////////////////
@@ -159,9 +165,14 @@ G4OpenGLWin32Viewer::G4OpenGLWin32Viewer (
)
:G4VViewer (scene, -1)
,G4OpenGLViewer (scene)
,fWindow(0)
,fMouseHovered(false)
,fMousePressed(false)
,fMousePressedX(0)
,fMousePressedY(0)
,fHDC(0)
,fWindow(0)
,fHGLRC(0)
,fInCreateWindow(false)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
@@ -190,50 +201,154 @@ G4OpenGLWin32Viewer::~G4OpenGLWin32Viewer (
}
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc (
HWND aWindow
,UINT aMessage
LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc(
HWND aWindow
,UINT aMessage
,WPARAM aWParam
,LPARAM aLParam
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
/*
switch (aMessage) {
case WM_PAINT:{
printf("debug : PAINT\n");
HDC hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(aWindow,&ps);
if(This) {
// FIXME : To have an automatic refresh someone have to redraw here.
switch (aMessage) {
case WM_SIZE: {
//FIXME : have to handle WM_RESIZE
// Seems to be done (ovidio.pena AT upm.es, 2021/02/23)
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
if (This) {
This->fWinSize_x = (G4int) LOWORD(aLParam);
This->fWinSize_y = (G4int) HIWORD(aLParam);
if (!This->fInCreateWindow) {
This->SetView();
glViewport(0, 0, This->fWinSize_x, This->fWinSize_y);
This->DrawView();
}
}
return 0;
}
EndPaint(aWindow, &ps);
//FIXME : have to handle WM_RESIZE
//pView->fWinSize_x = (G4int) width;
//pView->fWinSize_y = (G4int) height;
G4OpenGLWin32Viewer* This =
(G4OpenGLWin32Viewer*)::GetWindowLong(aWindow,GWL_USERDATA);
if(This) {
case WM_PAINT: {
PAINTSTRUCT ps;
BeginPaint(aWindow, &ps);
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
if (This) {
//FIXME : To have an automatic refresh someone have to redraw here.
// Seems to be done (ovidio.pena AT upm.es, 2021/02/23)
if(!This->fInCreateWindow) {
This->SetView();
This->ClearView();
This->DrawView();
}
}
EndPaint(aWindow, &ps);
return 0;
}
case WM_LBUTTONDOWN: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->TrackMouse(LOWORD(aLParam), HIWORD(aLParam));
return 0;
}
case WM_RBUTTONDOWN: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->TrackMouse(LOWORD(aLParam), HIWORD(aLParam));
return 0;
}
case WM_LBUTTONUP: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->ReleaseMouse();
return 0;
}
case WM_RBUTTONUP: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->ReleaseMouse();
return 0;
}
case WM_MOUSEHOVER: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->fMouseHovered = true;
return 0;
}
case WM_MOUSELEAVE: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
This->fMouseHovered = false;
return 0;
}
case WM_MOUSEMOVE: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
if (!This->fMouseHovered) {
// mouse hover/leave tracking
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = aWindow;
tme.dwHoverTime = HOVER_DEFAULT;
::TrackMouseEvent(&tme);
This->fMouseHovered = true;
}
if (This->fMousePressed) {
G4int x = (G4int) LOWORD(aLParam);
G4int y = (G4int) HIWORD(aLParam);
G4int dx = x - This->fMousePressedX;
G4int dy = y - This->fMousePressedY;
This->fMousePressedX = x;
This->fMousePressedY = y;
if (aWParam == MK_LBUTTON) { // Rotation
This->SetRotation(dx, dy);
}
if (aWParam == MK_RBUTTON) { // Shift
This->SetShift(dx, dy);
}
This->SetView();
This->ClearView();
This->DrawView();
}
return 0;
}
case WM_MOUSEWHEEL: {
auto* This = (G4OpenGLWin32Viewer*)
::GetWindowLongPtr(aWindow, GWLP_USERDATA);
G4int delta = (short) HIWORD(aWParam);
This->SetZoom(delta);
This->SetView();
glViewport(0,0,This->fWinSize_x,This->fWinSize_y);
This->ClearView();
This->DrawView();
// WARNING : the below empty the Windows message queue...
This->FinishView();
return 0;
}
} return 0;
default:
return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
default:
return DefWindowProc(aWindow, aMessage, aWParam, aLParam);
}
*/
return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
// return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
}
//////////////////////////////////////////////////////////////////////////////
bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
G4bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
HDC aHdc
)
//////////////////////////////////////////////////////////////////////////////
@@ -273,7 +388,7 @@ bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
pfd.dwVisibleMask = 0;
pfd.dwDamageMask = 0;
int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd);
G4int pixelIndex = ::ChoosePixelFormat(aHdc,&pfd);
if (pixelIndex==0) {
pixelIndex = 1;
if (::DescribePixelFormat(aHdc,
@@ -287,5 +402,86 @@ bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
return true;
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::TrackMouse(
G4int x
,G4int y
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
fMousePressed = true;
fMousePressedX = x;
fMousePressedY = y;
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::ReleaseMouse(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
fMousePressed = false;
fMousePressedX = 0;
fMousePressedY = 0;
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::SetShift(
G4int dx
,G4int dy
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
const G4double sceneRadius = GetSceneHandler()->GetScene()
->GetExtent().GetExtentRadius();
const G4double scale = 300; // Roughly pixels per window, empirically chosen
const G4double dxScene = dx*sceneRadius/scale;
const G4double dyScene = dy*sceneRadius/scale;
fVP.IncrementPan(-dxScene,dyScene);
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::SetRotation(
G4int dx
,G4int dy
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
// Simple ad-hoc algorithms (borrowed from G4Qt3DViewer)
const G4Vector3D& x_prime = fVP.GetViewpointDirection()
.cross(fVP.GetUpVector());
const G4Vector3D& y_prime = x_prime.cross(fVP.GetViewpointDirection());
const G4double scale = 200; // Roughly pixels per window, empirically chosen
G4Vector3D newViewpointDirection = fVP.GetViewpointDirection();
newViewpointDirection += dx*x_prime/scale;
newViewpointDirection += dy*y_prime/scale;
fVP.SetViewpointDirection(newViewpointDirection.unit());
if (fVP.GetRotationStyle() == G4ViewParameters::freeRotation) {
G4Vector3D newUpVector = fVP.GetUpVector();
newUpVector += dx*x_prime/scale;
newUpVector += dy*y_prime/scale;
fVP.SetUpVector(newUpVector.unit());
}
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::SetZoom(
G4int delta
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1. + delta/scale);
} else { // Perspective projection
const G4double scale = fVP.GetFieldHalfAngle()/(10.*deg); // Empirical
fVP.SetDolly(fVP.GetDolly() + delta/scale);
}
}
#endif
File diff suppressed because it is too large Load Diff
@@ -98,8 +98,3 @@ G4String G4VisFeaturesOfOpenGLSQt () {
return
"\n It runs everywhere ";
}
G4String G4VisFeaturesOfOpenGLIWt () {
return
"\n It runs everywhere";
}