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

Last change on this file since 605 was 599, checked in by garnier, 17 years ago

r636@mac-90108: laurentgarnier | 2007-11-12 16:46:00 +0100
modif pour qt3

  • Property svn:mime-type set to text/cpp
File size: 6.7 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//
[593]27// $Id: G4OpenGLImmediateQtViewer.cc,v 1.1 2007/09/28 14:44:13 lgarnier Exp $
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() {
55   printf("GLWidget::~GLWidget \n");
56     makeCurrent();
57   printf("GLWidget::~GLWidget END\n");
58}
59
[543]60void G4OpenGLImmediateQtViewer::Initialise() {
[551]61   printf("GLWidget::Initialise \n");
[552]62   printf("readyToPaint = false \n");
63   readyToPaint = false;
[564]64   CreateGLQtContext ();
65   printf("G4OpenGLImmediateQtViewer::Initialise () 2\n");
[541]66
[539]67  CreateMainWindow (this);
[543]68  printf("G4OpenGLImmediateQtViewer::Initialise () 3\n");
[551]69
[564]70  CreateFontLists ();  // FIXME Does nothing!
71 
[551]72  printf("readyToPaint = true \n");
[552]73  readyToPaint = true;
[564]74 
[557]75  // First Draw
[564]76  SetView();
77  printf("    ClearView\n");
78  ClearView (); //ok, put the background correct
79  ShowView();
80  FinishView();
[550]81}
82
[551]83void G4OpenGLImmediateQtViewer::initializeGL () {
[550]84
[554]85   InitializeGLView ();
[550]86
[554]87   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 1\n");
[531]88
[564]89   // If a double buffer context has been forced upon us, ignore the
90   // back buffer for this OpenGLImmediate view.
91   glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
[554]92   // clear the buffers and window.
[555]93   ClearView ();
94   //   printf("G4OpenGLImmediateQtViewer::InitialiseGL () 2\n");
95   FinishView ();
[564]96   
[531]97
[541]98
[554]99   glDepthFunc (GL_LEQUAL);
100   glDepthMask (GL_TRUE);
[551]101
[554]102   printf("G4OpenGLImmediateQtViewer::InitialiseGL  -------------------------------------------------------------------------------------\n");
[531]103}
104
[543]105
[533]106void G4OpenGLImmediateQtViewer::DrawView () {
[531]107
[542]108  printf("G4OpenGLImmediateQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
[553]109   // If a double buffer context has been forced upon us, ignore the
110   // back buffer for this OpenGLImmediate view.
[564]111  glDrawBuffer (GL_FRONT);
[552]112
[553]113   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
[552]114
[553]115   //Make sure current viewer is attached and clean...
116   //Qt version needed
117   glViewport (0, 0, WinSize_x, WinSize_y);
[552]118
[553]119   if(style!=G4ViewParameters::hlr &&
120      haloing_enabled) {
[564]121     printf("G4OpenGLImmediateQtViewer::DrawView DANS LE IF\n");
[552]122
[553]123     HaloingFirstPass ();
124     NeedKernelVisit ();
125     ProcessView ();
126     glFlush ();
[552]127
[553]128     HaloingSecondPass ();
[552]129
[553]130   }
[552]131
[553]132   NeedKernelVisit ();  // Always need to visit G4 kernel.
133   ProcessView ();
134   FinishView ();
[564]135  printf("G4OpenGLImmediateQtViewer::DrawView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",WinSize_x, WinSize_y);
[559]136  readyToPaint = false;
[552]137}
138
139
[531]140//////////////////////////////////////////////////////////////////////////////
[533]141void G4OpenGLImmediateQtViewer::FinishView (
[531]142)
143//////////////////////////////////////////////////////////////////////////////
144//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
145{
[542]146  printf("G4OpenGLImmediateQtViewer::FinishView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
[531]147
[554]148   glFlush ();
[542]149  printf("G4OpenGLImmediateQtViewer::FinishView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[531]150
151}
152
[539]153
[564]154/**
155 - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
156 */
[539]157void G4OpenGLImmediateQtViewer::resizeGL(
158 int width
159,int height)
[564]160
[599]161  int side = width;
162  if (width > height) {
163    side = height;
164  }
[553]165  glViewport((width - side) / 2, (height - side) / 2, side, side);
166  glMatrixMode(GL_PROJECTION);
167  glLoadIdentity();
168  glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
169  glMatrixMode(GL_MODELVIEW);
170  printf("G4OpenGLImmediateQtViewer::resizeGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
[539]171}
172
[559]173
[539]174void G4OpenGLImmediateQtViewer::paintGL()
175 {
[564]176   if (!readyToPaint) {
177     readyToPaint= true;
[552]178     return;
[564]179   }
[559]180   // DO NOT RESIZE IF SIZE HAS NOT CHANGE
181   if (((WinSize_x == (G4int)width())) &&(WinSize_y == (G4int) height())) {
182     return;
183   }
[557]184   nbPaint++;
[564]185   printf("\n\nG4OpenGLImmediateQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV %d ready %d\n",nbPaint,readyToPaint);
[553]186   WinSize_x = (G4int) width();
187   WinSize_y = (G4int) height();
[541]188
[556]189   glViewport (0, 0, width(), height());
[541]190
[556]191   SetView();
[551]192//   //  printf("before ClearView\n");
[555]193   printf("    ClearView\n");
[564]194   
195   ClearView (); //ok, put the background correct
196   DrawView();
[559]197   readyToPaint = true; // could be set to false by DrawView
198
[543]199
[564]200   printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %d ready %d\n\n\n",nbPaint,readyToPaint);
[539]201 }
[551]202
[564]203void G4OpenGLImmediateQtViewer::updateQWidget() {
204  updateGL();
205}
[551]206
[531]207#endif
Note: See TracBrowser for help on using the repository browser.