Index: trunk/source/visualization/management/src/G4VisManager.cc
===================================================================
--- trunk/source/visualization/management/src/G4VisManager.cc	(revision 1258)
+++ trunk/source/visualization/management/src/G4VisManager.cc	(revision 1288)
@@ -24,5 +24,5 @@
 // ********************************************************************
 //
-// $Id: G4VisManager.cc,v 1.124 2010/05/11 11:02:19 allison Exp $
+// $Id: G4VisManager.cc,v 1.128 2010/06/01 16:08:15 allison Exp $
 // GEANT4 tag $Name:  $
 //
@@ -79,5 +79,7 @@
 G4VisManager* G4VisManager::fpInstance = 0;
 
-G4VisManager::G4VisManager ():
+G4VisManager::Verbosity G4VisManager::fVerbosity = G4VisManager::warnings;
+
+G4VisManager::G4VisManager (const G4String& verbosityString):
   fVerbose         (1),
   fInitialised     (false),
@@ -87,5 +89,4 @@
   fpSceneHandler   (0),
   fpViewer         (0),
-  fVerbosity       (warnings),
   fpStateDependent (0),
   fEventRefreshing          (false),
@@ -101,4 +102,5 @@
   fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories");
   fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits");
+  fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi");
 
   VerbosityGuidanceStrings.push_back
@@ -123,52 +125,54 @@
       ("G4VisManager: attempt to Construct more than one VisManager.");
   }
-  else {
-
-    fpInstance = this;
-    SetConcreteInstance(this);
-
-    fpStateDependent = new G4VisStateDependent (this);
-    // No need to delete this; G4StateManager does this.
-
-    if (fVerbosity >= startup) {
-      G4cout << "Visualization Manager instantiating..." << G4endl;
-    }
-
-    // Note: The specific graphics systems must be instantiated in a
-    // higher level library to avoid circular dependencies.  Also,
-    // some specifically need additional external libararies that the
-    // user must supply.  Therefore we ask the user to implement
-    // RegisterGraphicsSystems() and RegisterModelFactories()
-    // in a subclass.  We have to wait for the subclass to instantiate
-    // so RegisterGraphicsSystems() cannot be called from this
-    // constructor; it is called from Initialise().  So we ask the
-    // user:
-    //   (a) to write a subclass and implement  RegisterGraphicsSystems()
-    //       and RegisterModelFactories().  See
-    //       visualization/include/G4VisExecutive.hh/icc as an example.
-    //   (b) instantiate the subclass.
-    //   (c) invoke the Initialise() method of the subclass.
-    // For example:
-    //   ...
-    // #ifdef G4VIS_USE
-    //   // Instantiate and initialise Visualization Manager.
-    //   G4VisManager* visManager = new G4VisExecutive;
-    //   visManager -> SetVerboseLevel (Verbose);
-    //   visManager -> Initialise ();
-    // #endif
-    //   // (Don't forget to delete visManager;)
-    //   ...
-
-    // Make top level command directory...
-    G4UIcommand* directory;
-    directory = new G4UIdirectory ("/vis/");
-    directory -> SetGuidance ("Visualization commands.");
-    fDirectoryList.push_back (directory);
-
-    // Instantiate top level basic commands
-    G4VVisCommand::SetVisManager (this);  // Sets shared pointer
-    RegisterMessenger(new G4VisCommandVerbose);
-    RegisterMessenger(new G4VisCommandInitialize);
-  }
+
+  fpInstance = this;
+  SetConcreteInstance(this);
+
+  fpStateDependent = new G4VisStateDependent (this);
+  // No need to delete this; G4StateManager does this.
+
+  fVerbosity = GetVerbosityValue(verbosityString);
+  if (fVerbosity >= startup) {
+      G4cout
+	<< "Visualization Manager instantiating with verbosity \""
+	<< VerbosityString(fVerbosity)
+	<< "\"..." << G4endl;
+  }
+
+  // Note: The specific graphics systems must be instantiated in a
+  // higher level library to avoid circular dependencies.  Also,
+  // some specifically need additional external libararies that the
+  // user must supply.  Therefore we ask the user to implement
+  // RegisterGraphicsSystems() and RegisterModelFactories()
+  // in a subclass.  We have to wait for the subclass to instantiate
+  // so RegisterGraphicsSystems() cannot be called from this
+  // constructor; it is called from Initialise().  So we ask the
+  // user:
+  //   (a) to write a subclass and implement  RegisterGraphicsSystems()
+  //       and RegisterModelFactories().  See
+  //       visualization/include/G4VisExecutive.hh/icc as an example.
+  //   (b) instantiate the subclass.
+  //   (c) invoke the Initialise() method of the subclass.
+  // For example:
+  //   ...
+  // #ifdef G4VIS_USE
+  //   // Instantiate and initialise Visualization Manager.
+  //   G4VisManager* visManager = new G4VisExecutive;
+  //   visManager -> SetVerboseLevel (Verbose);
+  //   visManager -> Initialise ();
+  // #endif
+  //   // (Don't forget to delete visManager;)
+  //   ...
+
+  // Make top level command directory...
+  G4UIcommand* directory;
+  directory = new G4UIdirectory ("/vis/");
+  directory -> SetGuidance ("Visualization commands.");
+  fDirectoryList.push_back (directory);
+
+  // Instantiate top level basic commands
+  G4VVisCommand::SetVisManager (this);  // Sets shared pointer
+  RegisterMessenger(new G4VisCommandVerbose);
+  RegisterMessenger(new G4VisCommandInitialize);
 }
 
@@ -200,7 +204,8 @@
   }
 
+  delete fpDigiFilterMgr;
+  delete fpHitFilterMgr;
+  delete fpTrajFilterMgr;
   delete fpTrajDrawModelMgr;
-  delete fpTrajFilterMgr;
-  delete fpHitFilterMgr;
 }
 
@@ -288,4 +293,10 @@
   directory -> SetGuidance ("Create hit filters and messengers.");
   fDirectoryList.push_back (directory);
+  directory = new G4UIdirectory ("/vis/filtering/digi/");
+  directory -> SetGuidance ("Digi filtering commands.");
+  fDirectoryList.push_back (directory);
+  directory = new G4UIdirectory ("/vis/filtering/digi/create/");
+  directory -> SetGuidance ("Create digi filters and messengers.");
+  fDirectoryList.push_back (directory);
 
   RegisterMessengers ();
@@ -436,4 +447,15 @@
 }
 
+void G4VisManager::RegisterModel(G4VFilter<G4VDigi>* model)
+{
+  fpDigiFilterMgr->Register(model);
+}
+
+void
+G4VisManager::RegisterModelFactory(G4DigiFilterFactory* factory)
+{
+  fpDigiFilterMgr->Register(factory);
+}
+
 void G4VisManager::SelectTrajectoryModel(const G4String& model) 
 {
@@ -613,4 +635,11 @@
     ClearTransientStoreIfMarked();
     fpSceneHandler -> AddCompound (hit);
+  }
+}
+
+void G4VisManager::Draw (const G4VDigi& digi) {
+  if (IsValidView ()) {
+    ClearTransientStoreIfMarked();
+    fpSceneHandler -> AddCompound (digi);
   }
 }
@@ -872,4 +901,33 @@
 }   
 
+G4bool G4VisManager::FilterDigi(const G4VDigi& digi)
+{
+  return fpDigiFilterMgr->Accept(digi);
+}   
+
+void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory)
+{
+  G4bool visible(true);
+
+  // See if trajectory passes filter
+  G4bool passed = FilterTrajectory(trajectory);
+
+  if (!passed) {
+    // Draw invisible trajectory if trajectory failed filter and
+    // are filtering in soft mode
+    if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false;
+    else {return;}
+  }
+
+  // Go on to draw trajectory
+  assert (0 != fpTrajDrawModelMgr);
+
+  const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
+
+  assert (0 != trajectoryModel); // Should exist
+
+  trajectoryModel->Draw(trajectory, visible);
+}
+
 void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode)
 {
@@ -902,19 +960,8 @@
     }
   } else {
-    //G4Exception("G4VisManager::DispatchToModel: Not a G4TrajectoriesModel.");
     // Just draw at user's request
     trajectoryModel->Draw(trajectory, i_mode, visible);
-    static G4bool warnedAboutIMode = false;
-    if (!warnedAboutIMode) {
-      G4Exception
-        ("G4VisManager::DispatchToModel",
-         "",
-         JustWarning,
-  "WARNING: DEPRECATED: The use of the i_mode argument in DrawTrajectory"
-  "\n  is deprecated and will be removed at the next major release.");
-      warnedAboutIMode = true;
-    }
-   }
-} 
+  }
+}
 
 void G4VisManager::SetUserAction
@@ -1105,4 +1152,5 @@
   RegisterMessenger(new G4VisCommandSceneAddGhosts);
   RegisterMessenger(new G4VisCommandSceneAddHits);
+  RegisterMessenger(new G4VisCommandSceneAddDigis);
   RegisterMessenger(new G4VisCommandSceneAddLogicalVolume);
   RegisterMessenger(new G4VisCommandSceneAddLogo);
@@ -1166,4 +1214,10 @@
   RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VHit> >
                     (fpHitFilterMgr, fpHitFilterMgr->Placement()));
+
+  // Digi filter manager commands
+  RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VDigi> >
+                    (fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
+  RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VDigi> >
+                    (fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
 }
 
@@ -1402,8 +1456,9 @@
 	"  Only useful if before starting the run:"
 	"\n    a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or"
-	"\n    b) the Draw method of any hits is implemented."
-	"\n  To view trajectories and hits:"
+	"\n    b) the Draw method of any hits or digis is implemented."
+	"\n  To view trajectories, hits or digis:"
 	"\n    open a viewer, draw a volume, \"/vis/scene/add/trajectories\""
-	"\n    \"/vis/scene/add/hits\" and, possibly, \"/vis/viewer/flush\"."
+	"\n    \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\""
+	"\n    and, possibly, \"/vis/viewer/flush\"."
 	"\n  To see all events: \"/vis/scene/endOfEventAction accumulate\"."
 	"\n  To see events individually: \"/vis/reviewKeptEvents\"."
