Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLStoredSceneHandler.cc
Go to the documentation of this file.
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 //
27 // $Id: G4OpenGLStoredSceneHandler.cc 66373 2012-12-18 09:41:34Z gcosmo $
28 //
29 //
30 // Andrew Walkden 10th February 1997
31 // OpenGL stored scene - creates OpenGL display lists.
32 
33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
34 
36 
37 #include "G4PhysicalVolumeModel.hh"
38 #include "G4LogicalVolumeModel.hh"
39 #include "G4VPhysicalVolume.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4Polyline.hh"
42 #include "G4Polymarker.hh"
43 #include "G4Text.hh"
44 #include "G4Circle.hh"
45 #include "G4Square.hh"
46 #include "G4Polyhedron.hh"
47 #include "G4AttHolder.hh"
48 #include "G4OpenGLTransform3D.hh"
49 #include "G4OpenGLViewer.hh"
50 #include "G4AttHolder.hh"
51 
52 #include <typeinfo>
53 
54 G4OpenGLStoredSceneHandler::PO::PO():
55  fDisplayListId(0),
56  fPickName(0),
57  fpG4TextPlus(0),
58  fMarkerOrPolyline(false)
59 {}
60 
61 G4OpenGLStoredSceneHandler::PO::PO(const G4OpenGLStoredSceneHandler::PO& po):
62  fDisplayListId(po.fDisplayListId),
63  fTransform(po.fTransform),
64  fPickName(po.fPickName),
65  fColour(po.fColour),
66  fpG4TextPlus(po.fpG4TextPlus? new G4TextPlus(*po.fpG4TextPlus): 0),
67  fMarkerOrPolyline(po.fMarkerOrPolyline)
68 {}
69 
70 G4OpenGLStoredSceneHandler::PO::PO(G4int id, const G4Transform3D& tr):
71  fDisplayListId(id),
72  fTransform(tr),
73  fPickName(0),
74  fpG4TextPlus(0),
75  fMarkerOrPolyline(false)
76 {}
77 
78 G4OpenGLStoredSceneHandler::PO::~PO()
79 {
80  delete fpG4TextPlus;
81 }
82 
83 G4OpenGLStoredSceneHandler::PO& G4OpenGLStoredSceneHandler::PO::operator=
84  (const G4OpenGLStoredSceneHandler::PO& rhs)
85 {
86  if (&rhs == this) return *this;
87  fDisplayListId = rhs.fDisplayListId;
88  fTransform = rhs.fTransform;
89  fPickName = rhs.fPickName;
90  fColour = rhs.fColour;
91  fpG4TextPlus = rhs.fpG4TextPlus? new G4TextPlus(*rhs.fpG4TextPlus): 0;
92  fMarkerOrPolyline = rhs.fMarkerOrPolyline;
93  return *this;
94 }
95 
96 G4OpenGLStoredSceneHandler::TO::TO():
97  fDisplayListId(0),
98  fPickName(0),
99  fStartTime(-DBL_MAX),
100  fEndTime(DBL_MAX),
101  fpG4TextPlus(0),
102  fMarkerOrPolyline(false)
103 {}
104 
105 G4OpenGLStoredSceneHandler::TO::TO(const G4OpenGLStoredSceneHandler::TO& to):
106  fDisplayListId(to.fDisplayListId),
107  fTransform(to.fTransform),
108  fPickName(to.fPickName),
109  fStartTime(to.fStartTime),
110  fEndTime(to.fEndTime),
111  fColour(to.fColour),
112  fpG4TextPlus(to.fpG4TextPlus? new G4TextPlus(*to.fpG4TextPlus): 0),
113  fMarkerOrPolyline(to.fMarkerOrPolyline)
114 {}
115 
116 G4OpenGLStoredSceneHandler::TO::TO(G4int id, const G4Transform3D& tr):
117  fDisplayListId(id),
118  fTransform(tr),
119  fPickName(0),
120  fStartTime(-DBL_MAX),
121  fEndTime(DBL_MAX),
122  fpG4TextPlus(0),
123  fMarkerOrPolyline(false)
124 {}
125 
126 G4OpenGLStoredSceneHandler::TO::~TO()
127 {
128  delete fpG4TextPlus;
129 }
130 
131 G4OpenGLStoredSceneHandler::TO& G4OpenGLStoredSceneHandler::TO::operator=
132  (const G4OpenGLStoredSceneHandler::TO& rhs)
133 {
134  if (&rhs == this) return *this;
135  fDisplayListId = rhs.fDisplayListId;
136  fTransform = rhs.fTransform;
137  fPickName = rhs.fPickName;
138  fStartTime = rhs.fStartTime;
139  fEndTime = rhs.fEndTime;
140  fColour = rhs.fColour;
141  fpG4TextPlus = rhs.fpG4TextPlus? new G4TextPlus(*rhs.fpG4TextPlus): 0;
142  fMarkerOrPolyline = rhs.fMarkerOrPolyline;
143  return *this;
144 }
145 
146 G4OpenGLStoredSceneHandler::G4OpenGLStoredSceneHandler
147 (G4VGraphicsSystem& system,
148  const G4String& name):
149 G4OpenGLSceneHandler (system, fSceneIdCount++, name),
150 fTopPODL (0)
151 {}
152 
153 G4OpenGLStoredSceneHandler::~G4OpenGLStoredSceneHandler ()
154 {}
155 
156 void G4OpenGLStoredSceneHandler::BeginPrimitives
157 (const G4Transform3D& objectTransformation)
158 {
159  G4OpenGLSceneHandler::BeginPrimitives (objectTransformation);
160  if (fReadyForTransients) glDrawBuffer (GL_FRONT);
161  // Display list setup moved to AddPrimitivePreamble. See notes there.
162 }
163 
164 void G4OpenGLStoredSceneHandler::EndPrimitives ()
165 {
166  // See all primitives immediately... At least soon...
167  ScaledFlush();
168  glDrawBuffer (GL_BACK);
169  G4OpenGLSceneHandler::EndPrimitives ();
170 }
171 
172 void G4OpenGLStoredSceneHandler::BeginPrimitives2D
173 (const G4Transform3D& objectTransformation)
174 {
175  G4OpenGLSceneHandler::BeginPrimitives2D(objectTransformation);
176  if (fReadyForTransients) glDrawBuffer (GL_FRONT);
177 }
178 
179 void G4OpenGLStoredSceneHandler::EndPrimitives2D ()
180 {
181  // See all primitives immediately... At least soon...
182  ScaledFlush();
183  glDrawBuffer (GL_BACK);
184  G4OpenGLSceneHandler::EndPrimitives2D ();
185 }
186 
187 G4bool G4OpenGLStoredSceneHandler::AddPrimitivePreamble(const G4Visible& visible)
188 {
189  const G4Colour& c = GetColour (visible);
190  G4double opacity = c.GetAlpha ();
191 
192  G4bool transparency_enabled = true;
193  G4bool isMarkerNotHidden = true;
194  G4OpenGLViewer* pViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
195  if (pViewer) {
196  transparency_enabled = pViewer->transparency_enabled;
197  isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
198  }
199 
200  G4bool isMarker = false;
201  try {
202  (void) dynamic_cast<const G4VMarker&>(visible);
203  isMarker = true;
204  }
205  catch (std::bad_cast) {}
206 
207  G4bool isPolyline = false;
208  try {
209  (void) dynamic_cast<const G4Polyline&>(visible);
210  isPolyline = true;
211  }
212  catch (std::bad_cast) {}
213 
214  G4bool isTransparent = opacity < 1.;
215  G4bool isMarkerOrPolyline = isMarker || isPolyline;
216  G4bool treatAsTransparent = transparency_enabled && isTransparent;
217  G4bool treatAsNotHidden = isMarkerNotHidden && isMarkerOrPolyline;
218 
219  if (fProcessing2D) glDisable (GL_DEPTH_TEST);
220  else {
221  if (isMarkerOrPolyline && isMarkerNotHidden)
222  glDisable (GL_DEPTH_TEST);
223  else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
224  }
225 
226  if (fThreePassCapable) {
227 
228  // Ensure transparent objects are drawn opaque ones and before
229  // non-hidden markers. The problem of blending/transparency/alpha
230  // is quite a tricky one - see History of opengl-V07-01-01/2/3.
231  if (!(fSecondPassForTransparency || fThirdPassForNonHiddenMarkers)) {
232  // First pass...
233  if (treatAsTransparent) { // Request pass for transparent objects...
234  fSecondPassForTransparencyRequested = true;
235  }
236  if (treatAsNotHidden) { // Request pass for non-hidden markers...
237  fThirdPassForNonHiddenMarkersRequested = true;
238  }
239  // On first pass, transparent objects and non-hidden markers are not drawn...
240  if (treatAsTransparent || treatAsNotHidden) {
241  return false; // No further processing.
242  }
243  }
244 
245  // On second pass, only transparent objects are drawn...
246  if (fSecondPassForTransparency) {
247  if (!treatAsTransparent) {
248  return false; // No further processing.
249  }
250  }
251 
252  // On third pass, only non-hidden markers are drawn...
253  if (fThirdPassForNonHiddenMarkers) {
254  if (!treatAsNotHidden) {
255  return false; // No further processing.
256 
257  }
258  }
259  } // fThreePassCapable
260 
261  // Loads G4Atts for picking...
262  G4bool isPicking = false;
263  if (fpViewer->GetViewParameters().IsPicking()) {
264  isPicking = true;
265  glLoadName(++fPickName);
266  G4AttHolder* holder = new G4AttHolder;
267  LoadAtts(visible, holder);
268  fPickMap[fPickName] = holder;
269  }
270 
271  // Can we re-use a display list?
272  const G4VSolid* pSolid = 0;
273  G4PhysicalVolumeModel* pPVModel =
274  dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
275  if (fpViewer->GetViewParameters().GetVisAttributesModifiers().size())
276  // Touchables have been modified - don't risk re-using display list.
277  goto end_of_display_list_reuse_test;
278  if (pPVModel) {
279  // Check that it isn't a G4LogicalVolumeModel (which is a sub-class of
280  // G4PhysicalVolumeModel).
281  G4LogicalVolumeModel* pLVModel =
282  dynamic_cast<G4LogicalVolumeModel*>(pPVModel);
283  if (pLVModel)
284  // Logical volume model - don't re-use.
285  goto end_of_display_list_reuse_test;
286  // If part of the geometry hierarchy, i.e., from a
287  // G4PhysicalVolumeModel, check if a display list already exists for
288  // this solid, re-use it if possible. We could be smarter, and
289  // recognise repeated branches of the geometry hierarchy, for
290  // example. But this algorithm should be secure, I think...
291  pSolid = pPVModel->GetCurrentPV()->GetLogicalVolume()->GetSolid();
292  EAxis axis = kRho;
293  G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
294  if (pCurrentPV -> IsReplicated ()) {
295  G4int nReplicas;
296  G4double width;
297  G4double offset;
298  G4bool consuming;
299  pCurrentPV->GetReplicationData(axis,nReplicas,width,offset,consuming);
300  }
301  // Provided it is not parametrised (because if so, the
302  // solid's parameters might have been changed)...
303  if (!(pCurrentPV -> IsParameterised ()) &&
304  // Provided it is not replicated radially (because if so, the
305  // solid's parameters will have been changed)...
306  !(pCurrentPV -> IsReplicated () && axis == kRho) &&
307  // ...and if the solid has already been rendered...
308  (fSolidMap.find (pSolid) != fSolidMap.end ())) {
309  fDisplayListId = fSolidMap [pSolid];
310  PO po(fDisplayListId,fObjectTransformation);
311  if (isPicking) po.fPickName = fPickName;
312  po.fColour = c;
313  po.fMarkerOrPolyline = isMarkerOrPolyline;
314  fPOList.push_back(po);
315  // No need to test if gl commands are used (result of
316  // ExtraPOProcessing) because we have already decided they will
317  // not, at least not here. Also, pass a dummy G4Visible since
318  // not relevant for G4PhysicalVolumeModel.
319  (void) ExtraPOProcessing(G4Visible(), fPOList.size() - 1);
320  return false; // No further processing.
321  }
322  }
323 end_of_display_list_reuse_test:
324 
325  // Because of our need to control colour of transients (display by
326  // time fading), display lists may only cover a single primitive.
327  // So display list setup is here.
328 
329  if (fMemoryForDisplayLists) {
330  fDisplayListId = glGenLists (1);
331  if (glGetError() == GL_OUT_OF_MEMORY ||
332  fDisplayListId > fDisplayListLimit) {
333  G4cout <<
334  "********************* WARNING! ********************"
335  "\n* Display list limit reached in OpenGL."
336  "\n* Continuing drawing WITHOUT STORING. Scene only partially refreshable."
337  "\n* Current limit: " << fDisplayListLimit <<
338  ". Change with \"/vis/ogl/set/displayListLimit\"."
339  "\n***************************************************"
340  << G4endl;
341  fMemoryForDisplayLists = false;
342  }
343  }
344 
345  if (pSolid) fSolidMap [pSolid] = fDisplayListId;
346 
347  if (fMemoryForDisplayLists) {
348  if (fReadyForTransients) {
349  TO to(fDisplayListId, fObjectTransformation);
350  if (isPicking) to.fPickName = fPickName;
351  to.fColour = c;
352  const G4VisAttributes* pVA =
353  fpViewer->GetApplicableVisAttributes(visible.GetVisAttributes());
354  to.fStartTime = pVA->GetStartTime();
355  to.fEndTime = pVA->GetEndTime();
356  to.fMarkerOrPolyline = isMarkerOrPolyline;
357  fTOList.push_back(to);
358  // For transient objects, colour, transformation, are kept in
359  // the TO, so should *not* be in the display list. As mentioned
360  // above, in some cases (display-by-time fading) we need to have
361  // independent control of colour. But for now transform and set
362  // colour for immediate display.
363  glPushMatrix();
364  G4OpenGLTransform3D oglt (fObjectTransformation);
365  glMultMatrixd (oglt.GetGLMatrix ());
366  if (transparency_enabled) {
367  glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
368  } else {
369  glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
370  }
371  (void) ExtraTOProcessing(visible, fTOList.size() - 1);
372  // Ignore return value of the above. If this visible does not use
373  // gl commands, a display list is created that is empty and not
374  // used.
375  glNewList (fDisplayListId, GL_COMPILE_AND_EXECUTE);
376  } else {
377  PO po(fDisplayListId, fObjectTransformation);
378  if (isPicking) po.fPickName = fPickName;
379  po.fColour = c;
380  po.fMarkerOrPolyline = isMarkerOrPolyline;
381  fPOList.push_back(po);
382  // For permanent objects, colour is kept in the PO, so should
383  // *not* be in the display list. This is so that sub-classes
384  // may implement colour modifications according to their own
385  // criteria, e.g., scen tree slider in Qt. But for now set
386  // colour for immediate display.
387  if (transparency_enabled) {
388  glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
389  } else {
390  glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
391  }
392  G4bool usesGLCommands = ExtraPOProcessing(visible, fPOList.size() - 1);
393  // Transients are displayed as they come (GL_COMPILE_AND_EXECUTE
394  // above) but persistents are compiled into display lists
395  // (GL_COMPILE only) and then drawn from the display lists with
396  // their fObjectTransformation as stored in fPOList. Thus,
397  // there is no need to do glMultMatrixd here. If
398  // ExtraPOProcessing says the visible object does not use gl
399  // commands, simply return and abandon further processing. It
400  // is assumed that all relevant information is kept in the
401  // POList.
402  if (!usesGLCommands) return false;
403  glNewList (fDisplayListId, GL_COMPILE);
404  }
405  } else { // Out of memory (or being used when display lists not required).
406  glDrawBuffer (GL_FRONT);
407  glPushMatrix();
408  G4OpenGLTransform3D oglt (fObjectTransformation);
409  glMultMatrixd (oglt.GetGLMatrix ());
410  if (transparency_enabled) {
411  glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
412  } else {
413  glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
414  }
415  }
416 
417  if (fProcessing2D) {
418  // Push current 3D world matrices and load identity to define screen
419  // coordinates...
420  glMatrixMode (GL_PROJECTION);
421  glPushMatrix();
422  glLoadIdentity();
423  glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
424  glMatrixMode (GL_MODELVIEW);
425  glPushMatrix();
426  glLoadIdentity();
427  G4OpenGLTransform3D oglt (fObjectTransformation);
428  glMultMatrixd (oglt.GetGLMatrix ());
429  glDisable(GL_DEPTH_TEST); // But see parent scene handler!! In
430  glDisable (GL_LIGHTING); // some cases, we need to re-iterate this.
431  }
432 
433  return true;
434 }
435 
436 void G4OpenGLStoredSceneHandler::AddPrimitivePostamble()
437 {
438  if (fProcessing2D) {
439  // Pop current 3D world matrices back again...
440  glMatrixMode (GL_PROJECTION);
441  glPopMatrix();
442  glMatrixMode (GL_MODELVIEW);
443  glPopMatrix();
444  }
445 
446  // if ((glGetError() == GL_TABLE_TOO_LARGE) || (glGetError() == GL_OUT_OF_MEMORY)) { // Could close?
447  if (glGetError() == GL_OUT_OF_MEMORY) { // Could close?
448  G4cout <<
449  "ERROR: G4OpenGLStoredSceneHandler::AddPrimitivePostamble: Failure"
450  " to allocate display List for fTopPODL - try OpenGL Immediated mode."
451  << G4endl;
452  }
453  if (fMemoryForDisplayLists) {
454  glEndList();
455  if (glGetError() == GL_OUT_OF_MEMORY) { // Could close?
456  G4cout <<
457  "ERROR: G4OpenGLStoredSceneHandler::AddPrimitivePostamble: Failure"
458  " to allocate display List for fTopPODL - try OpenGL Immediated mode."
459  << G4endl;
460  }
461  }
462  if (fReadyForTransients || !fMemoryForDisplayLists) {
463  glPopMatrix();
464  }
465 }
466 
467 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polyline& polyline)
468 {
469  G4bool furtherprocessing = AddPrimitivePreamble(polyline);
470  if (furtherprocessing) {
471  G4OpenGLSceneHandler::AddPrimitive(polyline);
472  AddPrimitivePostamble();
473  }
474 }
475 
476 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
477 {
478  G4bool furtherprocessing = AddPrimitivePreamble(polymarker);
479  if (furtherprocessing) {
480  G4OpenGLSceneHandler::AddPrimitive(polymarker);
481  AddPrimitivePostamble();
482  }
483 }
484 
485 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Text& text)
486 {
487  // Note: colour is still handled in
488  // G4OpenGLSceneHandler::AddPrimitive(const G4Text&), so it still
489  // gets into the display list
490  G4bool furtherprocessing = AddPrimitivePreamble(text);
491  if (furtherprocessing) {
492  G4OpenGLSceneHandler::AddPrimitive(text);
493  AddPrimitivePostamble();
494  }
495 }
496 
497 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Circle& circle)
498 {
499  G4bool furtherprocessing = AddPrimitivePreamble(circle);
500  if (furtherprocessing) {
501  G4OpenGLSceneHandler::AddPrimitive(circle);
502  AddPrimitivePostamble();
503  }
504 }
505 
506 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Square& square)
507 {
508  G4bool furtherprocessing = AddPrimitivePreamble(square);
509  if (furtherprocessing) {
510  G4OpenGLSceneHandler::AddPrimitive(square);
511  AddPrimitivePostamble();
512  }
513 }
514 
515 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Scale& scale)
516 {
517  // Let base class split into primitives.
518  G4OpenGLSceneHandler::AddPrimitive(scale);
519 }
520 
521 void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron)
522 {
523  // Note: colour is still handled in
524  // G4OpenGLSceneHandler::AddPrimitive(const G4Polyhedron&), so it still
525  // gets into the display list
526  G4bool furtherprocessing = AddPrimitivePreamble(polyhedron);
527  if (furtherprocessing) {
528  G4OpenGLSceneHandler::AddPrimitive(polyhedron);
529  AddPrimitivePostamble();
530  }
531 }
532 
533 void G4OpenGLStoredSceneHandler::BeginModeling () {
535  /* Debug...
536  fDisplayListId = glGenLists (1);
537  G4cout << "OGL::fDisplayListId (start): " << fDisplayListId << G4endl;
538  */
539 }
540 
541 void G4OpenGLStoredSceneHandler::EndModeling () {
542  // Make a List which calls the other lists.
543  fTopPODL = glGenLists (1);
544  if (glGetError() == GL_OUT_OF_MEMORY) { // Could pre-allocate?
545  G4cout <<
546  "ERROR: G4OpenGLStoredSceneHandler::EndModeling: Failure to allocate"
547  " display List for fTopPODL - try OpenGL Immediated mode."
548  << G4endl;
549  } else {
550 
551  glNewList (fTopPODL, GL_COMPILE); {
552  for (size_t i = 0; i < fPOList.size (); i++) {
553  glPushMatrix();
554  G4OpenGLTransform3D oglt (fPOList[i].fTransform);
555  glMultMatrixd (oglt.GetGLMatrix ());
556  if (fpViewer->GetViewParameters().IsPicking())
557  glLoadName(fPOList[i].fPickName);
558  glCallList (fPOList[i].fDisplayListId);
559  glPopMatrix();
560  }
561  }
562  glEndList ();
563 
564  if (glGetError() == GL_OUT_OF_MEMORY) { // Could close?
565  G4cout <<
566  "ERROR: G4OpenGLStoredSceneHandler::EndModeling: Failure to allocate"
567  " display List for fTopPODL - try OpenGL Immediated mode."
568  << G4endl;
569  }
570  }
571 
573 }
574 
575 void G4OpenGLStoredSceneHandler::ClearStore () {
576 
577  //G4cout << "G4OpenGLStoredSceneHandler::ClearStore" << G4endl;
578 
579  G4VSceneHandler::ClearStore (); // Sets need kernel visit, etc.
580 
581  // Delete OpenGL permanent display lists.
582  for (size_t i = 0; i < fPOList.size (); i++)
583  glDeleteLists (fPOList[i].fDisplayListId, 1);
584  if (fTopPODL) glDeleteLists (fTopPODL, 1);
585  fTopPODL = 0;
586 
587  // Clear other lists, dictionary, etc.
588  fPOList.clear ();
589  fSolidMap.clear ();
590  ClearAndDestroyAtts();
591 
592  // ...and clear transient store...
593  for (size_t i = 0; i < fTOList.size (); i++)
594  glDeleteLists(fTOList[i].fDisplayListId, 1);
595  fTOList.clear ();
596 
597  fMemoryForDisplayLists = true;
598 }
599 
600 void G4OpenGLStoredSceneHandler::ClearTransientStore ()
601 {
602  //G4cout << "G4OpenGLStoredSceneHandler::ClearTransientStore" << G4endl;
603 
604  // Delete OpenGL transient display lists and Transient Objects themselves.
605  for (size_t i = 0; i < fTOList.size (); i++)
606  glDeleteLists(fTOList[i].fDisplayListId, 1);
607  fTOList.clear ();
608 
609  fMemoryForDisplayLists = true;
610 
611  // Redraw the scene ready for the next event.
612  if (fpViewer) {
613  fpViewer -> SetView ();
614  fpViewer -> ClearView ();
615  fpViewer -> DrawView ();
616  }
617 }
618 
619 G4int G4OpenGLStoredSceneHandler::fSceneIdCount = 0;
620 
621 G4int G4OpenGLStoredSceneHandler::fDisplayListId = 0;
622 G4bool G4OpenGLStoredSceneHandler::fMemoryForDisplayLists = true;
623 G4int G4OpenGLStoredSceneHandler::fDisplayListLimit = 50000;
624 
625 #endif
G4double GetStartTime() const
virtual void ClearStore()
Definition: G4Text.hh:73
G4double GetAlpha() const
Definition: G4Colour.hh:142
virtual void BeginModeling()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
#define width
const XML_Char * name
G4double GetBlue() const
Definition: G4Colour.hh:141
const G4VisAttributes * GetVisAttributes() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4double GetRed() const
Definition: G4Colour.hh:139
bool G4bool
Definition: G4Types.hh:79
G4double GetGreen() const
Definition: G4Colour.hh:140
virtual void EndModeling()
G4LogicalVolume * GetLogicalVolume() const
EAxis
Definition: geomdefs.hh:54
G4double GetEndTime() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Definition: geomdefs.hh:54
G4VPhysicalVolume * GetCurrentPV() const
#define DBL_MAX
Definition: templates.hh:83
G4VSolid * GetSolid() const