ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HepRepViewer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4HepRepViewer.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 
32 //HepRep
33 #include "HEPREP/HepRep.h"
34 
35 //G4
36 #include "G4Types.hh"
37 //#include "G4VInteractorManager.hh"
38 #include "G4Scene.hh"
39 #include "G4HepRep.hh"
40 #include "G4HepRepMessenger.hh"
41 #include "G4HepRepSceneHandler.hh"
42 //This
43 #include "G4HepRepViewer.hh"
44 
45 using namespace HEPREP;
46 using namespace std;
47 
49  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name),
50  geometryIncluded(false) {
51 
52 #ifdef SDEBUG
53  cout << "G4HepRepViewer::G4HepRepViewer " << name << endl;
54 #endif
55 
56  // Make changes to view parameters for HepRep...
57  fVP.SetCulling(false);
58  fDefaultVP.SetCulling(false);
59 }
60 
61 
62 
64 #ifdef SDEBUG
65  cout << "G4HepRepViewer::~G4HepRepViewer" << endl;
66 #endif
67  G4HepRep* pHepRepSystem =
68  dynamic_cast<G4HepRep*>(GetSceneHandler()->GetGraphicsSystem());
69  if (pHepRepSystem) pHepRepSystem->removeViewer();
70 }
71 
72 
74 #ifdef SDEBUG
75  cout << "G4HepRepViewer::ClearView" << endl;
76 #endif
77 }
78 
80 #ifdef SDEBUG
81  cout << "G4HepRepViewer::SetView" << endl;
82 #endif
83 }
84 
85 
86 /* NOTE:
87  /run/beamOn calls ShowView for every event (unless accumulate is set)
88  /vis/viewer/flush calls /vis/viewer/refresh followed by /vis/viewer/update
89  /vis/viewer/refresh calls SetView, ClearView, DrawView
90  /vis/viewer/update calls ShowView
91 */
93 #ifdef SDEBUG
94  cout << "G4HepRepViewer::DrawView" << endl;
95 #endif
96  if (!geometryIncluded) {
97  // draws the geometry
99  ProcessView();
100  geometryIncluded = true;
101  }
102 }
103 
105 #ifdef SDEBUG
106  cout << "G4HepRepViewer::ShowView" << endl;
107 #endif
109 
110  G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler());
111  if (sceneHandler) {
112  if (sceneHandler->closeHepRep()) {
113  sceneHandler->openHepRep();
114 
116  if (messenger->appendGeometry()) geometryIncluded = false;
117  }
118  }
119 }
120 
122 #ifdef SDEBUG
123  cout << "G4HepRepViewer::FinishView" << endl;
124 #endif
126 }
127 
129  geometryIncluded = false;
130 }