G4VisCommandSceneEndOfEventAction Class Reference

#include <G4VisCommandsScene.hh>

Inheritance diagram for G4VisCommandSceneEndOfEventAction:

G4VVisCommandScene G4VVisCommand G4UImessenger

Public Member Functions

 G4VisCommandSceneEndOfEventAction ()
virtual ~G4VisCommandSceneEndOfEventAction ()
G4String GetCurrentValue (G4UIcommand *command)
void SetNewValue (G4UIcommand *command, G4String newValue)

Detailed Description

Definition at line 78 of file G4VisCommandsScene.hh.


Constructor & Destructor Documentation

G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction (  ) 

Definition at line 253 of file G4VisCommandsScene.cc.

00253                                                                       {
00254   G4bool omitable;
00255   fpCommand = new G4UIcommand ("/vis/scene/endOfEventAction", this);
00256   fpCommand -> SetGuidance
00257     ("Accumulate or refresh the viewer for each new event.");
00258   fpCommand -> SetGuidance
00259     ("\"accumulate\": viewer accumulates hits, etc., event by event, or");
00260   fpCommand -> SetGuidance
00261     ("\"refresh\": viewer shows them at end of event or, for direct-screen"
00262      "\n  viewers, refreshes the screen just before drawing the next event.");
00263   G4UIparameter* parameter;
00264   parameter = new G4UIparameter ("action", 's', omitable = true);
00265   parameter -> SetParameterCandidates ("accumulate refresh");
00266   parameter -> SetDefaultValue ("refresh");
00267   fpCommand -> SetParameter (parameter);
00268   parameter = new G4UIparameter ("maxNumber", 'i', omitable = true);
00269   parameter -> SetDefaultValue (100);
00270   parameter -> SetGuidance
00271   ("Maximum number of events kept.  Unlimited if negative.");
00272   fpCommand -> SetParameter (parameter);
00273 }

G4VisCommandSceneEndOfEventAction::~G4VisCommandSceneEndOfEventAction (  )  [virtual]

Definition at line 275 of file G4VisCommandsScene.cc.

00275                                                                        {
00276   delete fpCommand;
00277 }


Member Function Documentation

G4String G4VisCommandSceneEndOfEventAction::GetCurrentValue ( G4UIcommand command  )  [virtual]

Reimplemented from G4UImessenger.

Definition at line 279 of file G4VisCommandsScene.cc.

00279                                                                         {
00280   return "";
00281 }

void G4VisCommandSceneEndOfEventAction::SetNewValue ( G4UIcommand command,
G4String  newValue 
) [virtual]

Reimplemented from G4UImessenger.

Definition at line 283 of file G4VisCommandsScene.cc.

References G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4RunManager::GetCurrentRun(), G4VisManager::GetCurrentScene(), G4VisManager::GetCurrentSceneHandler(), G4Run::GetEventVector(), G4Scene::GetRefreshAtEndOfEvent(), G4Scene::GetRefreshAtEndOfRun(), G4RunManager::GetRunManager(), G4VisManager::GetVerbosity(), G4VisManager::ResetTransientsDrawnFlags(), G4VSceneHandler::SetMarkForClearingTransientStore(), G4Scene::SetMaxNumberOfKeptEvents(), G4Scene::SetRefreshAtEndOfEvent(), and G4VisManager::warnings.

00284                                                                         {
00285 
00286   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00287 
00288   G4String action;
00289   G4int maxNumberOfKeptEvents;
00290   std::istringstream is (newValue);
00291   is >> action >> maxNumberOfKeptEvents;
00292 
00293   G4Scene* pScene = fpVisManager->GetCurrentScene();
00294   if (!pScene) {
00295     if (verbosity >= G4VisManager::errors) {
00296       G4cout << "ERROR: No current scene.  Please create one." << G4endl;
00297     }
00298     return;
00299   }
00300 
00301   G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
00302   if (!pSceneHandler) {
00303     if (verbosity >= G4VisManager::errors) {
00304       G4cout << "ERROR: No current sceneHandler.  Please create one." << G4endl;
00305     }
00306     return;
00307   }
00308 
00309   if (action == "accumulate") {
00310     pScene->SetRefreshAtEndOfEvent(false);
00311     pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
00312   }
00313   else if (action == "refresh") {
00314     if (!pScene->GetRefreshAtEndOfRun()) {
00315       if (verbosity >= G4VisManager::errors) {
00316         G4cout <<
00317           "ERROR: Cannot refresh events unless runs refresh too."
00318           "\n  Use \"/vis/scene/endOfRun refresh\"."
00319                << G4endl;
00320       }
00321     } else {
00322       pScene->SetRefreshAtEndOfEvent(true);
00323       pSceneHandler->SetMarkForClearingTransientStore(true);
00324     }
00325   }
00326   else {
00327     if (verbosity >= G4VisManager::errors) {
00328       G4cout <<
00329         "ERROR: unrecognised parameter \"" << action << "\"."
00330              << G4endl;
00331     }
00332     return;
00333   }
00334 
00335   // Change of transients behaviour, so...
00336   fpVisManager->ResetTransientsDrawnFlags();
00337 
00338   // Are there any events currently kept...
00339   size_t nCurrentlyKept = 0;
00340   G4RunManager* runManager = G4RunManager::GetRunManager();
00341   if (runManager) {
00342     const G4Run* currentRun = runManager->GetCurrentRun();
00343     if (currentRun) {
00344       const std::vector<const G4Event*>* events =
00345         currentRun->GetEventVector();
00346       if (events) nCurrentlyKept = events->size();
00347     }
00348   }
00349 
00350   if (verbosity >= G4VisManager::confirmations) {
00351     G4cout << "End of event action set to ";
00352     if (pScene->GetRefreshAtEndOfEvent()) G4cout << "\"refresh\".";
00353     else {
00354       G4cout << "\"accumulate\"."
00355         "\n  Maximum number of events to be kept: "
00356              << maxNumberOfKeptEvents
00357              << " (unlimited if negative)."
00358         "\n  This may be changed with, e.g., "
00359         "\"/vis/scene/endOfEventAction accumulate 1000\".";
00360     }
00361     G4cout << G4endl;
00362   }
00363 
00364   if (!pScene->GetRefreshAtEndOfEvent() &&
00365       maxNumberOfKeptEvents != 0 &&
00366       verbosity >= G4VisManager::warnings) {
00367     G4cout << "WARNING: ";
00368     if (nCurrentlyKept) {
00369       G4cout <<
00370         "\n  There are currently " << nCurrentlyKept
00371              << " events kept for refreshing and/or reviewing.";
00372     } else {
00373       G4cout << "The vis manager will keep ";
00374       if (maxNumberOfKeptEvents < 0) G4cout << "an unlimited number of";
00375       else G4cout << "up to " << maxNumberOfKeptEvents;
00376       G4cout << " events.";
00377       if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
00378         G4cout <<
00379           "\n  This may use a lot of memory."
00380           "\n  It may be changed with, e.g., "
00381           "\"/vis/scene/endOfEventAction accumulate 10\".";
00382     }
00383     G4cout << G4endl;
00384   }
00385 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:45 2013 for Geant4 by  doxygen 1.4.7