Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandViewerClone Class Reference

#include <G4VisCommandsViewer.hh>

+ Inheritance diagram for G4VisCommandViewerClone:

Public Member Functions

 G4VisCommandViewerClone ()
 
virtual ~G4VisCommandViewerClone ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- 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 ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *pVisManager)
 
static const G4ColourGetCurrentTextColour ()
 
- Protected Member Functions inherited from G4VVisCommand
void SetViewParameters (G4VViewer *viewer, const G4ViewParameters &viewParams)
 
void RefreshIfRequired (G4VViewer *viewer)
 
void InterpolateViews (G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
void InterpolateToNewView (G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
const G4StringConvertToColourGuidance ()
 
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
 
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
 
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
 
G4bool CheckView ()
 
void G4VisCommandsSceneAddUnsuccessful (G4VisManager::Verbosity verbosity)
 
void CopyGuidanceFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
 
void CopyParametersFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd)
 
void DrawExtent (const G4VisExtent &)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (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 G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
 
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 G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
 
static G4VisExtent fCurrentExtentForField
 
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
 

Detailed Description

Definition at line 130 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerClone()

G4VisCommandViewerClone::G4VisCommandViewerClone ( )

Definition at line 570 of file G4VisCommandsViewer.cc.

570 {
571 G4bool omitable;
572 fpCommand = new G4UIcommand ("/vis/viewer/clone", this);
573 fpCommand -> SetGuidance ("Clones viewer.");
574 fpCommand -> SetGuidance
575 ("By default, clones current viewer. Clone becomes current."
576 "\nClone name, if not provided, is derived from the original name."
577 "\n\"/vis/viewer/list\" to see possible viewer names.");
578 G4UIparameter* parameter;
579 parameter = new G4UIparameter ("original-viewer-name", 's', omitable = true);
580 parameter -> SetCurrentAsDefault (true);
581 fpCommand -> SetParameter (parameter);
582 parameter = new G4UIparameter ("clone-name", 's', omitable = true);
583 parameter -> SetDefaultValue ("none");
584 fpCommand -> SetParameter (parameter);
585}
bool G4bool
Definition: G4Types.hh:86

◆ ~G4VisCommandViewerClone()

G4VisCommandViewerClone::~G4VisCommandViewerClone ( )
virtual

Definition at line 587 of file G4VisCommandsViewer.cc.

587 {
588 delete fpCommand;
589}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerClone::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 591 of file G4VisCommandsViewer.cc.

591 {
592 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
593 G4String originalName = viewer ? viewer -> GetName () : G4String("none");
594 return "\"" + originalName + "\"";
595}
static G4VisManager * fpVisManager

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 597 of file G4VisCommandsViewer.cc.

597 {
598
600
601 G4String originalName, cloneName;
602 std::istringstream is (newValue);
603
604 // Need to handle the possibility that the names contain embedded
605 // blanks within quotation marks...
606 char c = ' ';
607 while (is.get(c) && c == ' '){}
608 if (c == '"') {
609 while (is.get(c) && c != '"') {originalName += c;}
610 }
611 else {
612 originalName += c;
613 while (is.get(c) && c != ' ') {originalName += c;}
614 }
615 originalName = originalName.strip (G4String::both, ' ');
616 originalName = originalName.strip (G4String::both, '"');
617
618 G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
619 if (!originalViewer) {
620 if (verbosity >= G4VisManager::errors) {
621 G4cerr << "ERROR: Viewer \"" << originalName
622 << "\" not found - \"/vis/viewer/list\" to see possibilities."
623 << G4endl;
624 }
625 return;
626 }
627 originalName = originalViewer->GetName(); // Ensures long name.
628
629 while (is.get(c) && c == ' '){}
630 if (c == '"') {
631 while (is.get(c) && c != '"') {cloneName += c;}
632 }
633 else {
634 cloneName += c;
635 while (is.get(c) && c != ' ') {cloneName += c;}
636 }
637 cloneName = cloneName.strip (G4String::both, ' ');
638 cloneName = cloneName.strip (G4String::both, '"');
639
640 G4bool errorWhileNaming = false;
641 if (cloneName == "none") {
642 G4int subID = 0;
643 do {
644 cloneName = originalName;
645 std::ostringstream oss;
646 oss << '-' << subID++;
647 G4String::size_type lastDashPosition, nextSpacePosition;
648 if ((lastDashPosition = cloneName.rfind('-')) != G4String::npos &&
649 (nextSpacePosition = cloneName.find(" ", lastDashPosition)) !=
650 G4String::npos) {
651 cloneName.insert(nextSpacePosition, oss.str());
652 } else {
653 G4String::size_type spacePosition = cloneName.find(' ');
654 if (spacePosition != G4String::npos)
655 cloneName.insert(spacePosition, oss.str());
656 else
657 errorWhileNaming = true;
658 }
659 } while (!errorWhileNaming && fpVisManager -> GetViewer (cloneName));
660 }
661
662 if (errorWhileNaming) {
663 if (verbosity >= G4VisManager::errors) {
664 G4cerr << "ERROR: While naming clone viewer \"" << cloneName
665 << "\"."
666 << G4endl;
667 }
668 return;
669 }
670
671 if (fpVisManager -> GetViewer (cloneName)) {
672 if (verbosity >= G4VisManager::errors) {
673 G4cerr << "ERROR: Putative clone viewer \"" << cloneName
674 << "\" already exists."
675 << G4endl;
676 }
677 return;
678 }
679
680 G4String windowSizeHint =
681 originalViewer->GetViewParameters().GetXGeometryString();
682
684 G4int keepVerbose = UImanager->GetVerboseLevel();
685 G4int newVerbose(0);
686 if (keepVerbose >= 2 ||
688 newVerbose = 2;
689 UImanager->SetVerboseLevel(newVerbose);
690 UImanager->ApplyCommand(G4String("/vis/viewer/select " + originalName));
691 UImanager->ApplyCommand
692 (G4String("/vis/viewer/create ! \"" + cloneName + "\" " + windowSizeHint));
693 UImanager->ApplyCommand(G4String("/vis/viewer/set/all " + originalName));
694 UImanager->SetVerboseLevel(keepVerbose);
695
696 if (verbosity >= G4VisManager::confirmations) {
697 G4cout << "Viewer \"" << originalName << "\" cloned." << G4endl;
698 G4cout << "Clone \"" << cloneName << "\" now current." << G4endl;
699 }
700}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:193
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:192
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
const G4String & GetXGeometryString() const
static Verbosity GetVerbosity()

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