Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandReviewKeptEvents Class Reference

#include <G4VisCommands.hh>

+ Inheritance 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)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
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)
 
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::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:67

◆ ~G4VisCommandReviewKeptEvents()

G4VisCommandReviewKeptEvents::~G4VisCommandReviewKeptEvents ( )
virtual

Definition at line 219 of file G4VisCommands.cc.

220{
221 delete fpCommand;
222}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandReviewKeptEvents::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 224 of file G4VisCommands.cc.

225{
226 return "";
227}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 229 of file G4VisCommands.cc.

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
269 if (!pScene) {
270 if (verbosity >= G4VisManager::errors) {
271 G4cout << "ERROR: No current scene. Please create one." << G4endl;
272 }
273 return;
274 }
275
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 // Event by event refreshing...
284 reviewing = true;
285 G4bool currentRefreshAtEndOfEvent = pScene->GetRefreshAtEndOfEvent();
286 pScene->SetRefreshAtEndOfEvent(true);
287 if (macroFileName.empty()) {
288
289 // Draw to viewer and pause session...
290 G4UIsession* session = UImanager->GetSession();
291 for (size_t i = 0; i < nKeptEvents; ++i) {
292 const G4Event* event = (*events)[i];
293 if (verbosity >= G4VisManager::warnings) {
294 G4cout << "Drawing event : " << event->GetEventID() <<
295 ". At EndOfEvent, enter any command, then \"cont[inue]\"..."
296 << G4endl;
297 static G4bool first = true;
298 if (first) {
299 first = false;
300 G4cout <<
301 " Useful commands might be:"
302 "\n \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
303 "\n \"/vis/oglx/printEPS\" to get hard copy."
304 "\n \"/vis/open\" to get alternative viewer."
305 "\n \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort."
306 << G4endl;
307 }
308 }
310 UImanager->ApplyCommand("/vis/viewer/rebuild");
311 /* The above command forces a rebuild of the scene, including
312 the detector. This is fine for "immediate" viewers - a
313 refresh requires a rebuild anyway. But for "stored mode"
314 viewers, you could, in principle, avoid a rebuild of the
315 detector with something like the following:
316 sceneHandler->ClearTransientStore();
317 viewer->DrawView();
318 sceneHandler->DrawEvent(event);
319 but this causes mayhem for "immediate" viewers because
320 ClearTransientStore issues a DrawView and some curious sort
321 of recursion takes place. For "stored" viewers, the event
322 gets drawn but not the eventID, so something odd is happening
323 there too. This needs further investigation - enhanced
324 features or a complete re-think.
325 */
326 UImanager->ApplyCommand("/vis/viewer/flush");
327 session->PauseSessionStart("EndOfEvent");
330 }
332
333 } else {
334
335 // Execute macro file...
336 for (size_t i = 0; i < nKeptEvents; ++i) {
337 const G4Event* event = (*events)[i];
338 if (verbosity >= G4VisManager::warnings) {
339 G4cout << "Drawing event : " << event->GetEventID()
340 << " with macro file \"" << macroFileName << G4endl;
341 }
343 UImanager->ApplyCommand("/control/execute " + macroFileName);
345 }
346 }
347 pScene->SetRefreshAtEndOfEvent(currentRefreshAtEndOfEvent);
348 reviewing = false;
349
350 UImanager->SetVerboseLevel(keepVerbose);
351}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:62
const G4Run * GetCurrentRun() const
Definition: G4Run.hh:47
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:112
G4bool GetRefreshAtEndOfEvent() const
void SetRefreshAtEndOfEvent(G4bool)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:369
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:218
G4UIsession * GetSession() const
Definition: G4UImanager.hh:199
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:216
virtual void PauseSessionStart(const G4String &Prompt)
Definition: G4UIsession.cc:40
static G4VisManager * fpVisManager
G4Scene * GetCurrentScene() const
G4bool GetAbortReviewKeptEvents() const
void SetAbortReviewKeptEvents(G4bool)
G4VViewer * GetCurrentViewer() const
void SetRequestedEvent(const G4Event *)
static Verbosity GetVerbosity()

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