Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisCommandSceneAddVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddVolume:
Collaboration 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 ()
 
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 413 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 2712 of file G4VisCommandsSceneAdd.cc.

2712  {
2713  G4bool omitable;
2714  fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2715  fpCommand -> SetGuidance
2716  ("Adds a physical volume to current scene, with optional clipping volume.");
2717  fpCommand -> SetGuidance
2718  ("If physical-volume-name is \"world\" (the default), the top of the"
2719  "\nmain geometry tree (material world) is added. If \"worlds\", the"
2720  "\ntop of all worlds - material world and parallel worlds, if any - are"
2721  "\nadded. Otherwise a search of all worlds is made, taking the first"
2722  "\nmatching occurence only. To see a representation of the geometry"
2723  "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2724  "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2725  fpCommand -> SetGuidance
2726  ("If clip-volume-type is specified, the subsequent parameters are used to"
2727  "\nto define a clipping volume. For example,"
2728  "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2729  "\nwith the positive octant cut away. (If the Boolean Processor issues"
2730  "\nwarnings try replacing 0 by 0.000000001 or something.)");
2731  fpCommand -> SetGuidance
2732  ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2733  "\n(cutaway). (This is the default if there is no prepended character.)"
2734  "\nIf '*' is prepended, the intersection of the physical-volume and the"
2735  "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2736  "\nexample).");
2737  fpCommand -> SetGuidance
2738  ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2739  "\nOnly \"box\" is programmed at present.");
2740  G4UIparameter* parameter;
2741  parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2742  parameter -> SetDefaultValue ("world");
2743  fpCommand -> SetParameter (parameter);
2744  parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2745  parameter -> SetGuidance
2746  ("If negative, matches any copy no. First name match is taken.");
2747  parameter -> SetDefaultValue (-1);
2748  fpCommand -> SetParameter (parameter);
2749  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2750  parameter -> SetGuidance
2751  ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2752  parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2753  fpCommand -> SetParameter (parameter);
2754  parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2755  parameter -> SetParameterCandidates("none box -box *box");
2756  parameter -> SetDefaultValue ("none");
2757  parameter -> SetGuidance("[-|*]type. See general guidance.");
2758  fpCommand -> SetParameter (parameter);
2759  parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2760  parameter -> SetDefaultValue ("m");
2761  fpCommand -> SetParameter (parameter);
2762  parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2763  parameter -> SetDefaultValue (0.);
2764  fpCommand -> SetParameter (parameter);
2765  parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2766  parameter -> SetDefaultValue (0.);
2767  fpCommand -> SetParameter (parameter);
2768  parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2769  parameter -> SetDefaultValue (0.);
2770  fpCommand -> SetParameter (parameter);
2771  parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2772  parameter -> SetDefaultValue (0.);
2773  fpCommand -> SetParameter (parameter);
2774  parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2775  parameter -> SetDefaultValue (0.);
2776  fpCommand -> SetParameter (parameter);
2777  parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2778  parameter -> SetDefaultValue (0.);
2779  fpCommand -> SetParameter (parameter);
2780 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 2782 of file G4VisCommandsSceneAdd.cc.

2782  {
2783  delete fpCommand;
2784 }

Member Function Documentation

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 2786 of file G4VisCommandsSceneAdd.cc.

2786  {
2787  return "world 0 -1";
2788 }
void G4VisCommandSceneAddVolume::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 2790 of file G4VisCommandsSceneAdd.cc.

2791  {
2792 
2794  G4bool warn = verbosity >= G4VisManager::warnings;
2795 
2796  G4Scene* pScene = fpVisManager->GetCurrentScene();
2797  if (!pScene) {
2798  if (verbosity >= G4VisManager::errors) {
2799  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2800  }
2801  return;
2802  }
2803 
2804  G4String name, clipVolumeType, parameterUnit;
2805  G4int copyNo, requestedDepthOfDescent;
2806  G4double param1, param2, param3, param4, param5, param6;
2807  std::istringstream is (newValue);
2808  is >> name >> copyNo >> requestedDepthOfDescent
2809  >> clipVolumeType >> parameterUnit
2810  >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2812  G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2813  if (clipVolumeType[size_t(0)] == '-') {
2814  clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2815  } else if (clipVolumeType[size_t(0)] == '*') {
2816  clippingMode = G4PhysicalVolumeModel::intersection;
2817  clipVolumeType = clipVolumeType.substr(1);
2818  }
2819  G4double unit = G4UIcommand::ValueOf(parameterUnit);
2820  param1 *= unit; param2 *= unit; param3 *= unit;
2821  param4 *= unit; param5 *= unit; param6 *= unit;
2822 
2823  G4TransportationManager* transportationManager =
2825 
2826  size_t nWorlds = transportationManager->GetNoWorlds();
2827  if (nWorlds > 1) { // Parallel worlds in operation...
2828  if (verbosity >= G4VisManager::warnings) {
2829  static G4bool warned = false;
2830  if (!warned && name != "worlds") {
2831  G4cout <<
2832  "WARNING: Parallel worlds in operation. To visualise, specify"
2833  "\n \"worlds\" or the parallel world volume or sub-volume name"
2834  "\n and control visibility with /vis/geometry."
2835  << G4endl;
2836  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2837  transportationManager->GetWorldsIterator();
2838  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2839  G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2840  << G4endl;
2841  warned = true;
2842  }
2843  }
2844  }
2845  }
2846 
2847  // Get the world (the initial value of the iterator points to the mass world).
2848  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2849 
2850  if (!world) {
2851  if (verbosity >= G4VisManager::errors) {
2852  G4cerr <<
2853  "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2854  "\n No world. Maybe the geometry has not yet been defined."
2855  "\n Try \"/run/initialize\""
2856  << G4endl;
2857  }
2858  return;
2859  }
2860 
2861  std::vector<G4PhysicalVolumeModel*> models;
2862  std::vector<G4VPhysicalVolume*> foundVolumes;
2863  G4VPhysicalVolume* foundWorld = 0;
2865  typedef std::vector<PVNodeID> PVPath;
2866  PVPath foundFullPVPath;
2867  std::vector<G4int> foundDepths;
2868  std::vector<G4Transform3D> transformations;
2869 
2870  if (name == "world") {
2871 
2872  models.push_back
2873  (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2874  foundVolumes.push_back(world);
2875  foundDepths.push_back(0);
2876  transformations.push_back(G4Transform3D());
2877 
2878  } else if (name == "worlds") {
2879 
2880  if (nWorlds == 0) {
2881  if (verbosity >= G4VisManager::warnings) {
2882  G4cout <<
2883  "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2884  "\n Parallel worlds requested but none exist."
2885  "\n Just adding material world."
2886  << G4endl;
2887  }
2888  }
2889  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2890  transportationManager->GetWorldsIterator();
2891  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2892  models.push_back
2893  (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2894  foundVolumes.push_back(*iterWorld);
2895  foundDepths.push_back(0);
2896  transformations.push_back(G4Transform3D());
2897  }
2898 
2899  } else { // Search all worlds...
2900 
2901  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2902  transportationManager->GetWorldsIterator();
2903  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2904  G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2905  G4ModelingParameters mp; // Default - no culling.
2906  searchModel.SetModelingParameters (&mp);
2907  G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2908  searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2909  G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2910  if (foundVolume) {
2911  foundWorld = *iterWorld;
2912  foundVolumes.push_back(foundVolume);
2913  foundFullPVPath = searchScene.GetFoundFullPVPath();
2914  foundDepths.push_back(searchScene.GetFoundDepth());
2915  transformations.push_back(searchScene.GetFoundTransformation());
2916  break;
2917  }
2918  }
2919 
2920  if (foundVolumes.size()) {
2921  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2922  G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
2923  (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2924  foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2925  foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2926  models.push_back(foundPVModel);
2927  }
2928  } else {
2929  if (verbosity >= G4VisManager::errors) {
2930  G4cerr << "ERROR: Volume \"" << name << "\"";
2931  if (copyNo >= 0) {
2932  G4cerr << ", copy no. " << copyNo << ",";
2933  }
2934  G4cerr << " not found." << G4endl;
2935  }
2936  return;
2937  }
2938  }
2939 
2940  if (clipVolumeType == "box") {
2941  const G4double dX = (param2 - param1) / 2.;
2942  const G4double dY = (param4 - param3) / 2.;
2943  const G4double dZ = (param6 - param5) / 2.;
2944  const G4double x0 = (param2 + param1) / 2.;
2945  const G4double y0 = (param4 + param3) / 2.;
2946  const G4double z0 = (param6 + param5) / 2.;
2947  G4VSolid* clippingSolid =
2948  new G4DisplacedSolid
2949  ("_displaced_clipping_box",
2950  new G4Box("_clipping_box",dX,dY,dZ),
2951  G4Translate3D(x0,y0,z0));
2952  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2953  models[i]->SetClippingSolid(clippingSolid);
2954  models[i]->SetClippingMode(clippingMode);
2955  }
2956  } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2957 
2958  const G4String& currentSceneName = pScene -> GetName ();
2959  G4bool failure = true;
2960  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2961  G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2962  if (successful) {
2963  failure = false;
2964  if (verbosity >= G4VisManager::confirmations) {
2965  G4cout << "First occurrence of \""
2966  << foundVolumes[i] -> GetName ()
2967  << "\"";
2968  if (copyNo >= 0) {
2969  G4cout << ", copy no. " << copyNo << ",";
2970  }
2971  G4cout << "\n found ";
2972  if (foundWorld)
2973  G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2974  G4cout << "at depth " << foundDepths[i]
2975  << ",\n with a requested depth of further descent of ";
2976  if (requestedDepthOfDescent < 0) {
2977  G4cout << "<0 (unlimited)";
2978  }
2979  else {
2980  G4cout << requestedDepthOfDescent;
2981  }
2982  G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2983  << G4endl;
2984  }
2985  }
2986  }
2987 
2988  if (failure) {
2990  return;
2991  }
2992 
2993  UpdateVisManagerScene (currentSceneName);
2994 }
const XML_Char * name
Definition: expat.h:151
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
Definition: G4Box.hh:64
void UpdateVisManagerScene(const G4String &sceneName="")
int G4int
Definition: G4Types.hh:78
static void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
HepGeom::Transform3D G4Transform3D
std::vector< PVNodeID > PVPath
void SetBaseFullPVPath(const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath)
static G4TransportationManager * GetTransportationManager()
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:309
static Verbosity GetVerbosity()
HepGeom::Translate3D G4Translate3D
size_t GetNoWorlds() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
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: