Geant4 11.1.1
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 ()=default
 
 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 G4VisManagerGetVisManager ()
 
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="")
 
void Twinkle (G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
 
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 CopyCameraParameters (G4ViewParameters &target, const G4ViewParameters &from)
 
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 (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 = nullptr
 
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
 
static G4bool fThereWasAViewer = false
 
static G4ViewParameters fExistingVP
 

Detailed Description

Definition at line 130 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerClone()

G4VisCommandViewerClone::G4VisCommandViewerClone ( )

Definition at line 589 of file G4VisCommandsViewer.cc.

589 {
590 G4bool omitable;
591 fpCommand = new G4UIcommand ("/vis/viewer/clone", this);
592 fpCommand -> SetGuidance ("Clones viewer.");
593 fpCommand -> SetGuidance
594 ("By default, clones current viewer. Clone becomes current."
595 "\nClone name, if not provided, is derived from the original name."
596 "\n\"/vis/viewer/list\" to see possible viewer names.");
597 G4UIparameter* parameter;
598 parameter = new G4UIparameter ("original-viewer-name", 's', omitable = true);
599 parameter -> SetCurrentAsDefault (true);
600 fpCommand -> SetParameter (parameter);
601 parameter = new G4UIparameter ("clone-name", 's', omitable = true);
602 parameter -> SetDefaultValue ("none");
603 fpCommand -> SetParameter (parameter);
604}
bool G4bool
Definition: G4Types.hh:86

◆ ~G4VisCommandViewerClone()

G4VisCommandViewerClone::~G4VisCommandViewerClone ( )
virtual

Definition at line 606 of file G4VisCommandsViewer.cc.

606 {
607 delete fpCommand;
608}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerClone::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 610 of file G4VisCommandsViewer.cc.

610 {
611 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
612 G4String originalName = viewer ? viewer -> GetName () : G4String("none");
613 return "\"" + originalName + "\"";
614}
static G4VisManager * fpVisManager

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 616 of file G4VisCommandsViewer.cc.

616 {
617
619
620 G4String originalName, cloneName;
621 std::istringstream is (newValue);
622
623 // Need to handle the possibility that the names contain embedded
624 // blanks within quotation marks...
625 char c = ' ';
626 while (is.get(c) && c == ' '){}
627 if (c == '"') {
628 while (is.get(c) && c != '"') {originalName += c;}
629 }
630 else {
631 originalName += c;
632 while (is.get(c) && c != ' ') {originalName += c;}
633 }
634 G4StrUtil::strip(originalName, ' ');
635 G4StrUtil::strip(originalName, '"');
636
637 G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
638 if (!originalViewer) {
639 if (verbosity >= G4VisManager::errors) {
640 G4warn << "ERROR: Viewer \"" << originalName
641 << "\" not found - \"/vis/viewer/list\" to see possibilities."
642 << G4endl;
643 }
644 return;
645 }
646 originalName = originalViewer->GetName(); // Ensures long name.
647
648 while (is.get(c) && c == ' '){}
649 if (c == '"') {
650 while (is.get(c) && c != '"') {cloneName += c;}
651 }
652 else {
653 cloneName += c;
654 while (is.get(c) && c != ' ') {cloneName += c;}
655 }
656 G4StrUtil::strip(cloneName, ' ');
657 G4StrUtil::strip(cloneName, '"');
658
659 G4bool errorWhileNaming = false;
660 if (cloneName == "none") {
661 G4int subID = 0;
662 do {
663 cloneName = originalName;
664 std::ostringstream oss;
665 oss << '-' << subID++;
666 G4String::size_type lastDashPosition, nextSpacePosition;
667 if ((lastDashPosition = cloneName.rfind('-')) != G4String::npos &&
668 (nextSpacePosition = cloneName.find(" ", lastDashPosition)) !=
669 G4String::npos) {
670 cloneName.insert(nextSpacePosition, oss.str());
671 } else {
672 G4String::size_type spacePosition = cloneName.find(' ');
673 if (spacePosition != G4String::npos)
674 cloneName.insert(spacePosition, oss.str());
675 else
676 errorWhileNaming = true;
677 }
678 } while (!errorWhileNaming && fpVisManager -> GetViewer (cloneName));
679 }
680
681 if (errorWhileNaming) {
682 if (verbosity >= G4VisManager::errors) {
683 G4warn << "ERROR: While naming clone viewer \"" << cloneName
684 << "\"."
685 << G4endl;
686 }
687 return;
688 }
689
690 if (fpVisManager -> GetViewer (cloneName)) {
691 if (verbosity >= G4VisManager::errors) {
692 G4warn << "ERROR: Putative clone viewer \"" << cloneName
693 << "\" already exists."
694 << G4endl;
695 }
696 return;
697 }
698
699 G4String windowSizeHint =
700 originalViewer->GetViewParameters().GetXGeometryString();
701
703 UImanager->ApplyCommand(G4String("/vis/viewer/select " + originalName));
704 UImanager->ApplyCommand
705 (G4String("/vis/viewer/create ! \"" + cloneName + "\" " + windowSizeHint));
706 UImanager->ApplyCommand(G4String("/vis/viewer/set/all " + originalName));
707
708 if (verbosity >= G4VisManager::confirmations) {
709 G4cout << "Viewer \"" << originalName << "\" cloned." << G4endl;
710 G4cout << "Clone \"" << cloneName << "\" now current." << G4endl;
711 }
712}
#define G4warn
Definition: G4Scene.cc:41
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
const G4String & GetXGeometryString() const
static Verbosity GetVerbosity()
void strip(G4String &str, char ch=' ')
Remove leading and trailing characters from string.

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