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

#include <G4VisCommandsSceneAdd.hh>

+ Inheritance diagram for G4VisCommandSceneAddVolume:

Public Member Functions

 G4VisCommandSceneAddVolume ()
 
virtual ~G4VisCommandSceneAddVolume ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- 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 G4VVisCommandScene
G4String CurrentSceneName ()
 
- 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 439 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 2889 of file G4VisCommandsSceneAdd.cc.

2889 {
2890 G4bool omitable;
2891 fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2892 fpCommand -> SetGuidance
2893 ("Adds a physical volume to current scene, with optional clipping volume.");
2894 fpCommand -> SetGuidance
2895 ("If physical-volume-name is \"world\" (the default), the top of the"
2896 "\nmain geometry tree (material world) is added. If \"worlds\", the"
2897 "\ntops of all worlds - material world and parallel worlds, if any - are"
2898 "\nadded. Otherwise a search of all worlds is made.");
2899 fpCommand -> SetGuidance
2900 ("In the last case the names of all volumes in all worlds are matched"
2901 "\nagainst physical-volume-name. If this is of the form \"/regexp/\","
2902 "\nwhere regexp is a regular expression (see C++ regex), the match uses"
2903 "\nthe usual rules of regular expression matching. Otherwise an exact"
2904 "\nmatch is required."
2905 "\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
2906 fpCommand -> SetGuidance
2907 ("It may help to see a textual representation of the geometry hierarchy of"
2908 "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
2909 "\ncombinations that have the required functionality, e.g., HepRepFile.");
2910 fpCommand -> SetGuidance
2911 ("If clip-volume-type is specified, the subsequent parameters are used to"
2912 "\nto define a clipping volume. For example,"
2913 "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2914 "\nwith the positive octant cut away. (If the Boolean Processor issues"
2915 "\nwarnings try replacing 0 by 0.000000001 or something.)");
2916 fpCommand -> SetGuidance
2917 ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2918 "\n(cutaway). (This is the default if there is no prepended character.)"
2919 "\nIf '*' is prepended, the intersection of the physical-volume and the"
2920 "\nclip-volume is made. (You can make a section through the detector with"
2921 "\na thin box, for example).");
2922 fpCommand -> SetGuidance
2923 ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2924 "\nOnly \"box\" is programmed at present.");
2925 G4UIparameter* parameter;
2926 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2927 parameter -> SetDefaultValue ("world");
2928 fpCommand -> SetParameter (parameter);
2929 parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2930 parameter -> SetGuidance ("If negative, matches any copy no.");
2931 parameter -> SetDefaultValue (-1);
2932 fpCommand -> SetParameter (parameter);
2933 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2934 parameter -> SetGuidance
2935 ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2936 parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2937 fpCommand -> SetParameter (parameter);
2938 parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2939 parameter -> SetParameterCandidates("none box -box *box");
2940 parameter -> SetDefaultValue ("none");
2941 parameter -> SetGuidance("[-|*]type. See general guidance.");
2942 fpCommand -> SetParameter (parameter);
2943 parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2944 parameter -> SetDefaultValue ("m");
2945 fpCommand -> SetParameter (parameter);
2946 parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2947 parameter -> SetDefaultValue (0.);
2948 fpCommand -> SetParameter (parameter);
2949 parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2950 parameter -> SetDefaultValue (0.);
2951 fpCommand -> SetParameter (parameter);
2952 parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2953 parameter -> SetDefaultValue (0.);
2954 fpCommand -> SetParameter (parameter);
2955 parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2956 parameter -> SetDefaultValue (0.);
2957 fpCommand -> SetParameter (parameter);
2958 parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2959 parameter -> SetDefaultValue (0.);
2960 fpCommand -> SetParameter (parameter);
2961 parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2962 parameter -> SetDefaultValue (0.);
2963 fpCommand -> SetParameter (parameter);
2964}
bool G4bool
Definition: G4Types.hh:86
@ UNLIMITED
Definition: G4Scene.hh:54

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 2966 of file G4VisCommandsSceneAdd.cc.

2966 {
2967 delete fpCommand;
2968}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 2970 of file G4VisCommandsSceneAdd.cc.

2970 {
2971 return "world 0 -1";
2972}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 2974 of file G4VisCommandsSceneAdd.cc.

2975 {
2976
2978 G4bool warn = verbosity >= G4VisManager::warnings;
2979
2981 if (!pScene) {
2982 if (verbosity >= G4VisManager::errors) {
2983 G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2984 }
2985 return;
2986 }
2987
2988 G4String name, clipVolumeType, parameterUnit;
2989 G4int copyNo, requestedDepthOfDescent;
2990 G4double param1, param2, param3, param4, param5, param6;
2991 std::istringstream is (newValue);
2992 is >> name >> copyNo >> requestedDepthOfDescent
2993 >> clipVolumeType >> parameterUnit
2994 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2996 G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2997 if (clipVolumeType[size_t(0)] == '-') {
2998 clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2999 } else if (clipVolumeType[size_t(0)] == '*') {
3001 clipVolumeType = clipVolumeType.substr(1);
3002 }
3003 G4double unit = G4UIcommand::ValueOf(parameterUnit);
3004 param1 *= unit; param2 *= unit; param3 *= unit;
3005 param4 *= unit; param5 *= unit; param6 *= unit;
3006
3007 G4VSolid* clippingSolid = nullptr;
3008 if (clipVolumeType == "box") {
3009 const G4double dX = (param2 - param1) / 2.;
3010 const G4double dY = (param4 - param3) / 2.;
3011 const G4double dZ = (param6 - param5) / 2.;
3012 const G4double x0 = (param2 + param1) / 2.;
3013 const G4double y0 = (param4 + param3) / 2.;
3014 const G4double z0 = (param6 + param5) / 2.;
3015 clippingSolid = new G4DisplacedSolid
3016 ("_displaced_clipping_box",
3017 new G4Box("_clipping_box",dX,dY,dZ),
3018 G4Translate3D(x0,y0,z0));
3019 }
3020
3021 G4TransportationManager* transportationManager =
3023
3024 size_t nWorlds = transportationManager->GetNoWorlds();
3025 if (nWorlds > 1) { // Parallel worlds in operation...
3026 if (verbosity >= G4VisManager::warnings) {
3027 static G4bool warned = false;
3028 if (!warned && name != "worlds") {
3029 G4cout <<
3030 "WARNING: Parallel worlds in operation. To visualise, specify"
3031 "\n \"worlds\" or the parallel world volume or sub-volume name"
3032 "\n and control visibility with /vis/geometry."
3033 << G4endl;
3034 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3035 transportationManager->GetWorldsIterator();
3036 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3037 G4cout << " World " << i << ": " << (*iterWorld)->GetName()
3038 << G4endl;
3039 warned = true;
3040 }
3041 }
3042 }
3043 }
3044
3045 // Get the world (the initial value of the iterator points to the mass world).
3046 G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
3047
3048 if (!world) {
3049 if (verbosity >= G4VisManager::errors) {
3050 G4cerr <<
3051 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
3052 "\n No world. Maybe the geometry has not yet been defined."
3053 "\n Try \"/run/initialize\""
3054 << G4endl;
3055 }
3056 return;
3057 }
3058
3059 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
3060
3061 if (name == "world") {
3062
3063 findingsVector.push_back
3065
3066 } else if (name == "worlds") {
3067
3068 if (nWorlds <= 1) {
3069 if (verbosity >= G4VisManager::warnings) {
3070 G4cout <<
3071 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
3072 "\n Parallel worlds requested but none exist."
3073 "\n Just adding material world."
3074 << G4endl;
3075 }
3076 }
3077 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3078 transportationManager->GetWorldsIterator();
3079 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3080 findingsVector.push_back
3082 (*iterWorld,*iterWorld));
3083 }
3084
3085 } else { // Search all worlds...
3086
3087 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3088 transportationManager->GetWorldsIterator();
3089 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3090 G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
3091 G4ModelingParameters mp; // Default - no culling.
3092 searchModel.SetModelingParameters (&mp);
3093 G4PhysicalVolumesSearchScene searchScene (&searchModel, name, copyNo);
3094 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
3095 for (const auto& findings: searchScene.GetFindings()) {
3096 findingsVector.push_back(findings);
3097 }
3098 }
3099 }
3100
3101 for (const auto& findings: findingsVector) {
3102 // Set copy number from search findings for replicas and parameterisations.
3103 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
3104 // Create a physical volume model...
3106 (findings.fpFoundPV,
3107 requestedDepthOfDescent,
3108 findings.fFoundObjectTransformation,
3109 0, // No modelling parameters (these are set later by the scene handler).
3110 false, // Do not use full extent - only use non-culled extent.
3111 findings.fFoundBasePVPath);
3112 if (clippingSolid) {
3113 foundPVModel->SetClippingSolid(clippingSolid);
3114 foundPVModel->SetClippingMode(clippingMode);
3115 }
3116 if (!foundPVModel->Validate(warn)) return; // Calculates extent
3117 // ...so add it to the scene.
3118 G4bool successful = pScene->AddRunDurationModel(foundPVModel,warn);
3119 if (successful) {
3120 if (verbosity >= G4VisManager::confirmations) {
3121 G4cout << "\"" << findings.fpFoundPV->GetName()
3122 << "\", copy no. " << findings.fFoundPVCopyNo
3123 << ",\n found in searched volume \""
3124 << findings.fpSearchPV->GetName()
3125 << "\" at depth " << findings.fFoundDepth
3126 << ",\n base path: \"" << findings.fFoundBasePVPath
3127 << "\",\n with a requested depth of further descent of ";
3128 if (requestedDepthOfDescent < 0) {
3129 G4cout << "<0 (unlimited)";
3130 }
3131 else {
3132 G4cout << requestedDepthOfDescent;
3133 }
3134 G4cout << ",\n has been added to scene \"" << pScene->GetName() << "\"."
3135 << G4endl;
3136 }
3137 } else {
3139 }
3140 }
3141
3142 if (findingsVector.empty()) {
3143 if (verbosity >= G4VisManager::errors) {
3144 G4cerr << "ERROR: Volume \"" << name << "\"";
3145 if (copyNo >= 0) {
3146 G4cerr << ", copy no. " << copyNo << ",";
3147 }
3148 G4cerr << " not found." << G4endl;
3149 }
3151 return;
3152 }
3153
3155}
HepGeom::Translate3D G4Translate3D
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Definition: G4Box.hh:56
void SetClippingSolid(G4VSolid *pClippingSolid)
G4bool Validate(G4bool warn)
void SetClippingMode(ClippingMode mode)
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:50
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:348
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
G4Scene * GetCurrentScene() const
static Verbosity GetVerbosity()
const char * name(G4int ptype)

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