G4VisCommandReviewKeptEvents Class Reference

#include <G4VisCommands.hh>

Inheritance diagram for G4VisCommandReviewKeptEvents:

G4VVisCommand G4UImessenger

Public Member Functions

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

Detailed Description

Definition at line 88 of file G4VisCommands.hh.


Constructor & Destructor Documentation

G4VisCommandReviewKeptEvents::G4VisCommandReviewKeptEvents (  ) 

Definition at line 197 of file G4VisCommands.cc.

00198 {
00199   G4bool omitable;
00200 
00201   fpCommand = new G4UIcmdWithAString("/vis/reviewKeptEvents", this);
00202   fpCommand -> SetGuidance("Review kept events.");
00203   fpCommand -> SetGuidance
00204     ("If a macro file is specified, it is executed for each event.");
00205   fpCommand -> SetGuidance(
00206   "If a macro file is not specified, each event is drawn to the current"
00207   "\nviewer.  After each event, the session is paused.  The user may issue"
00208   "\nany allowed command.  Then enter \"cont[inue]\" to continue to the next"
00209   "\nevent."
00210   "\nUseful commands might be:"
00211   "\n  \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
00212   "\n  \"/vis/oglx/printEPS\" to get hard copy."
00213   "\n  \"/vis/open\" to get alternative viewer."
00214   "\n  \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort.");
00215   fpCommand -> SetParameterName("macro-file-name", omitable=true);
00216   fpCommand -> SetDefaultValue("");
00217 }

G4VisCommandReviewKeptEvents::~G4VisCommandReviewKeptEvents (  )  [virtual]

Definition at line 219 of file G4VisCommands.cc.

00220 {
00221   delete fpCommand;
00222 }


Member Function Documentation

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

Reimplemented from G4UImessenger.

Definition at line 224 of file G4VisCommands.cc.

00225 {
00226   return "";
00227 }

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

Reimplemented from G4UImessenger.

Definition at line 229 of file G4VisCommands.cc.

References G4UImanager::ApplyCommand(), G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetAbortReviewKeptEvents(), G4RunManager::GetCurrentRun(), G4VisManager::GetCurrentScene(), G4VisManager::GetCurrentViewer(), G4Run::GetEventVector(), G4Scene::GetRefreshAtEndOfEvent(), G4RunManager::GetRunManager(), G4UImanager::GetSession(), G4UImanager::GetUIpointer(), G4UImanager::GetVerboseLevel(), G4VisManager::GetVerbosity(), G4VisManager::SetAbortReviewKeptEvents(), G4Scene::SetRefreshAtEndOfEvent(), G4VisManager::SetRequestedEvent(), G4UImanager::SetVerboseLevel(), and G4VisManager::warnings.

00230 {
00231   static bool reviewing = false;
00232   if (reviewing) {
00233     G4cout <<
00234       "\"/vis/reviewKeptEvents\" not allowed within an already started review."
00235       "\n  No action taken."
00236            << G4endl;
00237     return;
00238   }
00239 
00240   G4String& macroFileName = newValue;
00241   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00242 
00243   G4RunManager* runManager = G4RunManager::GetRunManager();
00244   const G4Run* run = runManager? runManager->GetCurrentRun(): 0;
00245   const std::vector<const G4Event*>* events = run? run->GetEventVector(): 0;
00246   size_t nKeptEvents = events? events->size(): 0;
00247 
00248   if (!nKeptEvents) {
00249     if (verbosity >= G4VisManager::errors) {
00250       G4cout <<
00251         "ERROR: G4VisCommandReviewKeptEvents::SetNewValue: No kept events,"
00252         "\n  or kept events not accessible."
00253              << G4endl;
00254     }
00255     return;
00256   }
00257 
00258   G4VViewer* viewer = fpVisManager->GetCurrentViewer();
00259   if (!viewer) {
00260     if (verbosity >= G4VisManager::errors) {
00261       G4cout <<
00262   "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
00263              << G4endl;
00264     }
00265     return;
00266   }
00267 
00268   G4Scene* pScene = fpVisManager->GetCurrentScene();
00269   if (!pScene) {
00270     if (verbosity >= G4VisManager::errors) {
00271       G4cout << "ERROR: No current scene.  Please create one." << G4endl;
00272     }
00273     return;
00274   }
00275 
00276   G4UImanager* UImanager = G4UImanager::GetUIpointer();
00277   G4int keepVerbose = UImanager->GetVerboseLevel();
00278   G4int newVerbose(0);
00279   if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
00280     newVerbose = 2;
00281   UImanager->SetVerboseLevel(newVerbose);
00282 
00283   // Event by event refreshing...
00284   reviewing  = true;
00285   G4bool currentRefreshAtEndOfEvent = pScene->GetRefreshAtEndOfEvent();
00286   pScene->SetRefreshAtEndOfEvent(true);
00287   if (macroFileName.empty()) {
00288 
00289     // Draw to viewer and pause session...
00290     G4UIsession* session = UImanager->GetSession();
00291     for (size_t i = 0; i < nKeptEvents; ++i) {
00292       const G4Event* event = (*events)[i];
00293       if (verbosity >= G4VisManager::warnings) {
00294         G4cout << "Drawing event : " << event->GetEventID() <<
00295           ".  At EndOfEvent, enter any command, then \"cont[inue]\"..."
00296                << G4endl;
00297         static G4bool first = true;
00298         if (first) {
00299           first = false;
00300           G4cout <<
00301   "  Useful commands might be:"
00302   "\n    \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
00303   "\n    \"/vis/oglx/printEPS\" to get hard copy."
00304   "\n    \"/vis/open\" to get alternative viewer."
00305   "\n    \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort."
00306                  << G4endl;
00307         }
00308       }
00309       fpVisManager->SetRequestedEvent(event);
00310       UImanager->ApplyCommand("/vis/viewer/rebuild");
00311       /* The above command forces a rebuild of the scene, including
00312          the detector.  This is fine for "immediate" viewers - a
00313          refresh requires a rebuild anyway.  But for "stored mode"
00314          viewers, you could, in principle, avoid a rebuild of the
00315          detector with something like the following:
00316       sceneHandler->ClearTransientStore();
00317       viewer->DrawView();
00318       sceneHandler->DrawEvent(event);
00319          but this causes mayhem for "immediate" viewers because
00320          ClearTransientStore issues a DrawView and some curious sort
00321          of recursion takes place.  For "stored" viewers, the event
00322          gets drawn but not the eventID, so something odd is happening
00323          there too.  This needs further investigation - enhanced
00324          features or a complete re-think.
00325       */
00326       UImanager->ApplyCommand("/vis/viewer/flush");
00327       session->PauseSessionStart("EndOfEvent");
00328       fpVisManager->SetRequestedEvent(0);
00329       if (fpVisManager->GetAbortReviewKeptEvents()) break;
00330     }
00331     fpVisManager->SetAbortReviewKeptEvents(false);
00332 
00333   } else {
00334 
00335     // Execute macro file...
00336     for (size_t i = 0; i < nKeptEvents; ++i) {
00337       const G4Event* event = (*events)[i];
00338       if (verbosity >= G4VisManager::warnings) {
00339         G4cout << "Drawing event : " << event->GetEventID()
00340                << " with macro file \"" << macroFileName << G4endl;
00341       }
00342       fpVisManager->SetRequestedEvent(event);
00343       UImanager->ApplyCommand("/control/execute " + macroFileName);
00344       fpVisManager->SetRequestedEvent(0);
00345     }
00346   }
00347   pScene->SetRefreshAtEndOfEvent(currentRefreshAtEndOfEvent);
00348   reviewing  = false;
00349 
00350   UImanager->SetVerboseLevel(keepVerbose);
00351 }


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