Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
 

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 G4int fErrorCode = 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::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), readout geometry"
1094  "\n (if any) and local axes, under control of the appropriate flag."
1095  "\n Note: voxels are not constructed until start of run -"
1096  "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1097  G4UIparameter* parameter;
1098  parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1099  fpCommand -> SetParameter (parameter);
1100  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1101  parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1102  parameter -> SetDefaultValue (1);
1103  fpCommand -> SetParameter (parameter);
1104  parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1105  parameter -> SetDefaultValue (true);
1106  fpCommand -> SetParameter (parameter);
1107  parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1108  parameter -> SetDefaultValue (true);
1109  fpCommand -> SetParameter (parameter);
1110  parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1111  parameter -> SetDefaultValue (true);
1112  fpCommand -> SetParameter (parameter);
1113  parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1114  parameter -> SetDefaultValue (true);
1115  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1116  fpCommand -> SetParameter (parameter);
1117 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume ( )
virtual

Definition at line 1119 of file G4VisCommandsSceneAdd.cc.

1119  {
1120  delete fpCommand;
1121 }

Member Function Documentation

G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1123 of file G4VisCommandsSceneAdd.cc.

1123  {
1124  return "";
1125 }
void G4VisCommandSceneAddLogicalVolume::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 1127 of file G4VisCommandsSceneAdd.cc.

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

Here is the call graph for this function:


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