Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLStoredSceneHandler.cc (Version 2.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                             << 
 26 //                                                  7 //
                                                   >>   8 // $Id: G4OpenGLStoredSceneHandler.cc,v 1.7 2000/04/12 13:09:07 johna Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-02-00 $
 27 //                                                 10 //
 28 //                                                 11 // 
 29 // Andrew Walkden  10th February 1997              12 // Andrew Walkden  10th February 1997
 30 // OpenGL stored scene - creates OpenGL displa     13 // OpenGL stored scene - creates OpenGL display lists.
 31                                                    14 
 32 #include "G4OpenGLStoredSceneHandler.hh"       <<  15 #ifdef G4VIS_BUILD_OPENGL_DRIVER
 33                                                    16 
 34 #include "G4PhysicalVolumeModel.hh"            <<  17 // Included here - problems with HP compiler if not before other includes?
 35 #include "G4LogicalVolumeModel.hh"             <<  18 #include "G4NURBS.hh"
 36 #include "G4VPhysicalVolume.hh"                <<  19 
 37 #include "G4LogicalVolume.hh"                  <<  20 // Here follows a special for Mesa, the OpenGL emulator.  Does not affect
                                                   >>  21 // other OpenGL's, as far as I'm aware.   John Allison 18/9/96.
                                                   >>  22 #define CENTERLINE_CLPP  /* CenterLine C++ workaround: */
                                                   >>  23 // Also seems to be required for HP's CC and AIX xlC, at least.
                                                   >>  24 
                                                   >>  25 #include <GL/gl.h>
                                                   >>  26 #include <GL/glx.h>
                                                   >>  27 #include <GL/glu.h>
                                                   >>  28 
                                                   >>  29 #include "G4OpenGLSceneHandler.hh"
                                                   >>  30 #include "G4OpenGLViewer.hh"
                                                   >>  31 #include "G4OpenGLTransform3D.hh"
                                                   >>  32 #include "G4Point3D.hh"
                                                   >>  33 #include "G4Normal3D.hh"
                                                   >>  34 #include "G4Transform3D.hh"
 38 #include "G4Polyline.hh"                           35 #include "G4Polyline.hh"
 39 #include "G4Polymarker.hh"                     << 
 40 #include "G4Text.hh"                               36 #include "G4Text.hh"
 41 #include "G4Circle.hh"                             37 #include "G4Circle.hh"
 42 #include "G4Square.hh"                             38 #include "G4Square.hh"
 43 #include "G4Polyhedron.hh"                         39 #include "G4Polyhedron.hh"
 44 #include "G4AttHolder.hh"                      <<  40 #include "G4VisAttributes.hh"
 45 #include "G4OpenGLTransform3D.hh"              <<  41 #include "G4VPhysicalVolume.hh"
 46 #include "G4OpenGLViewer.hh"                   <<  42 #include "G4ModelingParameters.hh"
 47 #include "G4AttHolder.hh"                      <<  43 #include "G4VModel.hh"
 48                                                <<  44 #include "G4OpenGLStoredSceneHandler.hh"
 49 #include <typeinfo>                            << 
 50                                                << 
 51 G4int G4OpenGLStoredSceneHandler::fSceneIdCoun << 
 52                                                << 
 53 G4int  G4OpenGLStoredSceneHandler::fDisplayLis << 
 54                                                << 
 55 G4OpenGLStoredSceneHandler::PO::PO():          << 
 56   fDisplayListId(0),                           << 
 57   fPickName(0),                                << 
 58   fpG4TextPlus(0),                             << 
 59   fMarkerOrPolyline(false)                     << 
 60 {}                                             << 
 61                                                << 
 62 G4OpenGLStoredSceneHandler::PO::PO(const G4Ope << 
 63   fDisplayListId(po.fDisplayListId),           << 
 64   fTransform(po.fTransform),                   << 
 65   fPickName(po.fPickName),                     << 
 66   fColour(po.fColour),                         << 
 67   fpG4TextPlus(po.fpG4TextPlus? new G4TextPlus << 
 68   fMarkerOrPolyline(po.fMarkerOrPolyline)      << 
 69 {}                                             << 
 70                                                << 
 71 G4OpenGLStoredSceneHandler::PO::PO(G4int id, c << 
 72   fDisplayListId(id),                          << 
 73   fTransform(tr),                              << 
 74   fPickName(0),                                << 
 75   fpG4TextPlus(0),                             << 
 76   fMarkerOrPolyline(false)                     << 
 77 {}                                             << 
 78                                                << 
 79 G4OpenGLStoredSceneHandler::PO::~PO()          << 
 80 {                                              << 
 81   delete fpG4TextPlus;                         << 
 82 }                                              << 
 83                                                << 
 84 G4OpenGLStoredSceneHandler::PO& G4OpenGLStored << 
 85   (const G4OpenGLStoredSceneHandler::PO& rhs)  << 
 86 {                                              << 
 87   if (&rhs == this) return *this;              << 
 88   fDisplayListId = rhs.fDisplayListId;         << 
 89   fTransform = rhs.fTransform;                 << 
 90   fPickName = rhs.fPickName;                   << 
 91   fColour = rhs.fColour;                       << 
 92   fpG4TextPlus = rhs.fpG4TextPlus? new G4TextP << 
 93   fMarkerOrPolyline = rhs.fMarkerOrPolyline;   << 
 94   return *this;                                << 
 95 }                                              << 
 96                                                << 
 97 G4OpenGLStoredSceneHandler::TO::TO():          << 
 98   fDisplayListId(0),                           << 
 99   fPickName(0),                                << 
100   fStartTime(-G4VisAttributes::fVeryLongTime), << 
101   fEndTime(G4VisAttributes::fVeryLongTime),    << 
102   fpG4TextPlus(0),                             << 
103   fMarkerOrPolyline(false)                     << 
104 {}                                             << 
105                                                << 
106 G4OpenGLStoredSceneHandler::TO::TO(const G4Ope << 
107   fDisplayListId(to.fDisplayListId),           << 
108   fTransform(to.fTransform),                   << 
109   fPickName(to.fPickName),                     << 
110   fStartTime(to.fStartTime),                   << 
111   fEndTime(to.fEndTime),                       << 
112   fColour(to.fColour),                         << 
113   fpG4TextPlus(to.fpG4TextPlus? new G4TextPlus << 
114   fMarkerOrPolyline(to.fMarkerOrPolyline)      << 
115 {}                                             << 
116                                                << 
117 G4OpenGLStoredSceneHandler::TO::TO(G4int id, c << 
118   fDisplayListId(id),                          << 
119   fTransform(tr),                              << 
120   fPickName(0),                                << 
121   fStartTime(-G4VisAttributes::fVeryLongTime), << 
122   fEndTime(G4VisAttributes::fVeryLongTime),    << 
123   fpG4TextPlus(0),                             << 
124   fMarkerOrPolyline(false)                     << 
125 {}                                             << 
126                                                << 
127 G4OpenGLStoredSceneHandler::TO::~TO()          << 
128 {                                              << 
129   delete fpG4TextPlus;                         << 
130 }                                              << 
131                                                << 
132 G4OpenGLStoredSceneHandler::TO& G4OpenGLStored << 
133   (const G4OpenGLStoredSceneHandler::TO& rhs)  << 
134 {                                              << 
135   if (&rhs == this) return *this;              << 
136   fDisplayListId = rhs.fDisplayListId;         << 
137   fTransform = rhs.fTransform;                 << 
138   fPickName = rhs.fPickName;                   << 
139   fStartTime = rhs.fStartTime;                 << 
140   fEndTime = rhs.fEndTime;                     << 
141   fColour = rhs.fColour;                       << 
142   fpG4TextPlus = rhs.fpG4TextPlus? new G4TextP << 
143   fMarkerOrPolyline = rhs.fMarkerOrPolyline;   << 
144   return *this;                                << 
145 }                                              << 
146                                                    45 
147 G4OpenGLStoredSceneHandler::G4OpenGLStoredScen <<  46 G4OpenGLStoredSceneHandler::G4OpenGLStoredSceneHandler (G4VGraphicsSystem& system,
148 (G4VGraphicsSystem& system,                    <<  47             const G4String& name):
149  const G4String& name):                        << 
150 G4OpenGLSceneHandler (system, fSceneIdCount++,     48 G4OpenGLSceneHandler (system, fSceneIdCount++, name),
151 fDoNotUseDisplayList(false),                   <<  49 fMemoryForDisplayLists (true),
152 fTopPODL (0)                                       50 fTopPODL (0)
153 {}                                             << 
154                                                << 
155 G4OpenGLStoredSceneHandler::~G4OpenGLStoredSce << 
156 {}                                             << 
157                                                << 
158 void G4OpenGLStoredSceneHandler::BeginPrimitiv << 
159 (const G4Transform3D& objectTransformation)    << 
160 {                                              << 
161   G4OpenGLSceneHandler::BeginPrimitives (objec << 
162   if (fReadyForTransients) glDrawBuffer (GL_FR << 
163   // Display list setup moved to AddPrimitiveP << 
164 }                                              << 
165                                                << 
166 void G4OpenGLStoredSceneHandler::EndPrimitives << 
167 {                                                  51 {
168   // See all primitives immediately...  At lea <<  52   fSceneCount++;
169   ScaledFlush();                               << 
170   glDrawBuffer (GL_BACK);                      << 
171   G4OpenGLSceneHandler::EndPrimitives ();      << 
172 }                                                  53 }
173                                                    54 
174 void G4OpenGLStoredSceneHandler::BeginPrimitiv <<  55 G4OpenGLStoredSceneHandler::~G4OpenGLStoredSceneHandler ()
175 (const G4Transform3D& objectTransformation)    << 
176 {                                              << 
177   G4OpenGLSceneHandler::BeginPrimitives2D(obje << 
178   if (fReadyForTransients) glDrawBuffer (GL_FR << 
179 }                                              << 
180                                                << 
181 void G4OpenGLStoredSceneHandler::EndPrimitives << 
182 {                                              << 
183   // See all primitives immediately...  At lea << 
184   ScaledFlush();                               << 
185   glDrawBuffer (GL_BACK);                      << 
186   G4OpenGLSceneHandler::EndPrimitives2D ();    << 
187 }                                              << 
188                                                << 
189 G4bool G4OpenGLStoredSceneHandler::AddPrimitiv << 
190 {                                              << 
191   return AddPrimitivePreambleInternal(visible, << 
192 }                                              << 
193 G4bool G4OpenGLStoredSceneHandler::AddPrimitiv << 
194 {                                              << 
195   return AddPrimitivePreambleInternal(visible, << 
196 }                                              << 
197 G4bool G4OpenGLStoredSceneHandler::AddPrimitiv << 
198 {                                                  56 {
199   return AddPrimitivePreambleInternal(visible, <<  57   fSceneCount--;
200 }                                                  58 }
201                                                    59 
202 G4bool G4OpenGLStoredSceneHandler::AddPrimitiv <<  60 void G4OpenGLStoredSceneHandler::BeginPrimitives
203 (const G4Visible& visible, bool isMarker, bool <<  61 (const G4Transform3D& objectTransformation) {
204 {                                              << 
205 // Get applicable vis attributes for all primi << 
206   fpVisAttribs = fpViewer->GetApplicableVisAtt << 
207   const G4Colour& c = GetColour ();            << 
208   G4double opacity = c.GetAlpha ();            << 
209                                                << 
210   G4bool transparency_enabled = true;          << 
211   G4bool isMarkerNotHidden = true;             << 
212   G4OpenGLViewer* pOGLViewer = dynamic_cast<G4 << 
213   if (pOGLViewer) {                            << 
214     transparency_enabled = pOGLViewer->transpa << 
215     isMarkerNotHidden = pOGLViewer->fVP.IsMark << 
216   }                                            << 
217                                                << 
218   G4bool isTransparent = opacity < 1.;         << 
219   G4bool isMarkerOrPolyline = isMarker || isPo << 
220   G4bool treatAsTransparent = transparency_ena << 
221   G4bool treatAsNotHidden = isMarkerNotHidden  << 
222                                                << 
223   if (fProcessing2D) glDisable (GL_DEPTH_TEST) << 
224   else {                                       << 
225     if (isMarkerOrPolyline && isMarkerNotHidde << 
226       glDisable (GL_DEPTH_TEST);               << 
227     else {glEnable (GL_DEPTH_TEST); glDepthFun << 
228   }                                            << 
229                                                << 
230   if (fThreePassCapable) {                     << 
231                                                << 
232     // Ensure transparent objects are drawn *a << 
233     // non-hidden markers.  The problem of ble << 
234     // is quite a tricky one - see History of  << 
235     if (!(fSecondPassForTransparency || fThird << 
236       // First pass...                         << 
237       if (treatAsTransparent) {  // Request pa << 
238         fSecondPassForTransparencyRequested =  << 
239       }                                        << 
240       if (treatAsNotHidden) {    // Request pa << 
241         fThirdPassForNonHiddenMarkersRequested << 
242       }                                        << 
243       // On first pass, transparent objects an << 
244       if (treatAsTransparent || treatAsNotHidd << 
245         return false;  // No further processin << 
246       }                                        << 
247     }                                          << 
248                                                << 
249     // On second pass, only transparent object << 
250     if (fSecondPassForTransparency) {          << 
251       if (!treatAsTransparent) {               << 
252         return false;  // No further processin << 
253       }                                        << 
254     }                                          << 
255                                                << 
256     // On third pass, only non-hidden markers  << 
257     if (fThirdPassForNonHiddenMarkers) {       << 
258       if (!treatAsNotHidden) {                 << 
259         return false;  // No further processin << 
260       }                                        << 
261     }                                          << 
262   }  // fThreePassCapable                      << 
263                                                    62   
264   // Loads G4Atts for picking...               <<  63   G4VSceneHandler::BeginPrimitives (objectTransformation);
265   G4bool isPicking = false;                    << 
266   if (fpViewer->GetViewParameters().IsPicking( << 
267     isPicking = true;                          << 
268     glLoadName(++fPickName);                   << 
269     G4AttHolder* holder = new G4AttHolder;     << 
270     LoadAtts(visible, holder);                 << 
271     fPickMap[fPickName] = holder;              << 
272   }                                            << 
273                                                << 
274   // Because of our need to control colour of  << 
275   // time fading), display lists may only cove << 
276   // So display list setup is here.            << 
277                                                << 
278   if (fDoNotUseDisplayList) {                  << 
279                                                    64 
280     glPushMatrix();                            <<  65   if (fMemoryForDisplayLists) {
281     G4OpenGLTransform3D oglt (fObjectTransform <<  66     if (!(fDisplayListId = glGenLists (1))) {  // Could pre-allocate?
282     glMultMatrixd (oglt.GetGLMatrix ());       <<  67       G4cout << "********************* WARNING! ********************\n"
283     if (transparency_enabled) {                <<  68      <<"Unable to allocate any more display lists in OpenGL.\n "
284       glColor4d(c.GetRed(),c.GetGreen(),c.GetB <<  69      << "      Continuing drawing in IMMEDIATE MODE.\n"
285     } else {                                   <<  70      << "***************************************************" << G4endl;
286       glColor3d(c.GetRed(),c.GetGreen(),c.GetB <<  71       fMemoryForDisplayLists = false;
287     }                                          << 
288                                                << 
289   } else {                                     << 
290                                                << 
291     fDisplayListId = glGenLists (1);           << 
292     if (glGetError() == GL_OUT_OF_MEMORY) {    << 
293       static G4int errorCount = 0;             << 
294       if (errorCount < 5) {                    << 
295         errorCount++;                          << 
296         G4ExceptionDescription ed;             << 
297         ed <<                                  << 
298         "Error attempting to create an OpenGL  << 
299         "\nCurrent display list id: " << fDisp << 
300         "\nMaybe out of memory?";              << 
301         G4Exception                            << 
302         ("G4OpenGLStoredSceneHandler::AddPrimi << 
303          JustWarning,ed);                      << 
304       }                                        << 
305       return false;                            << 
306     }                                              72     }
                                                   >>  73   }
                                                   >>  74   if (fMemoryForDisplayLists) {
307     if (fReadyForTransients) {                     75     if (fReadyForTransients) {
308       TO to(fDisplayListId, fObjectTransformat <<  76       fTODLList.append (fDisplayListId);
309       if (isPicking) to.fPickName = fPickName; <<  77       fTODLTransformList.append (objectTransformation);
310       to.fColour = c;                          <<  78       glDrawBuffer (GL_FRONT);
311       to.fStartTime = fpVisAttribs->GetStartTi << 
312       to.fEndTime = fpVisAttribs->GetEndTime() << 
313       to.fMarkerOrPolyline = isMarkerOrPolylin << 
314       fTOList.push_back(to);                   << 
315       // For transient objects, colour, transf << 
316       // the TO, so should *not* be in the dis << 
317       // above, in some cases (display-by-time << 
318       // independent control of colour.  But f << 
319       // colour for immediate display.         << 
320       glPushMatrix();                              79       glPushMatrix();
321       G4OpenGLTransform3D oglt (fObjectTransfo <<  80       G4OpenGLTransform3D oglt (objectTransformation);
322       glMultMatrixd (oglt.GetGLMatrix ());         81       glMultMatrixd (oglt.GetGLMatrix ());
323       if (transparency_enabled) {              << 
324         glColor4d(c.GetRed(),c.GetGreen(),c.Ge << 
325       } else {                                 << 
326         glColor3d(c.GetRed(),c.GetGreen(),c.Ge << 
327       }                                        << 
328       (void) ExtraTOProcessing(visible, fTOLis << 
329       // Ignore return value of the above.  If << 
330       // gl commands, a display list is create << 
331       // used.                                 << 
332       glNewList (fDisplayListId, GL_COMPILE_AN     82       glNewList (fDisplayListId, GL_COMPILE_AND_EXECUTE);
333     } else {                                   << 
334       PO po(fDisplayListId, fObjectTransformat << 
335       if (isPicking) po.fPickName = fPickName; << 
336       po.fColour = c;                          << 
337       po.fMarkerOrPolyline = isMarkerOrPolylin << 
338       fPOList.push_back(po);                   << 
339       // For permanent objects, colour is kept << 
340       // *not* be in the display list.  This i << 
341       // may implement colour modifications ac << 
342       // criteria, e.g., scene tree slider in  << 
343       // colour for immediate display.         << 
344       if (transparency_enabled) {              << 
345         glColor4d(c.GetRed(),c.GetGreen(),c.Ge << 
346       } else {                                 << 
347         glColor3d(c.GetRed(),c.GetGreen(),c.Ge << 
348       }                                        << 
349       G4bool usesGLCommands = ExtraPOProcessin << 
350       // Transients are displayed as they come << 
351       // above) but persistents are compiled i << 
352       // (GL_COMPILE only) and then drawn from << 
353       // their fObjectTransformation as stored << 
354       // there is no need to do glMultMatrixd  << 
355       // ExtraPOProcessing says the visible ob << 
356       // commands, simply return and abandon f << 
357       // is assumed that all relevant informat << 
358       // POList.                               << 
359       if (!usesGLCommands) return false;       << 
360       glNewList (fDisplayListId, GL_COMPILE);  << 
361     }                                              83     }
362   }                                            <<  84     else {
363                                                <<  85       fPODLList.append (fDisplayListId);
364   if (fProcessing2D) {                         <<  86       fPODLTransformList.append (objectTransformation);
365     // Push current 3D world matrices and load <<  87       glNewList (fDisplayListId, GL_COMPILE);
366     // coordinates...                          << 
367     glMatrixMode (GL_PROJECTION);              << 
368     glPushMatrix();                            << 
369     glLoadIdentity();                          << 
370     if (pOGLViewer) {                          << 
371       pOGLViewer->g4GlOrtho (-1., 1., -1., 1., << 
372     }                                              88     }
373     glMatrixMode (GL_MODELVIEW);               <<  89   } else {
                                                   >>  90     glDrawBuffer (GL_FRONT);
374     glPushMatrix();                                91     glPushMatrix();
375     glLoadIdentity();                          <<  92     G4OpenGLTransform3D oglt (objectTransformation);
376     G4OpenGLTransform3D oglt (fObjectTransform << 
377     glMultMatrixd (oglt.GetGLMatrix ());           93     glMultMatrixd (oglt.GetGLMatrix ());
378     glDisable (GL_LIGHTING);                   << 
379   } else {                                     << 
380     if (isMarker) {                            << 
381       glDisable (GL_LIGHTING);                 << 
382     } else {                                   << 
383       glEnable (GL_LIGHTING);                  << 
384     }                                          << 
385   }                                                94   }
386                                                << 
387   return true;                                 << 
388 }                                                  95 }
389                                                    96 
390 void G4OpenGLStoredSceneHandler::AddPrimitiveP <<  97 void G4OpenGLStoredSceneHandler::EndPrimitives () {
391 {                                              <<  98   if (fMemoryForDisplayLists) {
392   if (fProcessing2D) {                         << 
393     // Pop current 3D world matrices back agai << 
394     glMatrixMode (GL_PROJECTION);              << 
395     glPopMatrix();                             << 
396     glMatrixMode (GL_MODELVIEW);               << 
397     glPopMatrix();                             << 
398   }                                            << 
399                                                << 
400   //  if ((glGetError() == GL_TABLE_TOO_LARGE) << 
401   if (glGetError() == GL_OUT_OF_MEMORY) {  //  << 
402     G4cerr <<                                  << 
403       "ERROR: G4OpenGLStoredSceneHandler::AddP << 
404       "  to allocate display List for fTopPODL << 
405            << G4endl;                          << 
406   }                                            << 
407   if (!fDoNotUseDisplayList) {                 << 
408     glEndList();                                   99     glEndList();
409     if (glGetError() == GL_OUT_OF_MEMORY) {  / << 
410       G4cerr <<                                << 
411         "ERROR: G4OpenGLStoredSceneHandler::Ad << 
412   "  to allocate display List for fTopPODL - t << 
413              << G4endl;                        << 
414     }                                          << 
415   }                                               100   }
416   if (fReadyForTransients || fDoNotUseDisplayL << 101   if (fReadyForTransients || !fMemoryForDisplayLists) {
417     glPopMatrix();                                102     glPopMatrix();
                                                   >> 103     glFlush ();
                                                   >> 104     glDrawBuffer (GL_BACK);
418   }                                               105   }
                                                   >> 106   G4VSceneHandler::EndPrimitives ();
419 }                                                 107 }
420                                                   108 
421 void G4OpenGLStoredSceneHandler::AddPrimitive  << 109 void G4OpenGLStoredSceneHandler::ClearStore () {
422 {                                              << 
423   G4bool furtherprocessing = AddPrimitivePream << 
424   if (furtherprocessing) {                     << 
425     G4OpenGLSceneHandler::AddPrimitive(polylin << 
426     AddPrimitivePostamble();                   << 
427   }                                            << 
428 }                                              << 
429                                                   110 
430 void G4OpenGLStoredSceneHandler::AddPrimitive  << 111   G4VSceneHandler::ClearStore ();  // Sets need kernel visit, etc.
431 {                                              << 
432   G4bool furtherprocessing = AddPrimitivePream << 
433   if (furtherprocessing) {                     << 
434     G4OpenGLSceneHandler::AddPrimitive(polymar << 
435     AddPrimitivePostamble();                   << 
436   }                                            << 
437 }                                              << 
438                                                   112 
439 void G4OpenGLStoredSceneHandler::AddPrimitive  << 113   int i;
440 {                                              << 
441   // Note: colour is still handled in          << 
442   // G4OpenGLSceneHandler::AddPrimitive(const  << 
443   // gets into the display list                << 
444   G4bool furtherprocessing = AddPrimitivePream << 
445   if (furtherprocessing) {                     << 
446     G4OpenGLSceneHandler::AddPrimitive(text);  << 
447     AddPrimitivePostamble();                   << 
448   }                                            << 
449 }                                              << 
450                                                   114 
451 void G4OpenGLStoredSceneHandler::AddPrimitive  << 115   // Delete OpenGL display lists.
452 {                                              << 116   for (i = 0; i < fPODLList.entries (); i++) {
453   G4bool furtherprocessing = AddPrimitivePream << 117     if (fPODLList (i)) {
454   if (furtherprocessing) {                     << 118       glDeleteLists (fPODLList (i), 1);
455     G4OpenGLSceneHandler::AddPrimitive(circle) << 119     } else {
456     AddPrimitivePostamble();                   << 120       G4cerr << "Warning : NULL display List in fPODLList." << G4endl;
                                                   >> 121     }
457   }                                               122   }
458 }                                              << 123   for (i = 0; i < fTODLList.entries (); i++) {
459                                                << 124     if (fTODLList (i)) {
460 void G4OpenGLStoredSceneHandler::AddPrimitive  << 125       glDeleteLists (fTODLList (i), 1);
461 {                                              << 126     } else {
462   G4bool furtherprocessing = AddPrimitivePream << 127       G4cerr << "Warning : NULL display List in fTODLList." << G4endl;
463   if (furtherprocessing) {                     << 128     }
464     G4OpenGLSceneHandler::AddPrimitive(square) << 
465     AddPrimitivePostamble();                   << 
466   }                                               129   }
467 }                                              << 
468                                                   130 
469 void G4OpenGLStoredSceneHandler::AddPrimitive  << 131   if (fTopPODL) glDeleteLists (fTopPODL, 1);
470 {                                              << 132   fTopPODL = 0;
471   // Note: colour is still handled in          << 133 
472   // G4OpenGLSceneHandler::AddPrimitive(const  << 134   fMemoryForDisplayLists = glIsList (fTopPODL = glGenLists (1));
473   // gets into the display list                << 135 
474   G4bool furtherprocessing = AddPrimitivePream << 136   // Clear other lists, dictionary, etc.
475   if (furtherprocessing) {                     << 137   fPODLList.clear ();
476     G4OpenGLSceneHandler::AddPrimitive(polyhed << 138   fTODLList.clear ();
477     AddPrimitivePostamble();                   << 139   fPODLTransformList.clear ();
478   }                                            << 140   fTODLTransformList.clear ();
                                                   >> 141   fSolidMap.clear ();
479 }                                                 142 }
480                                                   143 
481 void G4OpenGLStoredSceneHandler::BeginModeling    144 void G4OpenGLStoredSceneHandler::BeginModeling () {
                                                   >> 145 
                                                   >> 146   if (fpViewer -> GetViewParameters ().GetDrawingStyle() == G4ViewParameters::hlr) {
                                                   >> 147     initialize_hlr = true;
                                                   >> 148   }
482   G4VSceneHandler::BeginModeling();               149   G4VSceneHandler::BeginModeling();
483   /* Debug...                                  << 
484   fDisplayListId = glGenLists (1);             << 
485   G4cout << "OGL::fDisplayListId (start): " << << 
486   */                                           << 
487 }                                                 150 }
488                                                   151 
489 void G4OpenGLStoredSceneHandler::EndModeling (    152 void G4OpenGLStoredSceneHandler::EndModeling () {
490   // Make a List which calls the other lists.     153   // Make a List which calls the other lists.
491   fTopPODL = glGenLists (1);                   << 
492   if (glGetError() == GL_OUT_OF_MEMORY) {  //  << 
493     G4cerr <<                                  << 
494       "ERROR: G4OpenGLStoredSceneHandler::EndM << 
495       "  display List for fTopPODL - try OpenG << 
496      << G4endl;                                << 
497   } else {                                     << 
498                                                   154 
499     glNewList (fTopPODL, GL_COMPILE); {        << 155 //  if (!(fTopPODL = glGenLists (1))) {
500       for (size_t i = 0; i < fPOList.size ();  << 156 //    G4Exception ("Unable to allocate display List for fTopPODL in G4OpenGLStoredSceneHandler");
501   glPushMatrix();                              << 157 //  }
502   G4OpenGLTransform3D oglt (fPOList[i].fTransf << 
503   glMultMatrixd (oglt.GetGLMatrix ());         << 
504   if (fpViewer->GetViewParameters().IsPicking( << 
505     glLoadName(fPOList[i].fPickName);          << 
506   glCallList (fPOList[i].fDisplayListId);      << 
507   glPopMatrix();                               << 
508       }                                        << 
509     }                                          << 
510     glEndList ();                              << 
511                                                   158 
512     if (glGetError() == GL_OUT_OF_MEMORY) {  / << 159   glNewList (fTopPODL, GL_COMPILE); {
513       G4cerr <<                                << 160     for (int i = 0; i < fPODLList.entries (); i++) {
514         "ERROR: G4OpenGLStoredSceneHandler::En << 161       glPushMatrix();
515         "  display List for fTopPODL - try Ope << 162       G4OpenGLTransform3D oglt (fPODLTransformList (i));
516              << G4endl;                        << 163       glMultMatrixd (oglt.GetGLMatrix ());
                                                   >> 164       glCallList (fPODLList(i));
                                                   >> 165       glPopMatrix();
517     }                                             166     }
518   }                                               167   }
519                                                << 168   glEndList ();
520   G4VSceneHandler::EndModeling ();                169   G4VSceneHandler::EndModeling ();
521 }                                              << 
522                                                   170 
523 void G4OpenGLStoredSceneHandler::ClearStore () << 171   if (fpViewer -> GetViewParameters ().GetDrawingStyle() == G4ViewParameters::hlr) {
524                                                << 172     initialize_hlr = false;
525   //G4cout << "G4OpenGLStoredSceneHandler::Cle << 173     //    glDisable (GL_POLYGON_OFFSET_FILL);
526                                                << 174   }
527   G4VSceneHandler::ClearStore ();  // Sets nee << 
528                                                << 
529   // Delete OpenGL permanent display lists.    << 
530   for (size_t i = 0; i < fPOList.size (); i++) << 
531     glDeleteLists (fPOList[i].fDisplayListId,  << 
532   if (fTopPODL) glDeleteLists (fTopPODL, 1);   << 
533   fTopPODL = 0;                                << 
534                                                << 
535   // Clear other lists, dictionary, etc.       << 
536   fPOList.clear ();                            << 
537   fSolidMap.clear ();                          << 
538   ClearAndDestroyAtts();                       << 
539                                                << 
540   // ...and clear transient store...           << 
541   for (size_t i = 0; i < fTOList.size (); i++) << 
542     glDeleteLists(fTOList[i].fDisplayListId, 1 << 
543   fTOList.clear ();                            << 
544 }                                                 175 }
545                                                   176 
546 void G4OpenGLStoredSceneHandler::ClearTransien << 177 void G4OpenGLStoredSceneHandler::RequestPrimitives (const G4VSolid& solid) {
547 {                                              << 178   if (fReadyForTransients ||
548   //G4cout << "G4OpenGLStoredSceneHandler::Cle << 179       GetModel () -> GetModelingParameters () -> GetRepStyle () ==
549                                                << 180       G4ModelingParameters::hierarchy) {
550   // Delete OpenGL transient display lists and << 181     G4VSceneHandler::RequestPrimitives (solid);
551   for (size_t i = 0; i < fTOList.size (); i++) << 182   }
552     glDeleteLists(fTOList[i].fDisplayListId, 1 << 183   else {
553   fTOList.clear ();                            << 184     // Stop-gap solution for display List re-use.  A proper
554                                                << 185     // implementation would use geometry hierarchy.
555   // Redraw the scene ready for the next event << 186     const G4VSolid* pSolid = &solid;
556   if (fpViewer) {                              << 187     if (!(fpCurrentPV -> IsReplicated ()) &&
557     fpViewer -> SetView ();                    << 188   (fSolidMap.find (pSolid) != fSolidMap.end ())) {
558     fpViewer -> ClearView ();                  << 189       fDisplayListId = fSolidMap [pSolid];
559     fpViewer -> DrawView ();                   << 190       fPODLList.append (fDisplayListId);
                                                   >> 191       fPODLTransformList.append (*fpObjectTransformation);
                                                   >> 192     }
                                                   >> 193     else {
                                                   >> 194       G4VSceneHandler::RequestPrimitives (solid);
                                                   >> 195       fSolidMap [pSolid] = fDisplayListId;
                                                   >> 196     }
560   }                                               197   }
561 }                                                 198 }
                                                   >> 199 
                                                   >> 200 G4int G4OpenGLStoredSceneHandler::fSceneIdCount = 0;
                                                   >> 201 
                                                   >> 202 G4int G4OpenGLStoredSceneHandler::fSceneCount = 0;
                                                   >> 203 
                                                   >> 204 #endif
562                                                   205