Import Geant4 7.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 12:11:21 +02:00
parent 516dbf1a58
commit d93e1e39a9
5384 changed files with 125662 additions and 82444 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsScene.cc,v 1.37 2003/12/01 11:12:59 johna Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
// $Id: G4VisCommandsScene.cc,v 1.42 2005/06/07 17:00:59 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// /vis/scene commands - John Allison 9th August 1998
@@ -49,34 +49,16 @@ G4String G4VVisCommandScene::CurrentSceneName () {
return currentSceneName;
}
void G4VVisCommandScene::UpdateCandidateLists () {
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
G4int iScene, nScenes = sceneList.size ();
G4String nameList;
for (iScene = 0; iScene < nScenes; iScene++) {
nameList += sceneList [iScene] -> GetName () + " ";
}
nameList = nameList.strip ();
sceneNameCommandsIterator i;
for (i = sceneNameCommands.begin (); i != sceneNameCommands.end (); ++i) {
(*i)->GetParameter (0) -> SetParameterCandidates (nameList);
}
}
////////////// /vis/scene/create ///////////////////////////////////////
G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) {
G4bool omitable, currentAsDefault;
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/create", this);
fpCommand -> SetGuidance ("/vis/scene/create [<scene-name>]");
fpCommand -> SetGuidance ("Creates an empty scene.");
fpCommand -> SetGuidance ("Invents a name if not supplied.");
fpCommand -> SetGuidance ("This scene becomes current.");
fpCommand -> SetParameterName ("scene-name",
omitable = true,
currentAsDefault = true);
sceneNameCommands.push_back (fpCommand);
fpCommand -> SetGuidance
("Creates an empty scene.");
fpCommand -> SetGuidance
("Invents a name if not supplied. This scene becomes current.");
fpCommand -> SetParameterName ("scene-name", omitable = true);
}
G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
@@ -91,7 +73,7 @@ G4String G4VisCommandSceneCreate::NextName () {
}
G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand*) {
return NextName ();
return "";
}
void G4VisCommandSceneCreate::SetNewValue (G4UIcommand*, G4String newValue) {
@@ -125,89 +107,24 @@ void G4VisCommandSceneCreate::SetNewValue (G4UIcommand*, G4String newValue) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "New empty scene \"" << newName << "\" created." << G4endl;
}
UpdateCandidateLists ();
}
UpdateVisManagerScene (newName);
}
////////////// /vis/scene/edit ///////////////////////////////////////
G4VisCommandSceneEdit::G4VisCommandSceneEdit () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/scene/edit", this);
fpCommand -> SetGuidance ("/vis/scene/edit [<scene-name>]");
fpCommand -> SetGuidance ("Edits a scene (default current scene).");
fpCommand -> SetGuidance ("This scene becomes current.");
fpCommand -> SetParameterName ("scene-name",
omitable = true,
currentAsDefault = true);
sceneNameCommands.push_back (fpCommand);
}
G4VisCommandSceneEdit::~G4VisCommandSceneEdit () {
delete fpCommand;
}
G4String G4VisCommandSceneEdit::GetCurrentValue (G4UIcommand*) {
return CurrentSceneName ();
}
void G4VisCommandSceneEdit::SetNewValue (G4UIcommand*, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String sceneName;
std::istrstream is ((char*)newValue.data());
is >> sceneName;
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
G4int iScene, nScenes = sceneList.size ();
G4Scene* pScene;
for (iScene = 0; iScene < nScenes; iScene++) {
pScene = sceneList [iScene];
if (pScene -> GetName () == sceneName) break;
}
if (iScene >= nScenes) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: G4VisCommandSceneEdit::SetNewValue: Scene \""
<< sceneName << "\" not found."
"\n /vis/scene/list to see scenes."
<< G4endl;
}
return;
}
else {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Scene \"" << sceneName << "\" contains:" << G4endl;
G4String uiCommand ("/vis/scene/list ");
uiCommand += sceneName;
uiCommand += " confirmations";
G4UImanager::GetUIpointer () -> ApplyCommand (uiCommand);
G4cout <<
"BUT...YOU CAN DO NOTHING YET - /vis/scene/edit FACILITY IN PREPARATION."
<< G4endl;
}
}
UpdateVisManagerScene (sceneName);
}
////////////// /vis/scene/endOfEventAction ////////////////////////////
G4VisCommandSceneEndOfEventAction::G4VisCommandSceneEndOfEventAction () {
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfEventAction", this);
fpCommand -> SetGuidance
("/vis/scene/endOfEventAction [accumulate|refresh]");
("Accumulate or refresh the viewer for each new event.");
fpCommand -> SetGuidance
("Requests viewer"
"\na) to accumulate hits, etc., event by event, or"
"\nb) to show them at end of event or, for direct-screen viewers,"
"\n to refresh the screen just before drawing the next event."
"\n Detector remains or is redrawn.");
fpCommand -> SetParameterName ("action",
omitable = true);
("\"accumulate\": viewer accumulates hits, etc., event by event, or");
fpCommand -> SetGuidance
("\"refresh\": viewer shows them at end of event or, for direct-screen"
"\n viewers, refreshes the screen just before drawing the next event.");
fpCommand -> SetGuidance ("The detector remains or is redrawn.");
fpCommand -> SetParameterName ("action", omitable = true);
fpCommand -> SetCandidates ("accumulate refresh");
fpCommand -> SetDefaultValue ("refresh");
}
@@ -226,7 +143,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String action;
std::istrstream is ((char*)newValue.data());
std::istrstream is (newValue);
is >> action;
G4Scene* pScene = fpVisManager->GetCurrentScene();
@@ -275,15 +192,15 @@ G4VisCommandSceneEndOfRunAction::G4VisCommandSceneEndOfRunAction () {
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/endOfRunAction", this);
fpCommand -> SetGuidance
("/vis/scene/endOfRunAction [accumulate|refresh]");
("Accumulate or refresh the viewer for each new run.");
fpCommand -> SetGuidance
("Requests viewer"
"\na) to accumulate hits, etc., run by run, or"
"\nb) to show them at end of run or, for direct-screen viewers,"
"\n to refresh the screen just before drawing the next event."
"\n Detector remains or is redrawn.");
fpCommand -> SetParameterName ("action",
omitable = true);
("\"accumulate\": viewer accumulates hits, etc., run by run, or");
fpCommand -> SetGuidance
("\"refresh\": viewer shows them at end of run or, for direct-screen"
"\n viewers, refreshes the screen just before drawing the first"
"\n event of the next run.");
fpCommand -> SetGuidance ("The detector remains or is redrawn.");
fpCommand -> SetParameterName ("action", omitable = true);
fpCommand -> SetCandidates ("accumulate refresh");
fpCommand -> SetDefaultValue ("refresh");
}
@@ -302,7 +219,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String action;
std::istrstream is ((char*)newValue.data());
std::istrstream is (newValue);
is >> action;
G4Scene* pScene = fpVisManager->GetCurrentScene();
@@ -350,23 +267,16 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
G4VisCommandSceneList::G4VisCommandSceneList () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/scene/list", this);
fpCommand -> SetGuidance ("/vis/scene/list [<scene-name>] [<verbosity>]");
fpCommand -> SetGuidance ("Lists scene(s).");
fpCommand -> SetGuidance ("<scene-name> default is \"all\"");
fpCommand -> SetGuidance
("See /vis/verbose for definition of verbosity.");
("\"help /vis/verbose\" for definition of verbosity.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("scene-name", 's',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter = new G4UIparameter ("scene-name", 's', omitable = true);
parameter -> SetDefaultValue ("all");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("verbosity", 's',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter = new G4UIparameter ("verbosity", 's', omitable = true);
parameter -> SetDefaultValue (0);
fpCommand -> SetParameter (parameter);
sceneNameCommands.push_back (fpCommand);
}
G4VisCommandSceneList::~G4VisCommandSceneList () {
@@ -379,10 +289,13 @@ G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand*) {
void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
G4String name, verbosityString;
std::istrstream is ((char*)newValue.data());
std::istrstream is (newValue);
is >> name >> verbosityString;
G4VisManager::Verbosity verbosity =
fpVisManager->GetVerbosityValue(verbosityString);
const G4Scene* currentScene = fpVisManager -> GetCurrentScene ();
G4String currentName;
if (currentScene) currentName = currentScene->GetName();
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
G4int iScene, nScenes = sceneList.size ();
@@ -394,7 +307,13 @@ void G4VisCommandSceneList::SetNewValue (G4UIcommand*, G4String newValue) {
if (name != iName) continue;
}
found = true;
G4cout << "Scene name: \"" << iName << "\"";
if (iName == currentName) {
G4cout << " (current)";
}
else {
G4cout << " ";
}
G4cout << " scene \"" << iName << "\"";
if (verbosity >= G4VisManager::confirmations) {
G4int i;
G4cout << "\n Run-duration models:";
@@ -436,18 +355,18 @@ G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
fpCommand -> SetGuidance
("/vis/scene/notifyHandlers [<scene-name>] [r[efresh]|f[lush]]");
("Notifies scene handlers and forces re-rendering.");
fpCommand -> SetGuidance
("Notifies scene handlers of possible changes of scene and forces a"
"reconstruction of any graphical databases.");
fpCommand -> SetGuidance ("<scene-name> default is current scene name.");
fpCommand -> SetGuidance
("Clears and refreshes all viewers of current scene."
("Notifies the handler(s) of the specified scene and forces a"
"\nreconstruction of any graphical databases."
"\nClears and refreshes all viewers of current scene."
"\n The default action \"refresh\" does not issue \"update\" (see"
"\n /vis/viewer/update)."
"\nIf \"flush\" is specified, it issues an \"update\" as well as"
"\n \"refresh\". Useful for refreshing and initiating post-processing"
"\n \"refresh\" - useful for refreshing and initiating post-processing"
"\n for graphics systems which need post-processing.");
fpCommand -> SetGuidance
("The default for <scene-name> is the current scene name.");
fpCommand -> SetGuidance
("This command does not change current scene, scene handler or viewer.");
G4UIparameter* parameter;
@@ -458,8 +377,8 @@ G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
parameter = new G4UIparameter ("refresh-flush", 's',
omitable = true);
parameter -> SetDefaultValue("refresh");
parameter -> SetParameterCandidates("refresh flush");
fpCommand -> SetParameter (parameter);
sceneNameCommands.push_back (fpCommand);
}
G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
@@ -476,7 +395,7 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String sceneName, refresh_flush;
std::istrstream is ((char*)newValue.data());
std::istrstream is (newValue);
is >> sceneName >> refresh_flush;
G4bool flush(false);
if (refresh_flush(0) == 'f') flush = true;
@@ -501,6 +420,16 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
return;
}
// Store current context...
G4VSceneHandler* pCurrentSceneHandler =
fpVisManager -> GetCurrentSceneHandler();
G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
// Suppress messages during this process (only print errors)...
//fpVisManager -> SetVerboseLevel(G4VisManager::errors);
// For each scene handler, if it contains the scene, clear and
// rebuild the graphical database, then for each viewer set (make
// current), clear, (re)draw, and show.
@@ -517,8 +446,12 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
const G4int nViewers = viewerList.size ();
for (G4int iV = 0; iV < nViewers; iV++) {
G4VViewer* aViewer = viewerList [iV];
aSceneHandler -> SetCurrentViewer (aViewer); // Temporarily.
aViewer -> SetView (); // Temporarily switch contexts.
aSceneHandler -> SetCurrentViewer (aViewer);
// Ensure consistency of vis manager...
fpVisManager -> SetCurrentViewer(aViewer);
fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
fpVisManager -> SetCurrentScene(aScene);
aViewer -> SetView ();
//??aViewer -> ClearView ();
aViewer -> DrawView ();
if (flush) aViewer -> ShowView ();
@@ -543,87 +476,26 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
}
}
}
// Reclaim original context...
G4VSceneHandler* pCurrentSceneHandler =
fpVisManager -> GetCurrentSceneHandler();
G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
// Reclaim original context - but set viewer first, then scene
// handler, because the latter might have been created very recently
// and, not yet having a viewer, the current viewer will,
// temporarily, refer to another scene handler. SetCurrentViewer
// actually resets the scene handler, which is what we don't want,
// so we set it again on the next line...
fpVisManager -> SetCurrentViewer(pCurrentViewer);
fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
fpVisManager -> SetCurrentScene(pCurrentScene);
fpVisManager -> SetVerboseLevel(currentVerbosity);
// Take care of special case of scene handler with no viewer yet.
if (pCurrentSceneHandler) {
pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
if (pCurrentViewer && pCurrentSceneHandler->GetScene())
pCurrentViewer -> SetView ();
}
}
////////////// /vis/scene/remove ///////////////////////////////////////
G4VisCommandSceneRemove::G4VisCommandSceneRemove () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/scene/remove", this);
fpCommand -> SetGuidance ("/vis/scene/remove <scene-name>");
fpCommand -> SetGuidance ("Removes scenes.");
fpCommand -> SetGuidance
("/vis/scene/list to see possibilities.");
fpCommand -> SetParameterName ("scene-name",
omitable = false,
currentAsDefault = true);
sceneNameCommands.push_back (fpCommand);
}
G4VisCommandSceneRemove::~G4VisCommandSceneRemove () {
delete fpCommand;
}
G4String G4VisCommandSceneRemove::GetCurrentValue (G4UIcommand*) {
return CurrentSceneName ();
}
void G4VisCommandSceneRemove::SetNewValue (G4UIcommand*, G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4String& removeName = newValue;
const G4String& currentSceneName =
fpVisManager -> GetCurrentScene () -> GetName ();
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
G4SceneListIterator iScene;
for (iScene = sceneList.begin(); iScene != sceneList.end(); ++iScene) {
if ((*iScene) -> GetName () == removeName) break;
}
if (iScene != sceneList.end()) {
delete *iScene;
sceneList.erase (iScene);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Scene \"" << removeName << "\" removed." << G4endl;
}
UpdateCandidateLists ();
if (sceneList.empty ()) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: No scenes left. Please create a new one."
<< G4endl;
G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
const G4int nViewers = viewerList.size ();
if (nViewers) {
pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
pCurrentViewer -> SetView ();
}
UpdateVisManagerScene ();
}
else {
if (currentSceneName == removeName) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Current scene is now \""
<< fpVisManager -> GetCurrentScene () -> GetName ()
<< "\"" << G4endl;
}
UpdateVisManagerScene (sceneList [0] -> GetName ());
}
else {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Current scene unchanged." << G4endl;
}
}
}
}
else {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Scene \"" << removeName
<< "\" not found - \"/vis/scene/list\" to see possibilities."
<< G4endl;
}
}
}
@@ -631,16 +503,13 @@ void G4VisCommandSceneRemove::SetNewValue (G4UIcommand*, G4String newValue) {
////////////// /vis/scene/select ///////////////////////////////////////
G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
G4bool omitable, currentAsDefault;
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/select", this);
fpCommand -> SetGuidance ("/vis/scene/select [<scene-name>]");
fpCommand -> SetGuidance ("Selects current scene.");
fpCommand -> SetGuidance
("Specify scene by name (\"/vis/scene/list\" to see possibilities).");
fpCommand -> SetParameterName ("scene-name",
omitable = true,
currentAsDefault = true);
sceneNameCommands.push_back (fpCommand);
fpCommand -> SetGuidance ("Selects a scene");
fpCommand -> SetGuidance
("Makes the scene current. \"/vis/scene/list\" to see"
"\n possible scene names.");
fpCommand -> SetParameterName ("scene-name", omitable = false);
}
G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
@@ -648,7 +517,7 @@ G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
}
G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand*) {
return CurrentSceneName ();
return "";
}
void G4VisCommandSceneSelect::SetNewValue (G4UIcommand*, G4String newValue) {