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