Import Geant4 1.0.0 source tree
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
// 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: G4VisCommandsScene.cc,v 1.7 1999/05/10 14:04:15 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
// $Id: G4VisCommandsScene.cc,v 1.9.4.1 1999/12/07 20:54:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-01-00 $
|
||||
|
||||
// /vis/scene commands - John Allison 9th August 1998
|
||||
|
||||
@@ -30,6 +30,13 @@ G4VVisCommandScene::G4VVisCommandScene () {}
|
||||
|
||||
G4VVisCommandScene::~G4VVisCommandScene () {}
|
||||
|
||||
G4String G4VVisCommandScene::CurrentSceneName () {
|
||||
const G4Scene* pScene = fpVisManager -> GetCurrentScene ();
|
||||
G4String currentSceneName;
|
||||
if (pScene) currentSceneName = pScene -> GetName ();
|
||||
return currentSceneName;
|
||||
}
|
||||
|
||||
void G4VVisCommandScene::UpdateCandidateLists () {
|
||||
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
@@ -40,6 +47,11 @@ void G4VVisCommandScene::UpdateCandidateLists () {
|
||||
}
|
||||
nameList = nameList.strip ();
|
||||
|
||||
if (fpCommandSceneEdit) {
|
||||
fpCommandSceneEdit -> GetParameter (0) ->
|
||||
SetParameterCandidates (nameList);
|
||||
}
|
||||
|
||||
if (fpCommandSceneNotifyHandlers) {
|
||||
fpCommandSceneNotifyHandlers -> GetParameter (0) ->
|
||||
SetParameterCandidates (nameList);
|
||||
@@ -61,20 +73,16 @@ void G4VVisCommandScene::UpdateCandidateLists () {
|
||||
}
|
||||
}
|
||||
|
||||
void G4VVisCommandScene::UpdateVisManagerSceneAndViewParameters
|
||||
void G4VVisCommandScene::UpdateVisManagerScene
|
||||
(const G4String& sceneName) {
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
G4int iScene, nScenes = sceneList.entries ();
|
||||
for (iScene = 0; iScene < nScenes; iScene++) {
|
||||
if (sceneList [iScene] -> GetName () == sceneName) break;
|
||||
}
|
||||
if (iScene < nScenes) {
|
||||
fpVisManager -> SetCurrentScene (sceneList [iScene]);
|
||||
G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/camera/reset");
|
||||
}
|
||||
else {
|
||||
fpVisManager -> SetCurrentScene (0);
|
||||
}
|
||||
G4Scene* pScene = 0; // Zero unless scene has been found...
|
||||
if (iScene < nScenes) pScene = sceneList [iScene];
|
||||
fpVisManager -> SetCurrentScene (pScene);
|
||||
}
|
||||
|
||||
////////////// /vis/scene/create ///////////////////////////////////////
|
||||
@@ -89,6 +97,7 @@ G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) {
|
||||
fpCommand -> SetParameterName ("scene-name",
|
||||
omitable = true,
|
||||
currentAsDefault = true);
|
||||
fpCommandSceneEdit = fpCommand;
|
||||
}
|
||||
|
||||
G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
|
||||
@@ -129,13 +138,68 @@ void G4VisCommandSceneCreate::SetNewValue (G4UIcommand* command,
|
||||
sceneList.append (new G4Scene (newName));
|
||||
// Adds empty scene data object to list.
|
||||
|
||||
UpdateVisManagerSceneAndViewParameters (newName);
|
||||
UpdateVisManagerScene (newName);
|
||||
G4cout << "New empty scene \"" << newName << "\" created." << endl;
|
||||
|
||||
UpdateCandidateLists ();
|
||||
}
|
||||
}
|
||||
|
||||
////////////// /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);
|
||||
}
|
||||
|
||||
G4VisCommandSceneEdit::~G4VisCommandSceneEdit () {
|
||||
delete fpCommand;
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneEdit::GetCurrentValue (G4UIcommand* command) {
|
||||
return CurrentSceneName ();
|
||||
}
|
||||
|
||||
void G4VisCommandSceneEdit::SetNewValue (G4UIcommand* command,
|
||||
G4String newValue) {
|
||||
G4String sceneName;
|
||||
istrstream is ((char*)newValue.data());
|
||||
is >> sceneName;
|
||||
|
||||
G4SceneList& sceneList = fpVisManager -> SetSceneList ();
|
||||
G4int iScene, nScenes = sceneList.entries ();
|
||||
G4Scene* pScene;
|
||||
for (iScene = 0; iScene < nScenes; iScene++) {
|
||||
pScene = sceneList [iScene];
|
||||
if (pScene -> GetName () == sceneName) break;
|
||||
}
|
||||
if (iScene >= nScenes) {
|
||||
G4cout << "G4VisCommandSceneEdit::SetNewValue: Scene \""
|
||||
<< sceneName << "\" not found."
|
||||
"\n /vis/scene/list to see scenes."
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
G4cout << "Scene \"" << sceneName << "\" contains:" << endl;
|
||||
G4String uiCommand ("/vis/scene/list ");
|
||||
uiCommand += sceneName;
|
||||
uiCommand += " 1";
|
||||
G4UImanager::GetUIpointer () -> ApplyCommand (uiCommand);
|
||||
G4cout <<
|
||||
"(YOU CAN DO NOTHING YET - /vis/scene/edit FACILITY IN PREPARATION."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
UpdateVisManagerScene (sceneName);
|
||||
}
|
||||
|
||||
////////////// /vis/scene/list ///////////////////////////////////////
|
||||
|
||||
G4VisCommandSceneList::G4VisCommandSceneList () {
|
||||
@@ -145,7 +209,7 @@ G4VisCommandSceneList::G4VisCommandSceneList () {
|
||||
fpCommand -> SetGuidance ("Lists scene(s).");
|
||||
fpCommand -> SetGuidance ("<scene-name> default is \"all\"");
|
||||
fpCommand -> SetGuidance
|
||||
("<verbosity> is 0 for short (default) or 1 for long listing.");
|
||||
("<verbosity> is 0/1/2 for short/medium/long listing.");
|
||||
G4UIparameter* parameter;
|
||||
parameter = new G4UIparameter ("scene-name", 's',
|
||||
omitable = true);
|
||||
@@ -178,14 +242,36 @@ void G4VisCommandSceneList::SetNewValue (G4UIcommand* command,
|
||||
G4int iScene, nScenes = sceneList.entries ();
|
||||
G4bool found = false;
|
||||
for (iScene = 0; iScene < nScenes; iScene++) {
|
||||
const G4String& iName = sceneList [iScene] -> GetName ();
|
||||
G4Scene* pScene = sceneList [iScene];
|
||||
const G4String& iName = pScene -> GetName ();
|
||||
if (name != "all") {
|
||||
if (name != iName) continue;
|
||||
}
|
||||
found = true;
|
||||
G4cout << "Scene name: \"" << iName << "\"";
|
||||
if (verbosity > 0) {
|
||||
G4cout << ", " << *sceneList [iScene];
|
||||
if (verbosity == 1) {
|
||||
G4int i;
|
||||
G4cout << "\n Run-duration models:";
|
||||
G4int nRunModels = pScene -> GetRunDurationModelList ().entries ();
|
||||
if (nRunModels == 0) {
|
||||
G4cout << " none.";
|
||||
}
|
||||
for (i = 0; i < nRunModels; i++) {
|
||||
G4VModel* pModel = pScene -> GetRunDurationModelList () [i];
|
||||
G4cout << "\n " << pModel -> GetGlobalDescription ();
|
||||
}
|
||||
G4cout << "\n End-of-event models:";
|
||||
G4int nEOEModels = pScene -> GetEndOfEventModelList ().entries ();
|
||||
if (nEOEModels == 0) {
|
||||
G4cout << " none.";
|
||||
}
|
||||
for (i = 0; i < nEOEModels; i++) {
|
||||
G4VModel* pModel = pScene -> GetEndOfEventModelList () [i];
|
||||
G4cout << "\n " << pModel -> GetGlobalDescription ();
|
||||
}
|
||||
}
|
||||
if (verbosity >= 2) {
|
||||
G4cout << "\n " << *sceneList [iScene];
|
||||
}
|
||||
G4cout << endl;
|
||||
}
|
||||
@@ -221,7 +307,7 @@ G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
|
||||
|
||||
G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue
|
||||
(G4UIcommand* command) {
|
||||
return fpVisManager -> GetCurrentScene () -> GetName ();
|
||||
return CurrentSceneName ();
|
||||
}
|
||||
|
||||
void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand* command,
|
||||
@@ -248,25 +334,30 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand* command,
|
||||
return;
|
||||
}
|
||||
|
||||
// For each scene handler, if it contains the scene, for each viewer
|
||||
// set (make current), clear, (re)draw, and show.
|
||||
// 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.
|
||||
const G4int nSceneHandlers = sceneHandlerList.entries ();
|
||||
for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
|
||||
G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
|
||||
G4Scene* theScene = aSceneHandler -> GetScene ();
|
||||
const G4String& theSceneName = theScene -> GetName ();
|
||||
if (sceneName == theSceneName) {
|
||||
G4Scene* aScene = aSceneHandler -> GetScene ();
|
||||
const G4String& aSceneName = aScene -> GetName ();
|
||||
if (sceneName == aSceneName) {
|
||||
aSceneHandler -> ClearStore ();
|
||||
aSceneHandler -> ClearTransientStore ();
|
||||
G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
|
||||
const G4int nViewers = viewerList.entries ();
|
||||
for (G4int iV = 0; iV < nViewers; iV++) {
|
||||
G4VViewer* aViewer = viewerList [iV];
|
||||
aViewer -> SetView ();
|
||||
aViewer -> ClearView ();
|
||||
aViewer -> DrawView ();
|
||||
aViewer -> ShowView ();
|
||||
// Triggers rebuild of graphical database by notifying the scene
|
||||
// handler. The viewer is supposed to be smart enough to know
|
||||
// when not to do this. E.g., the second viewer of a scene
|
||||
// handler does not do it.
|
||||
G4cout << "Viewer \"" << aViewer -> GetName ()
|
||||
<< "\" of scene handler \"" << aSceneHandler -> GetName ()
|
||||
<< "\"\n refreshed at request of scene \"" << sceneName
|
||||
<< "\"\n prepared at request of scene \"" << sceneName
|
||||
<< "\"." << endl;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +384,7 @@ G4VisCommandSceneRemove::~G4VisCommandSceneRemove () {
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneRemove::GetCurrentValue (G4UIcommand* command) {
|
||||
return fpVisManager -> GetCurrentScene () -> GetName ();
|
||||
return CurrentSceneName ();
|
||||
}
|
||||
|
||||
void G4VisCommandSceneRemove::SetNewValue (G4UIcommand* command,
|
||||
@@ -312,12 +403,12 @@ void G4VisCommandSceneRemove::SetNewValue (G4UIcommand* command,
|
||||
G4cout << "Scene \"" << removeName << "\" removed." << endl;
|
||||
UpdateCandidateLists ();
|
||||
if (sceneList.isEmpty ()) {
|
||||
UpdateVisManagerSceneAndViewParameters ();
|
||||
UpdateVisManagerScene ();
|
||||
G4cout << "No scenes left. Please create a new one." << endl;
|
||||
}
|
||||
else {
|
||||
if (currentSceneName == removeName) {
|
||||
UpdateVisManagerSceneAndViewParameters (sceneList [0] -> GetName ());
|
||||
UpdateVisManagerScene (sceneList [0] -> GetName ());
|
||||
G4cout << "Current scene is now \""
|
||||
<< fpVisManager -> GetCurrentScene () -> GetName ()
|
||||
<< "\"" << endl;
|
||||
@@ -354,7 +445,7 @@ G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
|
||||
}
|
||||
|
||||
G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand* command) {
|
||||
return fpVisManager -> GetCurrentScene () -> GetName ();
|
||||
return CurrentSceneName ();
|
||||
}
|
||||
|
||||
void G4VisCommandSceneSelect::SetNewValue (G4UIcommand* command,
|
||||
@@ -367,7 +458,7 @@ void G4VisCommandSceneSelect::SetNewValue (G4UIcommand* command,
|
||||
}
|
||||
G4cout << "Scene \"" << selectName;
|
||||
if (iScene < nScenes) {
|
||||
UpdateVisManagerSceneAndViewParameters (selectName);
|
||||
UpdateVisManagerScene (selectName);
|
||||
G4cout << "\" selected." << endl;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user