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

#include <G4VisCommandsViewer.hh>

Inheritance diagram for G4VisCommandViewerClone:
Collaboration diagram for G4VisCommandViewerClone:

Public Member Functions

 G4VisCommandViewerClone ()
 
virtual ~G4VisCommandViewerClone ()
 
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 130 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

G4VisCommandViewerClone::G4VisCommandViewerClone ( )

Definition at line 430 of file G4VisCommandsViewer.cc.

430  {
431  G4bool omitable;
432  fpCommand = new G4UIcommand ("/vis/viewer/clone", this);
433  fpCommand -> SetGuidance ("Clones viewer.");
434  fpCommand -> SetGuidance
435  ("By default, clones current viewer. Clone becomes current."
436  "\nClone name, if not provided, is derived from the original name."
437  "\n\"/vis/viewer/list\" to see possible viewer names.");
438  G4UIparameter* parameter;
439  parameter = new G4UIparameter ("original-viewer-name", 's', omitable = true);
440  parameter -> SetCurrentAsDefault (true);
441  fpCommand -> SetParameter (parameter);
442  parameter = new G4UIparameter ("clone-name", 's', omitable = true);
443  parameter -> SetDefaultValue ("none");
444  fpCommand -> SetParameter (parameter);
445 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandViewerClone::~G4VisCommandViewerClone ( )
virtual

Definition at line 447 of file G4VisCommandsViewer.cc.

447  {
448  delete fpCommand;
449 }

Member Function Documentation

G4String G4VisCommandViewerClone::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 451 of file G4VisCommandsViewer.cc.

451  {
452  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
453  G4String originalName = viewer ? viewer -> GetName () : G4String("none");
454  return "\"" + originalName + "\"";
455 }
static G4VisManager * fpVisManager
void G4VisCommandViewerClone::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 457 of file G4VisCommandsViewer.cc.

457  {
458 
460 
461  G4String originalName, cloneName;
462  std::istringstream is (newValue);
463 
464  // Need to handle the possibility that the names contain embedded
465  // blanks within quotation marks...
466  char c = ' ';
467  while (is.get(c) && c == ' '){}
468  if (c == '"') {
469  while (is.get(c) && c != '"') {originalName += c;}
470  }
471  else {
472  originalName += c;
473  while (is.get(c) && c != ' ') {originalName += c;}
474  }
475  originalName = originalName.strip (G4String::both, ' ');
476  originalName = originalName.strip (G4String::both, '"');
477 
478  G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
479  if (!originalViewer) {
480  if (verbosity >= G4VisManager::errors) {
481  G4cerr << "ERROR: Viewer \"" << originalName
482  << "\" not found - \"/vis/viewer/list\" to see possibilities."
483  << G4endl;
484  }
485  return;
486  }
487  originalName = originalViewer->GetName(); // Ensures long name.
488 
489  while (is.get(c) && c == ' '){}
490  if (c == '"') {
491  while (is.get(c) && c != '"') {cloneName += c;}
492  }
493  else {
494  cloneName += c;
495  while (is.get(c) && c != ' ') {cloneName += c;}
496  }
497  cloneName = cloneName.strip (G4String::both, ' ');
498  cloneName = cloneName.strip (G4String::both, '"');
499 
500  G4bool errorWhileNaming = false;
501  if (cloneName == "none") {
502  G4int subID = 0;
503  do {
504  cloneName = originalName;
505  std::ostringstream oss;
506  oss << '-' << subID++;
507  G4String::size_type lastDashPosition, nextSpacePosition;
508  if ((lastDashPosition = cloneName.rfind('-')) != G4String::npos &&
509  (nextSpacePosition = cloneName.find(" ", lastDashPosition)) !=
510  G4String::npos) {
511  cloneName.insert(nextSpacePosition, oss.str());
512  } else {
513  G4String::size_type spacePosition = cloneName.find(' ');
514  if (spacePosition != G4String::npos)
515  cloneName.insert(spacePosition, oss.str());
516  else
517  errorWhileNaming = true;
518  }
519  } while (!errorWhileNaming && fpVisManager -> GetViewer (cloneName));
520  }
521 
522  if (errorWhileNaming) {
523  if (verbosity >= G4VisManager::errors) {
524  G4cerr << "ERROR: While naming clone viewer \"" << cloneName
525  << "\"."
526  << G4endl;
527  }
528  return;
529  }
530 
531  if (fpVisManager -> GetViewer (cloneName)) {
532  if (verbosity >= G4VisManager::errors) {
533  G4cerr << "ERROR: Putative clone viewer \"" << cloneName
534  << "\" already exists."
535  << G4endl;
536  }
537  return;
538  }
539 
540  G4String windowSizeHint =
541  originalViewer->GetViewParameters().GetXGeometryString();
542 
543  G4UImanager* UImanager = G4UImanager::GetUIpointer();
544  G4int keepVerbose = UImanager->GetVerboseLevel();
545  G4int newVerbose(0);
546  if (keepVerbose >= 2 ||
548  newVerbose = 2;
549  UImanager->SetVerboseLevel(newVerbose);
550  UImanager->ApplyCommand(G4String("/vis/viewer/select " + originalName));
551  UImanager->ApplyCommand
552  (G4String("/vis/viewer/create ! \"" + cloneName + "\" " + windowSizeHint));
553  UImanager->ApplyCommand(G4String("/vis/viewer/set/all " + originalName));
554  UImanager->SetVerboseLevel(keepVerbose);
555 
556  if (verbosity >= G4VisManager::confirmations) {
557  G4cout << "Viewer \"" << originalName << "\" cloned." << G4endl;
558  G4cout << "Clone \"" << cloneName << "\" now current." << G4endl;
559  }
560 }
const G4String & GetName() const
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4ViewParameters & GetViewParameters() const
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:227
int G4int
Definition: G4Types.hh:78
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:225
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
const G4String & GetXGeometryString() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
tuple c
Definition: test.py:13
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: