00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // $Id$ 00027 // 00028 00033 //HepRep 00034 #include "HEPREP/HepRep.h" 00035 00036 //G4 00037 #include "G4Types.hh" 00038 //#include "G4VInteractorManager.hh" 00039 #include "G4Scene.hh" 00040 #include "G4HepRep.hh" 00041 #include "G4HepRepMessenger.hh" 00042 #include "G4HepRepSceneHandler.hh" 00043 //This 00044 #include "G4HepRepViewer.hh" 00045 00046 using namespace HEPREP; 00047 using namespace std; 00048 00049 G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, const G4String& name) 00050 : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name), 00051 geometryIncluded(false) { 00052 00053 #ifdef SDEBUG 00054 cout << "G4HepRepViewer::G4HepRepViewer " << name << endl; 00055 #endif 00056 00057 // Make changes to view parameters for HepRep... 00058 fVP.SetCulling(false); 00059 fDefaultVP.SetCulling(false); 00060 } 00061 00062 00063 00064 G4HepRepViewer::~G4HepRepViewer () { 00065 #ifdef SDEBUG 00066 cout << "G4HepRepViewer::~G4HepRepViewer" << endl; 00067 #endif 00068 dynamic_cast<G4HepRep*>(GetSceneHandler()->GetGraphicsSystem())->removeViewer(); 00069 } 00070 00071 00072 void G4HepRepViewer::ClearView () { 00073 #ifdef SDEBUG 00074 cout << "G4HepRepViewer::ClearView" << endl; 00075 #endif 00076 } 00077 00078 void G4HepRepViewer::SetView () { 00079 #ifdef SDEBUG 00080 cout << "G4HepRepViewer::SetView" << endl; 00081 #endif 00082 } 00083 00084 00085 /* NOTE: 00086 /run/beamOn calls ShowView for every event (unless accumulate is set) 00087 /vis/viewer/flush calls /vis/viewer/refresh followed by /vis/viewer/update 00088 /vis/viewer/refresh calls SetView, ClearView, DrawView 00089 /vis/viewer/update calls ShowView 00090 */ 00091 void G4HepRepViewer::DrawView () { 00092 #ifdef SDEBUG 00093 cout << "G4HepRepViewer::DrawView" << endl; 00094 #endif 00095 if (!geometryIncluded) { 00096 // draws the geometry 00097 NeedKernelVisit(); 00098 ProcessView(); 00099 geometryIncluded = true; 00100 } 00101 } 00102 00103 void G4HepRepViewer::ShowView () { 00104 #ifdef SDEBUG 00105 cout << "G4HepRepViewer::ShowView" << endl; 00106 #endif 00107 G4VViewer::ShowView(); 00108 00109 G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler()); 00110 if (sceneHandler->closeHepRep()) { 00111 sceneHandler->openHepRep(); 00112 00113 G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance(); 00114 if (messenger->appendGeometry()) geometryIncluded = false; 00115 } 00116 } 00117 00118 void G4HepRepViewer::FinishView () { 00119 #ifdef SDEBUG 00120 cout << "G4HepRepViewer::FinishView" << endl; 00121 #endif 00122 G4VViewer::FinishView(); 00123 } 00124 00125 void G4HepRepViewer::reset() { 00126 geometryIncluded = false; 00127 }