Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentLineWidth = 1.
 
static
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 78 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction ( )

Definition at line 253 of file G4VisCommandsScene.cc.

253  {
254  G4bool omitable;
255  fpCommand = new G4UIcommand ("/vis/scene/endOfEventAction", this);
256  fpCommand -> SetGuidance
257  ("Accumulate or refresh the viewer for each new event.");
258  fpCommand -> SetGuidance
259  ("\"accumulate\": viewer accumulates hits, etc., event by event, or");
260  fpCommand -> SetGuidance
261  ("\"refresh\": viewer shows them at end of event or, for direct-screen"
262  "\n viewers, refreshes the screen just before drawing the next event.");
263  G4UIparameter* parameter;
264  parameter = new G4UIparameter ("action", 's', omitable = true);
265  parameter -> SetParameterCandidates ("accumulate refresh");
266  parameter -> SetDefaultValue ("refresh");
267  fpCommand -> SetParameter (parameter);
268  parameter = new G4UIparameter ("maxNumber", 'i', omitable = true);
269  parameter -> SetDefaultValue (100);
270  parameter -> SetGuidance
271  ("Maximum number of events kept. Unlimited if negative.");
272  fpCommand -> SetParameter (parameter);
273 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneEndOfEventAction::~G4VisCommandSceneEndOfEventAction ( )
virtual

Definition at line 275 of file G4VisCommandsScene.cc.

275  {
276  delete fpCommand;
277 }

Member Function Documentation

G4String G4VisCommandSceneEndOfEventAction::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 279 of file G4VisCommandsScene.cc.

279  {
280  return "";
281 }
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.

284  {
285 
287 
288  G4String action;
289  G4int maxNumberOfKeptEvents;
290  std::istringstream is (newValue);
291  is >> action >> maxNumberOfKeptEvents;
292 
293  G4Scene* pScene = fpVisManager->GetCurrentScene();
294  if (!pScene) {
295  if (verbosity >= G4VisManager::errors) {
296  G4cout << "ERROR: No current scene. Please create one." << G4endl;
297  }
298  return;
299  }
300 
302  if (!pSceneHandler) {
303  if (verbosity >= G4VisManager::errors) {
304  G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
305  }
306  return;
307  }
308 
309  if (action == "accumulate") {
310  pScene->SetRefreshAtEndOfEvent(false);
311  pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
312  }
313  else if (action == "refresh") {
314  if (!pScene->GetRefreshAtEndOfRun()) {
315  if (verbosity >= G4VisManager::errors) {
316  G4cout <<
317  "ERROR: Cannot refresh events unless runs refresh too."
318  "\n Use \"/vis/scene/endOfRun refresh\"."
319  << G4endl;
320  }
321  } else {
322  pScene->SetRefreshAtEndOfEvent(true);
323  pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
324  pSceneHandler->SetMarkForClearingTransientStore(true);
325  }
326  }
327  else {
328  if (verbosity >= G4VisManager::errors) {
329  G4cout <<
330  "ERROR: unrecognised parameter \"" << action << "\"."
331  << G4endl;
332  }
333  return;
334  }
335 
336  // Change of transients behaviour, so...
338 
339  // Are there any events currently kept...
340  size_t nCurrentlyKept = 0;
342  if (runManager) {
343  const G4Run* currentRun = runManager->GetCurrentRun();
344  if (currentRun) {
345  const std::vector<const G4Event*>* events =
346  currentRun->GetEventVector();
347  if (events) nCurrentlyKept = events->size();
348  }
349  }
350 
351  if (verbosity >= G4VisManager::confirmations) {
352  G4cout << "End of event action set to ";
353  if (pScene->GetRefreshAtEndOfEvent()) G4cout << "\"refresh\".";
354  else {
355  G4cout << "\"accumulate\"."
356  "\n Maximum number of events to be kept: "
357  << maxNumberOfKeptEvents
358  << " (unlimited if negative)."
359  "\n This may be changed with, e.g., "
360  "\"/vis/scene/endOfEventAction accumulate 1000\".";
361  }
362  G4cout << G4endl;
363  }
364 
365  if (!pScene->GetRefreshAtEndOfEvent() &&
366  maxNumberOfKeptEvents != 0 &&
367  verbosity >= G4VisManager::warnings) {
368  G4cout << "WARNING: ";
369  if (nCurrentlyKept) {
370  G4cout <<
371  "\n There are currently " << nCurrentlyKept
372  << " events kept for refreshing and/or reviewing.";
373  } else {
374  G4cout << "The vis manager will keep ";
375  if (maxNumberOfKeptEvents < 0) G4cout << "an unlimited number of";
376  else G4cout << "up to " << maxNumberOfKeptEvents;
377  G4cout << " events.";
378  if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
379  G4cout <<
380  "\n This may use a lot of memory."
381  "\n It may be changed with, e.g., "
382  "\"/vis/scene/endOfEventAction accumulate 10\".";
383  }
384  G4cout << G4endl;
385  }
386 }
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:115
G4bool GetRefreshAtEndOfEvent() const
int G4int
Definition: G4Types.hh:78
const G4Run * GetCurrentRun() const
G4GLOB_DLL std::ostream G4cout
void SetMaxNumberOfKeptEvents(G4int)
G4bool GetRefreshAtEndOfRun() const
void ResetTransientsDrawnFlags()
Definition: G4Run.hh:46
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
void SetMarkForClearingTransientStore(G4bool)
G4Scene * GetCurrentScene() const
void SetRefreshAtEndOfEvent(G4bool)
static G4VisManager * fpVisManager

The documentation for this class was generated from the following files: