Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VSceneHandler.cc,v 1.91 2009/11/16 13:51:08 lgarnier Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VSceneHandler.cc,v 1.96 2010/11/05 16:00:11 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// John Allison 19th July 1996
@@ -66,6 +66,7 @@
#include "G4Torus.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4DisplacedSolid.hh"
#include "G4LogicalVolume.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ModelingParameters.hh"
@@ -73,6 +74,7 @@
#include "G4VTrajectoryPoint.hh"
#include "G4HitsModel.hh"
#include "G4VHit.hh"
#include "G4VDigi.hh"
#include "G4ScoringManager.hh"
#include "G4DefaultLinearColorMap.hh"
#include "Randomize.hh"
@@ -257,11 +259,17 @@ void G4VSceneHandler::AddSolid (const G4VSolid& solid) {
}
void G4VSceneHandler::AddCompound (const G4VTrajectory& traj) {
G4TrajectoriesModel* pTrModel =
G4TrajectoriesModel* trajectoriesModel =
dynamic_cast<G4TrajectoriesModel*>(fpModel);
if (!pTrModel) G4Exception
if (!trajectoriesModel) G4Exception
("G4VSceneHandler::AddCompound(const G4VTrajectory&): Not a G4TrajectoriesModel.");
traj.DrawTrajectory(pTrModel->GetDrawingMode());
else {
if (trajectoriesModel->IsDrawingModeSet()) {
traj.DrawTrajectory(trajectoriesModel->GetDrawingMode());
} else {
traj.DrawTrajectory();
}
}
}
void G4VSceneHandler::AddCompound (const G4VHit& hit) {
@@ -269,6 +277,11 @@ void G4VSceneHandler::AddCompound (const G4VHit& hit) {
const_cast<G4VHit&>(hit).Draw();
}
void G4VSceneHandler::AddCompound (const G4VDigi& digi) {
// Cast away const because Draw is non-const!!!!
const_cast<G4VDigi&>(digi).Draw();
}
void G4VSceneHandler::AddCompound (const G4THitsMap<G4double>& hits) {
//G4cout << "AddCompound: hits: " << &hits << G4endl;
G4bool scoreMapHits = false;
@@ -479,8 +492,7 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid) {
break;
}
else {
G4VisManager::Verbosity verbosity =
G4VisManager::GetInstance()->GetVerbosity();
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cout <<
"ERROR: G4VSceneHandler::RequestPrimitives"
@@ -500,8 +512,7 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid) {
AddPrimitive (*pPolyhedron);
}
else {
G4VisManager::Verbosity verbosity =
G4VisManager::GetInstance()->GetVerbosity();
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cout <<
"ERROR: G4VSceneHandler::RequestPrimitives"
@@ -735,28 +746,27 @@ G4ModelingParameters* G4VSceneHandler::CreateModelingParameters ()
);
pModelingParams->SetWarning
(G4VisManager::GetInstance()->GetVerbosity() >= G4VisManager::warnings);
(G4VisManager::GetVerbosity() >= G4VisManager::warnings);
pModelingParams->SetExplodeFactor(vp.GetExplodeFactor());
pModelingParams->SetExplodeCentre(vp.GetExplodeCentre());
pModelingParams->SetSectionPolyhedron(CreateSectionPolyhedron());
pModelingParams->SetCutawayPolyhedron(CreateCutawayPolyhedron());
pModelingParams->SetSectionSolid(CreateSectionSolid());
pModelingParams->SetCutawaySolid(CreateCutawaySolid());
// The polyhedron objects are deleted in the modeling parameters destructor.
return pModelingParams;
}
const G4Polyhedron* G4VSceneHandler::CreateSectionPolyhedron()
G4VSolid* G4VSceneHandler::CreateSectionSolid()
{
/* Disable for now. Boolean processor not up to it.
G4VSolid* sectioner = 0;
const G4ViewParameters& vp = fpViewer->GetViewParameters();
if (vp.IsSection () ) {
G4double radius = fpScene->GetExtent().GetExtentRadius();
G4double safe = radius + fpScene->GetExtent().GetExtentCentre().mag();
G4Box sectionBox("clipper",
safe, safe, 1.e-5 * radius); // Thin in z-plane.
G4Polyhedron* sectioner = sectionBox.CreatePolyhedron();
G4VSolid* sectionBox =
new G4Box("_sectioner", safe, safe, 1.e-5 * radius); // Thin in z-plane.
const G4Plane3D& s = vp.GetSectionPlane ();
G4double a = s.a();
G4double b = s.b();
@@ -769,16 +779,13 @@ const G4Polyhedron* G4VSceneHandler::CreateSectionPolyhedron()
const G4Vector3D axis = G4Normal3D(0,0,1).cross(normal);
transform = G4Rotate3D(angle, axis) * transform;
}
sectioner->Transform(transform);
return sectioner;
} else {
return 0;
sectioner = new G4DisplacedSolid
("_displaced_sectioning_box", sectionBox, transform);
}
*/
return 0;
return sectioner;
}
const G4Polyhedron* G4VSceneHandler::CreateCutawayPolyhedron()
G4VSolid* G4VSceneHandler::CreateCutawaySolid()
{
return 0;
}
@@ -24,13 +24,15 @@
// ********************************************************************
//
//
// $Id: G4ViewParameters.cc,v 1.36 2009/01/21 17:05:12 lgarnier Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4ViewParameters.cc,v 1.38 2010/11/05 16:00:11 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// John Allison 19th July 1996
// View parameters and options.
#include <sstream>
#include "G4ViewParameters.hh"
#include "G4VisManager.hh"
@@ -46,6 +48,7 @@ G4ViewParameters::G4ViewParameters ():
fAllValues(0x000F),
fXNegative(0x0010),
fYNegative(0x0020),
fGeometryMask(0),
fDrawingStyle (wireframe),
fAuxEdgeVisible (false),
fRepStyle (polyhedron),
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsCompound.cc,v 1.39 2007/11/16 20:29:04 perl Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VisCommandsCompound.cc,v 1.40 2010/05/20 07:54:01 allison Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
// Compound /vis/ commands - John Allison 15th May 2000
@@ -65,6 +65,11 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
std::istringstream is(newValue);
is >> pvname >> system;
G4VGraphicsSystem* keepSystem = fpVisManager->GetCurrentGraphicsSystem();
G4Scene* keepScene = fpVisManager->GetCurrentScene();
G4VSceneHandler* keepSceneHandler = fpVisManager->GetCurrentSceneHandler();
G4VViewer* keepViewer = fpVisManager->GetCurrentViewer();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
G4int keepVerbose = UImanager->GetVerboseLevel();
G4int newVerbose(0);
@@ -76,6 +81,16 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
UImanager->ApplyCommand(G4String("/vis/drawVolume " + pvname));
UImanager->ApplyCommand("/vis/viewer/flush");
UImanager->SetVerboseLevel(keepVerbose);
if (keepViewer) {
if (fpVisManager->GetVerbosity() >= G4VisManager::warnings) {
G4cout << "Reverting to " << keepViewer->GetName() << G4endl;
}
fpVisManager->SetCurrentGraphicsSystem(keepSystem);
fpVisManager->SetCurrentScene(keepScene);
fpVisManager->SetCurrentSceneHandler(keepSceneHandler);
fpVisManager->SetCurrentViewer(keepViewer);
}
}
////////////// /vis/drawView ///////////////////////////////////////
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsGeometrySet.cc,v 1.7 2007/01/05 16:24:19 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VisCommandsGeometrySet.cc,v 1.8 2010/06/15 16:34:30 allison Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
// /vis/geometry commands - John Allison 31st January 2006
@@ -63,7 +63,7 @@ void G4VVisCommandGeometrySet::Set
return;
}
if (fpVisManager->GetCurrentViewer()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
}
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsScene.cc,v 1.68 2008/04/28 16:12:38 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VisCommandsScene.cc,v 1.70 2010/11/13 10:52:00 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
// /vis/scene commands - John Allison 9th August 1998
@@ -540,9 +540,6 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
if (aScene) {
const G4String& aSceneName = aScene -> GetName ();
if (sceneName == aSceneName) {
// Clear store and force a rebuild of graphical database...
//aSceneHandler -> ClearStore (); // Not nec?? Done below
//with NeedKernelVisit and DrawView. JA.
G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
const G4int nViewers = viewerList.size ();
for (G4int iV = 0; iV < nViewers; iV++) {
@@ -553,7 +550,18 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
fpVisManager -> SetCurrentViewer(aViewer);
fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
fpVisManager -> SetCurrentScene(aScene);
// Re-draw, forcing rebuild of graphics database, if any...
// ClearTransientStore. This clears the transient, e.g.,
// trajectories part of the store/graphical database but
// also re-draws the permanent part (detector) and thus
// has the effect of clearing trajectories from the view.
// This should not be necessary since NeedKernelVisit,
// ClearView and DrawView should have the effect of
// deleting the whole store and re-creating it, then
// clearing and re-drawing. But ClearView does not seem
// to work for all viewers. If it's a problem for you,
// uncomment the next line.
//aSceneHandler->ClearTransientStore();
// Now, force rebuild of graphical database, if any, and re-draw.
aViewer -> NeedKernelVisit();
aViewer -> SetView ();
aViewer -> ClearView ();
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsSceneAdd.cc,v 1.78 2009/11/22 14:02:30 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VisCommandsSceneAdd.cc,v 1.84 2010/11/06 18:34:26 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
// /vis/scene commands - John Allison 9th August 1998
#include "G4VisCommandsSceneAdd.hh"
@@ -36,6 +36,7 @@
#include "G4LogicalVolumeModel.hh"
#include "G4ModelingParameters.hh"
#include "G4HitsModel.hh"
#include "G4DigiModel.hh"
#include "G4PSHitsModel.hh"
#include "G4TrajectoriesModel.hh"
#include "G4ScaleModel.hh"
@@ -157,6 +158,51 @@ void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand*, G4String newValue) {
}
////////////// /vis/scene/add/digis ///////////////////////////////////////
G4VisCommandSceneAddDigis::G4VisCommandSceneAddDigis () {
fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/add/digis", this);
fpCommand -> SetGuidance ("Adds digis to current scene.");
fpCommand -> SetGuidance
("Digis are drawn at end of event when the scene in which"
"\nthey are added is current.");
}
G4VisCommandSceneAddDigis::~G4VisCommandSceneAddDigis () {
delete fpCommand;
}
G4String G4VisCommandSceneAddDigis::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneAddDigis::SetNewValue (G4UIcommand*, G4String) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn(verbosity >= G4VisManager::warnings);
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
G4DigiModel* model = new G4DigiModel;
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddEndOfEventModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Digis will be drawn in scene \""
<< currentSceneName << "\"."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
UpdateVisManagerScene (currentSceneName);
}
////////////// /vis/scene/add/eventID ///////////////////////////////////////
G4VisCommandSceneAddEventID::G4VisCommandSceneAddEventID () {
@@ -260,7 +306,7 @@ void G4VisCommandSceneAddEventID::EventID::operator()
nEvents = currentRun->GetNumberOfEventToBeProcessed();
} else {
const std::vector<const G4Event*>* events =
currentRun? currentRun->GetEventVector(): 0;
currentRun->GetEventVector();
if (events) nEvents = events->size();
}
if (eventID < nEvents - 1) return; // Not last event.
@@ -1372,6 +1418,7 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
propagatorInField->SetTrajectoryFilter(0); // Switch off smooth trajectories.
static G4IdentityTrajectoryFilter auxiliaryPointsFilter;
G4String defaultTrajectoryType;
G4bool i_mode_found = false;
G4int i_mode = 0;
if (smooth && rich) {
UImanager->ApplyCommand("/tracking/storeTrajectory 3");
@@ -1389,10 +1436,12 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
std::istringstream iss(newValue);
iss >> i_mode;
if (iss) {
i_mode_found = true;
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Integer parameter " << i_mode << " found."
"\n DEPRECATED - will be removed at next major release."
"\n Use \"/vis/modeling/trajectories\" commands."
G4cout <<
"WARNING: Integer parameter " << i_mode << " found."
"\n DEPRECATED - its use in this command will be removed at a future major"
"\n release. Use \"/vis/modeling/trajectories\" commands."
<< G4endl;
}
} else {
@@ -1420,7 +1469,12 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
}
}
G4TrajectoriesModel* model = new G4TrajectoriesModel(i_mode);
G4TrajectoriesModel* model = 0;
if (i_mode_found) {
model = new G4TrajectoriesModel(i_mode);
} else {
model = new G4TrajectoriesModel();
}
const G4String& currentSceneName = pScene -> GetName ();
pScene -> AddEndOfEventModel (model, warn);
@@ -1535,8 +1589,8 @@ void G4VisCommandSceneAddUserAction::SetNewValue (G4UIcommand*,
model->SetGlobalTag("Vis User Action");
model->SetExtent(extent);
const G4String& currentSceneName = pScene -> GetName ();
pScene -> AddRunDurationModel (model, warn);
if (verbosity >= G4VisManager::confirmations) {
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful && verbosity >= G4VisManager::confirmations) {
G4cout << "User Vis Action added to scene \""
<< currentSceneName << "\"";
if (verbosity >= G4VisManager::parameters) {
@@ -1804,12 +1858,13 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
const G4double x0 = (param2 + param1) / 2.;
const G4double y0 = (param4 + param3) / 2.;
const G4double z0 = (param6 + param5) / 2.;
G4Box clippingBox("_clipping_box",dX,dY,dZ);
G4Polyhedron* clippingPolyhedron =
new G4PolyhedronBox(dX,dY,dZ); // The model deletes.
clippingPolyhedron->Transform(G4Translate3D(x0,y0,z0));
G4VSolid* clippingSolid =
new G4DisplacedSolid
("_displaced_clipping_box",
new G4Box("_clipping_box",dX,dY,dZ),
G4Translate3D(x0,y0,z0));
for (size_t i = 0; i < foundVolumes.size(); ++i) {
models[i]->SetClippingPolyhedron(clippingPolyhedron);
models[i]->SetClippingSolid(clippingSolid);
models[i]->SetClippingMode(clippingMode);
}
} // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewer.cc,v 1.75 2009/01/19 15:47:49 lgarnier Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VisCommandsViewer.cc,v 1.77 2010/11/07 11:14:07 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
// /vis/viewer commands - John Allison 25th October 1998
@@ -437,6 +437,7 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
cloneName = cloneName.strip (G4String::both, ' ');
cloneName = cloneName.strip (G4String::both, '"');
G4bool errorWhileNaming = false;
if (cloneName == "none") {
G4int subID = 0;
do {
@@ -449,9 +450,22 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
G4String::npos) {
cloneName.insert(nextSpacePosition, oss.str());
} else {
cloneName.insert(cloneName.find(' '), oss.str());
G4String::size_type spacePosition = cloneName.find(' ');
if (spacePosition != G4String::npos)
cloneName.insert(spacePosition, oss.str());
else
errorWhileNaming = true;
}
} while (fpVisManager -> GetViewer (cloneName));
} while (!errorWhileNaming && fpVisManager -> GetViewer (cloneName));
}
if (errorWhileNaming) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: While naming clone viewer \"" << cloneName
<< "\"."
<< G4endl;
}
return;
}
if (fpVisManager -> GetViewer (cloneName)) {
@@ -1037,6 +1051,7 @@ void G4VisCommandViewerRebuild::SetNewValue (G4UIcommand*, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String& rebuildName = newValue;
G4VViewer* viewer = fpVisManager -> GetViewer (rebuildName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
@@ -1047,7 +1062,21 @@ void G4VisCommandViewerRebuild::SetNewValue (G4UIcommand*, G4String newValue) {
return;
}
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
if (!sceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << viewer->GetName() << "\"" <<
" has no scene handler - report serious bug."
<< G4endl;
}
return;
}
sceneHandler->ClearTransientStore();
viewer->NeedKernelVisit();
viewer->SetView();
viewer->ClearView();
viewer->DrawView();
// Check auto-refresh and print confirmations, but without changing
// view paramters...
@@ -1391,22 +1420,13 @@ void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand*, G4String newValue) {
return;
}
if (viewer) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Viewer \"" << viewer -> GetName () << "\"";
G4cout << " post-processing triggered." << G4endl;
}
viewer -> ShowView ();
// Assume future need to "refresh" transients...
sceneHandler -> SetMarkForClearingTransientStore(true);
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << updateName << "\"";
G4cout << " not found - \"/vis/viewer/list\""
"\n to see possibilities." << G4endl;
}
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Viewer \"" << viewer -> GetName () << "\"";
G4cout << " post-processing triggered." << G4endl;
}
viewer -> ShowView ();
// Assume future need to "refresh" transients...
sceneHandler -> SetMarkForClearingTransientStore(true);
}
////////////// /vis/viewer/zoom and zoomTo ////////////////////////////
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewerSet.cc,v 1.50 2009/05/13 18:17:25 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VisCommandsViewerSet.cc,v 1.53 2010/11/05 15:57:20 allison Exp $
// GEANT4 tag $Name: geant4-09-04 $
// /vis/viewer/set commands - John Allison 16th May 2000
@@ -142,6 +142,52 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
fpCommandCutawayMode->SetDefaultValue("union");
fpCommandDefaultColour = new G4UIcommand
("/vis/viewer/set/defaultColour",this);
fpCommandDefaultColour->SetGuidance
("Set defaultColour colour and transparency (default white and opaque).");
fpCommandDefaultColour->SetGuidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent colour.");
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommandDefaultColour -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultColour -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultColour -> SetParameter (parameter);
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultColour -> SetParameter (parameter);
fpCommandDefaultTextColour = new G4UIcommand
("/vis/viewer/set/defaultTextColour",this);
fpCommandDefaultTextColour->SetGuidance
("Set defaultTextColour colour and transparency (default white and opaque).");
fpCommandDefaultTextColour->SetGuidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent colour.");
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommandDefaultTextColour -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultTextColour -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultTextColour -> SetParameter (parameter);
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
fpCommandDefaultTextColour -> SetParameter (parameter);
fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
fpCommandEdge->SetGuidance
("Edges become visible/invisible in surface mode.");
@@ -266,9 +312,11 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
fpCommandProjection->SetParameter(parameter);
parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
parameter->SetDefaultValue(30.);
//parameter->SetCurrentAsDefault(true);
fpCommandProjection->SetParameter(parameter);
parameter = new G4UIparameter("unit",'s',omitable = true);
parameter->SetDefaultValue("deg");
//parameter->SetCurrentAsDefault(true);
fpCommandProjection->SetParameter(parameter);
fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
@@ -400,6 +448,8 @@ G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
delete fpCommandBackground;
delete fpCommandCulling;
delete fpCommandCutawayMode;
delete fpCommandDefaultColour;
delete fpCommandDefaultTextColour;
delete fpCommandEdge;
delete fpCommandExplodeFactor;
delete fpCommandGlobalLineWidthScale;
@@ -610,6 +660,56 @@ void G4VisCommandsViewerSet::SetNewValue
}
}
else if (command == fpCommandDefaultColour) {
G4String redOrString;
G4double green, blue, opacity;
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,1.,1.); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
G4Colour::GetColour(redOrString, colour); // Remains default (white) if
// not found.
} else {
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
}
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
G4VisAttributes va = vp.GetDefaultVisAttributes();
va.SetColour(colour);
vp.SetDefaultVisAttributes(va);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Default colour "
<< vp.GetDefaultVisAttributes()->GetColour()
<< " requested."
<< G4endl;
}
}
else if (command == fpCommandDefaultTextColour) {
G4String redOrString;
G4double green, blue, opacity;
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,1.,1.); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
G4Colour::GetColour(redOrString, colour); // Remains default (white) if
// not found.
} else {
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
}
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
G4VisAttributes va = vp.GetDefaultTextVisAttributes();
va.SetColour(colour);
vp.SetDefaultTextVisAttributes(va);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Default colour "
<< vp.GetDefaultTextVisAttributes()->GetColour()
<< " requested."
<< G4endl;
}
}
else if (command == fpCommandEdge) {
G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
if (G4UIcommand::ConvertToBool(newValue)) {
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VisManager.cc,v 1.122 2009/11/04 12:58:00 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VisManager.cc,v 1.131 2010/12/14 15:53:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
@@ -78,7 +78,9 @@
G4VisManager* G4VisManager::fpInstance = 0;
G4VisManager::G4VisManager ():
G4VisManager::Verbosity G4VisManager::fVerbosity = G4VisManager::warnings;
G4VisManager::G4VisManager (const G4String& verbosityString):
fVerbose (1),
fInitialised (false),
fpUserVisAction (0),
@@ -86,7 +88,6 @@ G4VisManager::G4VisManager ():
fpScene (0),
fpSceneHandler (0),
fpViewer (0),
fVerbosity (warnings),
fpStateDependent (0),
fEventRefreshing (false),
fTransientsDrawnThisRun (false),
@@ -100,6 +101,7 @@ G4VisManager::G4VisManager ():
fpTrajDrawModelMgr = new G4VisModelManager<G4VTrajectoryModel>("/vis/modeling/trajectories");
fpTrajFilterMgr = new G4VisFilterManager<G4VTrajectory>("/vis/filtering/trajectories");
fpHitFilterMgr = new G4VisFilterManager<G4VHit>("/vis/filtering/hits");
fpDigiFilterMgr = new G4VisFilterManager<G4VDigi>("/vis/filtering/digi");
VerbosityGuidanceStrings.push_back
("Simple graded message scheme - digit or string (1st character defines):");
@@ -122,54 +124,56 @@ G4VisManager::G4VisManager ():
G4Exception
("G4VisManager: attempt to Construct more than one VisManager.");
}
else {
fpInstance = this;
SetConcreteInstance(this);
fpInstance = this;
SetConcreteInstance(this);
fpStateDependent = new G4VisStateDependent (this);
// No need to delete this; G4StateManager does this.
fpStateDependent = new G4VisStateDependent (this);
// No need to delete this; G4StateManager does this.
if (fVerbosity >= startup) {
G4cout << "Visualization Manager instantiating..." << G4endl;
}
// Note: The specific graphics systems must be instantiated in a
// higher level library to avoid circular dependencies. Also,
// some specifically need additional external libararies that the
// user must supply. Therefore we ask the user to implement
// RegisterGraphicsSystems() and RegisterModelFactories()
// in a subclass. We have to wait for the subclass to instantiate
// so RegisterGraphicsSystems() cannot be called from this
// constructor; it is called from Initialise(). So we ask the
// user:
// (a) to write a subclass and implement RegisterGraphicsSystems()
// and RegisterModelFactories(). See
// visualization/include/G4VisExecutive.hh/icc as an example.
// (b) instantiate the subclass.
// (c) invoke the Initialise() method of the subclass.
// For example:
// ...
// #ifdef G4VIS_USE
// // Instantiate and initialise Visualization Manager.
// G4VisManager* visManager = new G4VisExecutive;
// visManager -> SetVerboseLevel (Verbose);
// visManager -> Initialise ();
// #endif
// // (Don't forget to delete visManager;)
// ...
// Make top level command directory...
G4UIcommand* directory;
directory = new G4UIdirectory ("/vis/");
directory -> SetGuidance ("Visualization commands.");
fDirectoryList.push_back (directory);
// Instantiate top level basic commands
G4VVisCommand::SetVisManager (this); // Sets shared pointer
RegisterMessenger(new G4VisCommandVerbose);
RegisterMessenger(new G4VisCommandInitialize);
fVerbosity = GetVerbosityValue(verbosityString);
if (fVerbosity >= startup) {
G4cout
<< "Visualization Manager instantiating with verbosity \""
<< VerbosityString(fVerbosity)
<< "\"..." << G4endl;
}
// Note: The specific graphics systems must be instantiated in a
// higher level library to avoid circular dependencies. Also,
// some specifically need additional external libararies that the
// user must supply. Therefore we ask the user to implement
// RegisterGraphicsSystems() and RegisterModelFactories()
// in a subclass. We have to wait for the subclass to instantiate
// so RegisterGraphicsSystems() cannot be called from this
// constructor; it is called from Initialise(). So we ask the
// user:
// (a) to write a subclass and implement RegisterGraphicsSystems()
// and RegisterModelFactories(). See
// visualization/include/G4VisExecutive.hh/icc as an example.
// (b) instantiate the subclass.
// (c) invoke the Initialise() method of the subclass.
// For example:
// ...
// #ifdef G4VIS_USE
// // Instantiate and initialise Visualization Manager.
// G4VisManager* visManager = new G4VisExecutive;
// visManager -> SetVerboseLevel (Verbose);
// visManager -> Initialise ();
// #endif
// // (Don't forget to delete visManager;)
// ...
// Make top level command directory...
G4UIcommand* directory;
directory = new G4UIdirectory ("/vis/");
directory -> SetGuidance ("Visualization commands.");
fDirectoryList.push_back (directory);
// Instantiate top level basic commands
G4VVisCommand::SetVisManager (this); // Sets shared pointer
RegisterMessenger(new G4VisCommandVerbose);
RegisterMessenger(new G4VisCommandInitialize);
}
G4VisManager::~G4VisManager () {
@@ -179,10 +183,14 @@ G4VisManager::~G4VisManager () {
delete fSceneList[i];
}
for (i = 0; i < fAvailableSceneHandlers.size (); ++i) {
if (fAvailableSceneHandlers[i] != NULL) {
delete fAvailableSceneHandlers[i];
}
}
for (i = 0; i < fAvailableGraphicsSystems.size (); ++i) {
delete fAvailableGraphicsSystems[i];
if (fAvailableGraphicsSystems[i]) {
delete fAvailableGraphicsSystems[i];
}
}
if (fVerbosity >= startup) {
G4cout << "Graphics systems deleted." << G4endl;
@@ -195,9 +203,10 @@ G4VisManager::~G4VisManager () {
delete fDirectoryList[i];
}
delete fpTrajDrawModelMgr;
delete fpTrajFilterMgr;
delete fpDigiFilterMgr;
delete fpHitFilterMgr;
delete fpTrajFilterMgr;
delete fpTrajDrawModelMgr;
}
G4VisManager* G4VisManager::GetInstance () {
@@ -283,6 +292,12 @@ void G4VisManager::Initialise () {
directory = new G4UIdirectory ("/vis/filtering/hits/create/");
directory -> SetGuidance ("Create hit filters and messengers.");
fDirectoryList.push_back (directory);
directory = new G4UIdirectory ("/vis/filtering/digi/");
directory -> SetGuidance ("Digi filtering commands.");
fDirectoryList.push_back (directory);
directory = new G4UIdirectory ("/vis/filtering/digi/create/");
directory -> SetGuidance ("Create digi filters and messengers.");
fDirectoryList.push_back (directory);
RegisterMessengers ();
@@ -431,6 +446,17 @@ G4VisManager::RegisterModelFactory(G4HitFilterFactory* factory)
fpHitFilterMgr->Register(factory);
}
void G4VisManager::RegisterModel(G4VFilter<G4VDigi>* model)
{
fpDigiFilterMgr->Register(model);
}
void
G4VisManager::RegisterModelFactory(G4DigiFilterFactory* factory)
{
fpDigiFilterMgr->Register(factory);
}
void G4VisManager::SelectTrajectoryModel(const G4String& model)
{
fpTrajDrawModelMgr->SetCurrent(model);
@@ -600,6 +626,13 @@ void G4VisManager::Draw (const G4VHit& hit) {
}
}
void G4VisManager::Draw (const G4VDigi& digi) {
if (IsValidView ()) {
ClearTransientStoreIfMarked();
fpSceneHandler -> AddCompound (digi);
}
}
void G4VisManager::Draw (const G4VTrajectory& traj,
G4int i_mode) {
if (IsValidView ()) {
@@ -856,6 +889,35 @@ G4bool G4VisManager::FilterHit(const G4VHit& hit)
return fpHitFilterMgr->Accept(hit);
}
G4bool G4VisManager::FilterDigi(const G4VDigi& digi)
{
return fpDigiFilterMgr->Accept(digi);
}
void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory)
{
G4bool visible(true);
// See if trajectory passes filter
G4bool passed = FilterTrajectory(trajectory);
if (!passed) {
// Draw invisible trajectory if trajectory failed filter and
// are filtering in soft mode
if (fpTrajFilterMgr->GetMode() == FilterMode::Soft) visible = false;
else {return;}
}
// Go on to draw trajectory
assert (0 != fpTrajDrawModelMgr);
const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
assert (0 != trajectoryModel); // Should exist
trajectoryModel->Draw(trajectory, visible);
}
void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode)
{
G4bool visible(true);
@@ -873,12 +935,25 @@ void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory, G4int i_mode
// Go on to draw trajectory
assert (0 != fpTrajDrawModelMgr);
const G4VTrajectoryModel* model = CurrentTrajDrawModel();
const G4VTrajectoryModel* trajectoryModel = CurrentTrajDrawModel();
assert (0 != model); // Should exist
assert (0 != trajectoryModel); // Should exist
model->Draw(trajectory, i_mode, visible);
}
if (IsValidView()) {
G4TrajectoriesModel* trajectoriesModel =
dynamic_cast<G4TrajectoriesModel*>(fpSceneHandler->GetModel());
if (trajectoriesModel) {
if (trajectoriesModel->IsDrawingModeSet()) {
trajectoryModel->Draw(trajectory, i_mode, visible);
} else {
trajectoryModel->Draw(trajectory, visible);
}
} else {
// Just draw at user's request
trajectoryModel->Draw(trajectory, i_mode, visible);
}
}
}
void G4VisManager::SetUserAction
(G4VUserVisAction* pVisAction,
@@ -985,7 +1060,13 @@ void G4VisManager::SetCurrentSceneHandler (G4VSceneHandler* pSceneHandler) {
<< G4endl;
}
}
IsValidView (); // Checks.
if (!IsValidView ()) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: Problem setting scene handler - please report circumstances."
<< G4endl;
}
}
}
else {
fpViewer = 0;
@@ -1008,7 +1089,13 @@ void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) {
fpSceneHandler -> SetCurrentViewer (pViewer);
fpScene = fpSceneHandler -> GetScene ();
fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
IsValidView (); // Checks.
if (!IsValidView ()) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: Problem setting viewer - please report circumstances."
<< G4endl;
}
}
}
void G4VisManager::RegisterMessengers () {
@@ -1067,6 +1154,7 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSceneAddEventID);
RegisterMessenger(new G4VisCommandSceneAddGhosts);
RegisterMessenger(new G4VisCommandSceneAddHits);
RegisterMessenger(new G4VisCommandSceneAddDigis);
RegisterMessenger(new G4VisCommandSceneAddLogicalVolume);
RegisterMessenger(new G4VisCommandSceneAddLogo);
RegisterMessenger(new G4VisCommandSceneAddPSHits);
@@ -1128,6 +1216,12 @@ void G4VisManager::RegisterMessengers () {
(fpHitFilterMgr, fpHitFilterMgr->Placement()));
RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VHit> >
(fpHitFilterMgr, fpHitFilterMgr->Placement()));
// Digi filter manager commands
RegisterMessenger(new G4VisCommandListManagerList< G4VisFilterManager<G4VDigi> >
(fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
RegisterMessenger(new G4VisCommandManagerMode< G4VisFilterManager<G4VDigi> >
(fpDigiFilterMgr, fpDigiFilterMgr->Placement()));
}
void G4VisManager::PrintAvailableGraphicsSystems () const {
@@ -1280,6 +1374,7 @@ void G4VisManager::EndOfEvent ()
// Unless last event (in which case wait end of run)...
if (eventID < nEventsToBeProcessed - 1) {
fpViewer->ShowView();
fpViewer->DrawView();
fpSceneHandler->SetMarkForClearingTransientStore(true);
} else { // Last event...
// Keep, but only if user has not kept any...
@@ -1364,10 +1459,11 @@ void G4VisManager::EndOfRun ()
G4cout <<
" Only useful if before starting the run:"
"\n a) trajectories are stored (\"/vis/scene/add/trajectories [smooth|rich]\"), or"
"\n b) the Draw method of any hits is implemented."
"\n To view trajectories and hits:"
"\n b) the Draw method of any hits or digis is implemented."
"\n To view trajectories, hits or digis:"
"\n open a viewer, draw a volume, \"/vis/scene/add/trajectories\""
"\n \"/vis/scene/add/hits\" and, possibly, \"/vis/viewer/flush\"."
"\n \"/vis/scene/add/hits\" or \"/vis/scene/add/digitisations\""
"\n and, possibly, \"/vis/viewer/flush\"."
"\n To see all events: \"/vis/scene/endOfEventAction accumulate\"."
"\n To see events individually: \"/vis/reviewKeptEvents\"."
<< G4endl;
@@ -1486,6 +1582,10 @@ G4VisManager::Verbosity G4VisManager::GetVerbosityValue(G4int intVerbosity) {
return verbosity;
}
G4VisManager::Verbosity G4VisManager::GetVerbosity () {
return fVerbosity;
}
void G4VisManager::SetVerboseLevel (G4int intVerbosity) {
fVerbosity = GetVerbosityValue(intVerbosity);
}