source: trunk/geant4/visualization/OpenGL/src/G4OpenGLImmediateQtViewer.cc @ 673

Last change on this file since 673 was 673, checked in by garnier, 16 years ago

debut de correction du ticket #105

  • Property svn:mime-type set to text/cpp
File size: 7.1 KB
RevLine 
[531]1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
[608]27// $Id: G4OpenGLImmediateQtViewer.cc,v 1.3 2007/11/15 18:24:28 lgarnier Exp $
[593]28// GEANT4 tag $Name:  $
[531]29//
[539]30//
[533]31// Class G4OpenGLImmediateQtViewer : a class derived from G4OpenGLQtViewer and
[531]32//                                G4OpenGLImmediateViewer.
33
[533]34#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
[531]35
[533]36#include "G4OpenGLImmediateQtViewer.hh"
[564]37#include "G4VisManager.hh"
[531]38
39#include "G4ios.hh"
40
[533]41G4OpenGLImmediateQtViewer::G4OpenGLImmediateQtViewer
[531]42(G4OpenGLImmediateSceneHandler& sceneHandler,
43 const G4String&  name):
[550]44 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLQtViewer (sceneHandler),
47 G4OpenGLImmediateViewer (sceneHandler),
48 QGLWidget()                      // FIXME : gerer le pb du parent !
49 {
[557]50   nbPaint =0;
[531]51  if (fViewId < 0) return;  // In case error in base class instantiation.
52}
53
[551]54G4OpenGLImmediateQtViewer::~G4OpenGLImmediateQtViewer() {
[608]55#ifdef GEANT4_QT_DEBUG
[551]56   printf("GLWidget::~GLWidget \n");
[608]57#endif
[551]58     makeCurrent();
[608]59#ifdef GEANT4_QT_DEBUG
[551]60   printf("GLWidget::~GLWidget END\n");
[608]61#endif
[551]62}
63
[543]64void G4OpenGLImmediateQtViewer::Initialise() {
[608]65#ifdef GEANT4_QT_DEBUG
[551]66   printf("GLWidget::Initialise \n");
[608]67#endif
68#ifdef GEANT4_QT_DEBUG
[552]69   printf("readyToPaint = false \n");
[608]70#endif
[552]71   readyToPaint = false;
[564]72   CreateGLQtContext ();
[608]73#ifdef GEANT4_QT_DEBUG
[564]74   printf("G4OpenGLImmediateQtViewer::Initialise () 2\n");
[608]75#endif
[541]76
[539]77  CreateMainWindow (this);
[608]78#ifdef GEANT4_QT_DEBUG
[543]79  printf("G4OpenGLImmediateQtViewer::Initialise () 3\n");
[608]80#endif
[551]81
[564]82  CreateFontLists ();  // FIXME Does nothing!
83 
[608]84#ifdef GEANT4_QT_DEBUG
[551]85  printf("readyToPaint = true \n");
[608]86#endif
[552]87  readyToPaint = true;
[564]88 
[557]89  // First Draw
[564]90  SetView();
[608]91#ifdef GEANT4_QT_DEBUG
[564]92  printf("    ClearView\n");
[608]93#endif
[564]94  ClearView (); //ok, put the background correct
95  ShowView();
96  FinishView();
[550]97}
98
[551]99void G4OpenGLImmediateQtViewer::initializeGL () {
[550]100
[554]101   InitializeGLView ();
[550]102
[608]103#ifdef GEANT4_QT_DEBUG
[554]104   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n");
[608]105#endif
[531]106
[564]107   // If a double buffer context has been forced upon us, ignore the
108   // back buffer for this OpenGLImmediate view.
109   glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
[554]110   // clear the buffers and window.
[555]111   ClearView ();
[608]112#ifdef GEANT4_QT_DEBUG
[555]113   //   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n");
[608]114#endif
[555]115   FinishView ();
[564]116   
[531]117
[541]118
[554]119   glDepthFunc (GL_LEQUAL);
120   glDepthMask (GL_TRUE);
[551]121
[608]122#ifdef GEANT4_QT_DEBUG
[554]123   printf("G4OpenGLImmediateQtViewer::InitialiseGL  -------------------------------------------------------------------------------------\n");
[608]124#endif
[531]125}
126
[543]127
[533]128void G4OpenGLImmediateQtViewer::DrawView () {
[531]129
[608]130#ifdef GEANT4_QT_DEBUG
[542]131  printf("G4OpenGLImmediateQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
[608]132#endif
[553]133   // If a double buffer context has been forced upon us, ignore the
134   // back buffer for this OpenGLImmediate view.
[564]135  glDrawBuffer (GL_FRONT);
[552]136
[553]137   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
[552]138
[553]139   //Make sure current viewer is attached and clean...
140   //Qt version needed
[673]141   //   glViewport (0, 0, WinSize_x, WinSize_y);
[552]142
[553]143   if(style!=G4ViewParameters::hlr &&
144      haloing_enabled) {
[608]145#ifdef GEANT4_QT_DEBUG
[564]146     printf("G4OpenGLImmediateQtViewer::DrawView DANS LE IF\n");
[608]147#endif
[552]148
[553]149     HaloingFirstPass ();
150     NeedKernelVisit ();
151     ProcessView ();
152     glFlush ();
[552]153
[553]154     HaloingSecondPass ();
[552]155
[553]156   }
[552]157
[553]158   NeedKernelVisit ();  // Always need to visit G4 kernel.
159   ProcessView ();
160   FinishView ();
[608]161#ifdef GEANT4_QT_DEBUG
[564]162  printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
[608]163#endif
[559]164  readyToPaint = false;
[552]165}
166
167
[531]168//////////////////////////////////////////////////////////////////////////////
[533]169void G4OpenGLImmediateQtViewer::FinishView (
[531]170)
171//////////////////////////////////////////////////////////////////////////////
172//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
173{
[608]174#ifdef GEANT4_QT_DEBUG
[542]175  printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
[608]176#endif
[531]177
[554]178   glFlush ();
[608]179#ifdef GEANT4_QT_DEBUG
[542]180  printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[608]181#endif
[531]182
183}
184
[539]185
[564]186/**
187 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
188 */
[539]189void G4OpenGLImmediateQtViewer::resizeGL(
190 int width
191,int height)
[564]192
[673]193  setupViewport(width,height);
[608]194#ifdef GEANT4_QT_DEBUG
[553]195  printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[608]196#endif
[539]197}
198
[559]199
[539]200void G4OpenGLImmediateQtViewer::paintGL()
201 {
[564]202   if (!readyToPaint) {
203     readyToPaint= true;
[552]204     return;
[564]205   }
[559]206   // DO NOT RESIZE IF SIZE HAS NOT CHANGE
207   if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) {
208     return;
209   }
[557]210   nbPaint++;
[608]211#ifdef GEANT4_QT_DEBUG
[564]212   printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
[608]213#endif
[553]214   WinSize_x = (G4int) width();
215   WinSize_y = (G4int) height();
[541]216
[673]217   setupViewport(width(),height());
[541]218
[556]219   SetView();
[608]220#ifdef GEANT4_QT_DEBUG
[551]221//   //  printf("before ClearView\n");
[608]222#endif
223#ifdef GEANT4_QT_DEBUG
[555]224   printf("    ClearView\n");
[608]225#endif
[564]226   
227   ClearView (); //ok, put the background correct
228   DrawView();
[559]229   readyToPaint = true; // could be set to false by DrawView
230
[543]231
[608]232#ifdef GEANT4_QT_DEBUG
[564]233   printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint);
[608]234#endif
[539]235 }
[551]236
[564]237void G4OpenGLImmediateQtViewer::updateQWidget() {
238  updateGL();
239}
[551]240
[531]241#endif
Note: See TracBrowser for help on using the repository browser.