Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandReviewKeptEvents Class Reference

#include <G4VisCommands.hh>

Inheritance diagram for G4VisCommandReviewKeptEvents:
Collaboration diagram for G4VisCommandReviewKeptEvents:

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
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
static const G4ColourGetCurrentColour ()
 
static G4double GetCurrentLineWidth ()
 
static const G4ColourGetCurrentTextColour ()
 
static G4Text::Layout GetCurrentTextLayout ()
 
static G4double GetCurrentTextSize ()
 
- 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
 
G4bool commandsShouldBeInMaster
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fErrorCode = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 88 of file G4VisCommands.hh.

Constructor & Destructor Documentation

G4VisCommandReviewKeptEvents::G4VisCommandReviewKeptEvents ( )

Definition at line 204 of file G4VisCommands.cc.

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

Definition at line 226 of file G4VisCommands.cc.

227 {
228  delete fpCommand;
229 }

Member Function Documentation

G4String G4VisCommandReviewKeptEvents::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 231 of file G4VisCommands.cc.

232 {
233  return "";
234 }
void G4VisCommandReviewKeptEvents::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 236 of file G4VisCommands.cc.

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

Here is the call graph for this function:


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