Geant4  10.02.p03
G4VisCommandSceneAddLogicalVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddLogicalVolume:
Collaboration diagram for G4VisCommandSceneAddLogicalVolume:

Public Member Functions

 G4VisCommandSceneAddLogicalVolume ()
 
virtual ~G4VisCommandSceneAddLogicalVolume ()
 
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 ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

 G4VisCommandSceneAddLogicalVolume (const G4VisCommandSceneAddLogicalVolume &)
 
G4VisCommandSceneAddLogicalVolumeoperator= (const G4VisCommandSceneAddLogicalVolume &)
 

Private Attributes

G4UIcommandfpCommand
 

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 G4VVisCommandScene
G4String CurrentSceneName ()
 
- 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 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 260 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogicalVolume() [1/2]

G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume ( )

Definition at line 1088 of file G4VisCommandsSceneAdd.cc.

1088  {
1089  G4bool omitable;
1090  fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this);
1091  fpCommand -> SetGuidance ("Adds a logical volume to the current scene,");
1092  fpCommand -> SetGuidance
1093  ("Shows boolean components (if any), voxels (if any) and readout geometry"
1094  "\n(if any). Note: voxels are not constructed until start of run -"
1095  "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1096  G4UIparameter* parameter;
1097  parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1098  fpCommand -> SetParameter (parameter);
1099  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1100  parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1101  parameter -> SetDefaultValue (1);
1102  fpCommand -> SetParameter (parameter);
1103  parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1104  parameter -> SetDefaultValue (true);
1105  fpCommand -> SetParameter (parameter);
1106  parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1107  parameter -> SetDefaultValue (true);
1108  fpCommand -> SetParameter (parameter);
1109  parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1110  parameter -> SetDefaultValue (true);
1111  fpCommand -> SetParameter (parameter);
1112  parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1113  parameter -> SetDefaultValue (true);
1114  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1115  fpCommand -> SetParameter (parameter);
1116 }
bool G4bool
Definition: G4Types.hh:79

◆ ~G4VisCommandSceneAddLogicalVolume()

G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume ( )
virtual

Definition at line 1118 of file G4VisCommandsSceneAdd.cc.

1118  {
1119  delete fpCommand;
1120 }

◆ G4VisCommandSceneAddLogicalVolume() [2/2]

G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume ( const G4VisCommandSceneAddLogicalVolume )
private

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1122 of file G4VisCommandsSceneAdd.cc.

1122  {
1123  return "";
1124 }

◆ operator=()

G4VisCommandSceneAddLogicalVolume& G4VisCommandSceneAddLogicalVolume::operator= ( const G4VisCommandSceneAddLogicalVolume )
private

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1126 of file G4VisCommandsSceneAdd.cc.

1127  {
1128 
1130  G4bool warn(verbosity >= G4VisManager::warnings);
1131 
1132  G4Scene* pScene = fpVisManager->GetCurrentScene();
1133  if (!pScene) {
1134  if (verbosity >= G4VisManager::errors) {
1135  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1136  }
1137  return;
1138  }
1139 
1140  G4String name;
1141  G4int requestedDepthOfDescent;
1142  G4String booleansString, voxelsString, readoutString, axesString;
1143  std::istringstream is (newValue);
1144  is >> name >> requestedDepthOfDescent
1145  >> booleansString >> voxelsString >> readoutString >> axesString;
1146  G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1147  G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1148  G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1149  G4bool axes = G4UIcommand::ConvertToBool(axesString);
1150 
1152  int nLV = pLVStore -> size ();
1153  int iLV;
1154  G4LogicalVolume* pLV = 0;
1155  for (iLV = 0; iLV < nLV; iLV++ ) {
1156  pLV = (*pLVStore) [iLV];
1157  if (pLV -> GetName () == name) break;
1158  }
1159  if (iLV == nLV) {
1160  if (verbosity >= G4VisManager::errors) {
1161  G4cerr << "ERROR: Logical volume " << name
1162  << " not found in logical volume store." << G4endl;
1163  }
1164  return;
1165  }
1166 
1167  const std::vector<G4Scene::Model>& rdModelList =
1168  pScene -> GetRunDurationModelList();
1169  std::vector<G4Scene::Model>::const_iterator i;
1170  for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1171  if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1172  }
1173  if (i != rdModelList.end()) {
1174  if (verbosity >= G4VisManager::errors) {
1175  G4cout << "There is already a volume, \""
1176  << i->fpModel->GetGlobalDescription()
1177  << "\",\n in the run-duration model list of scene \""
1178  << pScene -> GetName()
1179  << "\".\n Your logical volume must be the only volume in the scene."
1180  << "\n Create a new scene and try again:"
1181  << "\n /vis/specify " << name
1182  << "\n or"
1183  << "\n /vis/scene/create"
1184  << "\n /vis/scene/add/logicalVolume " << name
1185  << "\n /vis/sceneHandler/attach"
1186  << "\n (and also, if necessary, /vis/viewer/flush)"
1187  << G4endl;
1188  }
1189  return;
1190  }
1191 
1193  (pLV, requestedDepthOfDescent, booleans, voxels, readout);
1194  const G4String& currentSceneName = pScene -> GetName ();
1195  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1196 
1197  if (successful) {
1198 
1199  G4bool axesSuccessful = false;
1200  if (axes) {
1201  const G4double radius = model->GetExtent().GetExtentRadius();
1202  const G4double axisLengthMax = radius / 2.;
1203  const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1204  G4double axisLength = std::pow(10,intLog10Length);
1205  if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1206  else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1207  const G4double axisWidth = axisLength / 20.;
1208  G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1209  axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1210  }
1211 
1212 // if (verbosity >= G4VisManager::warnings) {
1213 // const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1214 // std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1215 // G4cout << G4AttCheck(attValues, attDefs);
1216 // delete attValues;
1217 // }
1218 
1219  if (verbosity >= G4VisManager::confirmations) {
1220  G4cout << "Logical volume \"" << pLV -> GetName ()
1221  << " with requested depth of descent "
1222  << requestedDepthOfDescent
1223  << ",\n with";
1224  if (!booleans) G4cout << "out";
1225  G4cout << " boolean components, with";
1226  if (!voxels) G4cout << "out";
1227  G4cout << " voxels and with";
1228  if (!readout) G4cout << "out";
1229  G4cout << " readout geometry,"
1230  << "\n has been added to scene \"" << currentSceneName << "\".";
1231  if (axes) {
1232  if (axesSuccessful) {
1233  G4cout <<
1234  "\n Axes have also been added at the origin of local cooordinates.";
1235  } else {
1236  G4cout <<
1237  "\n Axes have not been added for some reason possibly stated above.";
1238  }
1239  }
1240  G4cout << G4endl;
1241  }
1242  }
1243  else {
1245  return;
1246  }
1247 
1248  UpdateVisManagerScene (currentSceneName);
1249 }
const G4VisExtent & GetExtent() const
G4Scene * GetCurrentScene() const
void UpdateVisManagerScene(const G4String &sceneName="")
G4String name
Definition: TRTMaterials.hh:40
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:73
int G4int
Definition: G4Types.hh:78
static void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
G4GLOB_DLL std::ostream G4cout
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
bool G4bool
Definition: G4Types.hh:79
static G4LogicalVolumeStore * GetInstance()
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager
Here is the call graph for this function:

Member Data Documentation

◆ fpCommand

G4UIcommand* G4VisCommandSceneAddLogicalVolume::fpCommand
private

Definition at line 270 of file G4VisCommandsSceneAdd.hh.


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