Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4OpenGLViewer.cc 97315 2016-06-01 12:12:25Z gcosmo $
// $Id: G4OpenGLViewer.cc 101714 2016-11-22 08:53:13Z gcosmo $
//
//
// Andrew Walkden 27th March 1996
@@ -196,9 +196,12 @@ void G4OpenGLViewer::InitializeGLView ()
}
#endif
fWinSize_x = fVP.GetWindowSizeHintX();
fWinSize_y = fVP.GetWindowSizeHintY();
if (fWinSize_x == 0) {
fWinSize_x = fVP.GetWindowSizeHintX();
}
if (fWinSize_y == 0) {
fWinSize_y = fVP.GetWindowSizeHintY();
}
glClearColor (0.0, 0.0, 0.0, 0.0);
glClearDepth (1.0);
@@ -221,6 +224,11 @@ void G4OpenGLViewer::InitializeGLView ()
void G4OpenGLViewer::ClearView () {
ClearViewWithoutFlush();
if(!isFramebufferReady()) {
return;
}
glFlush();
}
@@ -228,11 +236,9 @@ void G4OpenGLViewer::ClearView () {
void G4OpenGLViewer::ClearViewWithoutFlush () {
// Ready for clear ?
// See : http://lists.apple.com/archives/mac-opengl/2012/Jul/msg00038.html
#if GL_EXT_framebuffer_object
// if ( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNDEFINED) {
// return;
// }
#endif
if(!isFramebufferReady()) {
return;
}
glClearColor (background.GetRed(),
background.GetGreen(),
@@ -377,31 +383,30 @@ void G4OpenGLViewer::SetView () {
// Light position is "true" light direction, so must come after gluLookAt.
glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
// OpenGL no longer seems to reconstruct clipped edges, so, when the
// BooleanProcessor is up to it, abandon this and use generic
// clipping in G4OpenGLSceneHandler::CreateSectionPolyhedron. Also,
// force kernel visit on change of clipping plane in
// G4OpenGLStoredViewer::CompareForKernelVisit.
//if (fVP.IsSection () ) { // pair of back to back clip planes.
if (false) { // pair of back to back clip planes.
const G4Plane3D& sp = fVP.GetSectionPlane ();
double sArray[4];
sArray[0] = sp.a();
sArray[1] = sp.b();
sArray[2] = sp.c();
sArray[3] = sp.d() + radius * 1.e-05;
glClipPlane (GL_CLIP_PLANE0, sArray);
glEnable (GL_CLIP_PLANE0);
sArray[0] = -sp.a();
sArray[1] = -sp.b();
sArray[2] = -sp.c();
sArray[3] = -sp.d() + radius * 1.e-05;
glClipPlane (GL_CLIP_PLANE1, sArray);
glEnable (GL_CLIP_PLANE1);
} else {
glDisable (GL_CLIP_PLANE0);
glDisable (GL_CLIP_PLANE1);
}
// The idea is to use back-to-back clipping planes. This can cut an object
// down to just a few pixels, which can make it difficult to see. So, for
// now, comment this out and use the generic (Boolean) method, via
// G4VSolid* G4OpenGLSceneHandler::CreateSectionSolid ()
// { return G4VSceneHandler::CreateSectionSolid(); }
// if (fVP.IsSection () ) { // pair of back to back clip planes.
// const G4Plane3D& sp = fVP.GetSectionPlane ();
// double sArray[4];
// sArray[0] = sp.a();
// sArray[1] = sp.b();
// sArray[2] = sp.c();
// sArray[3] = sp.d() + radius * 1.e-05;
// glClipPlane (GL_CLIP_PLANE0, sArray);
// glEnable (GL_CLIP_PLANE0);
// sArray[0] = -sp.a();
// sArray[1] = -sp.b();
// sArray[2] = -sp.c();
// sArray[3] = -sp.d() + radius * 1.e-05;
// glClipPlane (GL_CLIP_PLANE1, sArray);
// glEnable (GL_CLIP_PLANE1);
// } else {
// glDisable (GL_CLIP_PLANE0);
// glDisable (GL_CLIP_PLANE1);
// }
// What we call intersection of cutaways is easy in OpenGL. You
// just keep cutting. Unions are more tricky - you have to have
@@ -756,6 +761,32 @@ bool G4OpenGLViewer::isGl2psWriting() {
}
G4bool G4OpenGLViewer::isFramebufferReady() {
bool check = false;
#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
check = true;
#endif
#ifdef G4VIS_BUILD_OPENGLX_DRIVER
check = false;
#endif
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
check = false;
#endif
#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
check = false;
#endif
#if GL_ARB_framebuffer_object
if (check) {
// if ( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNDEFINED) {
// return false;
// }
}
#endif
return true;
}
/* Draw Gl2Ps text if needed
*/
void G4OpenGLViewer::DrawText(const G4Text& g4text)
@@ -861,8 +892,8 @@ bool G4OpenGLViewer::printGl2PS() {
// no need to redraw at each new primitive for printgl2PS
G4OpenGLSceneHandler& oglSceneHandler = dynamic_cast<G4OpenGLSceneHandler&>(fSceneHandler);
G4int drawInterval = oglSceneHandler.GetEventsDrawInterval();
oglSceneHandler.SetEventsDrawInterval(1000); // some big value but not too big to not crash memory
G4OpenGLSceneHandler::FlushAction originalFlushAction = oglSceneHandler.GetFlushAction();
oglSceneHandler.SetFlushAction(G4OpenGLSceneHandler::never);
if (!fGL2PSAction) return false;
@@ -931,7 +962,7 @@ bool G4OpenGLViewer::printGl2PS() {
fWinSize_x = X;
fWinSize_y = Y;
oglSceneHandler.SetEventsDrawInterval(drawInterval);
oglSceneHandler.SetFlushAction(originalFlushAction);
// Reset for next time (useful is size change)
// fPrintSizeX = 0;
@@ -1291,9 +1322,9 @@ bool G4OpenGLViewer::setExportImageFormat(std::string format, bool quiet) {
void G4OpenGLViewer::g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
GLint viewport[4])
{
GLfloat mat[16];
GLfloat sx, sy;
GLfloat tx, ty;
GLdouble mat[16];
GLdouble sx, sy;
GLdouble tx, ty;
sx = viewport[2] / width;
sy = viewport[3] / height;
@@ -1319,7 +1350,7 @@ void G4OpenGLViewer::g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLd
M(3, 3) = 1.0;
#undef M
glMultMatrixf(mat);
glMultMatrixd(mat);
}
@@ -1335,9 +1366,9 @@ void G4OpenGLViewer::g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
centerz,
GLdouble upx, GLdouble upy, GLdouble upz )
{
GLfloat mat[16];
GLfloat x[3], y[3], z[3];
GLfloat mag;
GLdouble mat[16];
GLdouble x[3], y[3], z[3];
GLdouble mag;
/* Make rotation matrix */
@@ -1404,10 +1435,10 @@ void G4OpenGLViewer::g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
M(3, 2) = 0.0;
M(3, 3) = 1.0;
#undef M
glMultMatrixf(mat);
glMultMatrixd(mat);
/* Translate Eye to Origin */
glTranslatef(-eyex, -eyey, -eyez);
glTranslated(-eyex, -eyey, -eyez);
}
void G4OpenGLViewer::g4GlOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) {