Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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)
 
- 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 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 88 of file G4VisCommands.hh.

Constructor & Destructor Documentation

G4VisCommandReviewKeptEvents::G4VisCommandReviewKeptEvents ( )

Definition at line 197 of file G4VisCommands.cc.

198 {
199  G4bool omitable;
200 
201  fpCommand = new G4UIcmdWithAString("/vis/reviewKeptEvents", this);
202  fpCommand -> SetGuidance("Review kept events.");
203  fpCommand -> SetGuidance
204  ("If a macro file is specified, it is executed for each event.");
205  fpCommand -> SetGuidance(
206  "If a macro file is not specified, each event is drawn to the current"
207  "\nviewer. After each event, the session is paused. The user may issue"
208  "\nany allowed command. Then enter \"cont[inue]\" to continue to the next"
209  "\nevent."
210  "\nUseful commands might be:"
211  "\n \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
212  "\n \"/vis/oglx/printEPS\" to get hard copy."
213  "\n \"/vis/open\" to get alternative viewer."
214  "\n \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort.");
215  fpCommand -> SetParameterName("macro-file-name", omitable=true);
216  fpCommand -> SetDefaultValue("");
217 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandReviewKeptEvents::~G4VisCommandReviewKeptEvents ( )
virtual

Definition at line 219 of file G4VisCommands.cc.

220 {
221  delete fpCommand;
222 }

Member Function Documentation

G4String G4VisCommandReviewKeptEvents::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 224 of file G4VisCommands.cc.

225 {
226  return "";
227 }
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::Disable(), G4VisManager::Enable(), G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetAbortReviewKeptEvents(), G4VVisManager::GetConcreteInstance(), G4RunManager::GetCurrentRun(), G4VisManager::GetCurrentScene(), G4VisManager::GetCurrentViewer(), G4Run::GetEventVector(), G4Scene::GetRefreshAtEndOfEvent(), G4RunManager::GetRunManager(), G4UImanager::GetSession(), G4UImanager::GetUIpointer(), G4UImanager::GetVerboseLevel(), G4VisManager::GetVerbosity(), G4UIsession::PauseSessionStart(), G4VisManager::SetAbortReviewKeptEvents(), G4Scene::SetRefreshAtEndOfEvent(), G4VisManager::SetRequestedEvent(), G4UImanager::SetVerboseLevel(), and G4VisManager::warnings.

230 {
231  static bool reviewing = false;
232  if (reviewing) {
233  G4cout <<
234  "\"/vis/reviewKeptEvents\" not allowed within an already started review."
235  "\n No action taken."
236  << G4endl;
237  return;
238  }
239 
240  G4String& macroFileName = newValue;
242 
244  const G4Run* run = runManager? runManager->GetCurrentRun(): 0;
245  const std::vector<const G4Event*>* events = run? run->GetEventVector(): 0;
246  size_t nKeptEvents = events? events->size(): 0;
247 
248  if (!nKeptEvents) {
249  if (verbosity >= G4VisManager::errors) {
250  G4cout <<
251  "ERROR: G4VisCommandReviewKeptEvents::SetNewValue: No kept events,"
252  "\n or kept events not accessible."
253  << G4endl;
254  }
255  return;
256  }
257 
259  if (!viewer) {
260  if (verbosity >= G4VisManager::errors) {
261  G4cout <<
262  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
263  << G4endl;
264  }
265  return;
266  }
267 
268  G4Scene* pScene = fpVisManager->GetCurrentScene();
269  if (!pScene) {
270  if (verbosity >= G4VisManager::errors) {
271  G4cout << "ERROR: No current scene. Please create one." << G4endl;
272  }
273  return;
274  }
275 
276  G4UImanager* UImanager = G4UImanager::GetUIpointer();
277  G4int keepVerbose = UImanager->GetVerboseLevel();
278  G4int newVerbose(0);
279  if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
280  newVerbose = 2;
281  UImanager->SetVerboseLevel(newVerbose);
282 
283  G4VVisManager* keepConcreteInstance = fpVisManager->GetConcreteInstance();
284  fpVisManager->Enable();
285 
286  // Event by event refreshing...
287  reviewing = true;
288  G4bool currentRefreshAtEndOfEvent = pScene->GetRefreshAtEndOfEvent();
289  pScene->SetRefreshAtEndOfEvent(true);
290  if (macroFileName.empty()) {
291 
292  // Draw to viewer and pause session...
293  G4UIsession* session = UImanager->GetSession();
294  for (size_t i = 0; i < nKeptEvents; ++i) {
295  const G4Event* event = (*events)[i];
296  if (verbosity >= G4VisManager::warnings) {
297  G4cout << "Drawing event : " << event->GetEventID() <<
298  ". At EndOfEvent, enter any command, then \"cont[inue]\"..."
299  << G4endl;
300  static G4bool first = true;
301  if (first) {
302  first = false;
303  G4cout <<
304  " Useful commands might be:"
305  "\n \"/vis/scene/add/trajectories\" if not already added."
306  "\n \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
307  "\n \"/vis/oglx/printEPS\" to get hard copy."
308  "\n \"/vis/open\" to get alternative viewer."
309  "\n \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort."
310  << G4endl;
311  }
312  }
314  UImanager->ApplyCommand("/vis/viewer/rebuild");
315  /* The above command forces a rebuild of the scene, including
316  the detector. This is fine for "immediate" viewers - a
317  refresh requires a rebuild anyway. But for "stored mode"
318  viewers, you could, in principle, avoid a rebuild of the
319  detector with something like the following:
320  sceneHandler->ClearTransientStore();
321  viewer->DrawView();
322  sceneHandler->DrawEvent(event);
323  but this causes mayhem for "immediate" viewers because
324  ClearTransientStore issues a DrawView and some curious sort
325  of recursion takes place. For "stored" viewers, the event
326  gets drawn but not the eventID, so something odd is happening
327  there too. This needs further investigation - enhanced
328  features or a complete re-think.
329  */
330  UImanager->ApplyCommand("/vis/viewer/flush");
331  session->PauseSessionStart("EndOfEvent");
334  }
336 
337  } else {
338 
339  // Execute macro file...
340  for (size_t i = 0; i < nKeptEvents; ++i) {
341  const G4Event* event = (*events)[i];
342  if (verbosity >= G4VisManager::warnings) {
343  G4cout << "Drawing event : " << event->GetEventID()
344  << " with macro file \"" << macroFileName << G4endl;
345  }
347  UImanager->ApplyCommand("/control/execute " + macroFileName);
349  }
350  }
351  pScene->SetRefreshAtEndOfEvent(currentRefreshAtEndOfEvent);
352  reviewing = false;
353 
354  if (keepConcreteInstance) fpVisManager->Enable();
355  else fpVisManager->Disable();
356  UImanager->SetVerboseLevel(keepVerbose);
357 }
G4UIsession * GetSession() const
Definition: G4UImanager.hh:208
virtual void PauseSessionStart(const G4String &Prompt)
Definition: G4UIsession.cc:40
static G4VVisManager * GetConcreteInstance()
void SetRequestedEvent(const G4Event *)
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:115
G4bool GetRefreshAtEndOfEvent() const
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:227
int G4int
Definition: G4Types.hh:78
const G4Run * GetCurrentRun() const
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:225
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
Definition: G4Run.hh:46
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
G4VViewer * GetCurrentViewer() const
G4bool GetAbortReviewKeptEvents() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
G4Scene * GetCurrentScene() const
void SetRefreshAtEndOfEvent(G4bool)
void SetAbortReviewKeptEvents(G4bool)
static G4VisManager * fpVisManager

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