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

Last change on this file since 1170 was 1170, checked in by garnier, 15 years ago

update contre CVS

  • Property svn:mime-type set to text/cpp
File size: 22.1 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.68 2008/04/28 16:12:38 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 <<
247          "\n  This may use a lot of memory."
248          "\n  It may be changed with, e.g., "
249          "\"/vis/scene/endOfEventAction accumulate 10\".";
250    }
251    G4cout << G4endl;
252  }
253}
254
255////////////// /vis/scene/endOfRunAction ////////////////////////////
256
257G4VisCommandSceneEndOfRunAction::G4VisCommandSceneEndOfRunAction () {
258  G4bool omitable;
259  fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfRunAction", this);
260  fpCommand -> SetGuidance
261    ("Accumulate or refresh the viewer for each new run.");
262  fpCommand -> SetGuidance
263    ("\"accumulate\": viewer accumulates hits, etc., run by run, or");
264  fpCommand -> SetGuidance
265    ("\"refresh\": viewer shows them at end of run or, for direct-screen"
266     "\n  viewers, refreshes the screen just before drawing the first"
267     "\n  event of the next run.");
268  fpCommand -> SetGuidance ("The detector remains or is redrawn.");
269  fpCommand -> SetParameterName ("action", omitable = true);
270  fpCommand -> SetCandidates ("accumulate refresh");
271  fpCommand -> SetDefaultValue ("refresh");
272}
273
274G4VisCommandSceneEndOfRunAction::~G4VisCommandSceneEndOfRunAction () {
275  delete fpCommand;
276}
277
278G4String G4VisCommandSceneEndOfRunAction::GetCurrentValue(G4UIcommand*) {
279  return "";
280}
281
282void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
283                                                     G4String newValue) {
284
285  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
286
287  G4String action;
288  std::istringstream is (newValue);
289  is >> action;
290
291  G4Scene* pScene = fpVisManager->GetCurrentScene();
292  if (!pScene) {
293    if (verbosity >= G4VisManager::errors) {
294      G4cout << "ERROR: No current scene.  Please create one." << G4endl;
295    }
296    return;
297  }
298
299  G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
300  if (!pSceneHandler) {
301    if (verbosity >= G4VisManager::errors) {
302      G4cout << "ERROR: No current sceneHandler.  Please create one." << G4endl;
303    }
304    return;
305  }
306
307  if (action == "accumulate") {
308    if (pScene->GetRefreshAtEndOfEvent()) {
309      if (verbosity >= G4VisManager::errors) {
310        G4cout <<
311          "ERROR: Cannot accumulate runs unless events accumulate too."
312          "\n  Use \"/vis/scene/endOfEventAction accumulate\"."
313               << G4endl;
314      }
315    }
316    else {
317      pScene->SetRefreshAtEndOfRun(false);
318    }
319  }
320  else if (action == "refresh") {
321    pScene->SetRefreshAtEndOfRun(true);
322    pSceneHandler->SetMarkForClearingTransientStore(true);
323  }
324  else {
325    if (verbosity >= G4VisManager::errors) {
326      G4cout <<
327        "ERROR: unrecognised parameter \"" << action << "\"."
328             << G4endl;
329    }
330    return;
331  }
332
333  // Change of transients behaviour, so...
334  fpVisManager->ResetTransientsDrawnFlags();
335
336  if (verbosity >= G4VisManager::confirmations) {
337    G4cout << "End of run action set to \"";
338    if (pScene->GetRefreshAtEndOfRun()) G4cout << "refresh";
339    else G4cout << "accumulate";
340    G4cout << "\"" << G4endl;
341  }
342}
343
344////////////// /vis/scene/list ///////////////////////////////////////
345
346G4VisCommandSceneList::G4VisCommandSceneList () {
347  G4bool omitable;
348  fpCommand = new G4UIcommand ("/vis/scene/list", this);
349  fpCommand -> SetGuidance ("Lists scene(s).");
350  fpCommand -> SetGuidance
351    ("\"help /vis/verbose\" for definition of verbosity.");
352  G4UIparameter* parameter;
353  parameter = new G4UIparameter ("scene-name", 's', omitable = true);
354  parameter -> SetDefaultValue ("all");
355  fpCommand -> SetParameter (parameter);
356  parameter = new G4UIparameter ("verbosity", 's', omitable = true);
357  parameter -> SetDefaultValue ("warnings");
358  fpCommand -> SetParameter (parameter);
359}
360
361G4VisCommandSceneList::~G4VisCommandSceneList () {
362  delete fpCommand;
363}
364
365G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) {
366  return "";
367}
368
369void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
370  G4String name, verbosityString;
371  std::istringstream is (newValue);
372  is >> name >> verbosityString;
373  G4VisManager::Verbosity verbosity =
374    fpVisManager->GetVerbosityValue(verbosityString);
375  const G4Scene* currentScene = fpVisManager -> GetCurrentScene ();
376  G4String currentName;
377  if (currentScene) currentName = currentScene->GetName();
378
379  G4SceneList& sceneList = fpVisManager -> SetSceneList ();
380  G4int iScene, nScenes = sceneList.size ();
381  G4bool found = false;
382  for (iScene = 0; iScene < nScenes; iScene++) {
383    G4Scene* pScene = sceneList [iScene];
384    const G4String& iName = pScene -> GetName ();
385    if (name != "all") {
386      if (name != iName) continue;
387    }
388    found = true;
389    if (iName == currentName) {
390      G4cout << "  (current)";
391    }
392    else {
393      G4cout << "           ";
394    }
395    G4cout << " scene \"" << iName << "\"";
396    if (verbosity >= G4VisManager::confirmations) {
397      G4int i;
398      G4cout << "\n  Run-duration models:";
399      G4int nRunModels = pScene -> GetRunDurationModelList ().size ();
400      if (nRunModels == 0) {
401        G4cout << " none.";
402      }
403      for (i = 0; i < nRunModels; i++) {
404        G4VModel* pModel = pScene -> GetRunDurationModelList () [i];
405        G4cout << "\n    " << pModel -> GetGlobalDescription ();
406      }
407      G4cout << "\n  End-of-event models:";
408      G4int nEOEModels = pScene -> GetEndOfEventModelList ().size ();
409      if (nEOEModels == 0) {
410        G4cout << " none.";
411      }
412      for (i = 0; i < nEOEModels; i++) {
413        G4VModel* pModel = pScene -> GetEndOfEventModelList () [i];
414        G4cout << "\n    " << pModel -> GetGlobalDescription ();
415      }
416    }
417    if (verbosity >= G4VisManager::parameters) {
418      G4cout << "\n  " << *sceneList [iScene];
419    }
420    G4cout << G4endl;
421  }
422  if (!found) {
423    G4cout << "No scenes found";
424    if (name != "all") {
425      G4cout << " of name \"" << name << "\"";
426    }
427    G4cout << "." << G4endl;
428  }
429}
430
431////////////// /vis/scene/notifyHandlers /////////////////////////
432
433G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
434  G4bool omitable;
435  fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
436  fpCommand -> SetGuidance
437    ("Notifies scene handlers and forces re-rendering.");
438  fpCommand -> SetGuidance
439    ("Notifies the handler(s) of the specified scene and forces a"
440     "\nreconstruction of any graphical databases."
441     "\nClears and refreshes all viewers of current scene."
442     "\n  The default action \"refresh\" does not issue \"update\" (see"
443     "\n    /vis/viewer/update)."
444     "\nIf \"flush\" is specified, it issues an \"update\" as well as"
445     "\n  \"refresh\" - \"update\" and initiates post-processing"
446     "\n  for graphics systems which need it.");
447  fpCommand -> SetGuidance
448    ("The default for <scene-name> is the current scene name.");
449  fpCommand -> SetGuidance
450    ("This command does not change current scene, scene handler or viewer.");
451  G4UIparameter* parameter;
452  parameter = new G4UIparameter ("scene-name", 's',
453                                 omitable = true);
454  parameter -> SetCurrentAsDefault(true);
455  fpCommand -> SetParameter (parameter);
456  parameter = new G4UIparameter ("refresh-flush", 's',
457                                 omitable = true);
458  parameter -> SetDefaultValue("refresh");
459  parameter -> SetParameterCandidates("r refresh f flush");
460  fpCommand -> SetParameter (parameter);
461}
462
463G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
464  delete fpCommand;
465}
466
467G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue(G4UIcommand*) {
468  return CurrentSceneName ();
469}
470
471void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
472                                                   G4String newValue) {
473
474  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
475
476  G4String sceneName, refresh_flush;
477  std::istringstream is (newValue);
478  is >> sceneName >> refresh_flush;
479  G4bool flush = false;
480  if (refresh_flush(0) == 'f') flush = true;
481
482  const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
483  G4SceneHandlerList& sceneHandlerList =
484    fpVisManager -> SetAvailableSceneHandlers ();
485
486  // Check scene name.
487  const G4int nScenes = sceneList.size ();
488  G4int iScene;
489  for (iScene = 0; iScene < nScenes; iScene++) {
490    G4Scene* scene = sceneList [iScene];
491    if (sceneName == scene -> GetName ()) break;
492  }
493  if (iScene >= nScenes ) {
494    if (verbosity >= G4VisManager::warnings) {
495      G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
496        "\n  /vis/scene/list to see scenes."
497             << G4endl;
498    }
499    return;
500  }
501
502  // Store current context...
503  G4VSceneHandler* pCurrentSceneHandler =
504    fpVisManager -> GetCurrentSceneHandler();
505  if (!pCurrentSceneHandler) {
506    if (verbosity >= G4VisManager::warnings) {
507      G4cout << "WARNING: No current scene handler."
508             << G4endl;
509    }
510    return;
511  }
512  G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
513  if (!pCurrentViewer) {
514    if (verbosity >= G4VisManager::warnings) {
515      G4cout << "WARNING: No current viewer."
516             << G4endl;
517    }
518    return;
519  }
520  G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
521  if (!pCurrentScene) {
522    if (verbosity >= G4VisManager::warnings) {
523      G4cout << "WARNING: No current scene."
524             << G4endl;
525    }
526    return;
527  }
528  G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
529
530  // Suppress messages during this process (only print errors)...
531  //fpVisManager -> SetVerboseLevel(G4VisManager::errors);
532
533  // For each scene handler, if it contains the scene, clear and
534  // rebuild the graphical database, then for each viewer set (make
535  // current), clear, (re)draw, and show.
536  const G4int nSceneHandlers = sceneHandlerList.size ();
537  for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
538    G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
539    G4Scene* aScene = aSceneHandler -> GetScene ();
540    if (aScene) {
541      const G4String& aSceneName = aScene -> GetName ();
542      if (sceneName == aSceneName) {
543        // Clear store and force a rebuild of graphical database...
544        //aSceneHandler -> ClearStore (); // Not nec??  Done below
545        //with NeedKernelVisit and DrawView.  JA.
546        G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
547        const G4int nViewers = viewerList.size ();
548        for (G4int iV = 0; iV < nViewers; iV++) {
549          G4VViewer* aViewer = viewerList [iV];
550          if (aViewer->GetViewParameters().IsAutoRefresh()) {
551            aSceneHandler -> SetCurrentViewer (aViewer);
552            // Ensure consistency of vis manager...
553            fpVisManager -> SetCurrentViewer(aViewer);
554            fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
555            fpVisManager -> SetCurrentScene(aScene);
556            // Re-draw, forcing rebuild of graphics database, if any...
557            aViewer -> NeedKernelVisit();
558            aViewer -> SetView ();
559            aViewer -> ClearView ();
560            aViewer -> DrawView ();
561            if (flush) aViewer -> ShowView ();
562            if (verbosity >= G4VisManager::confirmations) {
563              G4cout << "Viewer \"" << aViewer -> GetName ()
564                     << "\" of scene handler \"" << aSceneHandler -> GetName ()
565                     << "\"\n  ";
566              if (flush) G4cout << "flushed";
567              else G4cout << "refreshed";
568              G4cout << " at request of scene \"" << sceneName
569                     << "\"." << G4endl;
570            }
571          } else {
572            if (verbosity >= G4VisManager::warnings) {
573              G4cout << "WARNING: The scene, \""
574                     << sceneName
575                     << "\", of viewer \""
576                     << aViewer -> GetName ()
577                     << "\"\n  of scene handler \""
578                     << aSceneHandler -> GetName ()
579                     << "\"  has changed.  To see effect,"
580                     << "\n  \"/vis/viewer/select "
581                     << aViewer -> GetShortName ()
582                     << "\" and \"/vis/viewer/rebuild\"."
583                     << G4endl;
584            }
585          }
586        }
587      }
588    }
589    else {
590      if (verbosity >= G4VisManager::warnings) {
591        G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
592               << aSceneHandler->GetName()
593               << "\" has a null scene."
594               << G4endl;
595      }
596    }
597  }
598
599  // Reclaim original context - but set viewer first, then scene
600  // handler, because the latter might have been created very recently
601  // and, not yet having a viewer, the current viewer will,
602  // temporarily, refer to another scene handler.  SetCurrentViewer
603  // actually resets the scene handler, which is what we don't want,
604  // so we set it again on the next line...
605  fpVisManager -> SetCurrentViewer(pCurrentViewer);
606  fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
607  fpVisManager -> SetCurrentScene(pCurrentScene);
608  fpVisManager -> SetVerboseLevel(currentVerbosity);
609  // Take care of special case of scene handler with no viewer yet. 
610  if (pCurrentSceneHandler) {
611    G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
612    const G4int nViewers = viewerList.size ();
613    if (nViewers) {
614      pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
615      if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
616        pCurrentViewer -> SetView ();
617      }
618    }
619  }
620}
621
622////////////// /vis/scene/select ///////////////////////////////////////
623
624G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
625  G4bool omitable;
626  fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
627  fpCommand -> SetGuidance ("Selects a scene");
628  fpCommand -> SetGuidance
629    ("Makes the scene current.  \"/vis/scene/list\" to see"
630     "\n possible scene names.");
631  fpCommand -> SetParameterName ("scene-name", omitable = false);
632}
633
634G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
635  delete fpCommand;
636}
637
638G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand*) {
639  return "";
640}
641
642void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) {
643
644  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
645
646  G4String& selectName = newValue;
647  G4SceneList& sceneList = fpVisManager -> SetSceneList ();
648  G4int iScene, nScenes = sceneList.size ();
649  for (iScene = 0; iScene < nScenes; iScene++) {
650    if (sceneList [iScene] -> GetName () == selectName) break;
651  }
652  if (iScene >= nScenes) {
653    if (verbosity >= G4VisManager::warnings) {
654      G4cout << "WARNING: Scene \"" << selectName
655             << "\" not found - \"/vis/scene/list\" to see possibilities."
656             << G4endl;
657    }
658    return;
659  }
660
661  if (verbosity >= G4VisManager::confirmations) {
662    G4cout << "Scene \"" << selectName
663           << "\" selected." << G4endl;
664  }
665  UpdateVisManagerScene (selectName);
666}
Note: See TracBrowser for help on using the repository browser.