Import Geant4 3.2.0 source tree
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VisCommandsSceneAdd.cc,v 1.14 2001/02/23 15:43:27 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-03-01 $
|
||||
//
|
||||
// $Id: G4VisCommandsSceneAdd.cc,v 1.18.2.1 2001/06/28 19:16:15 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
|
||||
// /vis/scene commands - John Allison 9th August 1998
|
||||
|
||||
@@ -20,6 +36,8 @@
|
||||
#include "G4ModelingParameters.hh"
|
||||
#include "G4HitsModel.hh"
|
||||
#include "G4TrajectoriesModel.hh"
|
||||
#include "G4TextModel.hh"
|
||||
#include "G4AxesModel.hh"
|
||||
#include "G4PhysicalVolumeSearchScene.hh"
|
||||
#include "G4VGlobalFastSimulationManager.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
@@ -33,6 +51,70 @@
|
||||
#include "g4std/strstream"
|
||||
|
||||
|
||||
////////////// /vis/scene/add/axes //////////////////////////////////
|
||||
|
||||
G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes () {
|
||||
G4bool omitable;
|
||||
fpCommand = new G4UIcommand ("/vis/scene/add/axes", this);
|
||||
fpCommand -> SetGuidance
|
||||
("Draws axes at (x0, y0, z0) of given length.");
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("x0", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("y0", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("z0", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("length", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (1.*m);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("unit", 's', omitable = true);
|
||||
parameter->SetDefaultValue ("mm");
|
||||
parameter->SetGuidance ("mm, cm, or m.");
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddAxes::~G4VisCommandSceneAddAxes () {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneAddAxes::GetCurrentValue (G4UIcommand*) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand* command,
|
||||
G4String newValue) {
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
if (sceneList.empty ()) {
|
||||
G4cout << "No scenes - please create one before adding anything."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4String unitString;
|
||||
G4double x0, y0, z0, length;
|
||||
const char* s = newValue;
|
||||
G4std::istrstream is ((char*)s);
|
||||
is >> x0 >> y0 >> z0 >> length >> unitString;
|
||||
|
||||
G4double unit = ValueOf(unitString);
|
||||
x0 *= unit; y0 *= unit; z0 *= unit; length *= unit;
|
||||
|
||||
G4VModel* model = new G4AxesModel(x0, y0, z0, length);
|
||||
G4Scene* pScene = fpVisManager -> GetCurrentScene ();
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
G4bool succesful = pScene -> AddRunDurationModel (model);
|
||||
UpdateVisManagerScene (currentSceneName);
|
||||
if (succesful) {
|
||||
G4cout << "Axes have been added to scene \"" << currentSceneName << "\""
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////// /vis/scene/add/ghosts ///////////////////////////////////////
|
||||
|
||||
G4VisCommandSceneAddGhosts::G4VisCommandSceneAddGhosts () {
|
||||
@@ -82,9 +164,9 @@ void G4VisCommandSceneAddGhosts::SetNewValue (G4UIcommand* command,
|
||||
G4bool successful;
|
||||
for (G4int iParticle=0; iParticle<theParticleTable->entries();
|
||||
iParticle++)
|
||||
if(CurrentFlavoredWorld=theGlobalFastSimulationManager->
|
||||
GetFlavoredWorldForThis(theParticleTable->
|
||||
GetParticle(iParticle)))
|
||||
CurrentFlavoredWorld = theGlobalFastSimulationManager->
|
||||
GetFlavoredWorldForThis(theParticleTable->GetParticle(iParticle));
|
||||
if(CurrentFlavoredWorld)
|
||||
successful = pCurrentScene -> AddRunDurationModel
|
||||
(new G4FlavoredParallelWorldModel (CurrentFlavoredWorld));
|
||||
UpdateVisManagerScene ();
|
||||
@@ -102,9 +184,9 @@ void G4VisCommandSceneAddGhosts::SetNewValue (G4UIcommand* command,
|
||||
return;
|
||||
}
|
||||
|
||||
G4VFlavoredParallelWorld* worldForThis;
|
||||
if(worldForThis=theGlobalFastSimulationManager->
|
||||
GetFlavoredWorldForThis(currentParticle)) {
|
||||
G4VFlavoredParallelWorld* worldForThis =
|
||||
theGlobalFastSimulationManager->GetFlavoredWorldForThis(currentParticle);
|
||||
if(worldForThis) {
|
||||
G4bool successful = pCurrentScene -> AddRunDurationModel
|
||||
(new G4FlavoredParallelWorldModel (worldForThis));
|
||||
UpdateVisManagerScene (currentSceneName);
|
||||
@@ -201,7 +283,7 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand* command,
|
||||
is >> name >> requestedDepthOfDescent;
|
||||
|
||||
G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
|
||||
int nLV = pLVStore -> entries ();
|
||||
int nLV = pLVStore -> size ();
|
||||
int iLV;
|
||||
G4LogicalVolume* pLV;
|
||||
for (iLV = 0; iLV < nLV; iLV++ ) {
|
||||
@@ -229,6 +311,85 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand* command,
|
||||
}
|
||||
|
||||
|
||||
////////////// /vis/scene/add/text //////////////////////////////////
|
||||
|
||||
G4VisCommandSceneAddText::G4VisCommandSceneAddText () {
|
||||
G4bool omitable;
|
||||
fpCommand = new G4UIcommand ("/vis/scene/add/text", this);
|
||||
fpCommand -> SetGuidance
|
||||
("Adds text at (x, y, z) unit font_size x_offset y_offset text.");
|
||||
fpCommand -> SetGuidance
|
||||
("Font size and offsets in pixels.");
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("x", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("y", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("z", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("unit", 's', omitable = true);
|
||||
parameter->SetDefaultValue ("mm");
|
||||
parameter->SetGuidance ("mm, cm, or m.");
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("font_size", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("x_offset", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("y_offset", 'd', omitable = true);
|
||||
parameter->SetDefaultValue (0.);
|
||||
fpCommand->SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("text", 's', omitable = true);
|
||||
parameter->SetDefaultValue ("text");
|
||||
fpCommand->SetParameter (parameter);
|
||||
}
|
||||
|
||||
G4VisCommandSceneAddText::~G4VisCommandSceneAddText () {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneAddText::GetCurrentValue (G4UIcommand*) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void G4VisCommandSceneAddText::SetNewValue (G4UIcommand* command,
|
||||
G4String newValue) {
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
if (sceneList.empty ()) {
|
||||
G4cout << "No scenes - please create one before adding anything."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4String text, unitString;
|
||||
G4double x, y, z, font_size, x_offset, y_offset;
|
||||
const char* s = newValue;
|
||||
G4std::istrstream is ((char*)s);
|
||||
is >> x >> y >> z >> unitString >> font_size >> x_offset >> y_offset >> text;
|
||||
|
||||
G4double unit = ValueOf(unitString);
|
||||
x *= unit; y *= unit; z *= unit;
|
||||
|
||||
G4Text g4text(text, G4Point3D(x,y,z));
|
||||
g4text.SetScreenSize(font_size);
|
||||
g4text.SetOffset(x_offset,y_offset);
|
||||
G4VModel* model = new G4TextModel(g4text);
|
||||
G4Scene* pScene = fpVisManager -> GetCurrentScene ();
|
||||
const G4String& currentSceneName = pScene -> GetName ();
|
||||
G4bool succesful = pScene -> AddRunDurationModel (model);
|
||||
UpdateVisManagerScene (currentSceneName);
|
||||
if (succesful) {
|
||||
G4cout << "Text \"" << text
|
||||
<< "\" has been added to scene \"" << currentSceneName << "\""
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////// /vis/scene/add/trajectories ///////////////////////////////////
|
||||
|
||||
G4VisCommandSceneAddTrajectories::G4VisCommandSceneAddTrajectories () {
|
||||
@@ -281,7 +442,8 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
|
||||
// fpCommand -> SetGuidance // Not implemented - should be in geom?
|
||||
// (" \"list\" to list all volumes.");
|
||||
fpCommand -> SetGuidance
|
||||
("2nd parameter: copy number (default 0).");
|
||||
("2nd parameter: copy number (default -1)."
|
||||
"\n If negative, first occurrence of physical-volume-name is selected.");
|
||||
fpCommand -> SetGuidance
|
||||
("3rd parameter: depth of descending geometry hierarchy"
|
||||
" (default G4Scene::UNLIMITED (-1)).");
|
||||
@@ -290,7 +452,7 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
|
||||
parameter -> SetDefaultValue ("world");
|
||||
fpCommand -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
|
||||
parameter -> SetDefaultValue (0);
|
||||
parameter -> SetDefaultValue (-1);
|
||||
fpCommand -> SetParameter (parameter);
|
||||
parameter = new G4UIparameter ("depth", 'i', omitable = true);
|
||||
parameter -> SetDefaultValue (G4Scene::UNLIMITED);
|
||||
@@ -362,8 +524,11 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand* command,
|
||||
transformation);
|
||||
}
|
||||
else {
|
||||
G4cout << "Volume \"" << name << "\", copy no. " << copyNo
|
||||
<< " not found." << G4endl;
|
||||
G4cout << "Volume \"" << name << "\"";
|
||||
if (copyNo >= 0) {
|
||||
G4cout << ", copy no. " << copyNo << ",";
|
||||
}
|
||||
G4cout << " not found." << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,12 +538,22 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand* command,
|
||||
G4bool successful = pScene -> AddRunDurationModel (model);
|
||||
UpdateVisManagerScene (currentSceneName);
|
||||
if (successful) {
|
||||
G4cout << "First occurrence of \"" << foundVolume -> GetName ()
|
||||
<< "\", copy no. " << copyNo
|
||||
<< ", found at depth " << foundDepth
|
||||
<< ",\n with further requested depth of descent "
|
||||
<< requestedDepthOfDescent
|
||||
<< ", has been added to scene \"" << currentSceneName << "\""
|
||||
G4cout << "First occurrence of \""
|
||||
<< foundVolume -> GetName ()
|
||||
<< "\"";
|
||||
if (copyNo >= 0) {
|
||||
G4cout << ", copy no. " << copyNo << ",";
|
||||
}
|
||||
G4cout << " found at depth " << foundDepth
|
||||
<< ",\n with ";
|
||||
if (requestedDepthOfDescent < 0) {
|
||||
G4cout << "unlimited (-1)";
|
||||
}
|
||||
else {
|
||||
G4cout << requestedDepthOfDescent;
|
||||
}
|
||||
G4cout << " further requested depth of descent"
|
||||
<< ",\n has been added to scene \"" << currentSceneName << "\""
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user