Import Geant4 9.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:15:05 +02:00
parent b79225fb37
commit 74cad5e589
3877 changed files with 234205 additions and 167127 deletions
+5 -6
View File
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRep.cc,v 1.22 2006/06/29 21:17:20 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRep.cc,v 1.23 2009/11/23 05:42:28 perl Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
/**
@@ -53,11 +53,10 @@ G4HepRep::G4HepRep ()
G4VGraphicsSystem::threeD),
sceneHandler(NULL),
viewer(NULL) {
messenger = new G4HepRepMessenger();
G4HepRepMessenger::GetInstance();
}
G4HepRep::~G4HepRep () {
delete messenger;
}
G4VSceneHandler* G4HepRep::CreateSceneHandler (const G4String& name) {
@@ -65,7 +64,7 @@ G4VSceneHandler* G4HepRep::CreateSceneHandler (const G4String& name) {
cout << "G4HepRep::CreateSceneHandler: Cannot create more than one G4HepRepSceneHandler" << endl;
return NULL;
}
sceneHandler = new G4HepRepSceneHandler (*this, *messenger, name);
sceneHandler = new G4HepRepSceneHandler (*this, name);
return sceneHandler;
}
@@ -74,7 +73,7 @@ G4VViewer* G4HepRep::CreateViewer (G4VSceneHandler& scene, const G4String& name)
cout << "G4HepRep::CreateViewer: Cannot create more than one G4HepRepViewer" << endl;
return NULL;
}
viewer = new G4HepRepViewer ((G4HepRepSceneHandler&)scene, *messenger, name);
viewer = new G4HepRepViewer ((G4HepRepSceneHandler&)scene, name);
return viewer;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRepFile.cc,v 1.11 2007/05/22 17:05:26 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRepFile.cc,v 1.12 2009/11/23 05:42:28 perl Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// Joseph Perl 1 October 2001
@@ -37,6 +37,7 @@
#include "G4HepRepFile.hh"
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFileViewer.hh"
#include "G4HepRepMessenger.hh"
static G4HepRepFileXMLWriter* hepRepXMLWriter;
@@ -45,6 +46,7 @@ G4HepRepFile::G4HepRepFile():
"HepRepFile",
"A HepRep (format 1) ascii file driver",
G4VGraphicsSystem::threeD) {
G4HepRepMessenger::GetInstance();
hepRepXMLWriter = new G4HepRepFileXMLWriter();
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRepFileSceneHandler.cc,v 1.66 2008/01/04 22:11:31 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRepFileSceneHandler.cc,v 1.68 2009/12/16 17:51:21 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// Joseph Perl 27th January 2002
@@ -33,6 +33,8 @@
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFile.hh"
#include "G4HepRepMessenger.hh"
#include "G4UIcommand.hh"
#include "G4Version.hh"
#include "G4VSolid.hh"
@@ -70,27 +72,6 @@ G4VSceneHandler(system, fSceneIdCount++, name)
{
hepRepXMLWriter = ((G4HepRepFile*)(&system))->GetHepRepXMLWriter();
fileCounter = 0;
int length;
if (getenv("G4HEPREPFILE_DIR") == NULL)
strcpy(fileDir, "");
else
length = sprintf (fileDir, "%s%s", getenv("G4HEPREPFILE_DIR"),"/");
if (getenv("G4HEPREPFILE_NAME") == NULL)
strcpy(fileName, "G4Data");
else
strcpy(fileName, getenv("G4HEPREPFILE_NAME"));
if (getenv("G4HEPREPFILE_OVERWRITE") == NULL)
fileOverwrite = false;
else
fileOverwrite = strcmp(getenv("G4HEPREPFILE_OVERWRITE"),"0");
if (getenv("G4HEPREPFILE_CULL") == NULL)
cullInvisibleObjects = false;
else
cullInvisibleObjects = strcmp(getenv("G4HEPREPFILE_CULL"),"0");
inPrimitives2D = false;
warnedAbout3DText = false;
@@ -179,7 +160,9 @@ void G4HepRepFileSceneHandler::AddSolid(const G4Box& box) {
haveVisible = false;
AddHepRepInstance("Prism", NULL);
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
hepRepXMLWriter->addPrimitive();
@@ -242,7 +225,9 @@ void G4HepRepFileSceneHandler::AddSolid(const G4Cons& cons) {
haveVisible = false;
AddHepRepInstance("Cylinder", NULL);
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
G4Point3D vertex1(G4Point3D( 0., 0., -cons.GetZHalfLength()));
@@ -277,10 +262,23 @@ void G4HepRepFileSceneHandler::AddSolid(const G4Tubs& tubs) {
PrintThings();
#endif
// HepRApp does not correctly represent the end faces of cylinders at
// non-standard angles, let the base class convert these solids to polygons.
CLHEP::HepRotation r = fpObjectTransformation->getRotation();
G4bool linedUpWithAnAxis = (std::fabs(r.phiX())<=.001 ||
std::fabs(r.phiY())<=.001 ||
std::fabs(r.phiZ())<=.001 ||
std::fabs(r.phiX()-pi)<=.001 ||
std::fabs(r.phiY()-pi)<=.001 ||
std::fabs(r.phiZ()-pi)<=.001);
//G4cout << "Angle X:" << r.phiX() << ", Angle Y:" << r.phiY() << ", Angle Z:" << r.phiZ() << G4endl;
//G4cout << "linedUpWithAnAxis:" << linedUpWithAnAxis << G4endl;
// HepRep does not have a primitive for a cut cylinder,
// so if this cylinder is cut, let the base class convert this
// solid to polygons.
if (tubs.GetDeltaPhiAngle() < twopi) {
if (tubs.GetDeltaPhiAngle() < twopi || !linedUpWithAnAxis)
{
G4VSceneHandler::AddSolid(tubs); // Invoke default action.
} else {
@@ -293,7 +291,9 @@ void G4HepRepFileSceneHandler::AddSolid(const G4Tubs& tubs) {
haveVisible = false;
AddHepRepInstance("Cylinder", NULL);
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
G4Point3D vertex1(G4Point3D( 0., 0., -tubs.GetZHalfLength()));
@@ -339,7 +339,9 @@ void G4HepRepFileSceneHandler::AddSolid(const G4Trd& trd) {
haveVisible = false;
AddHepRepInstance("Prism", NULL);
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
hepRepXMLWriter->addPrimitive();
@@ -1003,7 +1005,9 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) {
PrintThings();
#endif
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
if (inPrimitives2D) {
@@ -1041,7 +1045,9 @@ void G4HepRepFileSceneHandler::AddPrimitive (const G4Polymarker& line) {
PrintThings();
#endif
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
if (inPrimitives2D) {
@@ -1143,7 +1149,9 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) {
PrintThings();
#endif
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
if (inPrimitives2D) {
@@ -1187,7 +1195,9 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) {
PrintThings();
#endif
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
if (inPrimitives2D) {
@@ -1230,7 +1240,9 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) {
PrintThings();
#endif
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
if(polyhedron.GetNoFacets()==0)return;
@@ -1429,7 +1441,9 @@ void G4HepRepFileSceneHandler::AddHepRepInstance(const char* primName,
hepRepXMLWriter->addType(pCurrentPV->GetName(),currentDepth+1);
hepRepXMLWriter->addInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && cullInvisibleObjects)
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
return;
// Additional attributes.
@@ -1511,18 +1525,22 @@ void G4HepRepFileSceneHandler::CheckFileOpen() {
#endif
if (!hepRepXMLWriter->isOpen) {
char* newFileSpec;
newFileSpec = new char [256];
int length;
G4String newFileSpec;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (messenger->getOverwrite()) {
newFileSpec = messenger->getFileDir()+messenger->getFileName()+".heprep";
} else {
newFileSpec = messenger->getFileDir()+messenger->getFileName()+G4UIcommand::ConvertToString(fileCounter)+".heprep";
}
if (fileOverwrite)
length = sprintf (newFileSpec, "%s%s%s",fileDir,fileName,".heprep");
else
length = sprintf (newFileSpec, "%s%s%d%s",fileDir,fileName,fileCounter,".heprep");
G4cout << "HepRepFile writing to " << newFileSpec << G4endl;
hepRepXMLWriter->open(newFileSpec);
fileCounter++;
if (!messenger->getOverwrite())
fileCounter++;
hepRepXMLWriter->addAttDef("Generator", "HepRep Data Generator", "Physics","");
G4String versionString = G4Version;
@@ -23,12 +23,26 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRepMessenger.cc,v 1.10 2006/06/29 21:17:30 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRepMessenger.cc,v 1.11 2009/11/23 05:42:28 perl Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
#include "G4HepRepMessenger.hh"
G4HepRepMessenger*
G4HepRepMessenger::fpInstance = 0;
G4HepRepMessenger*
G4HepRepMessenger::GetInstance()
{
if (!fpInstance) fpInstance = new G4HepRepMessenger;
return fpInstance;
}
G4HepRepMessenger::G4HepRepMessenger() :
fileDir(""),
fileName("G4Data"),
overwrite(false),
cullInvisibles(false),
suffix (""),
geometry(true),
solids(true),
@@ -36,68 +50,130 @@ G4HepRepMessenger::G4HepRepMessenger() :
heprepDirectory = new G4UIdirectory("/vis/heprep/");
heprepDirectory->SetGuidance("HepRep commands.");
setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
setFileDirCommand->SetGuidance("Set directory for output.");
setFileDirCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setFileDirCommand->SetParameterName("directory",false);
if ( getenv( "G4HEPREPFILE_DIR" ) == NULL ) {
setFileDirCommand->SetDefaultValue("");
} else {
setFileDirCommand->SetDefaultValue(getenv("G4HEPREPFILE_DIR"));
fileDir = getenv("G4HEPREPFILE_DIR");
}
setFileDirCommand->AvailableForStates(G4State_Idle);
setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
setFileNameCommand->SetGuidance("Set file name for output.");
setFileNameCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setFileNameCommand->SetParameterName("directory",false);
if ( getenv( "G4HEPREPFILE_NAME" ) == NULL ) {
setFileNameCommand->SetDefaultValue("G4Data");
} else {
setFileNameCommand->SetDefaultValue(getenv("G4HEPREPFILE_NAME"));
fileName = getenv("G4HEPREPFILE_NAME");
}
setFileNameCommand->AvailableForStates(G4State_Idle);
setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
setOverwriteCommand->SetGuidance("Set true to write all output to exact same file name.");
setOverwriteCommand->SetGuidance("Set false to increment the file name for each new output.");
setOverwriteCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setOverwriteCommand->SetParameterName("flag",false);
if ( getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) {
setOverwriteCommand->SetDefaultValue(false);
} else {
setOverwriteCommand->SetDefaultValue(getenv("G4HEPREPFILE_OVERWRITE"));
overwrite = setOverwriteCommand->ConvertToBool(getenv("G4HEPREPFILE_OVERWRITE"));
}
setOverwriteCommand->AvailableForStates(G4State_Idle);
setCullInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
setCullInvisiblesCommand->SetGuidance("Remove invisible objects from output file.");
setCullInvisiblesCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setCullInvisiblesCommand->SetParameterName("flag",false);
if ( getenv( "G4HEPREPFILE_CULL" ) == NULL ) {
setCullInvisiblesCommand->SetDefaultValue(false);
} else {
setCullInvisiblesCommand->SetDefaultValue(getenv("G4HEPREPFILE_CULL"));
cullInvisibles = setCullInvisiblesCommand->ConvertToBool(getenv("G4HEPREPFILE_CULL"));
}
setCullInvisiblesCommand->AvailableForStates(G4State_Idle);
setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
setEventNumberSuffixCommand->SetParameterName("suffix",false);
setEventNumberSuffixCommand->SetDefaultValue("");
setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
appendGeometryCommand->SetParameterName("flag",false);
appendGeometryCommand->SetDefaultValue(true);
appendGeometryCommand->AvailableForStates(G4State_Idle);
addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
addPointAttributesCommand->SetParameterName("flag",false);
addPointAttributesCommand->SetDefaultValue(false);
addPointAttributesCommand->AvailableForStates(G4State_Idle);
useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives.");
useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
useSolidsCommand->SetParameterName("flag",false);
useSolidsCommand->SetDefaultValue(true);
useSolidsCommand->AvailableForStates(G4State_Idle);
/* Not Enabled Yet
writeInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/writeInvisibles", this);
writeInvisiblesCommand->SetGuidance("Write invisible objects.");
writeInvisiblesCommand->SetParameterName("flag",false);
writeInvisiblesCommand->SetDefaultValue(true);
writeInvisiblesCommand->AvailableForStates(G4State_Idle);
*/
}
G4HepRepMessenger::~G4HepRepMessenger() {
delete setFileDirCommand;
delete setFileNameCommand;
delete setOverwriteCommand;
delete setCullInvisiblesCommand;
delete setEventNumberSuffixCommand;
delete appendGeometryCommand;
delete addPointAttributesCommand;
delete useSolidsCommand;
// delete writeInvisiblesCommand;
delete heprepDirectory;
}
G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) {
if (command==setEventNumberSuffixCommand) {
return suffix;
if (command==setFileDirCommand) {
return fileDir;
} else if (command==setFileNameCommand) {
return fileName;
} else if (command==setOverwriteCommand) {
return overwrite;
} else if (command==setCullInvisiblesCommand) {
return cullInvisibles;
} else if (command==setEventNumberSuffixCommand) {
return suffix;
} else if (command==appendGeometryCommand) {
return appendGeometryCommand->ConvertToString(geometry);
} else if (command==addPointAttributesCommand) {
return addPointAttributesCommand->ConvertToString(pointAttributes);
} else if (command==useSolidsCommand) {
return useSolidsCommand->ConvertToString(solids);
// } else if (command==writeInvisiblesCommand) {
// return writeInvisiblesCommand->ConvertToString(invisibles);
} else {
return "";
}
}
void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
if (command==setEventNumberSuffixCommand) {
if (command==setFileDirCommand) {
fileDir = newValue;
} else if (command==setFileNameCommand) {
fileName = newValue;
} else if (command==setOverwriteCommand) {
overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
} else if (command==setCullInvisiblesCommand) {
cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
} else if (command==setEventNumberSuffixCommand) {
suffix = newValue;
} else if (command==appendGeometryCommand) {
geometry = appendGeometryCommand->GetNewBoolValue(newValue);
@@ -105,11 +181,25 @@ void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
} else if (command==useSolidsCommand) {
solids = useSolidsCommand->GetNewBoolValue(newValue);
// } else if (command==writeInvisiblesCommand) {
// invisibles = writeInvisiblesCommand->GetNewBoolValue(newValue);
}
}
G4String G4HepRepMessenger::getFileDir() {
return fileDir;
}
G4String G4HepRepMessenger::getFileName() {
return fileName;
}
G4bool G4HepRepMessenger::getOverwrite() {
return overwrite;
}
G4bool G4HepRepMessenger::getCullInvisibles() {
return cullInvisibles;
}
G4String G4HepRepMessenger::getEventNumberSuffix() {
return suffix;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRepSceneHandler.cc,v 1.101 2007/11/16 20:29:04 perl Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRepSceneHandler.cc,v 1.102 2009/11/23 05:42:28 perl Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
/**
@@ -44,6 +44,7 @@
//HepRep
#include "HEPREP/HepRep.h"
#include "G4HepRepMessenger.hh"
//G4
#include "G4Vector3D.hh"
@@ -89,9 +90,8 @@ G4int G4HepRepSceneHandler::sceneIdCount = 0;
//#define SDEBUG 1
//#define PDEBUG 1
G4HepRepSceneHandler::G4HepRepSceneHandler (G4VGraphicsSystem& system, G4HepRepMessenger& heprepMessenger, const G4String& name)
G4HepRepSceneHandler::G4HepRepSceneHandler (G4VGraphicsSystem& system, const G4String& name)
: G4VSceneHandler (system, sceneIdCount++, name),
messenger (heprepMessenger),
geometryLayer ("Geometry"),
eventLayer ("Event"),
calHitLayer ("CalHit"),
@@ -246,7 +246,10 @@ void G4HepRepSceneHandler::open(G4String name) {
writeMultipleFiles = false;
int startDigit = -1; int endDigit = -1;
string suffix = messenger.getEventNumberSuffix();
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
string suffix = messenger->getEventNumberSuffix();
if (suffix != "") {
// look for 0000 pattern in suffix
endDigit = suffix.length()-1;
@@ -330,6 +333,8 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
<< "forgot to call /vis/viewer/update before exit. No event written." << endl;
}
} else {
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
// add geometry to the heprep if there is an event (separate geometries are written
// using DrawView() called from /vis/viewer/flush)
@@ -337,7 +342,8 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
GetCurrentViewer()->DrawView();
// couple geometry
if (messenger.appendGeometry()) {
if ( messenger->appendGeometry()) {
// couple geometry to event if geometry was written
if ((_geometryInstanceTree != NULL)) {
getEventInstanceTree()->addInstanceTree(getGeometryInstanceTree());
@@ -373,7 +379,7 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
}
// write out separate geometry
if (!messenger.appendGeometry() && (_heprepGeometry != NULL)) {
if (! messenger->appendGeometry() && (_heprepGeometry != NULL)) {
if (writeMultipleFiles) {
char fileName[128];
sprintf(fileName, "%s%s%s", baseName.c_str(), "-geometry", extension.c_str());
@@ -492,8 +498,10 @@ void G4HepRepSceneHandler::AddSolid(const G4Box& box) {
#endif
if (dontWrite()) return;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (!messenger.useSolids()) {
if (! messenger->useSolids()) {
G4VSceneHandler::AddSolid(box);
return;
}
@@ -546,8 +554,10 @@ void G4HepRepSceneHandler::AddSolid(const G4Cons& cons) {
#endif
if (dontWrite()) return;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (!messenger.useSolids() || (cons.GetDeltaPhiAngle() < twopi)) {
if (! messenger->useSolids() || (cons.GetDeltaPhiAngle() < twopi)) {
G4VSceneHandler::AddSolid(cons);
return;
}
@@ -608,8 +618,10 @@ void G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs) {
#endif
if (dontWrite()) return;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (!messenger.useSolids() || (tubs.GetDeltaPhiAngle() < twopi)) {
if (! messenger->useSolids() || (tubs.GetDeltaPhiAngle() < twopi)) {
G4VSceneHandler::AddSolid(tubs);
return;
}
@@ -665,8 +677,10 @@ void G4HepRepSceneHandler::AddSolid(const G4Trd& trd) {
cout << "G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
#endif
if (dontWrite()) return;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (!messenger.useSolids()) {
if (! messenger->useSolids()) {
G4VSceneHandler::AddSolid(trd);
return;
}
@@ -993,8 +1007,9 @@ void G4HepRepSceneHandler::EndPrimitives () {
}
G4bool G4HepRepSceneHandler::dontWrite() {
return !(messenger.writeInvisibles() || (fpVisAttribs ? (bool)fpVisAttribs->IsVisible() : true));
G4bool G4HepRepSceneHandler::dontWrite() {
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
return !( messenger->writeInvisibles() || (fpVisAttribs ? (bool)fpVisAttribs->IsVisible() : true));
}
void G4HepRepSceneHandler::setColor (HepRepAttribute *attribute,
@@ -1366,12 +1381,14 @@ void G4HepRepSceneHandler::addTopLevelAttributes(HepRepType* type) {
type->addAttDef( "PointUnit", "Length", "Physics", "");
type->addAttValue("PointUnit", G4String("m"));
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
type->addAttDef( "UseSolids", "Use HepRep Solids rather than Geant4 Primitives", "Draw", "");
type->addAttValue("UseSolids", messenger.useSolids());
type->addAttValue("UseSolids", messenger->useSolids());
type->addAttDef( "WriteInvisibles", "Write Invisible Objects", "Draw", "");
type->addAttValue("WriteInvisibles", messenger.writeInvisibles());
type->addAttValue("WriteInvisibles", messenger->writeInvisibles());
}
@@ -1408,7 +1425,9 @@ HepRepInstanceTree* G4HepRepSceneHandler::getGeometryInstanceTree() {
if (_geometryInstanceTree == NULL) {
// Create the Geometry InstanceTree.
_geometryInstanceTree = factory->createHepRepInstanceTree("G4GeometryData", "1.0", getGeometryTypeTree());
if (messenger.appendGeometry()) {
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if ( messenger->appendGeometry()) {
getHepRep()->addInstanceTree(_geometryInstanceTree);
} else {
getHepRepGeometry()->addInstanceTree(_geometryInstanceTree);
@@ -1475,7 +1494,9 @@ HepRepTypeTree* G4HepRepSceneHandler::getGeometryTypeTree() {
// Create the Geometry TypeTree.
HepRepTreeID* geometryTreeID = factory->createHepRepTreeID("G4GeometryTypes", "1.0");
_geometryTypeTree = factory->createHepRepTypeTree(geometryTreeID);
if (messenger.appendGeometry()) {
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if ( messenger->appendGeometry()) {
getHepRep()->addTypeTree(_geometryTypeTree);
} else {
getHepRepGeometry()->addTypeTree(_geometryTypeTree);
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HepRepViewer.cc,v 1.26 2006/06/29 21:17:34 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4HepRepViewer.cc,v 1.27 2009/11/23 05:42:28 perl Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
/**
@@ -39,6 +39,7 @@
//#include "G4VInteractorManager.hh"
#include "G4Scene.hh"
#include "G4HepRep.hh"
#include "G4HepRepMessenger.hh"
#include "G4HepRepSceneHandler.hh"
//This
#include "G4HepRepViewer.hh"
@@ -46,10 +47,9 @@
using namespace HEPREP;
using namespace std;
G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, G4HepRepMessenger& heprepMessenger, const G4String& name)
G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, const G4String& name)
: G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name),
geometryIncluded(false),
messenger(heprepMessenger) {
geometryIncluded(false) {
#ifdef SDEBUG
cout << "G4HepRepViewer::G4HepRepViewer " << name << endl;
@@ -110,7 +110,9 @@ void G4HepRepViewer::ShowView () {
G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler());
if (sceneHandler->closeHepRep()) {
sceneHandler->openHepRep();
if (messenger.appendGeometry()) geometryIncluded = false;
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (messenger->appendGeometry()) geometryIncluded = false;
}
}