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

#include <G4VisCommandsViewer.hh>

Inheritance diagram for G4VisCommandViewerCreate:
G4VVisCommandViewer G4VVisCommand G4UImessenger

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
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
- 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
 
- 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 144 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

G4VisCommandViewerCreate::G4VisCommandViewerCreate ( )

Definition at line 589 of file G4VisCommandsViewer.cc.

References G4UIparameter::SetDefaultValue(), and G4UIparameter::SetGuidance().

589  : fId (0) {
590  G4bool omitable;
591  fpCommand = new G4UIcommand ("/vis/viewer/create", this);
592  fpCommand -> SetGuidance
593  ("Creates a viewer for the specified scene handler.");
594  fpCommand -> SetGuidance
595  ("Default scene handler is the current scene handler. Invents a name"
596  "\nif not supplied. (Note: the system adds information to the name"
597  "\nfor identification - only the characters up to the first blank are"
598  "\nused for removing, selecting, etc.) This scene handler and viewer"
599  "\nbecome current.");
600  G4UIparameter* parameter;
601  parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
602  parameter -> SetCurrentAsDefault (true);
603  fpCommand -> SetParameter (parameter);
604  parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
605  parameter -> SetCurrentAsDefault (true);
606  fpCommand -> SetParameter (parameter);
607  parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
608  parameter->SetGuidance
609  ("integer (pixels) for square window placed by window manager or"
610  " X-Windows-type geometry string, e.g. 600x600-100+100");
611  parameter->SetDefaultValue("600");
612  fpCommand -> SetParameter (parameter);
613 }
void SetDefaultValue(const char *theDefaultValue)
bool G4bool
Definition: G4Types.hh:79
void SetGuidance(const char *theGuidance)
G4VisCommandViewerCreate::~G4VisCommandViewerCreate ( )
virtual

Definition at line 615 of file G4VisCommandsViewer.cc.

615  {
616  delete fpCommand;
617 }

Member Function Documentation

G4String G4VisCommandViewerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 633 of file G4VisCommandsViewer.cc.

References G4VVisCommand::fpVisManager.

633  {
634  G4String currentValue;
635  G4VSceneHandler* currentSceneHandler =
636  fpVisManager -> GetCurrentSceneHandler ();
637  if (currentSceneHandler) {
638  currentValue = currentSceneHandler -> GetName ();
639  }
640  else {
641  currentValue = "none";
642  }
643  currentValue += ' ';
644  currentValue += '"';
645  currentValue += NextName ();
646  currentValue += '"';
647 
648  currentValue += " 600"; // Default number of pixels for window size hint.
649 
650  return currentValue;
651 }
static G4VisManager * fpVisManager
void G4VisCommandViewerCreate::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 653 of file G4VisCommandsViewer.cc.

References G4UImanager::ApplyCommand(), G4String::both, test::c, G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4UImanager::GetUIpointer(), G4VisManager::GetVerbosity(), G4VViewer::GetViewParameters(), G4ViewParameters::IsAutoRefresh(), G4String::strip(), and G4VisManager::warnings.

653  {
654 
656 
657  G4String sceneHandlerName, newName;
658  G4String windowSizeHintString;
659  std::istringstream is (newValue);
660  is >> sceneHandlerName;
661 
662  // Now need to handle the possibility that the second string
663  // contains embedded blanks within quotation marks...
664  char c;
665  while (is.get(c) && c == ' '){}
666  if (c == '"') {
667  while (is.get(c) && c != '"') {newName += c;}
668  }
669  else {
670  newName += c;
671  while (is.get(c) && c != ' ') {newName += c;}
672  }
673  newName = newName.strip (G4String::both, ' ');
674  newName = newName.strip (G4String::both, '"');
675 
676  // Now get window size hint...
677  is >> windowSizeHintString;
678 
679  const G4SceneHandlerList& sceneHandlerList =
680  fpVisManager -> GetAvailableSceneHandlers ();
681  G4int nHandlers = sceneHandlerList.size ();
682  if (nHandlers <= 0) {
683  if (verbosity >= G4VisManager::errors) {
684  G4cout <<
685  "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
686  "\n Create a scene handler with \"/vis/sceneHandler/create\""
687  << G4endl;
688  }
689  return;
690  }
691 
692  G4int iHandler;
693  for (iHandler = 0; iHandler < nHandlers; iHandler++) {
694  if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
695  }
696 
697  if (iHandler < 0 || iHandler >= nHandlers) {
698  // Invalid command line argument or none.
699  // This shouldn't happen!!!!!!
700  if (verbosity >= G4VisManager::errors) {
701  G4cout << "G4VisCommandViewerCreate::SetNewValue:"
702  " invalid scene handler specified."
703  << G4endl;
704  }
705  return;
706  }
707 
708  // Valid index. Set current scene handler and graphics system in
709  // preparation for creating viewer.
710  G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
711  if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
712  fpVisManager -> SetCurrentSceneHandler (sceneHandler);
713  }
714 
715  // Now deal with name of viewer.
716  G4String nextName = NextName ();
717  if (newName == "") {
718  newName = nextName;
719  }
720  if (newName == nextName) fId++;
721  G4String newShortName = fpVisManager -> ViewerShortName (newName);
722 
723  for (G4int ih = 0; ih < nHandlers; ih++) {
724  G4VSceneHandler* sh = sceneHandlerList [ih];
725  const G4ViewerList& viewerList = sh -> GetViewerList ();
726  for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
727  if (viewerList [iViewer] -> GetShortName () == newShortName ) {
728  if (verbosity >= G4VisManager::errors) {
729  G4cout << "ERROR: Viewer \"" << newShortName << "\" already exists."
730  << G4endl;
731  }
732  return;
733  }
734  }
735  }
736 
737  // WindowSizeHint and XGeometryString are picked up from the vis
738  // manager in the G4VViewer constructor. In G4VisManager, after Viewer
739  // creation, we will store theses parameters in G4ViewParameters.
740 
741  fpVisManager -> CreateViewer (newName,windowSizeHintString);
742 
743  G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
744  if (newViewer && newViewer -> GetName () == newName) {
745  if (verbosity >= G4VisManager::confirmations) {
746  G4cout << "New viewer \"" << newName << "\" created." << G4endl;
747  }
748  }
749  else {
750  if (verbosity >= G4VisManager::errors) {
751  if (newViewer) {
752  G4cout << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
753  } else {
754  G4cout << "WARNING: No viewer created." << G4endl;
755  }
756  }
757  }
758  // Refresh if appropriate...
759  if (newViewer) {
760  if (newViewer->GetViewParameters().IsAutoRefresh()) {
761  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
762  }
763  else {
764  if (verbosity >= G4VisManager::warnings) {
765  G4cout << "Issue /vis/viewer/refresh or flush to see effect."
766  << G4endl;
767  }
768  }
769  }
770 }
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4ViewParameters & GetViewParameters() const
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
G4bool IsAutoRefresh() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
static G4VisManager * fpVisManager

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