Geant4  10.01.p01
G4VisCommandsTouchable.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisCommandsTouchable.cc 75794 2013-11-06 13:25:30Z allison $
28 
29 // /vis/touchable commands - John Allison 14th May 2014
30 
32 
35 #include "G4TouchableDumpScene.hh"
36 
38 
40 {
41  fpCommandDump = new G4UIcmdWithoutParameter("/vis/touchable/dump",this);
42  fpCommandDump->SetGuidance("Dump touchable attributes.");
44  ("Use \"/vis/set/touchable\" to set current touchable.");
45 }
46 
48  delete fpCommandDump;
49 }
50 
52  return "";
53 }
54 
57 {
58  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
59 
60  G4TransportationManager* transportationManager =
62 
63  size_t nWorlds = transportationManager->GetNoWorlds();
64 
65  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
66  if (!world) {
67  if (verbosity >= G4VisManager::errors) {
68  G4cerr <<
69  "ERROR: G4VisCommandsTouchable::SetNewValue:"
70  "\n No world. Maybe the geometry has not yet been defined."
71  "\n Try \"/run/initialize\""
72  << G4endl;
73  }
74  return;
75  }
76 
77  if (command == fpCommandDump)
78  {
79  G4bool found = false;
80  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
81  transportationManager->GetWorldsIterator();
82  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
83  G4PhysicalVolumeModel pvModel (*iterWorld); // Unlimited depth.
84  G4ModelingParameters mp; // Default - no culling.
85  pvModel.SetModelingParameters (&mp);
86  G4TouchableDumpScene dumpScene (G4cout,&pvModel,fCurrentTouchablePath);
87  pvModel.DescribeYourselfTo (dumpScene); // Initiate dump.
88  if (dumpScene.IsFound()) found = true;
89  }
90  if (!found) {
91  G4cout << "Touchable not found." << G4endl;
92  }
93  return;
94 
95  } else {
96 
97  if (verbosity >= G4VisManager::errors) {
98  G4cerr <<
99  "ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."
100  << G4endl;
101  }
102  return;
103  }
104 }
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetModelingParameters(const G4ModelingParameters *)
G4UIcmdWithoutParameter * fpCommandDump
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4String GetCurrentValue(G4UIcommand *command)
static G4TransportationManager * GetTransportationManager()
size_t GetNoWorlds() const
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void DescribeYourselfTo(G4VGraphicsScene &)