source: trunk/source/visualization/management/src/G4VisCommandsScene.cc@ 845

Last change on this file since 845 was 606, checked in by garnier, 18 years ago

r647@mac-90108: laurentgarnier | 2007-11-15 11:32:46 +0100
Ok en Qt 4.3.0

  • Property svn:mime-type set to text/cpp
File size: 22.0 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4VisCommandsScene.cc,v 1.67 2007/11/10 15:03:56 allison Exp $
28// GEANT4 tag $Name: $
29
30// /vis/scene commands - John Allison 9th August 1998
31
32#include "G4VisCommandsScene.hh"
33
34#include "G4VisManager.hh"
35#include "G4TransportationManager.hh"
36#include "G4RunManager.hh"
37#include "G4Run.hh"
38#include "G4PhysicalVolumeModel.hh"
39#include "G4ApplicationState.hh"
40#include "G4UImanager.hh"
41#include "G4UIcommand.hh"
42#include "G4UIcmdWithAString.hh"
43#include "G4ios.hh"
44#include <sstream>
45
46G4VVisCommandScene::G4VVisCommandScene () {}
47
48G4VVisCommandScene::~G4VVisCommandScene () {}
49
50G4String G4VVisCommandScene::CurrentSceneName () {
51 const G4Scene* pScene = fpVisManager -> GetCurrentScene ();
52 G4String currentSceneName;
53 if (pScene) currentSceneName = pScene -> GetName ();
54 return currentSceneName;
55}
56
57////////////// /vis/scene/create ///////////////////////////////////////
58
59G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) {
60 G4bool omitable;
61 fpCommand = new G4UIcmdWithAString ("/vis/scene/create", this);
62 fpCommand -> SetGuidance
63 ("Creates an empty scene.");
64 fpCommand -> SetGuidance
65 ("Invents a name if not supplied. This scene becomes current.");
66 fpCommand -> SetParameterName ("scene-name", omitable = true);
67}
68
69G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
70 delete fpCommand;
71}
72
73G4String G4VisCommandSceneCreate::NextName () {
74 std::ostringstream oss;
75 oss << "scene-" << fId;
76 return oss.str();
77}
78
79G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand*) {
80 return "";
81}
82
83void G4VisCommandSceneCreate::SetNewValue (G4UIcommand*, G4String newValue) {
84
85 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
86
87 G4String& newName = newValue;
88 G4String nextName = NextName ();
89
90 if (newName == "") {
91 newName = nextName;
92 }
93 if (newName == nextName) fId++;
94
95 G4SceneList& sceneList = fpVisManager -> SetSceneList ();
96 G4int iScene, nScenes = sceneList.size ();
97 for (iScene = 0; iScene < nScenes; iScene++) {
98 if (sceneList [iScene] -> GetName () == newName) break;
99 }
100 if (iScene < nScenes) {
101 if (verbosity >= G4VisManager::warnings) {
102 G4cout << "WARNING: Scene \"" << newName << "\" already exists."
103 << "\n New scene not created."
104 << G4endl;
105 }
106 } else {
107
108 // Add empty scene data object to list...
109 G4Scene* pScene = new G4Scene (newName);
110 sceneList.push_back (pScene);
111 fpVisManager -> SetCurrentScene (pScene);
112
113 if (verbosity >= G4VisManager::confirmations) {
114 G4cout << "New empty scene \"" << newName << "\" created." << G4endl;
115 }
116 }
117}
118
119////////////// /vis/scene/endOfEventAction ////////////////////////////
120
121G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction () {
122 G4bool omitable;
123 fpCommand = new G4UIcommand ("/vis/scene/endOfEventAction", this);
124 fpCommand -> SetGuidance
125 ("Accumulate or refresh the viewer for each new event.");
126 fpCommand -> SetGuidance
127 ("\"accumulate\": viewer accumulates hits, etc., event by event, or");
128 fpCommand -> SetGuidance
129 ("\"refresh\": viewer shows them at end of event or, for direct-screen"
130 "\n viewers, refreshes the screen just before drawing the next event.");
131 G4UIparameter* parameter;
132 parameter = new G4UIparameter ("action", 's', omitable = true);
133 parameter -> SetParameterCandidates ("accumulate refresh");
134 parameter -> SetDefaultValue ("refresh");
135 fpCommand -> SetParameter (parameter);
136 parameter = new G4UIparameter ("maxNumber", 'i', omitable = true);
137 parameter -> SetDefaultValue (100);
138 parameter -> SetGuidance
139 ("Maximum number of events kept. Unlimited if negative.");
140 fpCommand -> SetParameter (parameter);
141}
142
143G4VisCommandSceneEndOfEventAction::~G4VisCommandSceneEndOfEventAction () {
144 delete fpCommand;
145}
146
147G4String G4VisCommandSceneEndOfEventAction::GetCurrentValue(G4UIcommand*) {
148 return "";
149}
150
151void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
152 G4String newValue) {
153
154 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
155
156 G4String action;
157 G4int maxNumberOfKeptEvents;
158 std::istringstream is (newValue);
159 is >> action >> maxNumberOfKeptEvents;
160
161 G4Scene* pScene = fpVisManager->GetCurrentScene();
162 if (!pScene) {
163 if (verbosity >= G4VisManager::errors) {
164 G4cout << "ERROR: No current scene. Please create one." << G4endl;
165 }
166 return;
167 }
168
169 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
170 if (!pSceneHandler) {
171 if (verbosity >= G4VisManager::errors) {
172 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
173 }
174 return;
175 }
176
177 if (action == "accumulate") {
178 pScene->SetRefreshAtEndOfEvent(false);
179 pScene->SetMaxNumberOfKeptEvents(maxNumberOfKeptEvents);
180 }
181 else if (action == "refresh") {
182 if (!pScene->GetRefreshAtEndOfRun()) {
183 if (verbosity >= G4VisManager::errors) {
184 G4cout <<
185 "ERROR: Cannot refresh events unless runs refresh too."
186 "\n Use \"/vis/scene/endOfRun refresh\"."
187 << G4endl;
188 }
189 } else {
190 pScene->SetRefreshAtEndOfEvent(true);
191 pSceneHandler->SetMarkForClearingTransientStore(true);
192 }
193 }
194 else {
195 if (verbosity >= G4VisManager::errors) {
196 G4cout <<
197 "ERROR: unrecognised parameter \"" << action << "\"."
198 << G4endl;
199 }
200 return;
201 }
202
203 // Change of transients behaviour, so...
204 fpVisManager->ResetTransientsDrawnFlags();
205
206 // Are there any events currently kept...
207 size_t nCurrentlyKept = 0;
208 G4RunManager* runManager = G4RunManager::GetRunManager();
209 if (runManager) {
210 const G4Run* currentRun = runManager->GetCurrentRun();
211 if (currentRun) {
212 const std::vector<const G4Event*>* events =
213 currentRun->GetEventVector();
214 if (events) nCurrentlyKept = events->size();
215 }
216 }
217
218 if (verbosity >= G4VisManager::confirmations) {
219 G4cout << "End of event action set to ";
220 if (pScene->GetRefreshAtEndOfEvent()) G4cout << "\"refresh\".";
221 else {
222 G4cout << "\"accumulate\"."
223 "\n Maximum number of events to be kept: "
224 << maxNumberOfKeptEvents
225 << " (unlimited if negative)."
226 "\n This may be changed with, e.g., "
227 "\"/vis/scene/endOfEventAction accumulate 1000\".";
228 }
229 G4cout << G4endl;
230 }
231
232 if (!pScene->GetRefreshAtEndOfEvent() &&
233 maxNumberOfKeptEvents != 0 &&
234 verbosity >= G4VisManager::warnings) {
235 G4cout << "WARNING: ";
236 if (nCurrentlyKept) {
237 G4cout <<
238 "\n There are currently " << nCurrentlyKept
239 << " events kept for refreshing and/or reviewing.";
240 } else {
241 G4cout << "The vis manager will keep ";
242 if (maxNumberOfKeptEvents < 0) G4cout << "an unlimited number of";
243 else G4cout << "up to " << maxNumberOfKeptEvents;
244 G4cout << " events.";
245 if (maxNumberOfKeptEvents > 1 || maxNumberOfKeptEvents < 0)
246 G4cout << "\n This may use a lot of memory.";
247 }
248 G4cout << G4endl;
249 }
250}
251
252////////////// /vis/scene/endOfRunAction ////////////////////////////
253
254G4VisCommandSceneEndOfRunAction::G4VisCommandSceneEndOfRunAction () {
255 G4bool omitable;
256 fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfRunAction", this);
257 fpCommand -> SetGuidance
258 ("Accumulate or refresh the viewer for each new run.");
259 fpCommand -> SetGuidance
260 ("\"accumulate\": viewer accumulates hits, etc., run by run, or");
261 fpCommand -> SetGuidance
262 ("\"refresh\": viewer shows them at end of run or, for direct-screen"
263 "\n viewers, refreshes the screen just before drawing the first"
264 "\n event of the next run.");
265 fpCommand -> SetGuidance ("The detector remains or is redrawn.");
266 fpCommand -> SetParameterName ("action", omitable = true);
267 fpCommand -> SetCandidates ("accumulate refresh");
268 fpCommand -> SetDefaultValue ("refresh");
269}
270
271G4VisCommandSceneEndOfRunAction::~G4VisCommandSceneEndOfRunAction () {
272 delete fpCommand;
273}
274
275G4String G4VisCommandSceneEndOfRunAction::GetCurrentValue(G4UIcommand*) {
276 return "";
277}
278
279void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
280 G4String newValue) {
281
282 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
283
284 G4String action;
285 std::istringstream is (newValue);
286 is >> action;
287
288 G4Scene* pScene = fpVisManager->GetCurrentScene();
289 if (!pScene) {
290 if (verbosity >= G4VisManager::errors) {
291 G4cout << "ERROR: No current scene. Please create one." << G4endl;
292 }
293 return;
294 }
295
296 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
297 if (!pSceneHandler) {
298 if (verbosity >= G4VisManager::errors) {
299 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
300 }
301 return;
302 }
303
304 if (action == "accumulate") {
305 if (pScene->GetRefreshAtEndOfEvent()) {
306 if (verbosity >= G4VisManager::errors) {
307 G4cout <<
308 "ERROR: Cannot accumulate runs unless events accumulate too."
309 "\n Use \"/vis/scene/endOfEventAction accumulate\"."
310 << G4endl;
311 }
312 }
313 else {
314 pScene->SetRefreshAtEndOfRun(false);
315 }
316 }
317 else if (action == "refresh") {
318 pScene->SetRefreshAtEndOfRun(true);
319 pSceneHandler->SetMarkForClearingTransientStore(true);
320 }
321 else {
322 if (verbosity >= G4VisManager::errors) {
323 G4cout <<
324 "ERROR: unrecognised parameter \"" << action << "\"."
325 << G4endl;
326 }
327 return;
328 }
329
330 // Change of transients behaviour, so...
331 fpVisManager->ResetTransientsDrawnFlags();
332
333 if (verbosity >= G4VisManager::confirmations) {
334 G4cout << "End of run action set to \"";
335 if (pScene->GetRefreshAtEndOfRun()) G4cout << "refresh";
336 else G4cout << "accumulate";
337 G4cout << "\"" << G4endl;
338 }
339}
340
341////////////// /vis/scene/list ///////////////////////////////////////
342
343G4VisCommandSceneList::G4VisCommandSceneList () {
344 G4bool omitable;
345 fpCommand = new G4UIcommand ("/vis/scene/list", this);
346 fpCommand -> SetGuidance ("Lists scene(s).");
347 fpCommand -> SetGuidance
348 ("\"help /vis/verbose\" for definition of verbosity.");
349 G4UIparameter* parameter;
350 parameter = new G4UIparameter ("scene-name", 's', omitable = true);
351 parameter -> SetDefaultValue ("all");
352 fpCommand -> SetParameter (parameter);
353 parameter = new G4UIparameter ("verbosity", 's', omitable = true);
354 parameter -> SetDefaultValue ("warnings");
355 fpCommand -> SetParameter (parameter);
356}
357
358G4VisCommandSceneList::~G4VisCommandSceneList () {
359 delete fpCommand;
360}
361
362G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) {
363 return "";
364}
365
366void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
367 G4String name, verbosityString;
368 std::istringstream is (newValue);
369 is >> name >> verbosityString;
370 G4VisManager::Verbosity verbosity =
371 fpVisManager->GetVerbosityValue(verbosityString);
372 const G4Scene* currentScene = fpVisManager -> GetCurrentScene ();
373 G4String currentName;
374 if (currentScene) currentName = currentScene->GetName();
375
376 G4SceneList& sceneList = fpVisManager -> SetSceneList ();
377 G4int iScene, nScenes = sceneList.size ();
378 G4bool found = false;
379 for (iScene = 0; iScene < nScenes; iScene++) {
380 G4Scene* pScene = sceneList [iScene];
381 const G4String& iName = pScene -> GetName ();
382 if (name != "all") {
383 if (name != iName) continue;
384 }
385 found = true;
386 if (iName == currentName) {
387 G4cout << " (current)";
388 }
389 else {
390 G4cout << " ";
391 }
392 G4cout << " scene \"" << iName << "\"";
393 if (verbosity >= G4VisManager::confirmations) {
394 G4int i;
395 G4cout << "\n Run-duration models:";
396 G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
397 if (nRunModels == 0) {
398 G4cout << " none.";
399 }
400 for (i = 0; i < nRunModels; i++) {
401 G4VModel* pModel = pScene -> GetRunDurationModelList () [i];
402 G4cout << "\n " << pModel -> GetGlobalDescription ();
403 }
404 G4cout << "\n End-of-event models:";
405 G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
406 if (nEOEModels == 0) {
407 G4cout << " none.";
408 }
409 for (i = 0; i < nEOEModels; i++) {
410 G4VModel* pModel = pScene -> GetEndOfEventModelList () [i];
411 G4cout << "\n " << pModel -> GetGlobalDescription ();
412 }
413 }
414 if (verbosity >= G4VisManager::parameters) {
415 G4cout << "\n " << *sceneList [iScene];
416 }
417 G4cout << G4endl;
418 }
419 if (!found) {
420 G4cout << "No scenes found";
421 if (name != "all") {
422 G4cout << " of name \"" << name << "\"";
423 }
424 G4cout << "." << G4endl;
425 }
426}
427
428////////////// /vis/scene/notifyHandlers /////////////////////////
429
430G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
431 G4bool omitable;
432 fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
433 fpCommand -> SetGuidance
434 ("Notifies scene handlers and forces re-rendering.");
435 fpCommand -> SetGuidance
436 ("Notifies the handler(s) of the specified scene and forces a"
437 "\nreconstruction of any graphical databases."
438 "\nClears and refreshes all viewers of current scene."
439 "\n The default action \"refresh\" does not issue \"update\" (see"
440 "\n /vis/viewer/update)."
441 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
442 "\n \"refresh\" - \"update\" and initiates post-processing"
443 "\n for graphics systems which need it.");
444 fpCommand -> SetGuidance
445 ("The default for <scene-name> is the current scene name.");
446 fpCommand -> SetGuidance
447 ("This command does not change current scene, scene handler or viewer.");
448 G4UIparameter* parameter;
449 parameter = new G4UIparameter ("scene-name", 's',
450 omitable = true);
451 parameter -> SetCurrentAsDefault(true);
452 fpCommand -> SetParameter (parameter);
453 parameter = new G4UIparameter ("refresh-flush", 's',
454 omitable = true);
455 parameter -> SetDefaultValue("refresh");
456 parameter -> SetParameterCandidates("r refresh f flush");
457 fpCommand -> SetParameter (parameter);
458}
459
460G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
461 delete fpCommand;
462}
463
464G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue(G4UIcommand*) {
465 return CurrentSceneName ();
466}
467
468void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
469 G4String newValue) {
470
471 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
472
473 G4String sceneName, refresh_flush;
474 std::istringstream is (newValue);
475 is >> sceneName >> refresh_flush;
476 G4bool flush = false;
477 if (refresh_flush(0) == 'f') flush = true;
478
479 const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
480 G4SceneHandlerList& sceneHandlerList =
481 fpVisManager -> SetAvailableSceneHandlers ();
482
483 // Check scene name.
484 const G4int nScenes = sceneList.size ();
485 G4int iScene;
486 for (iScene = 0; iScene < nScenes; iScene++) {
487 G4Scene* scene = sceneList [iScene];
488 if (sceneName == scene -> GetName ()) break;
489 }
490 if (iScene >= nScenes ) {
491 if (verbosity >= G4VisManager::warnings) {
492 G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
493 "\n /vis/scene/list to see scenes."
494 << G4endl;
495 }
496 return;
497 }
498
499 // Store current context...
500 G4VSceneHandler* pCurrentSceneHandler =
501 fpVisManager -> GetCurrentSceneHandler();
502 if (!pCurrentSceneHandler) {
503 if (verbosity >= G4VisManager::warnings) {
504 G4cout << "WARNING: No current scene handler."
505 << G4endl;
506 }
507 return;
508 }
509 G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
510 if (!pCurrentViewer) {
511 if (verbosity >= G4VisManager::warnings) {
512 G4cout << "WARNING: No current viewer."
513 << G4endl;
514 }
515 return;
516 }
517 G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
518 if (!pCurrentScene) {
519 if (verbosity >= G4VisManager::warnings) {
520 G4cout << "WARNING: No current scene."
521 << G4endl;
522 }
523 return;
524 }
525 G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
526
527 // Suppress messages during this process (only print errors)...
528 //fpVisManager -> SetVerboseLevel(G4VisManager::errors);
529
530 // For each scene handler, if it contains the scene, clear and
531 // rebuild the graphical database, then for each viewer set (make
532 // current), clear, (re)draw, and show.
533 const G4int nSceneHandlers = sceneHandlerList.size ();
534 for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
535 G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
536 G4Scene* aScene = aSceneHandler -> GetScene ();
537 if (aScene) {
538 const G4String& aSceneName = aScene -> GetName ();
539 if (sceneName == aSceneName) {
540 // Clear store and force a rebuild of graphical database...
541 //aSceneHandler -> ClearStore (); // Not nec?? Done below
542 //with NeedKernelVisit and DrawView. JA.
543 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
544 const G4int nViewers = viewerList.size ();
545 for (G4int iV = 0; iV < nViewers; iV++) {
546 G4VViewer* aViewer = viewerList [iV];
547 if (aViewer->GetViewParameters().IsAutoRefresh()) {
548 aSceneHandler -> SetCurrentViewer (aViewer);
549 // Ensure consistency of vis manager...
550 fpVisManager -> SetCurrentViewer(aViewer);
551 fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
552 fpVisManager -> SetCurrentScene(aScene);
553 // Re-draw, forcing rebuild of graphics database, if any...
554 aViewer -> NeedKernelVisit();
555 aViewer -> SetView ();
556 aViewer -> ClearView ();
557 aViewer -> DrawView ();
558 if (flush) aViewer -> ShowView ();
559 if (verbosity >= G4VisManager::confirmations) {
560 G4cout << "Viewer \"" << aViewer -> GetName ()
561 << "\" of scene handler \"" << aSceneHandler -> GetName ()
562 << "\"\n ";
563 if (flush) G4cout << "flushed";
564 else G4cout << "refreshed";
565 G4cout << " at request of scene \"" << sceneName
566 << "\"." << G4endl;
567 }
568 } else {
569 if (verbosity >= G4VisManager::warnings) {
570 G4cout << "WARNING: The scene, \""
571 << sceneName
572 << "\", of viewer \""
573 << aViewer -> GetName ()
574 << "\"\n of scene handler \""
575 << aSceneHandler -> GetName ()
576 << "\" has changed. To see effect,"
577 << "\n \"/vis/viewer/select "
578 << aViewer -> GetShortName ()
579 << "\" and \"/vis/viewer/rebuild\"."
580 << G4endl;
581 }
582 }
583 }
584 }
585 }
586 else {
587 if (verbosity >= G4VisManager::warnings) {
588 G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
589 << aSceneHandler->GetName()
590 << "\" has a null scene."
591 << G4endl;
592 }
593 }
594 }
595
596 // Reclaim original context - but set viewer first, then scene
597 // handler, because the latter might have been created very recently
598 // and, not yet having a viewer, the current viewer will,
599 // temporarily, refer to another scene handler. SetCurrentViewer
600 // actually resets the scene handler, which is what we don't want,
601 // so we set it again on the next line...
602 fpVisManager -> SetCurrentViewer(pCurrentViewer);
603 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
604 fpVisManager -> SetCurrentScene(pCurrentScene);
605 fpVisManager -> SetVerboseLevel(currentVerbosity);
606 // Take care of special case of scene handler with no viewer yet.
607 if (pCurrentSceneHandler) {
608 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
609 const G4int nViewers = viewerList.size ();
610 if (nViewers) {
611 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
612 if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
613 pCurrentViewer -> SetView ();
614 }
615 }
616 }
617}
618
619////////////// /vis/scene/select ///////////////////////////////////////
620
621G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
622 G4bool omitable;
623 fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
624 fpCommand -> SetGuidance ("Selects a scene");
625 fpCommand -> SetGuidance
626 ("Makes the scene current. \"/vis/scene/list\" to see"
627 "\n possible scene names.");
628 fpCommand -> SetParameterName ("scene-name", omitable = false);
629}
630
631G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
632 delete fpCommand;
633}
634
635G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand*) {
636 return "";
637}
638
639void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) {
640
641 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
642
643 G4String& selectName = newValue;
644 G4SceneList& sceneList = fpVisManager -> SetSceneList ();
645 G4int iScene, nScenes = sceneList.size ();
646 for (iScene = 0; iScene < nScenes; iScene++) {
647 if (sceneList [iScene] -> GetName () == selectName) break;
648 }
649 if (iScene >= nScenes) {
650 if (verbosity >= G4VisManager::warnings) {
651 G4cout << "WARNING: Scene \"" << selectName
652 << "\" not found - \"/vis/scene/list\" to see possibilities."
653 << G4endl;
654 }
655 return;
656 }
657
658 if (verbosity >= G4VisManager::confirmations) {
659 G4cout << "Scene \"" << selectName
660 << "\" selected." << G4endl;
661 }
662 UpdateVisManagerScene (selectName);
663}
Note: See TracBrowser for help on using the repository browser.