Geant4 11.4.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 ()=default
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual ~G4UImessenger ()
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, const 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 LtoS (G4long l)
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 (const 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
static G4SceneTreeItem fExistingSceneTree

Detailed Description

Definition at line 130 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerClone()

G4VisCommandViewerClone::G4VisCommandViewerClone ( )

Definition at line 588 of file G4VisCommandsViewer.cc.

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

◆ ~G4VisCommandViewerClone()

G4VisCommandViewerClone::~G4VisCommandViewerClone ( )
virtual

Definition at line 605 of file G4VisCommandsViewer.cc.

605 {
606 delete fpCommand;
607}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerClone::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 609 of file G4VisCommandsViewer.cc.

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

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 615 of file G4VisCommandsViewer.cc.

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

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