// // ******************************************************************** // * 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. * // ******************************************************************** // // // $Id: G4OpenGLImmediateQtViewer.cc,v 1.16 2007/06/25 16:38:13 $ // GEANT4 tag $Name: geant4-08-02-patch-01 $ // // // Class G4OpenGLImmediateQtViewer : a class derived from G4OpenGLQtViewer and // G4OpenGLImmediateViewer. #ifdef G4VIS_BUILD_OPENGLQT_DRIVER #include "G4OpenGLImmediateQtViewer.hh" #include "G4ios.hh" G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer (G4OpenGLImmediateSceneHandler& sceneHandler, const G4String& name): G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name), G4OpenGLViewer (sceneHandler), G4OpenGLQtViewer (sceneHandler), G4OpenGLImmediateViewer (sceneHandler), QGLWidget() // FIXME : gerer le pb du parent ! { if (fViewId < 0) return; // In case error in base class instantiation. } G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQtViewer() { printf("GLWidget::~GLWidget \n"); makeCurrent(); printf("GLWidget::~GLWidget END\n"); } void G4OpenGLImmediateQtViewer::Initialise() { printf("GLWidget::Initialise \n"); printf("readyToPaint = false \n"); readyToPaint = false; // printf("G4OpenGLImmediateQtViewer::Initialise () 1\n"); // CreateGLQtContext (); printf("G4OpenGLImmediateQtViewer::Initialise () 2\n"); CreateMainWindow (this); printf("G4OpenGLImmediateQtViewer::Initialise () 3\n"); // CreateFontLists (); // FIXME Does nothing! printf("readyToPaint = true \n"); readyToPaint = true; } void G4OpenGLImmediateQtViewer::initializeGL () { InitializeGLView (); printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n"); // clear the buffers and window. // ClearView (); // printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n"); // FinishView (); // If a double buffer context has been forced upon us, ignore the // back buffer for this OpenGLImmediate view. // glDrawBuffer (GL_FRONT); glDepthFunc (GL_LEQUAL); glDepthMask (GL_TRUE); printf("G4OpenGLImmediateQtViewer::InitialiseGL -------------------------------------------------------------------------------------\n"); } void G4OpenGLImmediateQtViewer::DrawView () { printf("G4OpenGLImmediateQtViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); glDraw(); printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); } void G4OpenGLImmediateQtViewer::DrawView2 () { printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y); // If a double buffer context has been forced upon us, ignore the // back buffer for this OpenGLImmediate view. // glDrawBuffer (GL_FRONT); G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); //Make sure current viewer is attached and clean... //Qt version needed //glXMakeCurrent (dpy, win, cx); glViewport (0, 0, WinSize_x, WinSize_y); if(style!=G4ViewParameters::hlr && haloing_enabled) { HaloingFirstPass (); NeedKernelVisit (); ProcessView (); glFlush (); HaloingSecondPass (); } NeedKernelVisit (); // Always need to visit G4 kernel. ProcessView (); FinishView (); printf("G4OpenGLImmediateQtViewer::DrawView2 %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y); } ////////////////////////////////////////////////////////////////////////////// void G4OpenGLImmediateQtViewer::FinishView ( ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); // // if(!fHDC) return; glFlush (); printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); // Empty the Windows message queue : // MSG event; // while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) { // ::TranslateMessage(&event); // ::DispatchMessage (&event); // } } void G4OpenGLImmediateQtViewer::resizeGL( int width ,int height) { printf("G4OpenGLImmediateQtViewer::resizeGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n"); int side = qMin(width, height); glViewport((width - side) / 2, (height - side) / 2, side, side); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); glMatrixMode(GL_MODELVIEW); printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n"); } void G4OpenGLImmediateQtViewer::paintGL() { if (!readyToPaint) return; // printf("GLWidget::paintGL\n"); // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // glLoadIdentity(); // glTranslated(0.0, 0.0, -10.0); // glRotated(xRot / 16.0, 1.0, 0.0, 0.0); // glRotated(yRot / 16.0, 0.0, 1.0, 0.0); // glRotated(zRot / 16.0, 0.0, 0.0, 1.0); // glCallList(object); // printf("GLWidget::paintGL END\n"); // printf("G4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV \n"); // float b=3; WinSize_x = (G4int) width(); WinSize_y = (G4int) height(); glViewport (0, 0, width(), height()); SetView(); // // printf("before ClearView\n"); // // makeCurrent(); // // for (int a=0;a<100000000;a++) {b = b/3.1456;} // printf(" ClearView\n"); ClearView (); //ok, put the background correct DrawView2(); // // ShowView(); // // printf("before ClearView\n"); // // ClearView (); //ok, put the background correct // // FIXME FinishView(); // // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // // glLoadIdentity(); // // glTranslated(0.0, 0.0, -10.0); // printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); } #endif