Import Geant4 3.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:03:00 +02:00
parent cfcb558cfe
commit 137e303ecc
2843 changed files with 37082 additions and 38426 deletions
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VisCommandsViewer.cc,v 1.19 2000/06/07 08:43:28 johna Exp $
// GEANT4 tag $Name: geant4-03-00 $
// $Id: G4VisCommandsViewer.cc,v 1.25 2001/04/02 10:08:46 johna Exp $
// GEANT4 tag $Name: geant4-03-01 $
// /vis/viewer commands - John Allison 25th October 1998
@@ -15,8 +15,11 @@
#include "G4VisManager.hh"
#include "G4GraphicsSystemList.hh"
#include "G4VisCommandsScene.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
#include "g4std/strstream"
@@ -25,17 +28,30 @@ G4VVisCommandViewer::G4VVisCommandViewer () {}
G4VVisCommandViewer::~G4VVisCommandViewer () {}
void G4VVisCommandViewer::SetViewParameters
(G4VViewer* viewer, const G4ViewParameters& viewParams) {
viewer->SetViewParameters(viewParams);
if (viewParams.IsAutoRefresh()) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
}
else {
G4cout << "Issue /vis/viewer/refresh to see effect." << G4endl;
}
// For now...
fpVisManager->SetCurrentViewParameters() = viewParams;
}
void G4VVisCommandViewer::UpdateCandidateLists () {
const G4SceneHandlerList& sceneHandlerList =
fpVisManager -> GetAvailableSceneHandlers ();
G4int nHandlers = sceneHandlerList.entries ();
G4int nHandlers = sceneHandlerList.size ();
G4String viewerNameList;
for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
for (int iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
for (int iViewer = 0; iViewer < viewerList.size (); iViewer++) {
viewerNameList += viewerList [iViewer] -> GetShortName () + " ";
}
}
@@ -46,13 +62,62 @@ void G4VVisCommandViewer::UpdateCandidateLists () {
}
}
////////////// /vis/viewer/clear ///////////////////////////////////////
G4VisCommandViewerClear::G4VisCommandViewerClear () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/viewer/clear", this);
fpCommand -> SetGuidance ("/vis/viewer/clear [<viewer-name>]");
fpCommand -> SetGuidance ("Clears viewer.");
fpCommand -> SetGuidance ("Viewer becomes current.");
fpCommand -> SetGuidance
("Specify viewer by name (\"/vis/viewer/list\""
"\n to see possibilities).");
fpCommand -> SetParameterName ("viewer-name",
omitable = true,
currentAsDefault = true);
viewerNameCommands.push_back (fpCommand);
}
G4VisCommandViewerClear::~G4VisCommandViewerClear () {
delete fpCommand;
}
G4String G4VisCommandViewerClear::GetCurrentValue (G4UIcommand* command) {
G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
if (viewer) {
return viewer -> GetName ();
}
else {
return "none";
}
}
void G4VisCommandViewerClear::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& clearName = newValue;
G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
if (!viewer) {
G4cout << "Viewer \"" << clearName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
return;
}
viewer->ClearView();
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Viewer \"" << clearName << "\" cleared." << G4endl;
}
}
////////////// /vis/viewer/create ///////////////////////////////////////
G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/viewer/create", this);
fpCommand -> SetGuidance
("/vis/viewer/create [<scene-handler>] [<viewer-name>]");
("/vis/viewer/create [<scene-handler>] [<viewer-name>] [<pixels>]");
fpCommand -> SetGuidance
("Creates an viewer for a specific scene handler.");
fpCommand -> SetGuidance
@@ -63,6 +128,8 @@ G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
("to the name for identification - only the characters up to the first");
fpCommand -> SetGuidance
("blank are used for removing, selecting, etc.)");
fpCommand -> SetGuidance
("The 3rd parameter is a window size hint.");
fpCommand -> SetGuidance ("This scene handler and viewer become current.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
@@ -71,6 +138,9 @@ G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("pixels", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommand -> SetParameter (parameter);
viewerNameCommands.push_back (fpCommand);
}
@@ -109,17 +179,7 @@ G4String G4VisCommandViewerCreate::GetCurrentValue (G4UIcommand* command) {
currentValue += NextName ();
currentValue += '"';
/* Replaces currentValue += NextName ();
// Now need to handle the possibility that NextName contains
// embedded blanks.
currentValue += '"';
const int charLength = 100;
char nextName [charLength];
strncpy (nextName, NextName (), charLength);
for (int i = 0; nextName[i]; i++) {
currentValue += nextName[i];
}
*/
currentValue += " 600"; // Default number of pixels for window size hint.
return currentValue;
}
@@ -127,18 +187,30 @@ G4String G4VisCommandViewerCreate::GetCurrentValue (G4UIcommand* command) {
void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String sceneHandlerName, newName;
G4int windowSizeHint;
G4std::istrstream is ((char*)newValue.data());
is >> sceneHandlerName;
// Now need to handle the possibility that the second string
// contains embedded blanks within quotation marks.
// contains embedded blanks within quotation marks...
char c;
while (is.get (c)) newName += c;
while (is.get(c) && c == ' ');
if (c == '"') {
while (is.get(c) && c != '"') newName += c;
}
else {
newName += c;
while (is.get(c) && c != ' ') newName += c;
}
newName = newName.strip (G4String::both, ' ');
newName = newName.strip (G4String::both, '"');
// Now get number of pixels...
is >> windowSizeHint;
const G4SceneHandlerList& sceneHandlerList =
fpVisManager -> GetAvailableSceneHandlers ();
G4int nHandlers = sceneHandlerList.entries ();
G4int nHandlers = sceneHandlerList.size ();
if (nHandlers <= 0) {
G4cout << "G4VisCommandViewerCreate::SetNewValue: no scene handlers."
"\n Create a scene handler with \"/vis/sceneHandler/create\""
@@ -178,7 +250,7 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command,
for (iHandler = 0; iHandler < nHandlers; iHandler++) {
G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
for (int iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
for (int iViewer = 0; iViewer < viewerList.size (); iViewer++) {
if (viewerList [iViewer] -> GetShortName () == newShortName ) {
G4cout << "Viewer \"" << newShortName << "\" already exists."
<< G4endl;
@@ -187,6 +259,12 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command,
}
}
fpVisManager->SetCurrentViewParameters().SetWindowSizeHint
(windowSizeHint, windowSizeHint);
// Currently the viewer does not pick up the above. So a viewer
// picks up a default set of view parameters adn thus, the default
// window size for the moment.
// Create viewer.
fpVisManager -> CreateViewer (newName);
if (fpVisManager -> GetCurrentViewer () -> GetName () == newName) {
@@ -195,6 +273,171 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command,
}
}
////////////// /vis/viewer/dolly and dollyTo ////////////////////////////
G4VisCommandViewerDolly::G4VisCommandViewerDolly ():
fDollyIncrement (0.),
fDollyTo (0.)
{
G4bool omitable, currentAsDefault;
fpCommandDolly = new G4UIcmdWithADoubleAndUnit
("/vis/viewer/dolly", this);
fpCommandDolly -> SetGuidance
("/vis/viewer/dolly [<increment>] [<unit>]");
fpCommandDolly -> SetGuidance
("Moves the camera incrementally in by this distance.");
fpCommandDolly -> SetParameterName("increment",
omitable=true,
currentAsDefault=true);
fpCommandDolly -> SetDefaultUnit("m");
fpCommandDollyTo = new G4UIcmdWithADoubleAndUnit
("/vis/viewer/dollyTo", this);
fpCommandDollyTo -> SetGuidance
("/vis/viewer/dollyTo [<distance>] [<unit>]");
fpCommandDollyTo -> SetGuidance
("Moves the camera in this distance relative to standard target point.");
fpCommandDollyTo -> SetParameterName("distance",
omitable=true,
currentAsDefault=true);
fpCommandDollyTo -> SetDefaultUnit("m");
}
G4VisCommandViewerDolly::~G4VisCommandViewerDolly () {
delete fpCommandDolly;
delete fpCommandDollyTo;
}
G4String G4VisCommandViewerDolly::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
if (command == fpCommandDolly) {
currentValue = fpCommandDolly->ConvertToString(fDollyIncrement, "m");
}
else if (command == fpCommandDollyTo) {
currentValue = fpCommandDollyTo->ConvertToString(fDollyTo, "m");
}
return currentValue;
}
void G4VisCommandViewerDolly::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
G4cout << "G4VisCommandsViewerDolly::SetNewValue: no current viewer."
<< G4endl;
return;
}
G4ViewParameters vp = currentViewer->GetViewParameters();
if (command == fpCommandDolly) {
fDollyIncrement = fpCommandDolly->GetNewDoubleValue(newValue);
vp.IncrementDolly(fDollyIncrement);
}
else if (command == fpCommandDollyTo) {
fDollyTo = fpCommandDolly->GetNewDoubleValue(newValue);
vp.SetDolly(fDollyTo);
}
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Dolly distance changed to " << vp.GetDolly() << G4endl;
}
SetViewParameters(currentViewer, vp);
}
//////// /vis/viewer/lightsThetaPhi and lightsVector /////////////
G4VisCommandViewerLights::G4VisCommandViewerLights ():
fLightsVector (G4ThreeVector(0.,0.,1.))
{
G4bool omitable;
fpCommandLightsThetaPhi = new G4UIcommand
("/vis/viewer/lightsThetaPhi", this);
fpCommandLightsThetaPhi -> SetGuidance
("/vis/viewer/lightsThetaPhi [<theta>] [<phi>] [deg|rad]");
fpCommandLightsThetaPhi -> SetGuidance
("Set direction from target to lights.");
G4UIparameter* parameter;
parameter = new G4UIparameter("theta", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandLightsThetaPhi -> SetParameter (parameter);
parameter = new G4UIparameter("phi", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandLightsThetaPhi -> SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter -> SetDefaultValue ("deg");
fpCommandLightsThetaPhi -> SetParameter (parameter);
fpCommandLightsVector = new G4UIcommand
("/vis/viewer/lightsVector", this);
fpCommandLightsVector -> SetGuidance
("/vis/viewer/lightsVector [<x>] [<y>] [<z>]");
fpCommandLightsVector -> SetGuidance
("Set direction from target to lights.");
parameter = new G4UIparameter("x", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandLightsVector -> SetParameter (parameter);
parameter = new G4UIparameter("y", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandLightsVector -> SetParameter (parameter);
parameter = new G4UIparameter ("z", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandLightsVector -> SetParameter (parameter);
}
G4VisCommandViewerLights::~G4VisCommandViewerLights () {
delete fpCommandLightsThetaPhi;
delete fpCommandLightsVector;
}
G4String G4VisCommandViewerLights::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
if (command == fpCommandLightsThetaPhi) {
currentValue = ConvertToString(fLightsVector.theta(),
fLightsVector.phi(), "deg");
}
else if (command == fpCommandLightsVector) {
currentValue = ConvertToString(fLightsVector);
}
return currentValue;
}
void G4VisCommandViewerLights::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
G4cout << "G4VisCommandsViewerLights::SetNewValue: no current viewer."
<< G4endl;
return;
}
G4ViewParameters vp = currentViewer->GetViewParameters();
if (command == fpCommandLightsThetaPhi) {
G4double theta, phi;
GetNewDoublePairValue(newValue, theta, phi);
G4double x = sin (theta) * cos (phi);
G4double y = sin (theta) * sin (phi);
G4double z = cos (theta);
fLightsVector = G4Vector3D (x, y, z);
}
else if (command == fpCommandLightsVector) {
fLightsVector = GetNew3VectorValue(newValue);
}
vp.SetLightpointDirection(fLightsVector);
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Lights direction set to " << fLightsVector << G4endl;
}
SetViewParameters(currentViewer, vp);
}
////////////// /vis/viewer/list ///////////////////////////////////////
G4VisCommandViewerList::G4VisCommandViewerList () {
@@ -245,7 +488,7 @@ void G4VisCommandViewerList::SetNewValue (G4UIcommand* command,
}
const G4SceneHandlerList& sceneHandlerList = fpVisManager -> GetAvailableSceneHandlers ();
G4int nHandlers = sceneHandlerList.entries ();
G4int nHandlers = sceneHandlerList.size ();
G4bool found = false;
G4bool foundCurrent = false;
for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
@@ -254,7 +497,7 @@ void G4VisCommandViewerList::SetNewValue (G4UIcommand* command,
const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
G4cout << "Scene handler \"" << sceneHandler -> GetName ()
<< "\", scene \"" << pScene -> GetName () << "\":";
G4int nViewers = viewerList.entries ();
G4int nViewers = viewerList.size ();
if (nViewers == 0) {
G4cout << "\n No viewers for this scene handler." << G4endl;
}
@@ -298,6 +541,96 @@ void G4VisCommandViewerList::SetNewValue (G4UIcommand* command,
}
}
////////////// /vis/viewer/pan and panTo ////////////////////////////
G4VisCommandViewerPan::G4VisCommandViewerPan ():
fPanIncrementRight (0.),
fPanIncrementUp (0.),
fPanToRight (0.),
fPanToUp (0.)
{
G4bool omitable;
fpCommandPan = new G4UIcommand
("/vis/viewer/pan", this);
fpCommandPan -> SetGuidance
("/vis/viewer/pan [<right-increment>] [<up-increment>] [<unit>]");
fpCommandPan -> SetGuidance
("Moves the camera incrementally right and up by these amounts.");
G4UIparameter* parameter;
parameter = new G4UIparameter("right-increment", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandPan -> SetParameter (parameter);
parameter = new G4UIparameter("up-increment", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandPan -> SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter -> SetDefaultValue ("m");
fpCommandPan -> SetParameter (parameter);
fpCommandPanTo = new G4UIcommand
("/vis/viewer/panTo", this);
fpCommandPanTo -> SetGuidance
("/vis/viewer/panTo [<right>] [<up>] [<unit>]");
fpCommandPanTo -> SetGuidance
("Moves the camera to this position right and up relative to standard"
"target point (as seen from viewpoint direction).");
parameter = new G4UIparameter("right", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandPanTo -> SetParameter (parameter);
parameter = new G4UIparameter("up", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandPanTo -> SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter -> SetDefaultValue ("m");
fpCommandPanTo -> SetParameter (parameter);
}
G4VisCommandViewerPan::~G4VisCommandViewerPan () {
delete fpCommandPan;
delete fpCommandPanTo;
}
G4String G4VisCommandViewerPan::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
if (command == fpCommandPan) {
currentValue = ConvertToString(fPanIncrementRight, fPanIncrementUp, "m");
}
else if (command == fpCommandPanTo) {
currentValue = ConvertToString(fPanToRight, fPanToUp, "m");
}
return currentValue;
}
void G4VisCommandViewerPan::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
G4cout << "G4VisCommandsViewerPan::SetNewValue: no current viewer."
<< G4endl;
return;
}
G4ViewParameters vp = currentViewer->GetViewParameters();
if (command == fpCommandPan) {
GetNewDoublePairValue(newValue, fPanIncrementRight, fPanIncrementUp);
vp.IncrementPan(fPanIncrementRight, fPanIncrementUp);
}
else if (command == fpCommandPanTo) {
GetNewDoublePairValue(newValue, fPanToRight, fPanToUp);
vp.SetPan(fPanToRight, fPanToUp);
}
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Current target point now " << vp.GetCurrentTargetPoint()
<< G4endl;
}
SetViewParameters(currentViewer, vp);
}
////////////// /vis/viewer/refresh ///////////////////////////////////////
G4VisCommandViewerRefresh::G4VisCommandViewerRefresh () {
@@ -335,19 +668,38 @@ void G4VisCommandViewerRefresh::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& refreshName = newValue;
G4VViewer* viewer = fpVisManager -> GetViewer (refreshName);
if (viewer) {
G4cout << "Refreshing viewer \"" << viewer -> GetName () << "\"..."
<< G4endl;
viewer -> ClearView ();
viewer -> DrawView ();
G4cout << "Viewer \"" << viewer -> GetName () << "\"" << " refreshed."
"\n (You might also need \"/vis/viewer/update\".)" << G4endl;
}
else {
if (!viewer) {
G4cout << "Viewer \"" << refreshName << "\"" <<
" not found - \"/vis/viewer/list\"\n to see possibilities."
<< G4endl;
return;
}
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
if (!sceneHandler) {
G4cout << "Viewer \"" << refreshName << "\"" <<
" has no scene handler - report serious bug."
<< G4endl;
return;
}
G4Scene* scene = sceneHandler->GetScene();
if (!scene) {
G4cout << "SceneHandler \"" << sceneHandler->GetName()
<< "\", to which viewer \"" << refreshName << "\"" <<
"\n is attached, has no scene - \"/vis/scene/create\" and"
"\"/vis/sceneHandler/attach\""
"\n (or use compound command \"/vis/drawVolume\")."
<< G4endl;
return;
}
G4cout << "Refreshing viewer \"" << viewer -> GetName () << "\"..."
<< G4endl;
viewer -> ClearView ();
viewer -> DrawView ();
G4cout << "Viewer \"" << viewer -> GetName () << "\"" << " refreshed."
"\n (You might also need \"/vis/viewer/update\".)" << G4endl;
}
////////////// /vis/viewer/remove ///////////////////////////////////////
@@ -407,7 +759,8 @@ void G4VisCommandViewerRemove::SetNewValue (G4UIcommand* command,
}
else {
G4VSceneHandler* sceneHandler = viewer -> GetSceneHandler ();
sceneHandler -> SetViewerList ().remove (viewer);
G4ViewerList& viewerList = sceneHandler -> SetViewerList ();
viewerList.remove (viewer);
G4cout << "Current viewer is unchanged (\""
<< currentViewer -> GetName () << "\")." << G4endl;
}
@@ -457,14 +810,7 @@ void G4VisCommandViewerReset::SetNewValue (G4UIcommand* command,
return;
}
if (fpVisManager -> IsValidView ()) {
G4ViewParameters vp; // Default view parameters.
viewer->SetViewParameters(vp);
G4cout << "Viewer \"" << viewer -> GetName () << "\" reset.";
G4cout << "\nIssue \"/vis/viewer/refresh\" to see effect." << G4endl;
// For now...
fpVisManager->SetCurrentViewParameters() = vp;
}
SetViewParameters(viewer, viewer->GetDefaultViewParameters());
}
////////////// /vis/viewer/select ///////////////////////////////////////
@@ -582,3 +928,172 @@ void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand* command,
"\n to see possibilities." << G4endl;
}
}
//////// /vis/viewer/viewpointThetaPhi and viewpointVector /////////////
G4VisCommandViewerViewpoint::G4VisCommandViewerViewpoint ():
fViewpointVector (G4ThreeVector(0.,0.,1.))
{
G4bool omitable;
fpCommandViewpointThetaPhi = new G4UIcommand
("/vis/viewer/viewpointThetaPhi", this);
fpCommandViewpointThetaPhi -> SetGuidance
("/vis/viewer/viewpointThetaPhi [<theta>] [<phi>] [deg|rad]");
fpCommandViewpointThetaPhi -> SetGuidance
("Set direction from target to camera. Also changes lightpoint direction"
"\nif lights are set to move with camera.");
G4UIparameter* parameter;
parameter = new G4UIparameter("theta", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandViewpointThetaPhi -> SetParameter (parameter);
parameter = new G4UIparameter("phi", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandViewpointThetaPhi -> SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter -> SetDefaultValue ("deg");
fpCommandViewpointThetaPhi -> SetParameter (parameter);
fpCommandViewpointVector = new G4UIcommand
("/vis/viewer/viewpointVector", this);
fpCommandViewpointVector -> SetGuidance
("/vis/viewer/viewpointVector [<x>] [<y>] [<z>]");
fpCommandViewpointVector -> SetGuidance
("Set direction from target to camera. Also changes lightpoint direction"
"\nif lights are set to move with camera.");
parameter = new G4UIparameter("x", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandViewpointVector -> SetParameter (parameter);
parameter = new G4UIparameter("y", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandViewpointVector -> SetParameter (parameter);
parameter = new G4UIparameter ("z", 'd', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommandViewpointVector -> SetParameter (parameter);
}
G4VisCommandViewerViewpoint::~G4VisCommandViewerViewpoint () {
delete fpCommandViewpointThetaPhi;
delete fpCommandViewpointVector;
}
G4String G4VisCommandViewerViewpoint::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
if (command == fpCommandViewpointThetaPhi) {
currentValue = ConvertToString(fViewpointVector.theta(),
fViewpointVector.phi(), "deg");
}
else if (command == fpCommandViewpointVector) {
currentValue = ConvertToString(fViewpointVector);
}
return currentValue;
}
void G4VisCommandViewerViewpoint::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
G4cout << "G4VisCommandsViewerViewpoint::SetNewValue: no current viewer."
<< G4endl;
return;
}
G4ViewParameters viewParams = currentViewer->GetViewParameters();
if (command == fpCommandViewpointThetaPhi) {
G4double theta, phi;
GetNewDoublePairValue(newValue, theta, phi);
G4double x = sin (theta) * cos (phi);
G4double y = sin (theta) * sin (phi);
G4double z = cos (theta);
fViewpointVector = G4Vector3D (x, y, z);
}
else if (command == fpCommandViewpointVector) {
fViewpointVector = GetNew3VectorValue(newValue);
}
viewParams.SetViewAndLights(fViewpointVector);
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Viewpoint direction set to " << fViewpointVector << G4endl;
if (viewParams.GetLightsMoveWithCamera ()) {
G4cout << "Lightpoint direction set to "
<< viewParams.GetActualLightpointDirection () << G4endl;
}
}
SetViewParameters(currentViewer, viewParams);
}
////////////// /vis/viewer/zoom and zoomTo ////////////////////////////
G4VisCommandViewerZoom::G4VisCommandViewerZoom ():
fZoomMultiplier (1.),
fZoomTo (1.)
{
G4bool omitable, currentAsDefault;
fpCommandZoom = new G4UIcmdWithADouble
("/vis/viewer/zoom", this);
fpCommandZoom -> SetGuidance
("/vis/viewer/zoom [<multiplier>]");
fpCommandZoom -> SetGuidance
("Multiplies magnification by this factor.");
fpCommandZoom -> SetParameterName("multiplier",
omitable=true,
currentAsDefault=true);
fpCommandZoomTo = new G4UIcmdWithADouble
("/vis/viewer/zoomTo", this);
fpCommandZoomTo -> SetGuidance
("/vis/viewer/zoomTo [<factor>]");
fpCommandZoomTo -> SetGuidance
("Magnifies by this factor relative to standard view.");
fpCommandZoomTo -> SetParameterName("factor",
omitable=true,
currentAsDefault=true);
}
G4VisCommandViewerZoom::~G4VisCommandViewerZoom () {
delete fpCommandZoom;
delete fpCommandZoomTo;
}
G4String G4VisCommandViewerZoom::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
if (command == fpCommandZoom) {
currentValue = fpCommandZoom->ConvertToString(fZoomMultiplier);
}
else if (command == fpCommandZoomTo) {
currentValue = fpCommandZoomTo->ConvertToString(fZoomTo);
}
return currentValue;
}
void G4VisCommandViewerZoom::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
G4cout << "G4VisCommandsViewerZoom::SetNewValue: no current viewer."
<< G4endl;
return;
}
G4ViewParameters vp = currentViewer->GetViewParameters();
if (command == fpCommandZoom) {
fZoomMultiplier = fpCommandZoom->GetNewDoubleValue(newValue);
vp.MultiplyZoomFactor(fZoomMultiplier);
}
else if (command == fpCommandZoomTo) {
fZoomTo = fpCommandZoom->GetNewDoubleValue(newValue);
vp.SetZoomFactor(fZoomTo);
}
if (fpVisManager->GetVerboseLevel() > 0) {
G4cout << "Zoom factor changed to " << vp.GetZoomFactor() << G4endl;
}
SetViewParameters(currentViewer, vp);
}