Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HepRepViewer.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 // $Id: G4HepRepViewer.cc 68043 2013-03-13 14:27:49Z gcosmo $
27 //
28 
29 /**
30  * @author Mark Donszelmann
31  */
32 
33 //HepRep
34 #include "HEPREP/HepRep.h"
35 
36 //G4
37 #include "G4Types.hh"
38 //#include "G4VInteractorManager.hh"
39 #include "G4Scene.hh"
40 #include "G4HepRep.hh"
41 #include "G4HepRepMessenger.hh"
42 #include "G4HepRepSceneHandler.hh"
43 //This
44 #include "G4HepRepViewer.hh"
45 
46 using namespace HEPREP;
47 using namespace std;
48 
50  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name),
51  geometryIncluded(false) {
52 
53 #ifdef SDEBUG
54  cout << "G4HepRepViewer::G4HepRepViewer " << name << endl;
55 #endif
56 
57  // Make changes to view parameters for HepRep...
58  fVP.SetCulling(false);
59  fDefaultVP.SetCulling(false);
60 }
61 
62 
63 
65 #ifdef SDEBUG
66  cout << "G4HepRepViewer::~G4HepRepViewer" << endl;
67 #endif
68  G4HepRep* pHepRepSystem =
69  dynamic_cast<G4HepRep*>(GetSceneHandler()->GetGraphicsSystem());
70  if (pHepRepSystem) pHepRepSystem->removeViewer();
71 }
72 
73 
75 #ifdef SDEBUG
76  cout << "G4HepRepViewer::ClearView" << endl;
77 #endif
78 }
79 
81 #ifdef SDEBUG
82  cout << "G4HepRepViewer::SetView" << endl;
83 #endif
84 }
85 
86 
87 /* NOTE:
88  /run/beamOn calls ShowView for every event (unless accumulate is set)
89  /vis/viewer/flush calls /vis/viewer/refresh followed by /vis/viewer/update
90  /vis/viewer/refresh calls SetView, ClearView, DrawView
91  /vis/viewer/update calls ShowView
92 */
94 #ifdef SDEBUG
95  cout << "G4HepRepViewer::DrawView" << endl;
96 #endif
97  if (!geometryIncluded) {
98  // draws the geometry
100  ProcessView();
101  geometryIncluded = true;
102  }
103 }
104 
106 #ifdef SDEBUG
107  cout << "G4HepRepViewer::ShowView" << endl;
108 #endif
110 
111  G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler());
112  if (sceneHandler) {
113  if (sceneHandler->closeHepRep()) {
114  sceneHandler->openHepRep();
115 
117  if (messenger->appendGeometry()) geometryIncluded = false;
118  }
119  }
120 }
121 
123 #ifdef SDEBUG
124  cout << "G4HepRepViewer::FinishView" << endl;
125 #endif
127 }
128 
130  geometryIncluded = false;
131 }
bool closeHepRep(bool final=false)
virtual void ShowView()
Definition: G4VViewer.cc:113
const XML_Char * name
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:145
static G4HepRepMessenger * GetInstance()
G4VGraphicsSystem * GetGraphicsSystem() const
G4ViewParameters fVP
Definition: G4VViewer.hh:144
virtual G4bool appendGeometry()
void removeViewer()
Definition: G4HepRep.cc:84
G4VSceneHandler * GetSceneHandler() const
virtual ~G4HepRepViewer()
void NeedKernelVisit()
Definition: G4VViewer.cc:86
void ProcessView()
Definition: G4VViewer.cc:115
G4HepRepViewer(G4VSceneHandler &scene, const G4String &name="")
void SetCulling(G4bool)
virtual void FinishView()
Definition: G4VViewer.cc:111