]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TGeant4/TG4VisManager.cxx
Enable clusterizing from any Digits branch
[u/mrichter/AliRoot.git] / TGeant4 / TG4VisManager.cxx
index e06460f25e2562598fdbf1b269d281d1e1086a2b..bec0f48948de6b687a48a13c7bdd339347c7aff3 100644 (file)
@@ -1,6 +1,11 @@
 // $Id$
 // Category: visualization
 //
+// Author: I. Hrivnacova, A. Gheata
+//
+// Class TG4VisManager
+// -------------------
+// See the class description in the header file.
 // According to visualization/management/include/MyVisManager.*
 // John Allison 24th January 1998.
 // I. Hrivnacova 12.5.98
 #include <G4VRML2File.hh>
 #endif
 
-TG4VisManager::TG4VisManager(G4int verboseLevel) {
+//_____________________________________________________________________________
+TG4VisManager::TG4VisManager(G4int verboseLevel)
+  : fVerboseLevel(0) {
 //  
-  fVerbose = verboseLevel; 
+  fVerboseLevel = verboseLevel; 
   fColourFlag = true;
 }
 
+//_____________________________________________________________________________
 TG4VisManager::TG4VisManager(const TG4VisManager& right) {
 // 
   TG4Globals::Exception(
     "Attempt to copy TG4VisManager singleton.");
 }
 
+//_____________________________________________________________________________
 TG4VisManager::~TG4VisManager() {
 //
 }  
 
 // operators
 
+//_____________________________________________________________________________
 TG4VisManager& TG4VisManager::operator=(const TG4VisManager& right) 
 {
   // check assignement to self
@@ -125,6 +135,7 @@ TG4VisManager& TG4VisManager::operator=(const TG4VisManager& right)
           
 // private methods
 
+//_____________________________________________________________________________
 void TG4VisManager::RegisterGraphicsSystems() 
 {
 // Registers the graphics systems.
@@ -182,7 +193,7 @@ void TG4VisManager::RegisterGraphicsSystems()
   RegisterGraphicsSystem(new G4VRML2File);
 #endif
 
-  if (fVerbose > 0) {
+  if (fVerboseLevel > 0) {
     G4cout <<
       "\nYou have successfully chosen to use the following graphics systems."
         << G4endl;
@@ -194,8 +205,39 @@ void TG4VisManager::RegisterGraphicsSystems()
 // private methods
 //---------------------------------------------------------------
 
+//_____________________________________________________________________________
+G4bool TG4VisManager::Contains(const LogicalVolumesVector& lvVector,
+                               const G4LogicalVolume* lv) const
+{
+// Returns true if the vector contains specified logical volume.
+// ---
+
+  LogicalVolumesVector::const_iterator i;
 
-G4RWTPtrOrderedVector<G4LogicalVolume> TG4VisManager::GetLVList(G4String name)
+  for (i = lvVector.begin(); i != lvVector.end(); i++) 
+    if (*i == lv) return true;
+
+  return false;
+}
+
+//_____________________________________________________________________________
+G4bool TG4VisManager::Contains(const PhysicalVolumesVector& pvVector,
+                               const G4VPhysicalVolume* pv) const
+{
+// Returns true if the vector contains specified physical volume.
+// ---
+
+  PhysicalVolumesVector::const_iterator i;
+
+  for (i = pvVector.begin(); i != pvVector.end(); i++) 
+    if (*i == pv) return true;
+
+  return false;
+}
+
+//_____________________________________________________________________________
+LogicalVolumesVector TG4VisManager::GetLVList(G4String name)
 {
 // Get function returning the list of logical volumes
 // associated to NAME; G4 built clones of a G3 volume (identified 
@@ -203,7 +245,7 @@ G4RWTPtrOrderedVector<G4LogicalVolume> TG4VisManager::GetLVList(G4String name)
 //  NAME can be the name of a logical or physical volume
 // ---
 
G4RWTPtrOrderedVector <G4LogicalVolume> lvList;
LogicalVolumesVector lvList;
  G4LogicalVolumeStore* pLVStore = G4LogicalVolumeStore::GetInstance();
  G4LogicalVolume* pLV = 0; 
  if (pLVStore)
@@ -213,11 +255,12 @@ G4RWTPtrOrderedVector<G4LogicalVolume> TG4VisManager::GetLVList(G4String name)
      pLV = (*pLVStore)[i];  
      if (CaseInsensitiveEqual(name,pLV->GetName())) 
      {
-       if (!lvList.contains(pLV)) lvList.append(pLV);
+       if (!Contains(lvList, pLV)) lvList.push_back(pLV);
      }
    }
  }  
- if (!lvList.isEmpty()) return lvList;
+ if (lvList.size()>0) return lvList;
+
  G4PhysicalVolumeStore* pPVStore = G4PhysicalVolumeStore::GetInstance();
  G4VPhysicalVolume* pPV = 0;
  if (pPVStore) 
@@ -228,7 +271,7 @@ G4RWTPtrOrderedVector<G4LogicalVolume> TG4VisManager::GetLVList(G4String name)
      if (CaseInsensitiveEqual(name,pPV->GetName())) 
      {
        pLV = pPV->GetLogicalVolume();
-       if (!lvList.contains(pLV)) lvList.append(pLV);
+       if (!Contains(lvList, pLV)) lvList.push_back(pLV);
      }     
    }
  }  
@@ -236,12 +279,13 @@ G4RWTPtrOrderedVector<G4LogicalVolume> TG4VisManager::GetLVList(G4String name)
 }
 
 
-G4RWTPtrOrderedVector<G4VPhysicalVolume> TG4VisManager::GetPVList(G4String name)
+//_____________________________________________________________________________
+PhysicalVolumesVector TG4VisManager::GetPVList(G4String name)
 {
 // Get function returning the physical volume pointer for NAME
 // ---
 
-  G4RWTPtrOrderedVector <G4VPhysicalVolume> pvList;
+  PhysicalVolumesVector pvList;
   G4PhysicalVolumeStore* pPVStore = G4PhysicalVolumeStore::GetInstance();
   if (!pPVStore)
   {
@@ -254,13 +298,14 @@ G4RWTPtrOrderedVector<G4VPhysicalVolume> TG4VisManager::GetPVList(G4String name)
     pPV = (*pPVStore)[i];
     if (CaseInsensitiveEqual(name,pPV->GetName()))
     {
-      if (!pvList.contains(pPV)) pvList.append(pPV);
+      if (!Contains(pvList, pPV)) pvList.push_back(pPV);
     }  
   }
   return pvList;
 }
 
 
+//_____________________________________________________________________________
 G4bool TG4VisManager::CaseInsensitiveEqual(const G4String string1,
                                           const G4String string2)
 {
@@ -284,6 +329,7 @@ G4bool TG4VisManager::CaseInsensitiveEqual(const G4String string1,
 }
  
 
+//_____________________________________________________________________________
 void TG4VisManager::SetAtt4Daughters(G4LogicalVolume* const lv, 
                                     const TG4G3Attribute att, const G4int val)
 {
@@ -311,6 +357,7 @@ void TG4VisManager::SetAtt4Daughters(G4LogicalVolume* const lv,
 }
 
 
+//_____________________________________________________________________________
 G4bool TG4VisManager::IsSharedVisAttributes(const G4LogicalVolume* pLV)
 {
 // Function seeking if the volume's visible attributes are shared with
@@ -336,6 +383,7 @@ G4bool TG4VisManager::IsSharedVisAttributes(const G4LogicalVolume* pLV)
 }
 
 
+//_____________________________________________________________________________
 void TG4VisManager::SetG4Attribute(G4LogicalVolume* const lv,
                                   const TG4G3Attribute att, const G4int val)
 {
@@ -420,7 +468,7 @@ void TG4VisManager::SetG4Attribute(G4LogicalVolume* const lv,
     case 3:
      lineStyle = G4VisAttributes::dotted; break;
     default:
-     if (fVerbose > 0)
+     if (fVerboseLevel > 0)
       G4cout << "TG4VisManager::Gsatt() Usage of LSTY :" << G4endl
             << "ATT = 1,2,3 means line unbroken, dashed or dotted" << G4endl
             << "any other value resets to the default : unbroken" << G4endl;
@@ -430,7 +478,7 @@ void TG4VisManager::SetG4Attribute(G4LogicalVolume* const lv,
   case kLWID:
    lineWidth = kAbsVal;
    if (lineWidth > 7) lineWidth = 7;
-   if (fVerbose > 0) 
+   if (fVerboseLevel > 0) 
        G4cout << "TG4VisManager::Gsatt() Usage for LWID :" << G4endl
               << "  The VAL you supply means the width of lines in pixels "
              << "for the screen and in 0.1*mm for paper." << G4endl
@@ -515,7 +563,7 @@ void TG4VisManager::SetG4Attribute(G4LogicalVolume* const lv,
      drawingStyle = G4VisAttributes::solid;
      break;
     default:
-     if (fVerbose > 0)
+     if (fVerboseLevel > 0)
          G4cout << "TG4VisManager::Gsatt() FILL usage :" << G4endl
                << "  The FILL values you can supply are only :" << G4endl
                << "+/- 1 : forces wireframe drawing (default)" << G4endl
@@ -543,6 +591,8 @@ void TG4VisManager::SetG4Attribute(G4LogicalVolume* const lv,
 // functions for drawing
 //-----------------------------------------------------------------
 
+
+//_____________________________________________________________________________
 void TG4VisManager::DrawOneSpec(const char* name)
 {
 // Function called when one double-clicks on a volume name
@@ -553,6 +603,7 @@ void TG4VisManager::DrawOneSpec(const char* name)
 }
 
 
+//_____________________________________________________________________________
 void TG4VisManager::SetColors()
 {
 // Function for setting default volume colours
@@ -632,6 +683,7 @@ void TG4VisManager::SetColors()
 } 
   
 
+//_____________________________________________________________________________
 void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
 {
 // Geant3 description :
@@ -647,7 +699,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
 
  G4int ival = val;
  G4LogicalVolume* lv = 0; 
G4RWTPtrOrderedVector<G4LogicalVolume> lvList;
LogicalVolumesVector lvList;
  G4String sname(name),
           satt(att);           
 
@@ -714,7 +766,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
 
  // get the logical volume pointer corresponding to NAME
  lvList = GetLVList(name);
- if (lvList.isEmpty())
+ if (lvList.size()==0)
  {
      G4String message = "TG4VisManager::Gsatt(): Ignored\n";
      message += "    Logical volume " + sname + " has not been found.\n";
@@ -724,7 +776,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
 // set attribute for all descendents
  if (doForDaughters)
  {
-   for (G4int i=0; i<lvList.entries(); i++)
+   for (G4int i=0; i<lvList.size(); i++)
    {
      lv = lvList[i];
      SetAtt4Daughters(lv,attribute,ival);
@@ -732,7 +784,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
  }
  else
  {
-   for (G4int i=0; i<lvList.entries(); i++)
+   for (G4int i=0; i<lvList.size(); i++)
    {
      lv = lvList[i];
      SetG4Attribute(lv,attribute,ival);
@@ -740,7 +792,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
  }
  if (topVisible) 
  {
-   for (G4int i=0; i<lvList.entries(); i++)
+   for (G4int i=0; i<lvList.size(); i++)
    {
      lv = lvList[i];
      SetG4Attribute(lv,attribute,1); 
@@ -749,6 +801,7 @@ void TG4VisManager::Gsatt(const char* name, const char* att, Int_t val)
 } 
 
 
+//_____________________________________________________________________________
 void TG4VisManager::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t psi,
                    Float_t u0,Float_t v0,Float_t ul,Float_t vl)
 { 
@@ -780,12 +833,12 @@ void TG4VisManager::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t p
   }
   
   const G4double kRad = M_PI/180.;
-  G4RWTPtrOrderedVector<G4VPhysicalVolume> pvList;
+  PhysicalVolumesVector pvList;
   G4String sname(name);
   G4bool  successful           = false;
 
   pvList = GetPVList(name);
-  if (pvList.isEmpty())
+  if (pvList.size()==0)
   {
     G4String message = "TG4VisManager::Gdraw() :\n";
     message += "Volume " + sname + " not found. Bailing out";
@@ -801,8 +854,8 @@ void TG4VisManager::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t p
   // create and add object's model list to the runtime-duration model 
   // list and draw it
   // (it is deleted in the VisManager destructor within 
-  // all the RWTPtrOrderedVectors of the scene)
-  for (G4int i=0; i<pvList.entries(); i++)
+  // all the vectors of the scene)
+  for (G4int i=0; i<pvList.size(); i++)
   { 
     pPV = pvList[i];
     G4LogicalVolume* pLV = pPV->GetLogicalVolume();
@@ -826,16 +879,17 @@ void TG4VisManager::Gdraw(const char *name,Float_t theta, Float_t phi, Float_t p
 
   // set and register view parameters to the viewer
   
-  fVP.SetLightsMoveWithCamera(true);
-  fVP.SetViewGeom();
-  fVP.UnsetViewHits();
-  fVP.UnsetViewDigis();
-  fVP.SetNoOfSides(48);
-  fVP.SetCurrentTargetPoint(kTargetPoint);
-  fVP.SetViewpointDirection(viewpointDirection);
-  fVP.SetUpVector(upVector);
-  fVP.SetDensityCulling(true);
-  fpViewer->SetViewParameters(fVP);
+  G4ViewParameters vp;;
+  vp.SetLightsMoveWithCamera(true);
+  vp.SetViewGeom();
+  vp.UnsetViewHits();
+  vp.UnsetViewDigis();
+  vp.SetNoOfSides(48);
+  vp.SetCurrentTargetPoint(kTargetPoint);
+  vp.SetViewpointDirection(viewpointDirection);
+  vp.SetUpVector(upVector);
+  vp.SetDensityCulling(true);
+  fpViewer->SetViewParameters(vp);
 
   if (IsValidView())
   {