Ignore:
Timestamp:
Jun 1, 2010, 6:36:22 PM (14 years ago)
Author:
garnier
Message:

update from CVS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/management/src/G4VisManager.cc

    r1258 r1288  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VisManager.cc,v 1.124 2010/05/11 11:02:19 allison Exp $
     26// $Id: G4VisManager.cc,v 1.128 2010/06/01 16:08:15 allison Exp $
    2727// GEANT4 tag $Name:  $
    2828//
     
    7979G4VisManager* G4VisManager::fpInstance = 0;
    8080
    81 G4VisManager::G4VisManager ():
     81G4VisManager::Verbosity G4VisManager::fVerbosity = G4VisManager::warnings;
     82
     83G4VisManager::G4VisManager (const G4String& verbosityString):
    8284  fVerbose         (1),
    8385  fInitialised     (false),
     
    8789  fpSceneHandler   (0),
    8890  fpViewer         (0),
    89   fVerbosity       (warnings),
    9091  fpStateDependent (0),
    9192  fEventRefreshing          (false),
     
    101102  fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories");
    102103  fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits");
     104  fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi");
    103105
    104106  VerbosityGuidanceStrings.push_back
     
    123125      ("G4VisManager: attempt to Construct more than one VisManager.");
    124126  }
    125   else {
    126 
    127     fpInstance = this;
    128     SetConcreteInstance(this);
    129 
    130     fpStateDependent = new G4VisStateDependent (this);
    131     // No need to delete this; G4StateManager does this.
    132 
    133     if (fVerbosity >= startup) {
    134       G4cout << "Visualization Manager instantiating..." << G4endl;
    135     }
    136 
    137     // Note: The specific graphics systems must be instantiated in a
    138     // higher level library to avoid circular dependencies.  Also,
    139     // some specifically need additional external libararies that the
    140     // user must supply.  Therefore we ask the user to implement
    141     // RegisterGraphicsSystems() and RegisterModelFactories()
    142     // in a subclass.  We have to wait for the subclass to instantiate
    143     // so RegisterGraphicsSystems() cannot be called from this
    144     // constructor; it is called from Initialise().  So we ask the
    145     // user:
    146     //   (a) to write a subclass and implement  RegisterGraphicsSystems()
    147     //       and RegisterModelFactories().  See
    148     //       visualization/include/G4VisExecutive.hh/icc as an example.
    149     //   (b) instantiate the subclass.
    150     //   (c) invoke the Initialise() method of the subclass.
    151     // For example:
    152     //   ...
    153     // #ifdef G4VIS_USE
    154     //   // Instantiate and initialise Visualization Manager.
    155     //   G4VisManager* visManager = new G4VisExecutive;
    156     //   visManager -> SetVerboseLevel (Verbose);
    157     //   visManager -> Initialise ();
    158     // #endif
    159     //   // (Don't forget to delete visManager;)
    160     //   ...
    161 
    162     // Make top level command directory...
    163     G4UIcommand* directory;
    164     directory = new G4UIdirectory ("/vis/");
    165     directory -> SetGuidance ("Visualization commands.");
    166     fDirectoryList.push_back (directory);
    167 
    168     // Instantiate top level basic commands
    169     G4VVisCommand::SetVisManager (this);  // Sets shared pointer
    170     RegisterMessenger(new G4VisCommandVerbose);
    171     RegisterMessenger(new G4VisCommandInitialize);
    172   }
     127
     128  fpInstance = this;
     129  SetConcreteInstance(this);
     130
     131  fpStateDependent = new G4VisStateDependent (this);
     132  // No need to delete this; G4StateManager does this.
     133
     134  fVerbosity = GetVerbosityValue(verbosityString);
     135  if (fVerbosity >= startup) {
     136      G4cout
     137        << "Visualization Manager instantiating with verbosity \""
     138        << VerbosityString(fVerbosity)
     139        << "\"..." << G4endl;
     140  }
     141
     142  // Note: The specific graphics systems must be instantiated in a
     143  // higher level library to avoid circular dependencies.  Also,
     144  // some specifically need additional external libararies that the
     145  // user must supply.  Therefore we ask the user to implement
     146  // RegisterGraphicsSystems() and RegisterModelFactories()
     147  // in a subclass.  We have to wait for the subclass to instantiate
     148  // so RegisterGraphicsSystems() cannot be called from this
     149  // constructor; it is called from Initialise().  So we ask the
     150  // user:
     151  //   (a) to write a subclass and implement  RegisterGraphicsSystems()
     152  //       and RegisterModelFactories().  See
     153  //       visualization/include/G4VisExecutive.hh/icc as an example.
     154  //   (b) instantiate the subclass.
     155  //   (c) invoke the Initialise() method of the subclass.
     156  // For example:
     157  //   ...
     158  // #ifdef G4VIS_USE
     159  //   // Instantiate and initialise Visualization Manager.
     160  //   G4VisManager* visManager = new G4VisExecutive;
     161  //   visManager -> SetVerboseLevel (Verbose);
     162  //   visManager -> Initialise ();
     163  // #endif
     164  //   // (Don't forget to delete visManager;)
     165  //   ...
     166
     167  // Make top level command directory...
     168  G4UIcommand* directory;
     169  directory = new G4UIdirectory ("/vis/");
     170  directory -> SetGuidance ("Visualization commands.");
     171  fDirectoryList.push_back (directory);
     172
     173  // Instantiate top level basic commands
     174  G4VVisCommand::SetVisManager (this);  // Sets shared pointer
     175  RegisterMessenger(new G4VisCommandVerbose);
     176  RegisterMessenger(new G4VisCommandInitialize);
    173177}
    174178
     
    200204  }
    201205
     206  delete fpDigiFilterMgr;
     207  delete fpHitFilterMgr;
     208  delete fpTrajFilterMgr;
    202209  delete fpTrajDrawModelMgr;
    203   delete fpTrajFilterMgr;
    204   delete fpHitFilterMgr;
    205210}
    206211
     
    288293  directory -> SetGuidance ("Create hit filters and messengers.");
    289294  fDirectoryList.push_back (directory);
     295  directory = new G4UIdirectory ("/vis/filtering/digi/");
     296  directory -> SetGuidance ("Digi filtering commands.");
     297  fDirectoryList.push_back (directory);
     298  directory = new G4UIdirectory ("/vis/filtering/digi/create/");
     299  directory -> SetGuidance ("Create digi filters and messengers.");
     300  fDirectoryList.push_back (directory);
    290301
    291302  RegisterMessengers ();
     
    436447}
    437448
     449void G4VisManager::RegisterModel(G4VFilter<G4VDigi>* model)
     450{
     451  fpDigiFilterMgr->Register(model);
     452}
     453
     454void
     455G4VisManager::RegisterModelFactory(G4DigiFilterFactory* factory)
     456{
     457  fpDigiFilterMgr->Register(factory);
     458}
     459
    438460void G4VisManager::SelectTrajectoryModel(const G4String& model)
    439461{
     
    613635    ClearTransientStoreIfMarked();
    614636    fpSceneHandler -> AddCompound (hit);
     637  }
     638}
     639
     640void G4VisManager::Draw (const G4VDigi& digi) {
     641  if (IsValidView ()) {
     642    ClearTransientStoreIfMarked();
     643    fpSceneHandler -> AddCompound (digi);
    615644  }
    616645}
     
    872901}   
    873902
     903G4bool G4VisManager::FilterDigi(const G4VDigi& digi)
     904{
     905  return fpDigiFilterMgr->Accept(digi);
     906}   
     907
     908void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory)
     909{
     910  G4bool visible(true);
     911
     912  // See if trajectory passes filter
     913  G4bool passed = FilterTrajectory(trajectory);
     914
     915  if (!passed) {
     916    // Draw invisible trajectory if trajectory failed filter and
     917    // are filtering in soft mode
     918    if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false;
     919    else {return;}
     920  }
     921
     922  // Go on to draw trajectory
     923  assert (0 != fpTrajDrawModelMgr);
     924
     925  const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
     926
     927  assert (0 != trajectoryModel); // Should exist
     928
     929  trajectoryModel->Draw(trajectory, visible);
     930}
     931
    874932void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode)
    875933{
     
    902960    }
    903961  } else {
    904     //G4Exception("G4VisManager::DispatchToModel: Not a G4TrajectoriesModel.");
    905962    // Just draw at user's request
    906963    trajectoryModel->Draw(trajectory, i_mode, visible);
    907     static G4bool warnedAboutIMode = false;
    908     if (!warnedAboutIMode) {
    909       G4Exception
    910         ("G4VisManager::DispatchToModel",
    911          "",
    912          JustWarning,
    913   "WARNING: DEPRECATED: The use of the i_mode argument in DrawTrajectory"
    914   "\n  is deprecated and will be removed at the next major release.");
    915       warnedAboutIMode = true;
    916     }
    917    }
    918 }
     964  }
     965}
    919966
    920967void G4VisManager::SetUserAction
     
    11051152  RegisterMessenger(new G4VisCommandSceneAddGhosts);
    11061153  RegisterMessenger(new G4VisCommandSceneAddHits);
     1154  RegisterMessenger(new G4VisCommandSceneAddDigis);
    11071155  RegisterMessenger(new G4VisCommandSceneAddLogicalVolume);
    11081156  RegisterMessenger(new G4VisCommandSceneAddLogo);
     
    11661214  RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VHit> >
    11671215                    (fpHitFilterMgr, fpHitFilterMgr->Placement()));
     1216
     1217  // Digi filter manager commands
     1218  RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VDigi> >
     1219                    (fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
     1220  RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VDigi> >
     1221                    (fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
    11681222}
    11691223
     
    14021456        "  Only useful if before starting the run:"
    14031457        "\n    a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or"
    1404         "\n    b) the Draw method of any hits is implemented."
    1405         "\n  To view trajectories and hits:"
     1458        "\n    b) the Draw method of any hits or digis is implemented."
     1459        "\n  To view trajectories, hits or digis:"
    14061460        "\n    open a viewer, draw a volume, \"/vis/scene/add/trajectories\""
    1407         "\n    \"/vis/scene/add/hits\" and, possibly, \"/vis/viewer/flush\"."
     1461        "\n    \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\""
     1462        "\n    and, possibly, \"/vis/viewer/flush\"."
    14081463        "\n  To see all events: \"/vis/scene/endOfEventAction accumulate\"."
    14091464        "\n  To see events individually: \"/vis/reviewKeptEvents\"."
Note: See TracChangeset for help on using the changeset viewer.