Geant4.10
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4VisCommandSceneNotifyHandlers Class Reference

#include <G4VisCommandsScene.hh>

Inheritance diagram for G4VisCommandSceneNotifyHandlers:
G4VVisCommandScene G4VVisCommand G4UImessenger

Public Member Functions

 G4VisCommandSceneNotifyHandlers ()
 
virtual ~G4VisCommandSceneNotifyHandlers ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- 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 G4VVisCommandScene
G4String CurrentSceneName ()
 
- 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 116 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers ( )

Definition at line 584 of file G4VisCommandsScene.cc.

584  {
585  G4bool omitable;
586  fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
587  fpCommand -> SetGuidance
588  ("Notifies scene handlers and forces re-rendering.");
589  fpCommand -> SetGuidance
590  ("Notifies the handler(s) of the specified scene and forces a"
591  "\nreconstruction of any graphical databases."
592  "\nClears and refreshes all viewers of current scene."
593  "\n The default action \"refresh\" does not issue \"update\" (see"
594  "\n /vis/viewer/update)."
595  "\nIf \"flush\" is specified, it issues an \"update\" as well as"
596  "\n \"refresh\" - \"update\" and initiates post-processing"
597  "\n for graphics systems which need it.");
598  fpCommand -> SetGuidance
599  ("The default for <scene-name> is the current scene name.");
600  fpCommand -> SetGuidance
601  ("This command does not change current scene, scene handler or viewer.");
602  G4UIparameter* parameter;
603  parameter = new G4UIparameter ("scene-name", 's',
604  omitable = true);
605  parameter -> SetCurrentAsDefault(true);
606  fpCommand -> SetParameter (parameter);
607  parameter = new G4UIparameter ("refresh-flush", 's',
608  omitable = true);
609  parameter -> SetDefaultValue("refresh");
610  parameter -> SetParameterCandidates("r refresh f flush");
611  fpCommand -> SetParameter (parameter);
612 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers ( )
virtual

Definition at line 614 of file G4VisCommandsScene.cc.

614  {
615  delete fpCommand;
616 }

Member Function Documentation

G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 618 of file G4VisCommandsScene.cc.

References G4VVisCommandScene::CurrentSceneName().

618  {
619  return CurrentSceneName ();
620 }
void G4VisCommandSceneNotifyHandlers::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 622 of file G4VisCommandsScene.cc.

References G4Scene::CalculateExtent(), G4VisManager::confirmations, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VSceneHandler::GetName(), G4VSceneHandler::GetScene(), G4VisManager::GetVerbosity(), G4VViewer::GetViewParameters(), G4ViewParameters::IsAutoRefresh(), and G4VisManager::warnings.

623  {
624 
626 
627  G4String sceneName, refresh_flush;
628  std::istringstream is (newValue);
629  is >> sceneName >> refresh_flush;
630  G4bool flush = false;
631  if (refresh_flush(0) == 'f') flush = true;
632 
633  const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
634  G4SceneHandlerList& sceneHandlerList =
635  fpVisManager -> SetAvailableSceneHandlers ();
636 
637  // Check scene name.
638  const G4int nScenes = sceneList.size ();
639  G4int iScene;
640  for (iScene = 0; iScene < nScenes; iScene++) {
641  G4Scene* scene = sceneList [iScene];
642  if (sceneName == scene -> GetName ()) break;
643  }
644  if (iScene >= nScenes ) {
645  if (verbosity >= G4VisManager::warnings) {
646  G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
647  "\n /vis/scene/list to see scenes."
648  << G4endl;
649  }
650  return;
651  }
652 
653  // Store current context...
654  G4VSceneHandler* pCurrentSceneHandler =
655  fpVisManager -> GetCurrentSceneHandler();
656  if (!pCurrentSceneHandler) {
657  if (verbosity >= G4VisManager::warnings) {
658  G4cout << "WARNING: No current scene handler."
659  << G4endl;
660  }
661  return;
662  }
663  G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
664  if (!pCurrentViewer) {
665  if (verbosity >= G4VisManager::warnings) {
666  G4cout << "WARNING: No current viewer."
667  << G4endl;
668  }
669  return;
670  }
671  G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
672  if (!pCurrentScene) {
673  if (verbosity >= G4VisManager::warnings) {
674  G4cout << "WARNING: No current scene."
675  << G4endl;
676  }
677  return;
678  }
679 
680  G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
681 
682  // Suppress messages during this process (only print errors)...
683  //fpVisManager -> SetVerboseLevel(G4VisManager::errors);
684 
685  // For each scene handler, if it contains the scene, clear and
686  // rebuild the graphical database, then for each viewer set (make
687  // current), clear, (re)draw, and show.
688  const G4int nSceneHandlers = sceneHandlerList.size ();
689  for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
690  G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
691  G4Scene* aScene = aSceneHandler -> GetScene ();
692  if (aScene) {
693  const G4String& aSceneName = aScene -> GetName ();
694  if (sceneName == aSceneName) {
695  aScene->CalculateExtent(); // Check and recalculate extent
696  G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
697  const G4int nViewers = viewerList.size ();
698  for (G4int iV = 0; iV < nViewers; iV++) {
699  G4VViewer* aViewer = viewerList [iV];
700  // Force rebuild of graphical database, if any.
701  aViewer -> NeedKernelVisit();
702  if (aViewer->GetViewParameters().IsAutoRefresh()) {
703  aSceneHandler -> SetCurrentViewer (aViewer);
704  // Ensure consistency of vis manager...
705  fpVisManager -> SetCurrentViewer(aViewer);
706  fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
707  fpVisManager -> SetCurrentScene(aScene);
708  aViewer -> SetView ();
709  aViewer -> ClearView ();
710  aViewer -> DrawView ();
711  if (flush) aViewer -> ShowView ();
712  if (verbosity >= G4VisManager::confirmations) {
713  G4cout << "Viewer \"" << aViewer -> GetName ()
714  << "\" of scene handler \"" << aSceneHandler -> GetName ()
715  << "\"\n ";
716  if (flush) G4cout << "flushed";
717  else G4cout << "refreshed";
718  G4cout << " at request of scene \"" << sceneName
719  << "\"." << G4endl;
720  }
721  } else {
722  if (verbosity >= G4VisManager::confirmations) {
723  G4cout << "NOTE: The scene, \""
724  << sceneName
725  << "\", of viewer \""
726  << aViewer -> GetName ()
727  << "\"\n of scene handler \""
728  << aSceneHandler -> GetName ()
729  << "\" has changed. To see effect,"
730  << "\n \"/vis/viewer/select "
731  << aViewer -> GetShortName ()
732  << "\" and \"/vis/viewer/rebuild\"."
733  << G4endl;
734  }
735  }
736  }
737  }
738  }
739  else {
740  if (verbosity >= G4VisManager::warnings) {
741  G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
742  << aSceneHandler->GetName()
743  << "\" has a null scene."
744  << G4endl;
745  }
746  }
747  }
748 
749  // Reclaim original context - but set viewer first, then scene
750  // handler, because the latter might have been created very recently
751  // and, not yet having a viewer, the current viewer will,
752  // temporarily, refer to another scene handler. SetCurrentViewer
753  // actually resets the scene handler, which is what we don't want,
754  // so we set it again on the next line...
755  fpVisManager -> SetCurrentViewer(pCurrentViewer);
756  fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
757  fpVisManager -> SetCurrentScene(pCurrentScene);
758  fpVisManager -> SetVerboseLevel(currentVerbosity);
759  // Take care of special case of scene handler with no viewer yet.
760  if (pCurrentSceneHandler) {
761  G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
762  const G4int nViewers = viewerList.size ();
763  if (nViewers) {
764  pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
765  if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
766  pCurrentViewer -> SetView ();
767  }
768  }
769  }
770 }
const G4ViewParameters & GetViewParameters() const
const G4String & GetName() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
void CalculateExtent()
Definition: G4Scene.cc:72
G4Scene * GetScene() const
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
G4bool IsAutoRefresh() const
static G4VisManager * fpVisManager

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