Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisCommandSceneNotifyHandlers Class Reference

#include <G4VisCommandsScene.hh>

Inheritance diagram for G4VisCommandSceneNotifyHandlers:
Collaboration diagram for G4VisCommandSceneNotifyHandlers:

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
 
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 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
 
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 116 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers ( )

Definition at line 591 of file G4VisCommandsScene.cc.

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

Definition at line 621 of file G4VisCommandsScene.cc.

621  {
622  delete fpCommand;
623 }

Member Function Documentation

G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 625 of file G4VisCommandsScene.cc.

625  {
626  return CurrentSceneName ();
627 }

Here is the call graph for this function:

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

Reimplemented from G4UImessenger.

Definition at line 629 of file G4VisCommandsScene.cc.

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

Here is the call graph for this function:


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