- Timestamp:
- Jun 1, 2010, 6:36:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/management/src/G4VisManager.cc
r1258 r1288 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VisManager.cc,v 1.12 4 2010/05/11 11:02:19allison Exp $26 // $Id: G4VisManager.cc,v 1.128 2010/06/01 16:08:15 allison Exp $ 27 27 // GEANT4 tag $Name: $ 28 28 // … … 79 79 G4VisManager* G4VisManager::fpInstance = 0; 80 80 81 G4VisManager::G4VisManager (): 81 G4VisManager::Verbosity G4VisManager::fVerbosity = G4VisManager::warnings; 82 83 G4VisManager::G4VisManager (const G4String& verbosityString): 82 84 fVerbose (1), 83 85 fInitialised (false), … … 87 89 fpSceneHandler (0), 88 90 fpViewer (0), 89 fVerbosity (warnings),90 91 fpStateDependent (0), 91 92 fEventRefreshing (false), … … 101 102 fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories"); 102 103 fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits"); 104 fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi"); 103 105 104 106 VerbosityGuidanceStrings.push_back … … 123 125 ("G4VisManager: attempt to Construct more than one VisManager."); 124 126 } 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); 173 177 } 174 178 … … 200 204 } 201 205 206 delete fpDigiFilterMgr; 207 delete fpHitFilterMgr; 208 delete fpTrajFilterMgr; 202 209 delete fpTrajDrawModelMgr; 203 delete fpTrajFilterMgr;204 delete fpHitFilterMgr;205 210 } 206 211 … … 288 293 directory -> SetGuidance ("Create hit filters and messengers."); 289 294 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); 290 301 291 302 RegisterMessengers (); … … 436 447 } 437 448 449 void G4VisManager::RegisterModel(G4VFilter<G4VDigi>* model) 450 { 451 fpDigiFilterMgr->Register(model); 452 } 453 454 void 455 G4VisManager::RegisterModelFactory(G4DigiFilterFactory* factory) 456 { 457 fpDigiFilterMgr->Register(factory); 458 } 459 438 460 void G4VisManager::SelectTrajectoryModel(const G4String& model) 439 461 { … … 613 635 ClearTransientStoreIfMarked(); 614 636 fpSceneHandler -> AddCompound (hit); 637 } 638 } 639 640 void G4VisManager::Draw (const G4VDigi& digi) { 641 if (IsValidView ()) { 642 ClearTransientStoreIfMarked(); 643 fpSceneHandler -> AddCompound (digi); 615 644 } 616 645 } … … 872 901 } 873 902 903 G4bool G4VisManager::FilterDigi(const G4VDigi& digi) 904 { 905 return fpDigiFilterMgr->Accept(digi); 906 } 907 908 void 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 874 932 void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode) 875 933 { … … 902 960 } 903 961 } else { 904 //G4Exception("G4VisManager::DispatchToModel: Not a G4TrajectoriesModel.");905 962 // Just draw at user's request 906 963 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 } 919 966 920 967 void G4VisManager::SetUserAction … … 1105 1152 RegisterMessenger(new G4VisCommandSceneAddGhosts); 1106 1153 RegisterMessenger(new G4VisCommandSceneAddHits); 1154 RegisterMessenger(new G4VisCommandSceneAddDigis); 1107 1155 RegisterMessenger(new G4VisCommandSceneAddLogicalVolume); 1108 1156 RegisterMessenger(new G4VisCommandSceneAddLogo); … … 1166 1214 RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VHit> > 1167 1215 (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())); 1168 1222 } 1169 1223 … … 1402 1456 " Only useful if before starting the run:" 1403 1457 "\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:" 1406 1460 "\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\"." 1408 1463 "\n To see all events: \"/vis/scene/endOfEventAction accumulate\"." 1409 1464 "\n To see events individually: \"/vis/reviewKeptEvents\"."
Note: See TracChangeset
for help on using the changeset viewer.