Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandViewerCreate Class Reference

#include <G4VisCommandsViewer.hh>

Inheritance diagram for G4VisCommandViewerCreate:
Collaboration diagram for G4VisCommandViewerCreate:

Public Member Functions

 G4VisCommandViewerCreate ()
 
virtual ~G4VisCommandViewerCreate ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandViewer
 G4VVisCommandViewer ()
 
virtual ~G4VVisCommandViewer ()
 
- 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 G4VVisCommandViewer
void SetViewParameters (G4VViewer *, const G4ViewParameters &)
 
void RefreshIfRequired (G4VViewer *)
 
- 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 156 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

G4VisCommandViewerCreate::G4VisCommandViewerCreate ( )

Definition at line 642 of file G4VisCommandsViewer.cc.

642  : fId (0) {
643  G4bool omitable;
644  fpCommand = new G4UIcommand ("/vis/viewer/create", this);
645  fpCommand -> SetGuidance
646  ("Creates a viewer for the specified scene handler.");
647  fpCommand -> SetGuidance
648  ("Default scene handler is the current scene handler. Invents a name"
649  "\nif not supplied. (Note: the system adds information to the name"
650  "\nfor identification - only the characters up to the first blank are"
651  "\nused for removing, selecting, etc.) This scene handler and viewer"
652  "\nbecome current.");
653  G4UIparameter* parameter;
654  parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
655  parameter -> SetCurrentAsDefault (true);
656  fpCommand -> SetParameter (parameter);
657  parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
658  parameter -> SetCurrentAsDefault (true);
659  fpCommand -> SetParameter (parameter);
660  parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
661  parameter->SetGuidance
662  ("integer (pixels) for square window placed by window manager or"
663  " X-Windows-type geometry string, e.g. 600x600-100+100");
664  parameter->SetDefaultValue("600");
665  fpCommand -> SetParameter (parameter);
666 }
void SetDefaultValue(const char *theDefaultValue)
bool G4bool
Definition: G4Types.hh:79
void SetGuidance(const char *theGuidance)

Here is the call graph for this function:

G4VisCommandViewerCreate::~G4VisCommandViewerCreate ( )
virtual

Definition at line 668 of file G4VisCommandsViewer.cc.

668  {
669  delete fpCommand;
670 }

Member Function Documentation

G4String G4VisCommandViewerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 686 of file G4VisCommandsViewer.cc.

686  {
687  G4String currentValue;
688  G4VSceneHandler* currentSceneHandler =
689  fpVisManager -> GetCurrentSceneHandler ();
690  if (currentSceneHandler) {
691  currentValue = currentSceneHandler -> GetName ();
692  }
693  else {
694  currentValue = "none";
695  }
696  currentValue += ' ';
697  currentValue += '"';
698  currentValue += NextName ();
699  currentValue += '"';
700 
701  currentValue += " 600"; // Default number of pixels for window size hint.
702 
703  return currentValue;
704 }
static G4VisManager * fpVisManager
void G4VisCommandViewerCreate::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 706 of file G4VisCommandsViewer.cc.

706  {
707 
709 
710  G4String sceneHandlerName, newName;
711  G4String windowSizeHintString;
712  std::istringstream is (newValue);
713  is >> sceneHandlerName;
714 
715  // Now need to handle the possibility that the second string
716  // contains embedded blanks within quotation marks...
717  char c = ' ';
718  while (is.get(c) && c == ' '){}
719  if (c == '"') {
720  while (is.get(c) && c != '"') {newName += c;}
721  }
722  else {
723  newName += c;
724  while (is.get(c) && c != ' ') {newName += c;}
725  }
726  newName = newName.strip (G4String::both, ' ');
727  newName = newName.strip (G4String::both, '"');
728 
729  // Now get window size hint...
730  is >> windowSizeHintString;
731 
732  const G4SceneHandlerList& sceneHandlerList =
733  fpVisManager -> GetAvailableSceneHandlers ();
734  G4int nHandlers = sceneHandlerList.size ();
735  if (nHandlers <= 0) {
736  if (verbosity >= G4VisManager::errors) {
737  G4cerr <<
738  "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
739  "\n Create a scene handler with \"/vis/sceneHandler/create\""
740  << G4endl;
741  }
742  return;
743  }
744 
745  G4int iHandler;
746  for (iHandler = 0; iHandler < nHandlers; iHandler++) {
747  if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
748  }
749 
750  if (iHandler < 0 || iHandler >= nHandlers) {
751  // Invalid command line argument or none.
752  // This shouldn't happen!!!!!!
753  if (verbosity >= G4VisManager::errors) {
754  G4cout << "G4VisCommandViewerCreate::SetNewValue:"
755  " invalid scene handler specified."
756  << G4endl;
757  }
758  return;
759  }
760 
761  // Valid index. Set current scene handler and graphics system in
762  // preparation for creating viewer.
763  G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
764  if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
765  fpVisManager -> SetCurrentSceneHandler (sceneHandler);
766  }
767 
768  // Now deal with name of viewer.
769  G4String nextName = NextName ();
770  if (newName == "") {
771  newName = nextName;
772  }
773  if (newName == nextName) fId++;
774  G4String newShortName = fpVisManager -> ViewerShortName (newName);
775 
776  for (G4int ih = 0; ih < nHandlers; ih++) {
777  G4VSceneHandler* sh = sceneHandlerList [ih];
778  const G4ViewerList& viewerList = sh -> GetViewerList ();
779  for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
780  if (viewerList [iViewer] -> GetShortName () == newShortName ) {
781  if (verbosity >= G4VisManager::errors) {
782  G4cerr << "ERROR: Viewer \"" << newShortName << "\" already exists."
783  << G4endl;
784  }
785  return;
786  }
787  }
788  }
789 
790  // WindowSizeHint and XGeometryString are picked up from the vis
791  // manager in the G4VViewer constructor. In G4VisManager, after Viewer
792  // creation, we will store theses parameters in G4ViewParameters.
793 
794  fpVisManager -> CreateViewer (newName,windowSizeHintString);
795 
796  G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
797  if (newViewer && newViewer -> GetName () == newName) {
798  if (verbosity >= G4VisManager::confirmations) {
799  G4cout << "New viewer \"" << newName << "\" created." << G4endl;
800  }
801  }
802  else {
803  if (verbosity >= G4VisManager::errors) {
804  if (newViewer) {
805  G4cerr << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
806  } else {
807  G4cout << "WARNING: No viewer created." << G4endl;
808  }
809  }
810  }
811  // Refresh if appropriate...
812  if (newViewer) {
813  if (newViewer->GetViewParameters().IsAutoRefresh()) {
814  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
815  }
816  else {
817  if (verbosity >= G4VisManager::warnings) {
818  G4cout << "Issue /vis/viewer/refresh or flush to see effect."
819  << G4endl;
820  }
821  }
822  }
823 }
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4ViewParameters & GetViewParameters() const
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
tuple c
Definition: test.py:13
G4bool IsAutoRefresh() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager

Here is the call graph for this function:


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