From e1f62005038b0c0783041a14aaeb74c3b032e1bf Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Wed, 19 Jun 2013 17:20:57 +0000
Subject: [PATCH]   - enable visualization for ILDExSimu   - add some debug
 output to Geant4Converter.cpp     -> visualization works in principle       
 but screen stays black         -> issue w/ visualization attributes ??

---
 DDExamples/ILDExSimu/CMakeLists.txt |  4 +++-
 DDExamples/ILDExSimu/ILDExSimu.cpp  | 20 ++++++++++++--------
 DDG4/CMakeLists.txt                 |  4 ++--
 DDG4/src/Geant4Converter.cpp        | 13 +++++++++++++
 4 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/DDExamples/ILDExSimu/CMakeLists.txt b/DDExamples/ILDExSimu/CMakeLists.txt
index f5fc20735..faad5ea76 100644
--- a/DDExamples/ILDExSimu/CMakeLists.txt
+++ b/DDExamples/ILDExSimu/CMakeLists.txt
@@ -1,12 +1,14 @@
 cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
 
-find_package(Geant4 REQUIRED)
+find_package(Geant4 REQUIRED ui_all vis_all)
 ##---Handle the case CLHEP is not included in Geant4------------------------------
 #if(NOT Geant4_clhep_FOUND)
 #  find_package(CLHEP REQUIRED)
 #  set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS})
 #  set(Geant4_LIBRARIES ${Geant4_LIBRARIES} ${CLHEP_LIBRARIES})
 #endif()
+INCLUDE(${Geant4_USE_FILE})   # this also takes care of geant 4 definitions and include dirs
+
 
 find_package(LCIO REQUIRED) 
 
diff --git a/DDExamples/ILDExSimu/ILDExSimu.cpp b/DDExamples/ILDExSimu/ILDExSimu.cpp
index 34b4ae80b..e3c3f458d 100644
--- a/DDExamples/ILDExSimu/ILDExSimu.cpp
+++ b/DDExamples/ILDExSimu/ILDExSimu.cpp
@@ -108,21 +108,25 @@ int main(int argc,char** argv)
   
   G4UImanager* UImanager = G4UImanager::GetUIpointer();
   
-  if ( argc!=1) {   // batch mode
+  // if ( argc > 3 ) {   // batch mode
 
-    G4String command = "/control/execute ";
-    G4String fileName = argv[argc-1];
-    UImanager->ApplyCommand(command+fileName);    
+  //   G4String command = "/control/execute ";
+  //   G4String fileName = argv[argc-1];
+  //   UImanager->ApplyCommand(command+fileName);    
 
-  } else {  // interactive mode : define UI session
+  //  } else {  // interactive mode : define UI session
     
-    G4UIsession *ui = new G4UIterminal(new G4UItcsh());
-    //    G4UIsession* ui = new G4UIQt(argc, argv);
+  //G4UIsession *ui = new G4UIterminal(new G4UItcsh());
+  //G4UIsession* ui = new G4UIQt(argc, argv);
+  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
+
+
+
     ui->SessionStart();
     // end ...
     delete ui;
     
-  }
+    //}
   
   // Job termination
   // Free the store: user actions, physics_list and detector_description are
diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt
index ed0fe8dd2..d8f198ef2 100644
--- a/DDG4/CMakeLists.txt
+++ b/DDG4/CMakeLists.txt
@@ -1,6 +1,6 @@
 #---Find Geant4-------------------------------------------------------------------
 
-find_package(Geant4 REQUIRED)
+find_package(Geant4 REQUIRED gdml ui_all vis_all)
 #if(NOT Geant4_clhep_FOUND)
 #  find_package(CLHEP REQUIRED)
 #  set(Geant4_INCLUDE_DIRS ${Geant4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS})
@@ -42,4 +42,4 @@ install(TARGETS DD4hepG4
   LIBRARY DESTINATION lib
   )
 # to do: add corresponding uninstall...
-#-------------------------------------------------------
\ No newline at end of file
+#-------------------------------------------------------
diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp
index c0b285c16..5c4aab8af 100644
--- a/DDG4/src/Geant4Converter.cpp
+++ b/DDG4/src/Geant4Converter.cpp
@@ -81,6 +81,7 @@ using namespace DD4hep::Geometry;
 using namespace DD4hep;
 using namespace std;
 
+
 namespace {
   static TGeoNode* s_topPtr;
   static string indent = "";
@@ -381,6 +382,18 @@ void* Geant4Converter::handleVolume(const string& name, const TGeoVolume* volume
     }
     if ( vis.isValid() ) {
       vis_attr = (G4VisAttributes*)handleVis(vis.name(),vis.ptr());
+
+      if(  std::string(vis.name())  == "WorldVis" ){ 
+
+	printout(INFO,"Geant4Converter","************** vis.name() == \"WorldVis\" " ) ;
+	vis_attr->SetVisibility(true)  ;
+      }
+
+      printout(INFO,"Geant4Converter","**************  (G4VisAttributes*)handleVis( %s , 0x%x )   =   %d ", vis.name() ,
+	       vis.ptr(), vis_attr->IsVisible() ) ;
+
+
+
     }
     Region    reg = _v.region();
     G4Region* region = 0;
-- 
GitLab