Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,88 @@
// This code implementation is the intellectual property of
// the RD44 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: G4SceneData.cc,v 2.7 1998/11/29 15:34:05 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Scene data John Allison 19th July 1996.
#include "G4SceneData.hh"
#include "G4Vector3D.hh"
#include "G4BoundingSphereScene.hh"
G4SceneData::G4SceneData (const G4String& name):
fName (name)
{} // Note all data members have default initial values.
G4SceneData::~G4SceneData () {}
void G4SceneData::AddRunDurationModel (G4VModel* pModel) {
fRunDurationModelList.append (pModel);
G4int nModels = fRunDurationModelList.entries ();
G4BoundingSphereScene boundingSphereScene;
for (int i = 0; i < nModels; i++) {
const G4VisExtent& thisExtent =
fRunDurationModelList[i] -> GetExtent ();
G4Point3D thisCentre = thisExtent.GetExtentCentre ();
G4double thisRadius = thisExtent.GetExtentRadius ();
//thisCentre.transform (fRunDurationModelList[i] -> GetTransformation ());
// To by-pass temporary CLHEP non-const problem...
G4Transform3D modelTransformation =
fRunDurationModelList[i] -> GetTransformation ();
thisCentre.transform (modelTransformation);
boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
}
fExtent = boundingSphereScene.GetBoundingSphereExtent ();
fStandardTargetPoint = fExtent.GetExtentCentre ();
}
void G4SceneData::Clear () {
fRunDurationModelList.clearAndDestroy ();
fEndOfEventModelList.clearAndDestroy ();
}
ostream& operator << (ostream& os, const G4SceneData& d) {
os << "Scene data:";
os << "\n Run-duration model list:";
for (int i = 0; i < d.fRunDurationModelList.entries (); i++) {
os << "\n " << *(d.fRunDurationModelList[i]);
}
os << "\n End-of-event model list:";
for (int ii = 0; ii < d.fEndOfEventModelList.entries (); ii++) {
os << "\n " << *(d.fEndOfEventModelList[ii]);
}
os << "\n Extent or bounding box: " << d.fExtent;
os << "\n Standard target point: " << d.fStandardTargetPoint;
return os;
}
G4bool operator != (const G4SceneData& d1,
const G4SceneData& d2) {
if (
(d1.fRunDurationModelList.entries () !=
d2.fRunDurationModelList.entries ()) ||
(d1.fExtent != d2.fExtent) ||
!(d1.fStandardTargetPoint == d2.fStandardTargetPoint)
) return true;
for (int i = 0; i < d1.fRunDurationModelList.entries (); i++) {
if (d1.fRunDurationModelList[i] != d2.fRunDurationModelList[i])
return true;
}
return false;
}
@@ -0,0 +1,27 @@
// This code implementation is the intellectual property of
// the RD44 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: G4SceneDataObjectList.cc,v 2.2 1998/08/10 10:19:09 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 9th August 1998
#include "G4SceneDataObjectList.hh"
G4SceneDataObjectList::G4SceneDataObjectList
(
unsigned (*hashFun)(const G4String&), // Hashing function
size_t size // No. of buckets
):
RWTValHashDictionary <G4String, G4SceneData> (hashFun, size)
{}
G4SceneDataObjectListIterator::G4SceneDataObjectListIterator
(G4SceneDataObjectList& list):
RWTValHashDictionaryIterator <G4String, G4SceneData> (list)
{}
@@ -0,0 +1,80 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VGraphicsSystem.cc,v 2.1 1998/11/06 13:43:10 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 27th March 1996
// Abstract interface class for graphics systems.
#include "G4VGraphicsSystem.hh"
#include "G4VisManager.hh"
G4VGraphicsSystem::G4VGraphicsSystem (const G4String& name,
Functionality f):
fName (name),
fNickname (""),
fDescription (""),
fFunctionality (f) {}
G4VGraphicsSystem::G4VGraphicsSystem (const G4String& name,
const G4String& nickname,
Functionality f):
fName (name),
fNickname (nickname),
fDescription (""),
fFunctionality (f) {}
G4VGraphicsSystem::G4VGraphicsSystem (const G4String& name,
const G4String& nickname,
const G4String& description,
Functionality f):
fName (name),
fNickname (nickname),
fDescription (description),
fFunctionality (f) {}
ostream& operator << (ostream& os, const G4VGraphicsSystem& gs) {
G4VisManager* pVMan = G4VisManager::GetInstance ();
const G4SceneList& scenes = pVMan -> GetAvailableScenes ();
os << "Graphics System: " << gs.GetName ();
if (gs.GetNickname () != "") {
os << ", nickname: " << gs.GetNickname ();
}
if (gs.GetDescription () != "") {
os << "\n Description: " << gs.GetDescription ();
}
os << "\n Functionality: " << gs.GetFunctionality ();
if (pVMan -> GetVerboseLevel () > 1) {
G4int nScenes = scenes.entries ();
if (nScenes) {
G4int nScenesOfThisSystem = 0;
for (int i = 0; i < nScenes; i++) {
if (scenes [i] -> GetGraphicsSystem () == &gs) {
nScenesOfThisSystem++;
}
}
if (nScenesOfThisSystem) {
os << "\n Its scenes are: ";
for (int i = 0; i < nScenes; i++) {
if (scenes [i] -> GetGraphicsSystem () == &gs) {
os << "\n " << *(scenes [i]);
}
}
}
else {
os << "\n It has no scenes at present.";
}
}
else {
os << "\n There are no scenes instantiated at present.";
}
}
return os;
}
@@ -0,0 +1,400 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VScene.cc,v 2.8 1998/11/29 15:34:06 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 19th July 1996
// Abstract interface class for graphics scenes.
#include "G4VScene.hh"
#include "G4ios.hh"
#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
#include "G4VisManager.hh"
#include "G4VGraphicsSystem.hh"
#include "G4VView.hh"
#include "G4VSolid.hh"
#include "G4RotationMatrix.hh"
#include "G4ThreeVector.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Material.hh"
#include "G4Polyline.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Polymarker.hh"
#include "G4Polyhedron.hh"
#include "G4NURBS.hh"
#include "G4Visible.hh"
#include "G4VisAttributes.hh"
#include "G4VModel.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ModelingParameters.hh"
G4VScene::G4VScene (G4VGraphicsSystem& system, G4int id, const G4String& name):
fSystem (system),
fSceneId (id),
fViewCount (0),
fpView (0),
fReadyForTransients (false),
fpModel (0),
fpObjectTransformation (0),
fpVisAttribs (0),
fCurrentDepth (0),
fpCurrentPV (0),
fpCurrentLV (0)
{
G4VisManager* pVMan = G4VisManager::GetInstance ();
fSD = pVMan -> GetCurrentSceneData ();
if (name == "") {
char charname [50];
ostrstream ost (charname, 50);
ost << fSystem.GetName () << '-' << fSceneId << ends;
fName = charname;
}
else {
fName = name;
}
}
G4VScene::~G4VScene () {
fViewList.clearAndDestroy ();
}
void G4VScene::AddViewToList (G4VView* pView) {
fViewList.append (pView);
}
void G4VScene::EstablishSpecials (G4PhysicalVolumeModel& pvModel) {
pvModel.DefinePointersToWorkingSpace (&fCurrentDepth,
&fpCurrentPV,
&fpCurrentLV);
}
void G4VScene::BeginModeling () {
if (!GetModel ()) G4Exception ("G4VScene::BeginModeling: NO MODEL!!!");
}
void G4VScene::BeginPrimitives
(const G4Transform3D& objectTransformation) {
if (!GetModel ()) G4Exception ("G4VScene::BeginPrimitives: NO MODEL!!!");
fpObjectTransformation = &objectTransformation;
}
void G4VScene::EndPrimitives () {}
void G4VScene::AddPrimitive (const G4Polymarker& polymarker) {
switch (polymarker.GetMarkerType()) {
default:
case G4Polymarker::line:
{
G4Polyline polyline (polymarker);
for (int iPoint = 0; iPoint < polymarker.entries (); iPoint++) {
polyline.append (polymarker[iPoint]);
}
AddPrimitive (polyline);
}
break;
case G4Polymarker::dots:
{
for (int iPoint = 0; iPoint < polymarker.entries (); iPoint++) {
G4Circle dot (polymarker);
dot.SetPosition (polymarker[iPoint]);
dot.SetWorldSize (0.);
dot.SetScreenSize (0.1); // Very small circle.
AddPrimitive (dot);
}
}
break;
case G4Polymarker::circles:
{
for (int iPoint = 0; iPoint < polymarker.entries (); iPoint++) {
G4Circle circle (polymarker);
circle.SetPosition (polymarker[iPoint]);
AddPrimitive (circle);
}
}
break;
case G4Polymarker::squares:
{
for (int iPoint = 0; iPoint < polymarker.entries (); iPoint++) {
G4Square Square (polymarker);
Square.SetPosition (polymarker[iPoint]);
AddPrimitive (Square);
}
}
break;
}
}
void G4VScene::RemoveViewFromList (G4VView* pView) {
fViewList.remove (pView);
}
void G4VScene::SetSceneData (const G4SceneData& sd) {
fSD = sd;
// Notify all views that a kernel visit is required.
for (int i = 0; i < fViewList.entries (); i++) {
fViewList [i] -> SetNeedKernelVisit ();
}
}
void G4VScene::RequestPrimitives (const G4VSolid& solid) {
G4Polyhedron* pPolyhedron;
G4NURBS* pNURBS;
BeginPrimitives (*fpObjectTransformation);
switch (GetModel () -> GetModelingParameters () -> GetRepStyle ()) {
case G4ModelingParameters::nurbs:
pNURBS = solid.CreateNURBS ();
if (pNURBS) {
pNURBS -> SetVisAttributes
(fpView -> GetApplicableVisAttributes (fpVisAttribs));
AddPrimitive (*pNURBS);
delete pNURBS;
break;
}
else {
G4cerr << "NURBS not available for " << solid.GetName () << endl;
G4cerr << "Trying polyhedron." << endl;
}
// Dropping through to polyhedron...
case G4ModelingParameters::polyhedron:
default:
G4Polyhedron::SetNumberOfRotationSteps
(GetModel () -> GetModelingParameters () -> GetNoOfSides ());
pPolyhedron = solid.CreatePolyhedron ();
G4Polyhedron::ResetNumberOfRotationSteps ();
if (pPolyhedron) {
pPolyhedron -> SetVisAttributes
(fpView -> GetApplicableVisAttributes (fpVisAttribs));
AddPrimitive (*pPolyhedron);
delete pPolyhedron;
}
else {
G4cerr << "Polyhedron not available for " << solid.GetName ()
<<".\nThis means it cannot be visualized on most systems."
"\nContact the Visualization Coordinator." << endl;
}
break;
case G4ModelingParameters::hierarchy:
G4cout << "Geometry hierarchy requested: tag "
<< GetModel () -> GetCurrentTag ()
<< ", depth "
<< fCurrentDepth
<< endl;
break;
}
EndPrimitives ();
}
void G4VScene::ProcessScene (G4VView& view) {
fReadyForTransients = false;
// Clear stored scene, if any, i.e., display lists, scene graphs.
ClearStore ();
if (fpView -> GetViewParameters ().IsViewGeom ()) {
// Traverse geometry tree and send drawing primitives to window(s).
const RWTPtrOrderedVector <G4VModel>& runDurationModelList =
fSD.GetRunDurationModelList ();
if (runDurationModelList.entries ()) {
G4cout << "Traversing scene data..." << endl;
G4ModelingParameters* pMP = CreateModelingParameters ();
for (int i = 0; i < runDurationModelList.entries (); i++) {
G4VModel* pModel = runDurationModelList[i];
const G4ModelingParameters* tempMP =
pModel -> GetModelingParameters ();
// NOTE THAT tempMP COULD BE ZERO.
// (Not sure the above is necessary; but in future we might
// want to take notice of the modeling parameters with which
// the model was created. For the time being we are ignoring
// them and simply using the view parameters. When the time
// comes to do this, then perhaps there should be a default
// set of modeling parameters in the view parameters for the
// case of a zero modeling parameters pointer.)
pModel -> SetModelingParameters (pMP);
SetModel (pModel); // Store for use by derived class.
BeginModeling ();
pModel -> DescribeYourselfTo (*this);
EndModeling ();
pModel -> SetModelingParameters (tempMP);
}
delete pMP;
SetModel (0); // Flags invalid model.
}
else {
G4cerr << "No run-duration models in scene data." << endl;
}
}
fReadyForTransients = true;
}
G4ModelingParameters* G4VScene::CreateModelingParameters () {
// Create modeling parameters from View Parameters...
const G4ViewParameters& vp = fpView -> GetViewParameters ();
// Convert rep styles...
G4ModelingParameters::RepStyle modelRepStyle =
G4ModelingParameters::wireframe;
if (vp.GetDrawingStyle () != G4ViewParameters::wireframe) {
switch (vp.GetRepStyle ()) {
default:
case G4ViewParameters::polyhedron:
modelRepStyle = G4ModelingParameters::polyhedron;
break;
case G4ViewParameters::nurbs:
modelRepStyle = G4ModelingParameters::nurbs;
break;
}
}
// Decide if covered daughters are really to be culled...
G4bool reallyCullCovered =
vp.IsCullingCovered() // Culling daughters depends also on...
&& !vp.IsSection () // Sections (DCUT) not requested.
&& !vp.IsCutaway () // Cutaways not requested.
&& ( // Surface drawing in operation.
vp.GetDrawingStyle () == G4ViewParameters::hsr ||
vp.GetDrawingStyle () == G4ViewParameters::hlhsr
);
/////////////// TESTING TESTING
//modelRepStyle = G4ModelingParameters::hierarchy;
///////////////////////////////
G4ModelingParameters* pModelingParams = new G4ModelingParameters
(vp.GetDefaultVisAttributes (),
modelRepStyle,
vp.IsCulling (),
vp.IsCullingInvisible (),
vp.IsDensityCulling (),
vp.GetVisibleDensity (),
reallyCullCovered,
vp.GetNoOfSides ());
return pModelingParams;
}
const G4Colour& G4VScene::GetColour (const G4Visible& visible) {
// Colour is determined by the applicable (real) vis attributes.
const G4VisAttributes* pVA = visible.GetVisAttributes ();
pVA = fpView -> GetApplicableVisAttributes (pVA);
return pVA -> GetColour ();
}
const G4Colour& G4VScene::GetTextColour (const G4Text& text) {
const G4VisAttributes* pVA = text.GetVisAttributes ();
if (!pVA) {
pVA = fpView -> GetViewParameters (). GetDefaultTextVisAttributes ();
}
return pVA -> GetColour ();
}
G4ViewParameters::DrawingStyle G4VScene::GetDrawingStyle
(const G4Visible& visible) {
// Drawing style is determined by the applicable (real) vis
// attributes, except when overridden - see GetDrawingStyle (const
// G4VisAttributes* pVisAttribs).
const G4VisAttributes* pVA = visible.GetVisAttributes ();
pVA = fpView -> GetApplicableVisAttributes (pVA);
return GetDrawingStyle (pVA);
}
G4ViewParameters::DrawingStyle G4VScene::GetDrawingStyle
(const G4VisAttributes* pVisAttribs) {
// Drawing style is normally determined by the view parameters, but
// it can be overriddden by the ForceDrawingStyle flag in the vis
// attributes.
G4ViewParameters::DrawingStyle style =
fpView->GetViewParameters().GetDrawingStyle();
if (pVisAttribs -> IsForceDrawingStyle ()) {
G4VisAttributes::ForcedDrawingStyle forcedStyle =
pVisAttribs -> GetForcedDrawingStyle ();
// This is complicated because is hidden line removal has been
// requested we wish to preserve this.
switch (forcedStyle) {
case (G4VisAttributes::solid):
switch (style) {
case (G4ViewParameters::hlr):
style = G4ViewParameters::hlhsr;
break;
case (G4ViewParameters::wireframe):
style = G4ViewParameters::hsr;
break;
case (G4ViewParameters::hlhsr):
case (G4ViewParameters::hsr):
default:
break;
}
break;
case (G4VisAttributes::wireframe):
default:
switch (style) {
case (G4ViewParameters::hlhsr):
style = G4ViewParameters::hlr;
break;
case (G4ViewParameters::hsr):
style = G4ViewParameters::wireframe;
break;
case (G4ViewParameters::hlr):
case (G4ViewParameters::wireframe):
default:
break;
}
break;
}
}
return style;
}
G4double G4VScene::GetMarkerSize (const G4VMarker& marker,
G4VScene::MarkerSizeType& markerSizeType) {
G4bool userSpecified = marker.GetWorldSize() || marker.GetScreenSize();
const G4VMarker& defaultMarker =
fpView -> GetViewParameters().GetDefaultMarker();
G4double size;
if (size = // Assignment intentional.
userSpecified ? marker.GetWorldSize() : defaultMarker.GetWorldSize()) {
// Draw in world coordinates.
markerSizeType = world;
}
else {
size = // Assignment intentional.
userSpecified ? marker.GetScreenSize() : defaultMarker.GetScreenSize();
// Draw in screen coordinates.
markerSizeType = screen;
}
if (size <= 0.) size = 1.;
size *= fpView -> GetViewParameters().GetGlobalMarkerScale();
return size;
}
ostream& operator << (ostream& os, const G4VScene& s) {
G4VisManager* pVMan = G4VisManager::GetInstance ();
os << "Scene " << s.fName << " has "
<< s.fViewList.entries () << " views:";
for (int i = 0; i < s.fViewList.entries (); i++) {
os << "\n " << s.fViewList [i];
}
os << "\n " << s.fSD;
return os;
}
@@ -0,0 +1,125 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VView.cc,v 2.5 1998/11/06 13:43:12 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 27th March 1996
// Abstract interface class for graphics views.
#include "G4VView.hh"
#include "G4ios.hh"
#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
#include "G4VisManager.hh"
#include "G4VGraphicsSystem.hh"
#include "G4VScene.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Transform3D.hh"
#include "G4Event.hh"
// Forward declaration for g++ linker.
#ifdef GNU_GCC
#include <rw/tvvector.h>
#include "G4Plane3D.hh"
template class RWTValVector<G4Plane3D>;
#endif
G4VView::G4VView (G4VScene& scene, G4int id, const G4String& name):
fScene (scene),
fViewId (id),
fModified (true),
fNeedKernelVisit (true)
{
G4VisManager* pVMan = G4VisManager::GetInstance ();
fVP = pVMan -> GetCurrentViewParameters ();
if (name == "") {
char charname [50];
ostrstream ost (charname, 50);
ost << fScene.GetName () << '-' << fViewId << ends;
fName = charname;
}
else {
fName = name;
}
}
G4VView::~G4VView () {}
const G4VisAttributes* G4VView::GetApplicableVisAttributes
(const G4VisAttributes* pVisAttribs) const {
// If the pointer is null, pick up the default vis attributes from
// the view parameters.
if (!pVisAttribs)
pVisAttribs = GetViewParameters ().GetDefaultVisAttributes ();
return pVisAttribs;
}
void G4VView::NeedKernelVisit () {
// Notify all views that a kernel visit is required.
const G4VViewList& viewList = fScene.GetViewList ();
for (int i = 0; i < viewList.entries (); i++) {
viewList [i] -> SetNeedKernelVisit ();
}
}
void G4VView::ShowView () {}
void G4VView::ProcessView () {
// If view parameters have been modified, SetView () works out consequences.
if (fModified) {
fModified = false;
SetView ();
}
// If the scene data has changed (fNeedVisit is set to true in
// G4VScene::SetSceneData), or if the concrete view has decided that it
// necessary to visit the kernel (this should be Done in the concrete
// object's DrawView ())...
if (fNeedKernelVisit) {
fNeedKernelVisit = false;
fScene.ProcessScene (*this);
}
/*********************************************
Note that hits and digi drawing is totally the responsibility of the
"user" at present. So the following code just represents an
alternative approach, namely, the user sets a flag, then the Vis
Manager draws them. I will leave the code hear for now; also the
flags and methods in G4ViewParameters.
// If event data is available...
G4Event* pEvent = G4VisManager::GetInstance () -> GetEvent ();
if (pEvent) {
if (fVP.IsViewHits ()) {
G4cout << "Drawing hits..." << endl;
}
if (fVP.IsViewDigis ()) {
G4cout << "Drawing digis..." << endl;
}
}
***********************************************/
}
void G4VView::SetViewParameters (const G4ViewParameters& vp) {
fVP = vp;
fModified = true;
}
ostream& operator << (ostream& os, const G4VView& v) {
os << "View " << v.fName << ":\n";
os << v.fVP;
return os;
}
@@ -0,0 +1,34 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VVisCommand.cc,v 2.4 1998/12/09 23:56:27 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// Base class for visualization commands - John Allison 9th August 1998
// It is really a messenger - we have one command per messenger.
#include "G4VVisCommand.hh"
G4VisManager* G4VVisCommand::fpVisManager = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneNotifyHandlers = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneRemove = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneSelect = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneHandlerAttach = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneHandlerRemove = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandSceneHandlerSelect = 0;
G4UIcommand* G4VVisCommand::fpCommandViewerCreate = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandViewerRemove = 0;
G4UIcmdWithAString* G4VVisCommand::fpCommandViewerSelect = 0;
@@ -0,0 +1,437 @@
// This code implementation is the intellectual property of
// the RD44 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: G4ViewParameters.cc,v 2.4 1998/11/25 16:31:28 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 19th July 1996
// View parameters and options.
#include "G4ViewParameters.hh"
#include "G4VisManager.hh"
#include "G4ios.hh"
G4ViewParameters::G4ViewParameters ():
fDrawingStyle (wireframe),
fRepStyle (polyhedron),
fCulling (true),
fCullInvisible (true),
fDensityCulling (false),
fVisibleDensity (0.01 * g / cm3),
fCullCovered (false),
fSection (false),
fCutaway (false),
fExplode (false),
fExplodeFactor (1.),
fNoOfSides (24),
fViewpointDirection (G4Vector3D (0., 0., 1.)), // On z-axis.
fUpVector (G4Vector3D (0., 1., 0.)), // y-axis up.
fFieldHalfAngle (0.), // Orthogonal projection.
fZoomFactor (1.),
fDolly (0.),
fRelativeLightpointDirection (G4Vector3D (1., 1., 1.)),
fActualLightpointDirection (G4Vector3D (1., 1., 1.)),
fLightsMoveWithCamera (false),
fViewGeom (true),
fViewHits (false),
fViewDigis (false),
fDefaultTextVisAttributes (G4Colour (0., 0., 1.)),
fGlobalMarkerScale (1.),
fMarkerNotHidden (true),
fWindowSizeHintX (600),
fWindowSizeHintY (600)
// Note: all other parameters use default constructors.
{
fDefaultMarker.SetScreenSize (5.);
// Markers are 5 pixels radius, 10 pixels diameter.
}
G4ViewParameters::~G4ViewParameters () {
// Clear cutaway planes? Rogue Wave probably destroys OK.
}
G4Vector3D& G4ViewParameters::GetActualLightpointDirection () {
SetViewAndLights (fViewpointDirection);
return fActualLightpointDirection;
}
// Useful quantities - begin snippet.
// Here Follow functions to evaluate the above algorithms as a
// function of the radius of the Bounding Sphere of the object being
// viewed. Call them in the order given - for efficiency, later
// functions depend on the results of earlier ones (Store the
// results of earlier functions in your own temporary variables -
// see, for example, G4OpenGLView::SetView ().)
G4double G4ViewParameters::GetCameraDistance (G4double radius) const {
G4double cameraDistance;
if (fFieldHalfAngle == 0.) {
cameraDistance = radius;
}
else {
cameraDistance = radius / sin (fFieldHalfAngle) - fDolly;
}
return cameraDistance;
}
G4double G4ViewParameters::GetNearDistance (G4double cameraDistance,
G4double radius) const {
const G4double small = 1.e-6 * radius;
G4double nearDistance = cameraDistance - radius;
if (nearDistance < small) nearDistance = small;
return nearDistance;
}
G4double G4ViewParameters::GetFarDistance (G4double cameraDistance,
G4double nearDistance,
G4double radius) const {
G4double farDistance = cameraDistance + radius;
if (farDistance < nearDistance) farDistance = nearDistance;
return farDistance;
}
G4double G4ViewParameters::GetFrontHalfHeight (G4double nearDistance,
G4double radius) const {
G4double frontHalfHeight;
if (fFieldHalfAngle == 0.) {
frontHalfHeight = radius / fZoomFactor;
}
else {
frontHalfHeight = nearDistance * tan (fFieldHalfAngle) / fZoomFactor;
}
return frontHalfHeight;
}
// Useful quantities - end snippet.
void G4ViewParameters::AddCutawayPlane (const G4Plane3D& cutawayPlane) {
fCutaway = true;
if (fCutawayPlanes.entries () < 3 ) {
fCutawayPlanes.insert (cutawayPlane);
}
else {
G4cerr << "A maximum of 3 cutaway planes supported." << endl;
}
}
void G4ViewParameters::ClearCutawayPlanes () {
fCutaway = false;
fCutawayPlanes.clear ();
}
void G4ViewParameters::SetVisibleDensity (G4double visibleDensity) {
const G4double reasonableMaximum = 10.0 * g / cm3;
if (visibleDensity < 0) {
G4cout << "G4ViewParameters::SetVisibleDensity: attempt to set negative "
"density - ignored." << endl;
}
else {
if (fVisibleDensity > reasonableMaximum) {
G4cout << "G4ViewParameters::SetVisibleDensity: density > "
<< reasonableMaximum
<< " g / cm3 - did you mean this?"
<< endl;
}
fVisibleDensity = visibleDensity;
}
}
void G4ViewParameters::SetNoOfSides (G4int nSides) {
const G4int nSidesMin = 3;
if (nSides < nSidesMin) {
nSides = nSidesMin;
G4cout << "G4ViewParameters::SetNoOfSides: attempt to set the"
"\nnumber of sides per circle < " << nSidesMin
<< "; forced to" << nSides << endl;
}
fNoOfSides = nSides;
}
void G4ViewParameters::SetViewAndLights
(const G4Vector3D& viewpointDirection) {
fViewpointDirection = viewpointDirection;
if (fLightsMoveWithCamera) {
G4Vector3D zprime = fViewpointDirection.unit ();
G4Vector3D xprime = (fUpVector.cross (zprime)).unit ();
G4Vector3D yprime = zprime.cross (xprime);
fActualLightpointDirection =
fRelativeLightpointDirection.x () * xprime +
fRelativeLightpointDirection.y () * yprime +
fRelativeLightpointDirection.x () * zprime;
}
else {
fActualLightpointDirection = fRelativeLightpointDirection;
}
}
void G4ViewParameters::SetLightpointDirection
(const G4Vector3D& lightpointDirection) {
fRelativeLightpointDirection = lightpointDirection;
SetViewAndLights (fViewpointDirection);
}
void G4ViewParameters::Pan (G4double right, G4double up) {
G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit();
fCurrentTargetPoint += right * unitRight + up * unitUp;
}
void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const {
// Put performance-sensitive parameters first.
if (
// This first to optimise spin, etc.
(fViewpointDirection != v.fViewpointDirection) ||
// No particular order from here on.
(fDrawingStyle != v.fDrawingStyle) ||
(fRepStyle != v.fRepStyle) ||
(fCulling != v.fCulling) ||
(fCullInvisible != v.fCullInvisible) ||
(fDensityCulling != v.fDensityCulling) ||
(fVisibleDensity != v.fVisibleDensity) ||
(fCullCovered != v.fCullCovered) ||
(fSection != v.fSection) ||
(fCutaway != v.fCutaway) ||
(fExplode != v.fExplode) ||
(fNoOfSides != v.fNoOfSides) ||
(fUpVector != v.fUpVector) ||
(fFieldHalfAngle != v.fFieldHalfAngle) ||
(fZoomFactor != v.fZoomFactor) ||
(fCurrentTargetPoint != v.fCurrentTargetPoint) ||
(fDolly != v.fDolly) ||
(fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
(fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
(fViewGeom != v.fViewGeom) ||
(fViewHits != v.fViewHits) ||
(fViewDigis != v.fViewDigis) ||
(fDefaultVisAttributes != v.fDefaultVisAttributes) ||
(fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
(fDefaultMarker != v.fDefaultMarker) ||
(fGlobalMarkerScale != v.fGlobalMarkerScale) ||
(fMarkerNotHidden != v.fMarkerNotHidden) ||
(fWindowSizeHintY != v.fWindowSizeHintY))
G4cout << "Difference in 1st batch." << endl;
if (fSection) {
if (!(fSectionPlane == v.fSectionPlane))
G4cout << "Difference in section planes batch." << endl;
}
if (fCutaway) {
if (fCutawayPlanes.entries () != v.fCutawayPlanes.entries ()) {
G4cout << "Difference in no of cutaway planes." << endl;
}
else {
for (int i = 0; i < fCutawayPlanes.entries (); i++) {
if (!(fCutawayPlanes (i) == v.fCutawayPlanes (i)))
G4cout << "Difference in cutaway plane no. " << i << endl;
}
}
}
if (fExplode) {
if (fExplodeFactor != v.fExplodeFactor)
G4cout << "Difference in explode factor." << endl;
}
}
ostream& operator << (ostream& os, const G4ViewParameters& v) {
os << "View parameters and options:";
os << "\n Drawing style: ";
switch (v.fDrawingStyle) {
case G4ViewParameters::wireframe:
os << "wireframe"; break;
case G4ViewParameters::hlr:
os << "hlr - hidden lines removed"; break;
case G4ViewParameters::hsr:
os << "hsr - hidden surfaces removed"; break;
case G4ViewParameters::hlhsr:
os << "hlhsr - hidden line, hidden surface removed"; break;
default: os << "unrecognised"; break;
}
os << "\n Representation style: ";
switch (v.fRepStyle) {
case G4ViewParameters::polyhedron:
os << "polyhedron"; break;
case G4ViewParameters::nurbs:
os << "nurbs"; break;
default: os << "unrecognised"; break;
}
os << "\n Culling: ";
if (v.fCulling) os << "on";
else os << "off";
os << "\n Culling invisible objects: ";
if (v.fCullInvisible) os << "on";
else os << "off";
os << "\n Density culling: ";
if (v.fDensityCulling) {
os << "on - invisible if density less than "
<< v.fVisibleDensity / (1. * g / cm3) << " g cm^-3";
}
else os << "off";
os << "\n Culling daughters covered by opaque mothers: ";
if (v.fCullCovered) os << "on";
else os << "off";
os << "\n Section flag: ";
if (v.fSection) os << "true, section/cut plane: " << v.fSectionPlane;
else os << "false";
os << "\n Cutaway flag: ";
if (v.fCutaway) {
os << "true, cutaway planes: ";
for (int i = 0; i < v.fCutawayPlanes.entries (); i++) {
os << ' ' << v.fCutawayPlanes[i];
}
}
else {
os << "false";
}
os << "\n Explode flag: ";
if (v.fExplode) os << "true, explode factor: " << v.fExplodeFactor;
else os << "false";
os << "\n No. of sides used in circle polygon approximation: "
<< v.fNoOfSides;
os << "\n Viewpoint direction: " << v.fViewpointDirection;
os << "\n Up vector: " << v.fUpVector;
os << "\n Field half angle: " << v.fFieldHalfAngle;
os << "\n Zoom factor: " << v.fZoomFactor;
os << "\n Current target point: " << v.fCurrentTargetPoint;
os << "\n Dolly distance: " << v.fDolly;
os << "\n Light ";
if (v.fLightsMoveWithCamera) os << "moves";
else os << "does not move";
os << " with camera";
os << "\n Relative lightpoint direction: "
<< v.fRelativeLightpointDirection;
os << "\n Actual lightpoint direction: "
<< v.fActualLightpointDirection;
os << "\n Derived parameters for standard view of object of unit radius:";
G4ViewParameters tempVP = v;
tempVP.fDolly = 0.;
tempVP.fZoomFactor = 1.;
const G4double radius = 1.;
const G4double cameraDistance = tempVP.GetCameraDistance (radius);
const G4double nearDistance =
tempVP.GetNearDistance (cameraDistance, radius);
const G4double farDistance =
tempVP.GetFarDistance (cameraDistance, nearDistance, radius);
const G4double right = tempVP.GetFrontHalfHeight (nearDistance, radius);
os << "\n Camera distance: " << cameraDistance;
os << "\n Near distance: " << nearDistance;
os << "\n Far distance: " << farDistance;
os << "\n Front half height: " << right;
os << "\n View geometry: ";
if (v.fViewGeom) os << "true";
else os << "false";
os << "\n View hits : ";
if (v.fViewHits) os << "true";
else os << "false";
os << "\n View digits : ";
if (v.fViewDigis) os << "true";
else os << "false";
os << "\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
os << "\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
os << "\n Default marker: " << v.fDefaultMarker;
os << "\n Global marker scale: " << v.fGlobalMarkerScale;
os << "\n Marker ";
if (v.fMarkerNotHidden) os << "not";
os << " hidden by surfaces.";
os << "\n Window size hint: "
<< v.fWindowSizeHintX << 'x'<< v.fWindowSizeHintX;
return os;
}
G4bool operator != (const G4ViewParameters& v1,
const G4ViewParameters& v2) {
// Put performance-sensitive parameters first.
if (
// This first to optimise spin, etc.
(v1.fViewpointDirection != v2.fViewpointDirection) ||
// No particular order from here on.
(v1.fDrawingStyle != v2.fDrawingStyle) ||
(v1.fRepStyle != v2.fRepStyle) ||
(v1.fCulling != v2.fCulling) ||
(v1.fCullInvisible != v2.fCullInvisible) ||
(v1.fDensityCulling != v2.fDensityCulling) ||
(v1.fCullCovered != v2.fCullCovered) ||
(v1.fSection != v2.fSection) ||
(v1.fCutaway != v2.fCutaway) ||
(v1.fExplode != v2.fExplode) ||
(v1.fNoOfSides != v2.fNoOfSides) ||
(v1.fUpVector != v2.fUpVector) ||
(v1.fFieldHalfAngle != v2.fFieldHalfAngle) ||
(v1.fZoomFactor != v2.fZoomFactor) ||
(v1.fCurrentTargetPoint != v2.fCurrentTargetPoint) ||
(v1.fDolly != v2.fDolly) ||
(v1.fRelativeLightpointDirection != v2.fRelativeLightpointDirection) ||
(v1.fLightsMoveWithCamera != v2.fLightsMoveWithCamera) ||
(v1.fViewGeom != v2.fViewGeom) ||
(v1.fViewHits != v2.fViewHits) ||
(v1.fViewDigis != v2.fViewDigis) ||
(v1.fDefaultVisAttributes != v2.fDefaultVisAttributes) ||
(v1.fDefaultTextVisAttributes != v2.fDefaultTextVisAttributes) ||
(v1.fDefaultMarker != v2.fDefaultMarker) ||
(v1.fGlobalMarkerScale != v2.fGlobalMarkerScale) ||
(v1.fMarkerNotHidden != v2.fMarkerNotHidden) ||
(v1.fWindowSizeHintX != v2.fWindowSizeHintX) ||
(v1.fWindowSizeHintY != v2.fWindowSizeHintY))
return true;
if (v1.fDensityCulling &&
(v1.fVisibleDensity != v2.fVisibleDensity)) return true;
if (v1.fSection &&
(!(v1.fSectionPlane == v2.fSectionPlane))) return true;
if (v1.fCutaway) {
if (v1.fCutawayPlanes.entries () != v2.fCutawayPlanes.entries ())
return true;
else {
for (int i = 0; i < v1.fCutawayPlanes.entries (); i++) {
if (!(v1.fCutawayPlanes (i) == v2.fCutawayPlanes (i))) return true;
}
}
}
if (v1.fExplode &&
(v1.fExplodeFactor != v2.fExplodeFactor)) return true;
return false;
}
@@ -0,0 +1,52 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandTemplates.cc,v 2.2 1998/07/13 17:12:26 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Visualization Command Messenger Template private functions.
// John Allison 8th September 1997
#include "G4VisCommandTemplates.hh"
#include "globals.hh"
#include "G4UImessenger.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4ios.hh"
// OLD STYLE!!
G4UIcommand* G4VisButtonCommandMessengerRegister (G4String commandName,
G4String guidance,
G4UImessenger* messenger) {
G4UIcommand* command;
G4UIparameter* param;
command = new G4UIcommand (commandName, messenger);
command -> SetGuidance (guidance);
param = new G4UIparameter ("Selector", 'c', false);
param -> SetDefaultValue ("?");
command -> SetParameter (param);
return command;
}
// OLD STYLE!!
G4int G4VisButtonCommandMessengerInterpret (G4String newValues) {
G4String& choice = newValues;
G4int iSelector = -1;
if (choice.compareTo ("0") == 0 ||
choice.compareTo ("off", RWCString::ignoreCase) == 0 ||
choice.compareTo ("false", RWCString::ignoreCase) == 0) iSelector = 0;
if (choice.compareTo ("1") == 0 ||
choice.compareTo ("on", RWCString::ignoreCase) == 0 ||
choice.compareTo ("true", RWCString::ignoreCase) == 0) iSelector = 1;
if (iSelector < 0 || choice.isNull ()) {
G4cout << "Choice not recognised."
"\n Choice is 0 (or off or false) or 1 (or on or true)." << endl;;
}
return iSelector;
}
@@ -0,0 +1,33 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsCamera.cc,v 2.2 1998/07/23 02:18:55 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4VisCommandsCamera.hh"
void G4VisCommandCameraReset::SetValue () {
G4VisManager* pVMan = G4VisManager::GetInstance ();
if (pVMan -> IsValidView ()) {
const G4SceneData& sd = pVMan -> GetCurrentSceneData ();
G4ViewParameters& vp = pVMan -> SetCurrentViewParameters ();
vp.SetCurrentTargetPoint (sd.GetStandardTargetPoint ());
vp.SetZoomFactor (1.);
vp.SetDolly (0.);
if (pVMan -> GetVerboseLevel () > 0) {
G4cout << "Target point reset";
G4cout << "\nZoom factor reset to 1.";
G4cout << "\nDolly distance reset to 0.";
G4cout << endl;
if (pVMan -> GetVerboseLevel () > 1) {
pVMan -> PrintCurrentView ();
}
}
}
}
@@ -0,0 +1,34 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsCameraMessengers.cc,v 2.3 1998/07/12 03:44:55 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Messengers for /vis~/camera commands - John Allison 6th April 1998.
#include "G4VisCommandsCameraMessengers.hh"
#include "G4UIcommand.hh"
G4VisCommandsCameraSetMessenger::G4VisCommandsCameraSetMessenger () {
fpCommand = new G4UIcommand ("/new_vis/camera/set", this);
fpCommand -> SetGuidance
("Sets and updates view parameters of current view.");
}
G4VisCommandsCameraSetMessenger::~G4VisCommandsCameraSetMessenger () {
delete fpCommand;
}
G4String G4VisCommandsCameraSetMessenger::GetCurrentValue
(G4UIcommand * command) {
return "";
}
void G4VisCommandsCameraSetMessenger::SetNewValue (G4UIcommand* command, G4String newValues) {
}
@@ -0,0 +1,346 @@
// This code implementation is the intellectual property of
// the RD44 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 2.12 1998/12/09 23:56:28 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// /vis/scene commands - John Allison 9th August 1998
#include "G4VisCommandsScene.hh"
#include "G4VisManager.hh"
#include "G4TransportationManager.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ApplicationState.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4ios.hh"
#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
G4VVisCommandScene::G4VVisCommandScene () {}
void G4VVisCommandScene::UpdateCandidateLists () {
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
// Seems it has to be non-const to satisfy iterator.
G4SceneDataObjectListIterator iterator (list);
G4String fSceneNameList;
while (++iterator) {
fSceneNameList += iterator.key () + " ";
}
fSceneNameList = fSceneNameList.strip ();
if (fpCommandSceneNotifyHandlers) {
fpCommandSceneNotifyHandlers -> GetParameter (0) ->
SetParameterCandidates (fSceneNameList);
}
if (fpCommandSceneRemove) {
fpCommandSceneRemove -> GetParameter (0) ->
SetParameterCandidates (fSceneNameList);
}
if (fpCommandSceneSelect) {
fpCommandSceneSelect -> GetParameter (0) ->
SetParameterCandidates (fSceneNameList);
}
if (fpCommandSceneHandlerAttach) {
fpCommandSceneHandlerAttach -> GetParameter (0) ->
SetParameterCandidates (fSceneNameList);
}
}
void G4VVisCommandScene::UpdateVisManagerSceneDataAndViewParameters
(const G4String& sceneName) {
G4SceneData& currentScene = fpVisManager -> SetCurrentSceneData ();
G4SceneDataObjectList& sceneList = fpVisManager -> SetSceneDataObjectList ();
if (sceneList.contains (sceneName)) {
currentScene = sceneList [sceneName];
G4ViewParameters& currentVP = fpVisManager -> SetCurrentViewParameters ();
currentVP.SetCurrentTargetPoint (currentScene.GetStandardTargetPoint ());
currentVP.SetZoomFactor (1.);
currentVP.SetDolly (0.);
}
else {
currentScene = G4SceneData ("invalid scene");
}
}
G4String G4VVisCommandScene::fSceneNameList;
////////////// /vis/scene/create ///////////////////////////////////////
G4VisCommandSceneCreate::G4VisCommandSceneCreate (): fId (0) {
G4bool omitable, currentAsDefault;
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);
}
G4VisCommandSceneCreate::~G4VisCommandSceneCreate () {
delete fpCommand;
}
G4String G4VisCommandSceneCreate::NextName () {
char nextName [20];
ostrstream ost (nextName, 20);
ost << "scene-" << fId << ends;
return nextName;
}
G4String G4VisCommandSceneCreate::GetCurrentValue (G4UIcommand* command) {
return NextName ();
}
void G4VisCommandSceneCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& newName = newValue;
G4String nextName = NextName ();
if (newName == "") {
newName = nextName;
}
if (newName == nextName) fId++;
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
if (list.contains (newName)) {
G4cout << "Scene \"" << newName << "\" already exists." << endl;
}
else {
list [newName] = G4SceneData (newName);
// Adds empty scene data object to list.
UpdateVisManagerSceneDataAndViewParameters (newName);
G4cout << "New empty scene \"" << newName << "\" created." << endl;
UpdateCandidateLists ();
}
}
////////////// /vis/scene/list ///////////////////////////////////////
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
("<verbosity> is 0 for short (default) or 1 for long listing.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("scene-name", 's',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue ("all");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("verbosity", 'i',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue (0);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneList::~G4VisCommandSceneList () {
delete fpCommand;
}
G4String G4VisCommandSceneList::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneList::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String name;
G4int verbosity;
istrstream is ((char*)newValue.data());
is >> name >> verbosity;
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
G4SceneDataObjectListIterator iterator (list);
G4bool found = false;
while (++iterator) {
if (name != "all") {
if (name != iterator.key ()) continue;
}
found = true;
G4cout << "Scene name: \"" << iterator.key () << "\"";
if (verbosity > 0) {
G4cout << ", " << iterator.value ();
}
G4cout << endl;
}
if (!found) {
G4cout << "No scenes found";
if (name != "all") {
G4cout << " of name \"" << name << "\"";
}
G4cout << "." << endl;
}
}
////////////// /vis/scene/notifyHandlers /////////////////////////
G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/scene/notifyHandlers", this);
fpCommand -> SetGuidance ("/vis/scene/notifyHandlers [<scene-name>]");
fpCommand -> SetGuidance
("Notifies scene handlers of possible changes of scene.");
fpCommand -> SetGuidance ("<scene-name> default is current scene.");
fpCommand -> SetParameterName ("scene-name",
omitable = true,
currentAsDefault = true);
fpCommandSceneNotifyHandlers = fpCommand;
}
G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers () {
delete fpCommand;
}
G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue
(G4UIcommand* command) {
return fpVisManager -> GetCurrentSceneData ().GetName ();
}
void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& sceneName = newValue;
const G4SceneDataObjectList& sceneList =
fpVisManager -> GetSceneDataObjectList ();
G4SceneList& sceneHandlerList = fpVisManager -> SetAvailableScenes ();
// For each scene handler, if it contains the scene, for each viewer
// clear, (re)draw, and show.
const G4int nSceneHandlers = sceneHandlerList.entries ();
for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
G4VScene* aSceneHandler = sceneHandlerList [iSH];
const G4SceneData& theScene = aSceneHandler -> GetSceneData ();
const G4String& theSceneName = theScene.GetName ();
if (sceneName == theSceneName) {
G4VViewList& viewerList = aSceneHandler -> SetViewList ();
const G4int nViewers = viewerList.entries ();
for (G4int iV = 0; iV < nViewers; iV++) {
G4VView* aViewer = viewerList [iV];
aViewer -> ClearView ();
aViewer -> DrawView ();
aViewer -> ShowView ();
G4cout << "Viewer \"" << aViewer -> GetName ()
<< "\" of scene handler \"" << aSceneHandler -> GetName ()
<< "\"\n refreshed at request of scene \"" << sceneName
<< "\"." << endl;
}
}
}
}
////////////// /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);
fpCommandSceneRemove = fpCommand;
}
G4VisCommandSceneRemove::~G4VisCommandSceneRemove () {
delete fpCommand;
}
G4String G4VisCommandSceneRemove::GetCurrentValue (G4UIcommand* command) {
return fpVisManager -> GetCurrentSceneData ().GetName ();
}
void G4VisCommandSceneRemove::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& removeName = newValue;
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
const G4String& currentSceneName =
fpVisManager -> GetCurrentSceneData ().GetName ();
if (list.contains (removeName)) {
list.remove (removeName);
G4cout << "Scene \"" << removeName << "\" removed." << endl;
UpdateCandidateLists ();
if (list.isEmpty ()) {
UpdateVisManagerSceneDataAndViewParameters ();
G4cout << "No scenes left. Please create a new one." << endl;
}
else {
if (currentSceneName == removeName) {
G4SceneDataObjectListIterator iterator (list);
++iterator;
UpdateVisManagerSceneDataAndViewParameters (iterator.key ());
G4cout << "Current scene is now \""
<< fpVisManager -> GetCurrentSceneData ().GetName ()
<< "\"" << endl;
}
else {
G4cout << "Current scene unchanged." << endl;
}
}
}
else {
G4cout << "Scene \"" << removeName
<< "\" not found - \"/vis/scene/list\" to see possibilities."
<< endl;
}
}
////////////// /vis/scene/select ///////////////////////////////////////
G4VisCommandSceneSelect::G4VisCommandSceneSelect () {
G4bool omitable, currentAsDefault;
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);
fpCommandSceneSelect = fpCommand;
}
G4VisCommandSceneSelect::~G4VisCommandSceneSelect () {
delete fpCommand;
}
G4String G4VisCommandSceneSelect::GetCurrentValue (G4UIcommand* command) {
return fpVisManager -> GetCurrentSceneData ().GetName ();
}
void G4VisCommandSceneSelect::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& selectName = newValue;
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
G4cout << "Scene \"" << selectName;
if (list.contains (selectName)) {
UpdateVisManagerSceneDataAndViewParameters (selectName);
G4cout << "\" selected." << endl;
}
else {
G4cout << "\" not found - \"/vis/scene/list\" to see possibilities."
<< endl;
}
}
@@ -0,0 +1,214 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsSceneAdd.cc,v 2.6 1998/11/29 15:34:08 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// /vis/scene commands - John Allison 9th August 1998
#include "G4VisCommandsSceneAdd.hh"
#include "G4VisManager.hh"
#include "G4TransportationManager.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ModelingParameters.hh"
#include "G4PhysicalVolumeSearchScene.hh"
#include "G4GlobalFastSimulationManager.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4FlavoredParallelWorldModel.hh"
#include "G4ApplicationState.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4ios.hh"
#ifdef WIN32
# include <Strstrea.h>
#else
# include <strstream.h>
#endif
////////////// /vis/scene/add/volume ///////////////////////////////////////
G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
fpCommand -> AvailableForStates (Idle, GeomClosed);
fpCommand -> SetGuidance
("/vis/scene/add/volume [<physical-volume-name>] [<copy-no>] [<depth-of-descending>]");
fpCommand -> SetGuidance ("Adds a physical volume to the current scene.");
fpCommand -> SetGuidance
("1st parameter: volume name (default \"world\").");
fpCommand -> SetGuidance
("2nd parameter: copy number (default 0).");
fpCommand -> SetGuidance
("3rd parameter: depth of descending geometry hierarchy"
" (default G4SceneData::UNLIMITED (-1)).");
G4UIparameter* parameter;
parameter = new G4UIparameter ("volume", 's', omitable = true);
parameter -> SetDefaultValue ("world");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
parameter -> SetDefaultValue (0);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("depth", 'i', omitable = true);
parameter -> SetDefaultValue (G4SceneData::UNLIMITED);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume () {
delete fpCommand;
}
G4String G4VisCommandSceneAddVolume::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
if (list.isEmpty ()) {
G4cout << "No scenes - please create one before adding anything."
<< endl;
return;
}
G4String name;
G4int copyNo;
G4int requestedDepthOfDescent;
const char* s = newValue;
istrstream is ((char*)s);
is >> name >> copyNo >> requestedDepthOfDescent;
G4VPhysicalVolume* world =
G4TransportationManager::GetTransportationManager ()
-> GetNavigatorForTracking () -> GetWorldVolume ();
G4PhysicalVolumeModel* model = 0;
G4VPhysicalVolume* foundVolume = 0;
G4int foundDepth = 0;
if (name == "world") {
if (world) {
model = new G4PhysicalVolumeModel (world);
foundVolume = world;
}
else {
G4cerr << "G4VisCommandSceneAddVolume::SetNewValue: *** ERROR ***"
<< "\n No world - shouldn't happen if G4ApplicationState is"
<< " being properly handled!!" << endl;
}
}
else {
G4PhysicalVolumeSearchScene searchScene (name, copyNo);
G4PhysicalVolumeModel searchModel (world);
searchModel.DescribeYourselfTo (searchScene);
foundVolume = searchScene.GetFoundVolume ();
const G4Transform3D&
transformation = searchScene.GetFoundTransformation ();
foundDepth = searchScene.GetFoundDepth ();
if (foundVolume) {
model = new G4PhysicalVolumeModel (foundVolume,
requestedDepthOfDescent,
transformation);
}
else {
G4cout << "Volume \"" << name << "\", copy no. " << copyNo
<< " not found." << endl;
}
}
if (model) {
const G4String& currentSceneName =
fpVisManager -> GetCurrentSceneData ().GetName ();
(list [currentSceneName]).AddRunDurationModel (model);
UpdateVisManagerSceneDataAndViewParameters (currentSceneName);
G4cout << "First occurrence of \"" << foundVolume -> GetName ()
<< "\", copy no. " << copyNo
<< ", found at depth " << foundDepth
<< ",\n with further requested depth of descent "
<< requestedDepthOfDescent
<< ", has been added to scene \"" << currentSceneName << "\""
<< endl;
}
}
////////////// /vis/scene/add/ghosts ///////////////////////////////////////
G4VisCommandSceneAddGhosts::G4VisCommandSceneAddGhosts () {
G4bool omitable;
fpCommand = new G4UIcmdWithAString ("/vis/scene/add/ghosts", this);
fpCommand -> AvailableForStates (Idle, GeomClosed);
fpCommand -> SetGuidance
("/vis/scene/add/ghosts [<particle-name>]");
fpCommand -> SetGuidance
("Adds ghost volumes (G4FlavoredParallelWorld) to the current scene.");
fpCommand -> SetGuidance
("Selects by particle (default = \"all\").");
fpCommand -> SetParameterName ("particle", omitable = true);
fpCommand -> SetDefaultValue ("all");
}
G4VisCommandSceneAddGhosts::~G4VisCommandSceneAddGhosts () {
delete fpCommand;
}
G4String G4VisCommandSceneAddGhosts::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneAddGhosts::SetNewValue (G4UIcommand* command,
G4String newValue) {
const G4String& currentSceneName =
fpVisManager -> GetCurrentSceneData ().GetName ();
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
if (list.isEmpty ()) {
G4cout << "No scenes - please create one before adding anything."
<< endl;
return;
}
G4GlobalFastSimulationManager* theGlobalFastSimulationManager;
if(!(theGlobalFastSimulationManager =
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager())){
G4cout<< "WARNING: no G4GlobalFastSimulationManager" << endl;
return;
}
G4ParticleTable* theParticleTable=G4ParticleTable::GetParticleTable();
if(newValue=="all") {
G4FlavoredParallelWorld* CurrentFlavoredWorld;
for (G4int iParticle=0; iParticle<theParticleTable->entries();
iParticle++)
if(CurrentFlavoredWorld=theGlobalFastSimulationManager->
GetFlavoredWorldForThis(theParticleTable->
GetParticle(iParticle)))
(list [currentSceneName]).AddRunDurationModel
(new G4FlavoredParallelWorldModel (CurrentFlavoredWorld));
UpdateVisManagerSceneDataAndViewParameters ();
G4cout << "Ghosts added to the Scene, refresh the view to see it."
<< endl;
return;
}
G4ParticleDefinition* currentParticle =
theParticleTable->FindParticle(newValue);
if (currentParticle == NULL) {
G4cout << "\"" << newValue << "\": not found this particle name!" << endl;
return;
}
G4FlavoredParallelWorld* worldForThis;
if(worldForThis=theGlobalFastSimulationManager->
GetFlavoredWorldForThis(currentParticle)) {
(list [currentSceneName]).AddRunDurationModel
(new G4FlavoredParallelWorldModel (worldForThis));
UpdateVisManagerSceneDataAndViewParameters (currentSceneName);
G4cout << "Ghosts added to the Scene, refresh the view to see it."
<< endl;
}
else G4cout << "There are no ghosts for \""<<newValue<<"\""<<endl;
}
@@ -0,0 +1,431 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsSceneHandler.cc,v 1.5 1998/12/09 23:56:29 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// /vis/sceneHandler commands - John Allison 10th October 1998
#include "G4VisCommandsSceneHandler.hh"
#include "G4VisManager.hh"
#include "G4GraphicsSystemList.hh"
#include "G4VisCommandsScene.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4ios.hh"
#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
G4VVisCommandSceneHandler::G4VVisCommandSceneHandler () {}
void G4VVisCommandSceneHandler::UpdateCandidateLists () {
const G4SceneList& list = fpVisManager -> GetAvailableScenes ();
fSceneHandlerNameList = G4String ();
for (int iScene = 0; iScene < list.entries (); iScene++) {
G4VScene* sceneHandler = list [iScene];
fSceneHandlerNameList += sceneHandler -> GetName () + " ";
}
fSceneHandlerNameList = fSceneHandlerNameList.strip ();
if (fpCommandSceneHandlerRemove) {
fpCommandSceneHandlerRemove -> GetParameter (0) ->
SetParameterCandidates (fSceneHandlerNameList);
}
if (fpCommandSceneHandlerSelect) {
fpCommandSceneHandlerSelect -> GetParameter (0) ->
SetParameterCandidates (fSceneHandlerNameList);
}
if (fpCommandViewerCreate) {
fpCommandViewerCreate -> GetParameter (0) ->
SetParameterCandidates (fSceneHandlerNameList);
}
}
G4String G4VVisCommandSceneHandler::fSceneHandlerNameList;
////////////// /vis/sceneHandler/attach ///////////////////////////////////////
G4VisCommandSceneHandlerAttach::G4VisCommandSceneHandlerAttach () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/attach", this);
fpCommand -> SetGuidance
("/vis/sceneHandler/attach [<scene-name>]");
fpCommand -> SetGuidance ("Attaches scene to current scene handler.");
fpCommand -> SetGuidance
("If scene-name is omitted, current scene is attached.");
fpCommand -> SetGuidance
("To see scenes and scene handlers, use \"/vis/scene/list\""
"\n and \"/vis/sceneHandler/list\"");
fpCommand -> SetParameterName ("scene-name",
omitable = true,
currentAsDefault = true);
fpCommandSceneHandlerAttach = fpCommand;
}
G4VisCommandSceneHandlerAttach::~G4VisCommandSceneHandlerAttach () {
delete fpCommand;
}
G4String G4VisCommandSceneHandlerAttach::GetCurrentValue (G4UIcommand* command) {
return fpVisManager -> GetCurrentSceneData ().GetName ();
}
void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& sceneName = newValue;
if (sceneName.length () == 0) {
G4cout <<
"Null string specified. Maybe there are no scenes available yet."
"\n Please create one." << endl;
return;
}
G4VScene* pSceneHandler = fpVisManager -> GetCurrentScene ();
if (!pSceneHandler) {
G4cout <<
"Current scene handler not defined. Please select or create one."
<< endl;
return;
}
G4SceneDataObjectList& sceneList =
fpVisManager -> SetSceneDataObjectList ();
if (sceneList.contains (sceneName)) {
const G4SceneData& scene = sceneList [sceneName];
pSceneHandler -> SetSceneData (scene);
fpVisManager -> SetCurrentSceneData () = scene;
G4cout << "Scene \"" << sceneName
<< "\" attached to scene handler \"" << pSceneHandler -> GetName ()
<< "." << endl;
}
else {
G4cout << "Scene \"" << sceneName
<< "\" not found. Use \"/vis/scene/list\" to see possibilities."
<< endl;
}
}
////////////// /vis/sceneHandler/create ///////////////////////////////////////
G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate (): fId (0) {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/sceneHandler/create", this);
fpCommand -> SetGuidance
("/vis/sceneHandler/create [<graphics-system>] [<scene-handler-name>]");
fpCommand -> SetGuidance
("Creates an scene handler for a specific graphics system.");
fpCommand -> SetGuidance
("Default graphics system is current graphics system.");
fpCommand -> SetGuidance ("Invents a name if not supplied.");
fpCommand -> SetGuidance
("This graphics system and scene handler become current.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("graphics-system", 's', omitable = true);
parameter -> SetCurrentAsDefault (true);
const G4GraphicsSystemList& gslist =
fpVisManager -> GetAvailableGraphicsSystems ();
G4String candidates;
for (int igslist = 0; igslist < gslist.entries (); igslist++) {
G4String name = gslist (igslist) -> GetName ();
G4String nickname = gslist (igslist) -> GetNickname ();
if (nickname.length () > 0) {
candidates += nickname + " ";
}
candidates += name + " ";
}
parameter -> SetParameterCandidates(candidates);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter
("scene-handler-name", 's', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate () {
delete fpCommand;
}
G4String G4VisCommandSceneHandlerCreate::NextName () {
char nextName [20];
ostrstream ost (nextName, 20);
ost << "scene-handler-" << fId << ends;
return nextName;
}
G4String G4VisCommandSceneHandlerCreate::GetCurrentValue
(G4UIcommand* command) {
G4String graphicsSystemName;
const G4GraphicsSystemList& gslist =
fpVisManager -> GetAvailableGraphicsSystems ();
if (gslist.entries ()) {
graphicsSystemName = gslist [0] -> GetName ();
}
else {
graphicsSystemName = "none";
}
return graphicsSystemName + " " + NextName ();
}
void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String graphicsSystem, newName;
istrstream is ((char*)newValue.data());
is >> graphicsSystem >> newName;
const G4GraphicsSystemList& gsl =
fpVisManager -> GetAvailableGraphicsSystems ();
int nSystems = gsl.entries ();
if (nSystems <= 0) {
G4cout << "G4VisCommandSceneHandlerCreate::SetNewValue:"
" no graphics systems available."
"\n Did you instantiate any in"
" YourVisManager::RegisterGraphicsSystems()?"
<< endl;
return;
}
int iGS; // Selector index.
for (iGS = 0; iGS < nSystems; iGS++) {
if (graphicsSystem.compareTo (gsl [iGS] -> GetName (),
RWCString::ignoreCase) == 0 ||
graphicsSystem.compareTo (gsl [iGS] -> GetNickname (),
RWCString::ignoreCase) == 0) {
break; // Match found.
}
}
if (iGS < 0 || iGS >= nSystems) {
// Invalid command line argument or non.
// This shouldn't happen!!!!!!
G4cerr << "G4VisCommandSceneHandlerCreate::SetNewValue:"
" invalid graphics system specified."
<< endl;
return;
}
// Valid index. Set current graphics system in preparation for
// creating scene handler.
G4VGraphicsSystem* pSystem = gsl [iGS];
fpVisManager -> SetCurrentGraphicsSystem (pSystem);
if (fpVisManager -> GetVerboseLevel () > 0) {
G4cout << "Graphics system set to " << pSystem -> GetName () << endl;
if (fpVisManager -> GetVerboseLevel () > 1) {
fpVisManager -> PrintCurrentSystem ();
}
}
// Now deal with name of scene handler.
G4String nextName = NextName ();
if (newName == "") {
newName = nextName;
}
if (newName == nextName) fId++;
const G4SceneList& list = fpVisManager -> GetAvailableScenes ();
int iScene;
for (iScene = 0; iScene < list.entries (); iScene++) {
G4VScene* sceneHandler = list [iScene];
if (sceneHandler -> GetName () == newName) {
G4cout << "Scene handler \"" << newName << "\" already exists." << endl;
return;
}
}
//Create scene handler.
fpVisManager -> CreateScene (newName);
G4cout << "New scene handler \"" << newName << "\" created." << endl;
UpdateCandidateLists ();
}
////////////// /vis/sceneHandler/list ///////////////////////////////////////
G4VisCommandSceneHandlerList::G4VisCommandSceneHandlerList () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/sceneHandler/list", this);
fpCommand -> SetGuidance
("/vis/sceneHandler/list [<scene-handler-name>] [<verbosity>]");
fpCommand -> SetGuidance ("Lists scene handler(s).");
fpCommand -> SetGuidance ("<scene-handler-name> default is \"all\"");
fpCommand -> SetGuidance
("<verbosity> is 0 for short (default) or 1 for long listing.");
G4UIparameter* parameter;
parameter = new G4UIparameter("scene-handler-name", 's',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue ("all");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("verbosity", 'i',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue (0);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneHandlerList::~G4VisCommandSceneHandlerList () {
delete fpCommand;
}
G4String G4VisCommandSceneHandlerList::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneHandlerList::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String name;
G4int verbosity;
istrstream is ((char*)newValue.data());
is >> name >> verbosity;
const G4SceneList& list = fpVisManager -> GetAvailableScenes ();
G4bool found = false;
for (int iSH = 0; iSH < list.entries (); iSH++) {
if (name != "all") {
if (name != list [iSH] -> GetName ()) continue;
}
found = true;
G4cout << "Scene handler \"" << list [iSH] -> GetName () << "\""
<< " (" << list [iSH] -> GetGraphicsSystem () -> GetName () << ")";
if (verbosity > 0) {
G4cout << "\n " << *(list [iSH]);
}
G4cout << endl;
}
if (!found) {
G4cout << "No scene handlers found";
if (name != "all") {
G4cout << " of name \"" << name << "\"";
}
G4cout << "." << endl;
}
}
////////////// /vis/sceneHandler/remove ///////////////////////////////////////
G4VisCommandSceneHandlerRemove::G4VisCommandSceneHandlerRemove () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/remove", this);
fpCommand -> SetGuidance ("/vis/sceneHandler/remove <scene-handler-name>");
fpCommand -> SetGuidance ("Removes scene handlers.");
fpCommand -> SetGuidance
("Specify scene handler by name (\"/vis/sceneHandler/list\""
"\n to see possibilities).");
fpCommand -> SetParameterName ("scene-handler-name",
omitable = false,
currentAsDefault = true);
fpCommandSceneHandlerRemove = fpCommand;
}
G4VisCommandSceneHandlerRemove::~G4VisCommandSceneHandlerRemove () {
delete fpCommand;
}
G4String G4VisCommandSceneHandlerRemove::GetCurrentValue (G4UIcommand* command) {
G4VScene* sceneHandler = fpVisManager -> GetCurrentScene ();
if (sceneHandler) {
return sceneHandler -> GetName ();
}
else {
return "none";
}
}
void G4VisCommandSceneHandlerRemove::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& removeName = newValue;
G4VScene* currentSceneHandler = fpVisManager -> GetCurrentScene ();
G4String currentName;
if (currentSceneHandler) {
currentName = currentSceneHandler -> GetName ();
}
G4SceneList& list = fpVisManager -> SetAvailableScenes ();
G4int iSH;
for (iSH = 0; iSH < list.entries (); iSH++) {
if (list [iSH] -> GetName () == removeName) break;
}
if (iSH >= list.entries ()) {
G4cout << "Scene handler \"" << removeName
<< "\" not found - \"/vis/sceneHandler/list\" to see possibilities."
<< endl;
return;
}
G4cout << "Scene handler \"" << removeName << "\" removed." << endl;
if (removeName == currentName) {
fpVisManager -> DeleteCurrentScene ();
}
else {
list.remove (list [iSH]);
G4cout << "Current scene handler unchanged." << endl;
}
UpdateCandidateLists ();
}
////////////// /vis/sceneHandler/select ///////////////////////////////////////
G4VisCommandSceneHandlerSelect::G4VisCommandSceneHandlerSelect () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/select", this);
fpCommand -> SetGuidance ("/vis/sceneHandler/select [<scene-handler-name>]");
fpCommand -> SetGuidance ("Selects current scene handler.");
fpCommand -> SetGuidance
("Specify scene handler by name (\"/vis/sceneHandler/list\""
"\n to see possibilities).");
fpCommand -> SetParameterName ("scene-handler-name",
omitable = true,
currentAsDefault = true);
fpCommandSceneHandlerSelect = fpCommand;
}
G4VisCommandSceneHandlerSelect::~G4VisCommandSceneHandlerSelect () {
delete fpCommand;
}
G4String G4VisCommandSceneHandlerSelect::GetCurrentValue
(G4UIcommand* command) {
G4VScene* sceneHandler = fpVisManager -> GetCurrentScene ();
if (sceneHandler) {
return sceneHandler -> GetName ();
}
else {
return "none";
}
}
void G4VisCommandSceneHandlerSelect::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& selectName = newValue;
const G4SceneList& list = fpVisManager -> GetAvailableScenes ();
G4cout << "Scene handler \"" << selectName << "\"";
G4int iSH;
for (iSH = 0; iSH < list.entries (); iSH++) {
if (list [iSH] -> GetName () == selectName) break;
}
if (iSH < list.entries ()) {
if (fpVisManager -> GetCurrentScene () -> GetName () == selectName) {
G4cout << " already selected." << endl;
}
else {
G4cout << " being selected." << endl;
fpVisManager -> SetCurrentScene (list [iSH]);
}
}
else {
G4cout << " not found - \"/vis/sceneHandler/list\""
"\n to see possibilities."
<< endl;
}
}
@@ -0,0 +1,97 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsSceneInclude.cc,v 2.3 1998/11/29 15:34:10 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// /vis/scene commands - John Allison 9th August 1998
#include "G4VisCommandsSceneInclude.hh"
#include "G4VisManager.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4HitsModel.hh"
#include "G4TrajectoriesModel.hh"
////////////// /vis/scene/include/hits ///////////////////////////////////////
G4VisCommandSceneIncludeHits::G4VisCommandSceneIncludeHits () {
fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/include/hits", this);
fpCommand -> AvailableForStates (Idle, GeomClosed);
fpCommand -> SetGuidance
("Includes hits in current scene.");
fpCommand -> SetGuidance
("Hits are drawn at end of event when the scene in which"
" they are included is current.");
}
G4VisCommandSceneIncludeHits::~G4VisCommandSceneIncludeHits () {
delete fpCommand;
}
G4String G4VisCommandSceneIncludeHits::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneIncludeHits::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
if (list.isEmpty ()) {
G4cout << "No scenes - please create one before adding anything."
<< endl;
return;
}
G4HitsModel* model = new G4HitsModel;
const G4String& currentSceneName =
fpVisManager -> GetCurrentSceneData ().GetName ();
(list [currentSceneName]).AddEndOfEventModel (model);
UpdateVisManagerSceneDataAndViewParameters ();
G4cout << "Hits will be drawn at end of event when scene \""
<< currentSceneName << "\" is current"
<< endl;
}
////////////// /vis/scene/include/trajectories ///////////////////////////////////////
G4VisCommandSceneIncludeTrajectories::G4VisCommandSceneIncludeTrajectories () {
fpCommand = new G4UIcmdWithoutParameter
("/vis/scene/include/trajectories", this);
fpCommand -> AvailableForStates (Idle, GeomClosed);
fpCommand -> SetGuidance
("Includes trajectories in current scene.");
fpCommand -> SetGuidance
("Trajectories are drawn at end of event when the scene in which"
" they are included is current.");
}
G4VisCommandSceneIncludeTrajectories::~G4VisCommandSceneIncludeTrajectories () {
delete fpCommand;
}
G4String G4VisCommandSceneIncludeTrajectories::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandSceneIncludeTrajectories::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4SceneDataObjectList& list = fpVisManager -> SetSceneDataObjectList ();
if (list.isEmpty ()) {
G4cout << "No scenes - please create one before adding anything."
<< endl;
return;
}
G4TrajectoriesModel* model = new G4TrajectoriesModel;
const G4String& currentSceneName =
fpVisManager -> GetCurrentSceneData ().GetName ();
(list [currentSceneName]).AddEndOfEventModel (model);
UpdateVisManagerSceneDataAndViewParameters ();
G4cout << "Trajectories will be drawn at end of event when scene \""
<< currentSceneName << "\" is current"
<< endl;
}
@@ -0,0 +1,428 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisCommandsViewer.cc,v 2.3 1998/12/09 23:56:30 allison Exp $
// GEANT4 tag $Name: geant4-00 $
// /vis/viewer commands - John Allison 25th October 1998
#include "G4VisCommandsViewer.hh"
#include "G4VisManager.hh"
#include "G4GraphicsSystemList.hh"
#include "G4VisCommandsScene.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAString.hh"
#include "G4ios.hh"
#ifdef WIN32
#include <strstrea.h>
#else
#include <strstream.h>
#endif
G4VVisCommandViewer::G4VVisCommandViewer () {}
G4String G4VVisCommandViewer::ShortName (const G4String& name) {
G4String shortName = name;
if (name.contains (' ')) {
shortName = name (0, name.first (' '));
}
return shortName;
}
void G4VVisCommandViewer::UpdateCandidateLists () {
const G4SceneList& sceneHandlerList = fpVisManager -> GetAvailableScenes ();
G4int nHandlers = sceneHandlerList.entries ();
fViewerNameList = G4String ();
for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
G4VScene* sceneHandler = sceneHandlerList [iHandler];
const G4VViewList& viewerList = sceneHandler -> GetViewList ();
for (int iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
const G4String& viewerName = viewerList [iViewer] -> GetName ();
fViewerNameList += ShortName (viewerName) + " ";
}
}
fViewerNameList = fViewerNameList.strip ();
if (fpCommandViewerRemove) {
fpCommandViewerRemove -> GetParameter (0) ->
SetParameterCandidates (fViewerNameList);
}
if (fpCommandViewerSelect) {
fpCommandViewerSelect -> GetParameter (0) ->
SetParameterCandidates (fViewerNameList);
}
}
G4String G4VVisCommandViewer::fViewerNameList;
////////////// /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>]");
fpCommand -> SetGuidance
("Creates an viewer for a specific scene handler.");
fpCommand -> SetGuidance
("Default scene handler is the current scene handler.");
fpCommand -> SetGuidance
("Invents a name if not supplied. (Note: the system adds information");
fpCommand -> SetGuidance
("to the name for identification - only the characters up to the first");
fpCommand -> SetGuidance
("blank are used for removing, selecting, etc.)");
fpCommand -> SetGuidance ("This scene handler and viewer become current.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
parameter -> SetCurrentAsDefault (true);
fpCommand -> SetParameter (parameter);
fpCommandViewerCreate = fpCommand;
}
G4VisCommandViewerCreate::~G4VisCommandViewerCreate () {
delete fpCommand;
}
G4String G4VisCommandViewerCreate::NextName () {
const int charLength = 100;
char nextName [charLength];
ostrstream ost (nextName, charLength);
G4VScene* sceneHandler = fpVisManager -> GetCurrentScene ();
ost << "viewer-" << fId << " (";
if (sceneHandler) {
ost << sceneHandler -> GetGraphicsSystem () -> GetName ();
}
else {
ost << "no_scene_handlers";
}
ost << ")" << ends;
return nextName;
}
G4String G4VisCommandViewerCreate::GetCurrentValue (G4UIcommand* command) {
G4String currentValue;
G4VScene* currentSceneHandler = fpVisManager -> GetCurrentScene ();
if (currentSceneHandler) {
currentValue = currentSceneHandler -> GetName ();
}
else {
currentValue = "none";
}
currentValue += ' ';
currentValue += '"';
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];
}
*/
return currentValue;
}
void G4VisCommandViewerCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String sceneHandlerName, newName;
istrstream is ((char*)newValue.data());
is >> sceneHandlerName;
// Now need to handle the possibility that the second string
// contains embedded blanks within quotation marks.
char c;
while (is.get (c)) newName += c;
newName = newName.strip (G4String::both, ' ');
newName = newName.strip (G4String::both, '"');
const G4SceneList& sceneHandlerList = fpVisManager -> GetAvailableScenes ();
G4int nHandlers = sceneHandlerList.entries ();
if (nHandlers <= 0) {
G4cout << "G4VisCommandViewerCreate::SetNewValue: no scene handlers."
"\n Create a scene handler with \"/vis/create/sceneHandler\""
<< endl;
return;
}
G4int iHandler;
for (iHandler = 0; iHandler < nHandlers; iHandler++) {
if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
}
if (iHandler < 0 || iHandler >= nHandlers) {
// Invalid command line argument or non.
// This shouldn't happen!!!!!!
G4cerr << "G4VisCommandViewerCreate::SetNewValue:"
" invalid scene handler specified."
<< endl;
return;
}
// Valid index. Set current scene handler and graphics system in
// preparation for creating viewer.
G4VScene* sceneHandler = sceneHandlerList [iHandler];
if (sceneHandler != fpVisManager -> GetCurrentScene ()) {
fpVisManager -> SetCurrentScene (sceneHandler);
}
// Now deal with name of viewer.
G4String nextName = NextName ();
if (newName == "") {
newName = nextName;
}
if (newName == nextName) fId++;
for (iHandler = 0; iHandler < nHandlers; iHandler++) {
G4VScene* sceneHandler = sceneHandlerList [iHandler];
const G4VViewList& viewerList = sceneHandler -> GetViewList ();
for (int iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
if (viewerList [iViewer] -> GetName () == newName ) {
G4cout << "Viewer \"" << newName << "\" already exists." << endl;
return;
}
}
}
// Create viewer.
fpVisManager -> CreateView (newName);
G4cout << "New viewer \"" << newName << "\" created." << endl;
UpdateCandidateLists ();
}
////////////// /vis/viewer/list ///////////////////////////////////////
G4VisCommandViewerList::G4VisCommandViewerList () {
G4bool omitable;
fpCommand = new G4UIcommand ("/vis/viewer/list", this);
fpCommand -> SetGuidance
("/vis/viewer/list [<viewer-name>] [<verbosity>]");
fpCommand -> SetGuidance ("Lists viewers(s).");
fpCommand -> SetGuidance ("<viewer-name> default is \"all\"");
fpCommand -> SetGuidance
("<verbosity> is 0 for short (default) or 1 for long listing.");
G4UIparameter* parameter;
parameter = new G4UIparameter("viewer-name", 's',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue ("all");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("verbosity", 'i',
omitable = true);
parameter -> SetCurrentAsDefault (false);
parameter -> SetDefaultValue (0);
fpCommand -> SetParameter (parameter);
}
G4VisCommandViewerList::~G4VisCommandViewerList () {
delete fpCommand;
}
G4String G4VisCommandViewerList::GetCurrentValue (G4UIcommand* command) {
return "";
}
void G4VisCommandViewerList::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String name;
G4int verbosity;
istrstream is ((char*)newValue.data());
is >> name >> verbosity;
G4bool found = false;
const G4SceneList& sceneHandlerList = fpVisManager -> GetAvailableScenes ();
G4int nHandlers = sceneHandlerList.entries ();
for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
G4VScene* sceneHandler = sceneHandlerList [iHandler];
const G4VViewList& viewerList = sceneHandler -> GetViewList ();
for (int iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
if (name != "all") {
if (name != viewerList [iViewer] -> GetName ()) continue;
}
found = true;
G4cout << "Scene handler \"" << sceneHandler -> GetName ()
<< "\": viewer \"" << viewerList [iViewer] -> GetName ()
<< "\"";
if (verbosity > 0) {
G4cout << "\n " << *(viewerList [iViewer]);
}
G4cout << endl;
}
}
if (!found) {
G4cout << "No viewers found";
if (name != "all") {
G4cout << " of name \"" << name << "\"";
}
G4cout << "." << endl;
}
}
////////////// /vis/viewer/remove ///////////////////////////////////////
G4VisCommandViewerRemove::G4VisCommandViewerRemove () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/viewer/remove", this);
fpCommand -> SetGuidance ("/vis/viewer/remove <viewer-name>");
fpCommand -> SetGuidance ("Removes viewers.");
fpCommand -> SetGuidance
("Specify viewer by name (\"/vis/viewer/list\""
"\n to see possibilities).");
fpCommand -> SetParameterName ("viewer-name",
omitable = false,
currentAsDefault = true);
fpCommandViewerRemove = fpCommand;
}
G4VisCommandViewerRemove::~G4VisCommandViewerRemove () {
delete fpCommand;
}
G4String G4VisCommandViewerRemove::GetCurrentValue (G4UIcommand* command) {
G4VView* viewer = fpVisManager -> GetCurrentView ();
if (viewer) {
return viewer -> GetName ();
}
else {
return "none";
}
}
void G4VisCommandViewerRemove::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& removeName = newValue;
G4String removeShortName = ShortName (removeName);
G4VView* currentViewer = fpVisManager -> GetCurrentView ();
G4String currentName;
if (currentViewer) {
currentName = currentViewer -> GetName ();
}
G4String currentShortName = ShortName (currentName);
const G4SceneList& sceneHandlerList = fpVisManager -> GetAvailableScenes ();
G4int nHandlers = sceneHandlerList.entries ();
G4int iHandler, iViewer;
G4VScene* sceneHandler;
G4VView* viewer;
G4bool found = false;
for (iHandler = 0; iHandler < nHandlers; iHandler++) {
sceneHandler = sceneHandlerList [iHandler];
const G4VViewList& viewerList = sceneHandler -> GetViewList ();
for (iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
viewer = viewerList [iViewer];
const G4String& viewerName = viewer -> GetName ();
if (removeShortName == ShortName (viewerName)) {
found = true;
break;
}
}
}
if (!found) {
G4cout << "Viewer \"" << removeName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< endl;
return;
}
G4cout << "Viewer \"" << removeName << "\" removed." << endl;
if (removeShortName == currentShortName) {
fpVisManager -> DeleteCurrentView ();
}
else {
sceneHandler -> SetViewList ().remove (viewer);
G4cout << "Current viewer unchanged." << endl;
}
UpdateCandidateLists ();
}
////////////// /vis/viewer/select ///////////////////////////////////////
G4VisCommandViewerSelect::G4VisCommandViewerSelect () {
G4bool omitable, currentAsDefault;
fpCommand = new G4UIcmdWithAString ("/vis/viewer/select", this);
fpCommand -> SetGuidance ("/vis/viewer/select [<viewer-name>]");
fpCommand -> SetGuidance ("Selects current viewer.");
fpCommand -> SetGuidance
("Specify viewer by name (\"/vis/viewer/list\""
"\n to see possibilities).");
fpCommand -> SetParameterName ("viewer-name",
omitable = true,
currentAsDefault = true);
fpCommandViewerSelect = fpCommand;
}
G4VisCommandViewerSelect::~G4VisCommandViewerSelect () {
delete fpCommand;
}
G4String G4VisCommandViewerSelect::GetCurrentValue
(G4UIcommand* command) {
G4VView* viewer = fpVisManager -> GetCurrentView ();
if (viewer) {
return viewer -> GetName ();
}
else {
return "none";
}
}
void G4VisCommandViewerSelect::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4String& selectName = newValue;
G4String selectShortName = ShortName (selectName);
const G4SceneList& sceneHandlerList = fpVisManager -> GetAvailableScenes ();
G4int nHandlers = sceneHandlerList.entries ();
G4int iHandler, iViewer;
G4VScene* sceneHandler;
G4VView* viewer;
G4bool found = false;
for (iHandler = 0; iHandler < nHandlers; iHandler++) {
sceneHandler = sceneHandlerList [iHandler];
const G4VViewList& viewerList = sceneHandler -> GetViewList ();
for (iViewer = 0; iViewer < viewerList.entries (); iViewer++) {
viewer = viewerList [iViewer];
if (selectShortName == ShortName (viewer -> GetName ())) {
found = true;
break;
}
}
}
G4cout << "Viewer \"" << selectName << "\"";
if (found) {
if (ShortName (fpVisManager -> GetCurrentView () -> GetName ())
== selectShortName) {
G4cout << " already selected." << endl;
}
else {
G4cout << " being selected." << endl;
fpVisManager -> SetCurrentView (viewer);
}
}
else {
G4cout << " not found - \"/vis/viewer/list\""
"\n to see possibilities."
<< endl;
}
}
@@ -0,0 +1,26 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisFeaturesOfDAWNFILE.cc,v 2.2 1998/07/12 03:10:19 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4VisFeaturesOfDAWNFILE.hh"
G4String G4VisFeaturesOfDAWNFILE () {
return
"High quality technical renderer."
"\n Features: exact hidden line, hidden surface algorithms."
"\n high (unlimited) resolution."
"\n renders to PostScript for viewing and/or hardcopy."
"\n remote rendering."
"\n off-line rendering."
"\n graphical user interface."
"\n connection via g4.prim file to Fukui Renderer DAWN etc."
"\n Disadvantages: compute intensive, takes time (use a fast graphics"
"\n system, such as OpenGL, to select view, then copy"
"\n to this renderer - /vis~/copy/view, /vis~/set/view).";
}
@@ -0,0 +1,27 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisFeaturesOfFukuiRenderer.cc,v 2.2 1998/07/12 03:10:20 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4VisFeaturesOfFukuiRenderer.hh"
G4String G4VisFeaturesOfFukuiRenderer () {
return
"High quality technical renderer."
"\n Features: exact hidden line, hidden surface algorithms."
"\n high (unlimited) resolution."
"\n renders to PostScript for viewing and/or hardcopy."
"\n remote rendering."
"\n off-line rendering."
"\n graphical user interface."
"\n Disadvantages: compute intensive, takes time (use a fast graphics"
"\n system, such as OpenGL, to select view, then copy"
"\n to this renderer - /vis~/copy/view, /vis~/set/view).";
}
@@ -0,0 +1,73 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisFeaturesOfOpenGL.cc,v 2.1 1998/07/12 03:10:21 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4VisFeaturesOfOpenGL.hh"
G4String G4VisFeaturesOfOpenGLIX () {
return
" Dumb single buffered X Window, No Graphics Database."
"\n Advantages: does not gobble server memory."
"\n good for drawing steps and hits."
"\n Disadvantages: needs G4 kernel for re-Draw."
"\n cannot take advantage of graphics accelerators.";
}
G4String G4VisFeaturesOfOpenGLSX () {
return
" Dumb double buffered X Window with Graphics Database."
"\n Advantages: uses display lists as graphics database."
"\n fastest possible redraw, e.g., on simple change"
"\n of viewpoint."
"\n uses client-server model for remote viewing"
"\n (but only if you have a full client-server"
"\n implementation of OpenGL, i.e., not Mesa)."
"\n Disadvantages: not advised for viewing large numbers of steps"
"\n and/or hits, because it gobbles memory for"
" database.";
}
G4String G4VisFeaturesOfOpenGLIXm () {
return
" Smart single buffered X Window, No Graphics Database."
"\n Advantages: resizeable, and has Motif-based view-control panel."
"\n does not gobble server memory."
"\n good for drawing steps and hits."
"\n Disadvantages: currently locks out GEANT4 commands, until \"exit\"."
"\n needs G4 kernel for re-Draw."
"\n cannot take advantage of graphics accelerators.";
}
G4String G4VisFeaturesOfOpenGLSXm () {
return
" Smart double buffered X Window with Graphics Database."
"\n Advantages: resizeable, and has Motif-based view-control panel."
"\n uses display lists as graphics database."
"\n fastest possible redraw, e.g., on simple change"
"\n of viewpoint."
"\n uses client-server model for remote viewing"
"\n (but only if you have a full client-server"
"\n implementation of OpenGL, i.e., not Mesa)."
"\n Disadvantages: currently locks out GEANT4 commands, until \"exit\"."
"\n not advised for viewing large numbers of steps"
"\n and/or hits, because it gobbles memory for"
" database.";
}
G4String G4VisFeaturesOfOpenGLIWin32 () {
return
"\n It runs on WindowsNT ";
}
G4String G4VisFeaturesOfOpenGLSWin32 () {
return
"\n It runs on WindowsNT ";
}
@@ -0,0 +1,21 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisFeaturesOfOpenInventor.cc,v 2.1 1998/09/11 15:10:41 jkallenb Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4VisFeaturesOfOpenInventor.hh"
G4String G4VisFeaturesOfOpenInventor () {
return
" Open Inventor Window/View/Scene."
"\n Advantages: Open Inventor feature set (interactivity, scene control)."
"\n Disadvantages: Requires Open Inventor license ($$), Hepvis library (Free).";
}
@@ -0,0 +1,21 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisFeaturesOfRay.cc,v 2.0 1998/07/02 16:49:56 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "G4VisFeaturesOfRay.hh"
G4String G4VisFeaturesOfRayX () {
return
" GEANT4 Ray Tracing to a dumb single buffered X Window."
"\n Advantages: uses GEANT4's own tracking algorithms."
"\n photo-realistic."
"\n Disadvantages: slow.";
}
@@ -0,0 +1,450 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessCamera.cc,v 2.3 1998/07/13 17:12:30 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Camera sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4ios.hh"
void G4VisManMessenger::AddCommandCamera () {
G4UIcommand* command;
G4UIparameter* param;
/////////////////////////////////////// /vis~/camera/dolly ////
//camera \hline
//camera /vis~/camera/dolly & distance &
//camera Moves the camera in by this distance.
//camera Reset with {\tt /vis~/camera/reset}. \\%
command = new G4UIcommand ("/vis~/camera/dolly", this);
command -> SetGuidance
(
" Moves the camera in by this distance."
" Reset with /vis~/camera/reset."
);
param = new G4UIparameter ("move in", 'd', true);
param -> SetDefaultValue (0.);
param -> SetGuidance ("world coordinates");
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/camera/orbit ////
//camera \hline
//camera /vis~/camera/orbit & $N_\mathrm{frames}$, $\Delta\beta$ &
//camera Orbits the scene about the up-vector, lights fixed to the scene.
//camera Draws $N_\mathrm{frames}$ frames, the camera
//camera rotated $\Delta\beta$ about the up-vector each frame. \\%
command = new G4UIcommand ("/vis~/camera/orbit", this);
command -> SetGuidance
(
"Orbits the scene about the up-vector, lights fixed to the scene."
" Draws N frames, the camera "
"rotated Delta-beta about the up-vector each frame."
);
param = new G4UIparameter ("No. of frames", 'i', true);
param -> SetDefaultValue (1);
command -> SetParameter (param);
param = new G4UIparameter ("angle_increment", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (1.);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////// /vis~/camera/pan ////
//camera \hline
//camera /vis~/camera/pan & right, up &
//camera Moves the camera right and up by these amounts.
//camera Reset with {\tt /vis~/camera/reset}. \\%
command = new G4UIcommand ("/vis~/camera/pan", this);
command -> SetGuidance
(
" Moves the camera by right and up by these amounts."
" Reset with /vis~/camera/reset."
);
param = new G4UIparameter ("right shift", 'd', true);
param -> SetDefaultValue (0.);
param -> SetGuidance ("world coordinates");
command -> SetParameter (param);
param = new G4UIparameter ("up shift", 'd', true);
param -> SetDefaultValue (0.);
param -> SetGuidance ("world coordinates");
command -> SetParameter (param);
fCommandList.append (command);
///////////////////////////////////// /vis~/camera/projection_style ////
//camera \hline
//camera /vis~/camera/projection\_style & choice &
//camera Projection style (orthogonal, perspective). \\%
command = new G4UIcommand ("/vis~/camera/projection_style", this);
command -> SetGuidance
(
"Projection style (orthogonal, perspective)."
);
param = new G4UIparameter ("Style selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
param = new G4UIparameter ("Perspective view half angle.", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/camera/spin ////
//camera \hline
//camera /vis~/camera/spin & $N_\mathrm{frames}$, $\Delta\beta$ &
//camera Spins the scene about the up-vector, lights fixed to the camera.
//camera Draws $N_\mathrm{frames}$ frames, the scene
//camera rotated $\Delta\beta$ about the up-vector each frame. \\%
command = new G4UIcommand ("/vis~/camera/spin", this);
command -> SetGuidance
(
"Spins the scene about the up-vector, lights fixed to the camera."
" Draws N frames, the scene "
"rotated Delta-beta about the up-vector each frame."
);
param = new G4UIparameter ("No. of frames", 'i', true);
param -> SetDefaultValue (1);
command -> SetParameter (param);
param = new G4UIparameter ("angle_increment", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (1.);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/camera/viewpoint ////
//camera \hline
//camera /vis~/camera/viewpoint & $\theta$ $\phi$ &
//camera Set direction from target to camera as
//camera $\theta$, $\phi$ (in degrees). Also changes lightpoint
//camera direction if lights are set to move with camera.\\%
command = new G4UIcommand ("/vis~/camera/viewpoint", this);
command -> SetGuidance
(
"Set direction from target to camera as "
"theta, phi (in degrees). Also changes lightpoint"
"\n direction if lights are set to move with camera."
);
param = new G4UIparameter ("theta", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (0.0);
command -> SetParameter (param);
param = new G4UIparameter ("phi", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (0.0);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////// /vis~/camera/window_size_hint ////
//camera \hline
//camera /vis~/camera/window\_size\_hint & size&
//camera Size in pixels (Square window `size $\Times$ size'). Affects
//camera future create\_view commands (hint only). \\%
command = new G4UIcommand ("/vis~/camera/window_size_hint", this);
command -> SetGuidance
(
"Size in pixels (Square window `size x size'). Affects "
"future create_view commands (hint only)."
);
param = new G4UIparameter ("Window size hint in pixels", 'i', true);
param -> SetDefaultValue (600);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////// /vis~/camera/zoom ////
//camera \hline
//camera /vis~/camera/zoom & factor &
//camera Magnifies by this factor.
//camera Reset with {\tt /vis~/camera/reset}. \\%
command = new G4UIcommand ("/vis~/camera/zoom", this);
command -> SetGuidance
(
"Magnifies by this factor."
" Reset with /vis~/camera/reset."
);
param = new G4UIparameter ("zoom factor", 'd', true);
param -> SetDefaultValue (1.);
param -> SetGuidance ("magnifies by this");
command -> SetParameter (param);
fCommandList.append (command);
}
void G4VisManMessenger::DoCommandCamera (const G4String& commandPath,
G4String& newValues) {
/////////////////////////////// /vis~/camera/dolly ////
if (commandPath == "/vis~/camera/dolly") {
if (ViewValid ()) {
G4double in;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> in;
G4cout << "Dolly " << in << " in." << endl;
fpVMan -> SetCurrentViewParameters ().IncrementDolly (in);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Dolly distance changed to "
<< fpVMan -> GetCurrentViewParameters ().GetDolly () << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
// fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
// fpVMan -> Draw ();
// fpVMan -> Show ();
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
//////////////////////////////// /vis~/camera/orbit ////
if (commandPath == "/vis~/camera/orbit") {
if (ViewValid ()) {
G4int nFrames;
G4double dbeta;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> nFrames >> dbeta;
dbeta = dbeta * deg;
fpVMan -> SetCurrentViewParameters ().SetLightsMoveWithCamera (false);
for (int i = 0; i < nFrames; i++) {
RotateViewpointAboutUpVectorBy (dbeta);
fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
fpVMan -> Draw ();
fpVMan -> Show ();
}
}
}
/////////////////////////////// /vis~/camera/pan ////
if (commandPath == "/vis~/camera/pan") {
if (ViewValid ()) {
G4double right, up;
const char* aString = newValues;
istrstream is((char*) aString);is >> right >> up;
G4cout << "Pan " << right << " right, " << up << " up." << endl;
fpVMan -> SetCurrentViewParameters ().Pan (right, up);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Current target point changed to "
<< fpVMan -> GetCurrentViewParameters ().GetCurrentTargetPoint ()
<< endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
// fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
// fpVMan -> Draw ();
// fpVMan -> Show ();
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
///////////////////////////////////// /vis~/camera/projection_style ////
if (commandPath == "/vis~/camera/projection_style") {
G4int iStyle;
G4double fieldHalfAngleDegrees;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iStyle >> fieldHalfAngleDegrees;
if (iStyle < 0 || iStyle > 1) {
G4cout << "Available representation styles:";
G4cout << "\n 0) orthogonal";
G4cout << "\n 1) perspective (also specify field half angle in degrees)";
G4cout << "\nChoose by specifying integer parameter and field half angle"
" (if relevant).";
G4cout << endl;
}
else {
switch (iStyle) {
default:
case 0:
fpVMan -> SetCurrentViewParameters ().SetFieldHalfAngle (0.);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "\nOrthogonal projection set." << endl;
}
break;
case 1:
if (fieldHalfAngleDegrees == 0.0) {
fieldHalfAngleDegrees = 30.;
G4cout << "Field half angle defaulted to "
<< fieldHalfAngleDegrees << " degrees." << endl;
}
if (fieldHalfAngleDegrees > 89.5 || fieldHalfAngleDegrees <= 0.0) {
G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
G4cout << endl;
}
else {
fpVMan -> SetCurrentViewParameters ().
SetFieldHalfAngle (fieldHalfAngleDegrees * deg);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "\nPerspective projection set.";
G4cout << "\nField half angle set to " << fieldHalfAngleDegrees
<< " degrees" << " ("
<< fpVMan -> GetCurrentViewParameters ().GetFieldHalfAngle ()
<< " radians)." << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
break;
}
}
// if (ViewValid ()) {
// fpVMan -> GetCurrentView () -> ClearView ();
// fpVMan -> Draw ();
// fpVMan -> Show ();
// }
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
//////////////////////////////// /vis~/camera/spin ////
if (commandPath == "/vis~/camera/spin") {
if (ViewValid ()) {
G4int nFrames;
G4double dbeta;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> nFrames >> dbeta;
dbeta = dbeta * deg;
fpVMan -> SetCurrentViewParameters ().SetLightsMoveWithCamera (true);
for (int i = 0; i < nFrames; i++) {
RotateViewpointAboutUpVectorBy (dbeta);
fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
fpVMan -> Draw ();
fpVMan -> Show ();
}
}
}
//////////////////////////////////////// /vis~/camera/viewpoint ////
if (commandPath == "/vis~/camera/viewpoint") {
G4double theta, phi ;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> theta >> phi;
theta = theta * deg;
phi = phi * deg;
G4double x = sin (theta) * cos (phi);
G4double y = sin (theta) * sin (phi);
G4double z = cos (theta);
G4Vector3D vp (x, y, z);
fpVMan -> SetCurrentViewParameters().SetViewAndLights (vp);
const G4ViewParameters& viewParams = fpVMan -> GetCurrentViewParameters ();
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Viewpoint direction set to " << vp << endl;
if (viewParams.GetLightsMoveWithCamera ()) {
G4cout << "Lightpoint direction set to "
<< viewParams.GetLightpointDirection () << endl;
}
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
// if (ViewValid ()) {
// fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
// fpVMan -> Draw ();
// fpVMan -> Show ();
// }
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
/////////////////////////////////////// /vis~/camera/window_size_hint ////
if (commandPath == "/vis~/camera/window_size_hint") {
G4int size;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> size;
fpVMan -> SetCurrentViewParameters ().SetWindowSizeHint (size, size);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Window size hint set to " << size << " x " << size << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
}
//////////////////////////////// /vis~/camera/zoom ////
if (commandPath == "/vis~/camera/zoom") {
if (ViewValid ()) {
G4double zoomBy;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> zoomBy;
fpVMan -> SetCurrentViewParameters ().MultiplyZoomFactor (zoomBy);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Zoom factor changed to "
<< fpVMan -> GetCurrentViewParameters ().GetZoomFactor () << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
// fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
// fpVMan -> Draw ();
// fpVMan -> Show ();
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
}
void G4VisManMessenger::RotateViewpointAboutUpVectorBy (G4double dbeta) {
// Rotates by fixed azimuthal angle dbeta.
const G4ViewParameters& viewParams = fpVMan -> GetCurrentViewParameters ();
G4Vector3D vp = viewParams.GetViewpointDirection ().unit ();
G4Vector3D up = viewParams.GetUpVector ().unit ();
G4Vector3D& zprime = up;
G4double cosalpha = up.dot (vp);
G4double sinalpha = sqrt (1. - pow (cosalpha, 2));
G4Vector3D viewPoint = viewParams.GetViewpointDirection ().unit ();
G4Vector3D yprime = (zprime.cross (viewPoint)).unit ();
G4Vector3D xprime = yprime.cross (zprime);
// Projection of vp on plane perpendicular to up...
G4Vector3D a1 = sinalpha * xprime;
// Required new projection...
G4Vector3D a2 =
sinalpha * (cos (dbeta) * xprime + sin (dbeta) * yprime);
// Required Increment vector...
G4Vector3D delta = a2 - a1;
// So new viewpoint is...
viewPoint += delta;
fpVMan -> SetCurrentViewParameters ().SetViewAndLights (viewPoint);
}
@@ -0,0 +1,153 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessCreateView.cc,v 2.4 1998/07/13 17:12:31 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Create View sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4ios.hh"
#include <string.h>
void G4VisManMessenger::AddCommandCreateView () {
G4UIcommand* command;
G4UIparameter* param;
/////////////////// /vis~/create_view/new_graphics_system /////
//cr_vw \hline
//cr_vw /vis~/create\_view/ new\_graphics\_system & choice &
//cr_vw Creates a new scene and a new view of a new graphics system; all
//cr_vw become current. \\%
command = new G4UIcommand ("/vis~/create_view/new_graphics_system", this);
command -> SetGuidance
(
"Creates a new scene and a new view of a new graphics system; all "
"become current."
);
param = new G4UIparameter ("Graphics system selector", 's', true);
param -> SetDefaultValue ("none");
const G4GraphicsSystemList& gslist =
fpVMan -> GetAvailableGraphicsSystems ();
G4String candidates;
for (int igslist = 0; igslist < gslist.entries (); igslist++) {
G4String nickname = gslist (igslist) -> GetNickname ();
if (nickname . length () > 0) {
candidates += nickname;
}
else {
candidates += gslist (igslist) -> GetName ();
}
candidates += " ";
}
param -> SetParameterCandidates(candidates);
command -> SetParameter (param);
fCommandList.append (command);
}
void G4VisManMessenger::DoCommandCreateView (const G4String& commandPath,
G4String& newValues) {
/////////////////// /vis~/create_view/new_graphics_system /////
if (commandPath == "/vis~/create_view/new_graphics_system") {
G4String selector;
const char* aString = newValues;
istrstream is ((char*) aString) ; is >> selector;
const G4GraphicsSystemList& gsl = fpVMan -> GetAvailableGraphicsSystems ();
int nSystems = gsl.entries ();
if (nSystems > 0) {
int iGS; // Selector index.
for (iGS = 0; iGS < nSystems; iGS++) {
if (selector.compareTo (gsl [iGS] -> GetName (),
RWCString::ignoreCase) == 0 ||
selector.compareTo (gsl [iGS] -> GetNickname (),
RWCString::ignoreCase) == 0) {
break; // Match found.
}
}
if (iGS < 0 || iGS >= nSystems) {
// Invalid command line argument or non. Print available systems.
G4bool help;
if (selector.compareTo ("help", RWCString::ignoreCase) == 0 ||
selector.compareTo ("info", RWCString::ignoreCase) == 0)
help = true;
else help = false;
int maxNameLength = strlen ("class name");
int nameLength;
int maxNicknameLength = strlen ("nickname");
int nicknameLength;
int igs;
for (igs = 0; igs < nSystems; igs++) {
nameLength = strlen (gsl [igs] -> GetName ());
if (maxNameLength < nameLength) maxNameLength = nameLength;
nicknameLength = strlen (gsl [igs] -> GetNickname ());
if (maxNicknameLength < nicknameLength)
maxNicknameLength = nicknameLength;
}
G4String className, nickname, description;
className = "class name";
int i;
for (i = className.length (); i < maxNameLength; i++)
className = className + " ";
G4cout << "Available graphics systems:\n " << className
<< "nickname";
className = "Help";
for (i = className.length (); i < maxNameLength; i++)
className = className + " ";
if (help) G4cout << '\n';
G4cout << "\n " << className << " info for more information";
for (igs = 0; igs < nSystems; igs++) {
className = gsl [igs] -> GetName ();
for (i = className.length (); i < maxNameLength; i++)
className = className + " ";
if (help) G4cout << '\n';
G4cout << "\n " << className;
nickname = gsl [igs] -> GetNickname ();
for (i = nickname.length (); i < maxNameLength; i++)
nickname = nickname + " ";
G4cout << " " << nickname;
if (help) {
description = gsl [igs] -> GetDescription ();
if (description != "") {
size_t index = 0;
while ((index = description.index ('\n', ++index)) != RW_NPOS) {
description.replace (index, 1, "\n ");
}
G4cout << "\n " << description;
}
}
}
if (nSystems == 1) iGS = 0; // Only one system - create view anyway.
else {
G4cout <<
"\nChoose by specifying class name or nickname, if any, or help.";
}
G4cout << endl;
}
if (iGS >=0 && iGS < nSystems) {
// Valid index. Create view.
G4VGraphicsSystem* pSystem = gsl [iGS];;
fpVMan -> SetCurrentGraphicsSystemAndCreateView (pSystem);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Graphics system set to " << pSystem -> GetName () << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentSystem ();
}
}
}
}
}
}
@@ -0,0 +1,268 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessDraw.cc,v 2.7 1998/08/14 08:48:45 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Draw sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4Polyline.hh"
#include "G4Text.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
#include "G4GlobalFastSimulationManager.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4FlavoredParallelWorldModel.hh"
#include "G4ModelingParameters.hh"
void G4VisManMessenger::AddCommandDraw () {
G4UIcommand* command;
G4UIparameter* param;
//////////////////////////////////// /vis~/draw/axes /////
//draw \hline
//draw /vis~/draw/axes & $x_0$, $y_0$, $z_0$, length, unit &
//draw Draws axes at $(x_0, y_0, z_0)$ of given length. \\%
command = new G4UIcommand ("/vis~/draw/axes", this);
command -> SetGuidance
(
"Draws axes at (x0, y0, z0) of given length."
);
param = new G4UIparameter ("x0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("length", 'd', true);
param -> SetDefaultValue (10000.);
command -> SetParameter (param);
param = new G4UIparameter ("unit", 's', true);
param -> SetDefaultValue ("mm");
param -> SetGuidance ("mm, cm, or m.");
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////// /vis~/draw/text /////
//draw \hline
//draw /vis~/draw/text & $x$, $y$, $z$, unit,
//draw font\_size, x\_offset, y\_offset, text &
//draw Draws text at $(x, y, z)$ with given parameters.
//draw Font size and offsets in pixels. \\%
command = new G4UIcommand ("/vis~/draw/text", this);
command -> SetGuidance
("Draws at (x, y, z) unit font_size x_offset y_offset text.");
command -> SetGuidance
("Font size and offsets in pixels.");
param = new G4UIparameter ("x", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("unit", 's', true);
param -> SetDefaultValue ("mm");
param -> SetGuidance ("mm, cm, or m.");
command -> SetParameter (param);
param = new G4UIparameter ("font_size", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("x_offset", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y_offset", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("text", 's', true);
param -> SetDefaultValue ("text");
command -> SetParameter (param);
fCommandList.append (command);
//
//////////////////////////////////// /vis~/draw/ghosts /////
command = new G4UIcommand ("/vis~/draw/ghosts", this);
command -> SetGuidance
(
"Adds to the current scene all ghost volumes"
);
param = new G4UIparameter ("ParticleName", 's', true);
param -> SetDefaultValue ("all");
command -> SetParameter (param);
fCommandList.append (command);
/******************************** UNDER DEVELOPMENT ?????????????
////////////////////////// /vis~/draw/volume /////
//??draw \hline
//??draw /vis~/draw/volume & name &
//??draw Clears the current scene, makes a new one consisting of the
//??draw physical volume ``name'' and
//??draw draws it in the current view, marking all other views of this scene
//??draw as needing refreshing. \\%
command = new G4UIcommand ("/vis~/draw/volume", this);
command -> SetGuidance
(
"Clears the current scene, makes a new one consisting of the "
"physical volume \"name\" and "
"draws it in the current view, marking all other views of this scene "
"as needing refreshing."
);
param = new G4UIparameter ("Physical volume name", 's', true);
param -> SetDefaultValue ("__none__");
command -> SetParameter (param);
fCommandList.append (command);
**************************************************************/
}
void G4VisManMessenger::DoCommandDraw (const G4String& commandPath,
G4String& newValues) {
///////////////////////////////////////// /vis~/draw/axes ////
if (commandPath == "/vis~/draw/axes") {
if (ViewValid ()) {
G4double x0, y0, z0;
G4double length ;
G4String unitString;
const char* aString = newValues;
istrstream is((char*) aString);
is >> x0 >> y0 >> z0 >> length >> unitString;
G4double unit = G4UnitDefinition::GetValueOf (unitString);
x0 *= unit; y0 *= unit; z0 *= unit; length *= unit;
G4Polyline x_axis, y_axis, z_axis;
G4Colour cx(1.0, 0.0, 0.0); // color for x-axis
G4Colour cy(0.0, 1.0, 0.0); // color for y-axis
G4Colour cz(0.0, 0.0, 1.0); // color for z-axis
G4VisAttributes ax(cx); // VA for x-axis
G4VisAttributes ay(cy); // VA for y-axis
G4VisAttributes az(cz); // VA for z-axis
//----- Draw x-axis
x_axis.SetVisAttributes(&ax);
x_axis.append (G4Point3D (x0*unit,y0,z0));
x_axis.append ( G4Point3D ( (x0 +length) , y0, z0 ) );
fpVMan -> Draw (x_axis);
x_axis.clear ();
//----- Draw y-axis
y_axis.SetVisAttributes(&ay);
y_axis.append (G4Point3D (x0,y0,z0));
y_axis.append ( G4Point3D ( x0 , (y0 +length ) , z0 ) );
fpVMan -> Draw (y_axis);
y_axis.clear ();
//----- Draw z-axis
z_axis.SetVisAttributes(&az);
z_axis.append (G4Point3D (x0,y0,z0));
z_axis.append ( G4Point3D ( x0 , y0 , ( z0 +length ) ) );
fpVMan -> Draw (z_axis);
z_axis.clear ();
}
}
///////////////////////////////////////// /vis~/draw/text ////
if (commandPath == "/vis~/draw/text") {
if (ViewValid ()) {
G4double x, y, z;
G4double font_size, x_offset, y_offset;
G4String unitString, textString;
const char* aString = newValues;
istrstream is((char*) aString);
is >> x >> y >> z >> unitString
>> font_size >> x_offset >> y_offset >> textString;
G4double unit = G4UnitDefinition::GetValueOf (unitString);
x *= unit; y *= unit; z *= unit;
G4Text g4Text (textString, G4Point3D (x, y, z));
g4Text.SetScreenSize (font_size);
g4Text.SetOffset (x_offset, y_offset);
fpVMan -> Draw (g4Text);
}
}
////////////////////////// /vis~/draw/volume /////
if (commandPath == "/vis~/draw/volume") {
// Find physical_volume.
G4String name;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> name;
G4cout << "/vis~/draw/volume: requested name is " << name;
G4cout << "\n...but this command is \"UNDER DEVELOPMENT\"!";
G4cout << endl;
}
////////////////////////// /vis~/draw/ghosts /////
if (commandPath == "/vis~/draw/ghosts") {
// preliminaries
G4VisManager* theVisManager;
if(!(theVisManager= G4VisManager::GetInstance())) {
G4cout<< "grafic system not yet avaliable." << endl;
return;
}
G4GlobalFastSimulationManager* theGlobalFastSimulationManager;
if(!(theGlobalFastSimulationManager =
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager())){
G4cout<< "WARNING: none G4GlobalFastSimulationManager" << endl;
return;
}
G4ParticleTable* theParticleTable=G4ParticleTable::GetParticleTable();
G4SceneData& currentScene = theVisManager -> SetCurrentSceneData ();
// Ok, lets look on the parameters
if(newValues=="all") {
G4FlavoredParallelWorld* CurrentFlavoredWorld;
for (G4int iParticle=0; iParticle<theParticleTable->entries();
iParticle++)
if(CurrentFlavoredWorld=theGlobalFastSimulationManager->
GetFlavoredWorldForThis(theParticleTable->
GetParticle(iParticle)))
currentScene.AddRunDurationModel
(new G4FlavoredParallelWorldModel (CurrentFlavoredWorld));
G4cout << "Ghosts added to the Scene, refresh the view to see it."
<< endl;
return;
}
G4ParticleDefinition* currentParticle =
theParticleTable->FindParticle(newValues);
if (currentParticle == NULL) {
G4cout << newValues << ": not found this particle name!" << endl;
return;
}
G4FlavoredParallelWorld* worldForThis;
if(worldForThis=theGlobalFastSimulationManager->
GetFlavoredWorldForThis(currentParticle)) {
currentScene.AddRunDurationModel
(new G4FlavoredParallelWorldModel (worldForThis));
G4cout << "Ghosts added to the Scene, refresh the view to see it."
<< endl;
}
else G4cout << "There are no ghosts for "<<newValues<<endl;
}
}
@@ -0,0 +1,434 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessExpert.cc,v 2.4 1998/07/16 02:06:08 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Expert sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4Polyline.hh"
#include "G4Square.hh"
#include "G4Circle.hh"
#include "G4Text.hh"
#include "G4Polymarker.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "Randomize.hh"
#include "G4Vector3D.hh"
#include "G4Point3D.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4ios.hh"
void G4VisManMessenger::AddCommandExpert () {
G4UIcommand* command;
G4UIparameter* param;
//////////////////////////////////////////////////// /vis~/expert/... ////
//vis \hline
//vis /vis~/expert/ &&
//vis ...menu of expert commands. \\%
command = new G4UIcommand ("/vis~/expert/", this);
command -> SetGuidance
(
"...menu of expert commands."
);
fCommandList.append (command);
//////////////////////////////////////// /vis~/expert/draw_circle ////
//expert \hline
//expert /vis~/expert/draw\_circle & $x$, $y$, $z$, $size$ &
//expert Specify coordinates and world size. \\%
command = new G4UIcommand ("/vis~/expert/draw_circle", this);
command -> SetGuidance ("Specify coordinates x, y, z and world size");
param = new G4UIparameter ("x", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("size", 'd', true);
param -> SetDefaultValue (10.);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/expert/draw_line ////
//expert \hline
//expert /vis~/expert/draw\_line & $x_0$, $y_0$, $z_0$, $x_1$, $y_1$, $z_1$ &
//expert Specify coordinates of start and end. \\%
command = new G4UIcommand ("/vis~/expert/draw_line", this);
command -> SetGuidance ("Specify coordinates x0, y0, z0, x1, y1 and z1");
param = new G4UIparameter ("x0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z0", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("x1", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y1", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z1", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////// /vis~/expert/draw_marks_and_show ////
//expert \hline
//expert /vis~/expert/ draw\_marks\_and\_show & $x$, $y$, $z$, $size$ &
//expert Specify coordinates and world size. \\%
command = new G4UIcommand ("/vis~/expert/draw_marks_and_show", this);
command -> SetGuidance ("Specify coordinates x, y, z and world size");
param = new G4UIparameter ("x", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("size", 'd', true);
param -> SetDefaultValue (10.);
command -> SetParameter (param);
fCommandList.append (command);
/***************************************
//////////////////////////////////// /vis~/expert/draw_physical_volume ////
//expert \hline
//expert /vis~/expert/ draw\_physical\_volume &&
//expert A test of
//expert {\tt G4VisManager::Draw (const G4VPhysicalVolume\&},... \\%
command = new G4UIcommand ("/vis~/expert/draw_physical_volume", this);
command -> SetGuidance
(
"A test of G4VisManager::Draw (const G4VPhysicalVolume&,..."
);
fCommandList.append (command);
**************************************/
//////////////////////////////////////// /vis~/expert/draw_polymarkers ////
//expert \hline
//expert /vis~/expert/draw\_polymarkers & $N_\mathrm{spirals}$ &
//expert Draws {\tt G4Polymarker}s in the form of coloured spirals. \\%
command = new G4UIcommand ("/vis~/expert/draw_polymarkers", this);
command -> SetGuidance ("Takes 2 parameters: no. of random sets, type");
param = new G4UIparameter ("no. of polymarker sets", 'i', true);
param -> SetDefaultValue (1);
command -> SetParameter (param);
param = new G4UIparameter ("marker type", 'i', true);
param -> SetGuidance ("0/1/2/3 = line/dots/circles/squares");
param -> SetDefaultValue (0);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/expert/draw_spiral ////
//expert \hline
//expert /vis~/expert/draw\_spiral &&
//expert Draws a {\tt G4Polyline} in the form of a spiral. \\%
command = new G4UIcommand ("/vis~/expert/draw_spiral", this);
command -> SetGuidance
(
"Draws a G4Polyline in the form of a spiral."
);
fCommandList.append (command);
//////////////////////////////////////// /vis~/expert/draw_spirals ////
//expert \hline
//expert /vis~/expert/draw\_spirals & $N_\mathrm{spirals}$ &
//expert Draws {\tt G4Polyline}s in the form of coloured spirals. \\%
command = new G4UIcommand ("/vis~/expert/draw_spirals", this);
command -> SetGuidance
(
"Draws G4Polylines in the form of coloured spirals."
);
param = new G4UIparameter ("no. of spirals", 'i', true);
param -> SetDefaultValue (1);
command -> SetParameter (param);
fCommandList.append (command);
//////////////////////////////////////// /vis~/expert/draw_square ////
//expert \hline
//expert /vis~/expert/draw\_square & $x$, $y$, $z$, $size$ &
//expert Specify coordinates and world size. \\%
command = new G4UIcommand ("/vis~/expert/draw_square", this);
command -> SetGuidance ("Specify coordinates x, y, z and world size");
param = new G4UIparameter ("x", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("y", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("z", 'd', true);
param -> SetDefaultValue (0.);
command -> SetParameter (param);
param = new G4UIparameter ("size", 'd', true);
param -> SetDefaultValue (10.);
command -> SetParameter (param);
fCommandList.append (command);
}
void G4VisManMessenger::DoCommandExpert (const G4String& commandPath,
G4String& newValues) {
/////////////////////////////////////// /vis~/expert/draw_circle ////
if (commandPath == "/vis~/expert/draw_circle") {
if (ViewValid ()) {
G4double x, y, z, worldSize;
const char* aString = newValues;
istrstream is((char*) aString); is >> x >> y >> z >> worldSize;
G4Circle circle = G4Circle(G4Point3D(x,y,z));
circle.SetWorldSize (worldSize);
G4Colour c(0.0, 1.0, 1.0 );
G4VisAttributes a(c);
circle.SetVisAttributes(&a);
fpVMan->Draw (circle);
}
}
/////////////////////////////////////// /vis~/expert/draw_line ////
if (commandPath == "/vis~/expert/draw_line") {
if (ViewValid ()) {
G4double x0, y0, z0;
G4double x1, y1, z1;
const char* aString = newValues;
istrstream is((char*) aString); is >> x0 >> y0 >> z0 >> x1 >> y1 >> z1 ;
G4Polyline line;
G4Colour c(1.0, 0.0, 0.0);
G4VisAttributes a(c);
line.SetVisAttributes(&a);
line.append (G4Point3D (x0,y0,z0));
line.append (G4Point3D (x1,y1,z1));
fpVMan -> Draw (line);
line.clear ();
}
}
//////////////////////////////////// /vis~/expert/draw_marks_and_show ////
if (commandPath == "/vis~/expert/draw_marks_and_show") {
const G4int num_each_marks = 100 ;
const G4double mark_step = 1000.0 ;
G4int i ;
G4double xx, yy, zz ;
if (ViewValid ()) {
G4double x, y, z, worldSize;
const char* aString = newValues;
istrstream is((char*) aString); is >> x >> y >> z >> worldSize;
// Draw squares
xx = x ; yy = y; zz = z ;
for( i = 0 ; i < num_each_marks ; i++ ) {
G4Square Square = G4Square(G4Point3D(xx,yy,zz));
Square.SetWorldSize (worldSize);
G4Colour c(1.0, 0.0, 0.0 );
G4VisAttributes a(c);
Square.SetVisAttributes(&a);
fpVMan->Draw (Square);
xx += mark_step ;
yy = y ; zz = z ;
} // for
// Draw circles
xx = x ; yy = y; zz = z ;
for( i = 0 ; i < num_each_marks ; i++ ) {
G4Circle circle = G4Circle (G4Point3D(xx,yy,zz));
circle.SetWorldSize (worldSize);
G4Colour c(0.0, 1.0, 1.0 );
G4VisAttributes a(c);
circle.SetVisAttributes(&a);
fpVMan->Draw (circle);
yy += mark_step ;
xx = x ; zz = z ;
} // for
// show
fpVMan -> Show ();
} // if
}
/****************************************
////////////////////////////////// /vis~/expert/draw_physical_volume ////
if (commandPath == "/vis~/expert/draw_physical_volume") {
if (ViewValid ()) {
// Given a physical volume...
G4VPhysicalVolume* pPhysVol =
fpVMan -> GetCurrentSceneData ().GetPhysicalVolume ();
// Given its transformation (normally, this would be known from
// the hits or digis information)...
HepRotation m;
Hep3Vector axis (G4UniformRand(), G4UniformRand(), G4UniformRand());
m.rotate (twopi * G4UniformRand(), axis);
G4double scale = 1000. * G4UniformRand();
Hep3Vector v (scale * G4UniformRand(),
scale * G4UniformRand(),
scale * G4UniformRand());
G4Transform3D transform (m, v);
// Change attributes - begin snippet.
// pPhysVol is the pointer to the physical volume.
// transform is the required G4Transform3D in the world
// coordinate system.
// Find the corresponding logical volume...
G4LogicalVolume* pLV = pPhysVol -> GetLogicalVolume ();
// Copy its visualization attributes into local variable...
const G4VisAttributes* pVA = pLV -> GetVisAttributes ();
G4VisAttributes attribs; // Default vis attributes.
if (pVA) attribs = *pVA; // Set to those of logical volume if any.
// Modify the visualization attributes...
G4double red = G4UniformRand();
G4double green = G4UniformRand();
G4double blue = G4UniformRand();
G4Colour c (red, green, blue);
attribs.SetColour (c);
attribs.SetForceSolid (true);
// Draw it...
fpVMan -> Draw (*pPhysVol, attribs, transform);
// Change attributes - end snippet.
}
}
***********************************/
/////////////////////////////////////// /vis~/expert/draw_polymarkers ////
if (commandPath == "/vis~/expert/draw_polymarkers") {
if (ViewValid ()) {
int nPolyMarkers, type;
const char* aString = newValues;
istrstream is((char*) aString) ;is >> nPolyMarkers >> type;
G4Polymarker::MarkerType realType;
switch (type) {
default:
case 0: realType = G4Polymarker::line; break;
case 1: realType = G4Polymarker::dots; break;
case 2: realType = G4Polymarker::circles; break;
case 3: realType = G4Polymarker::squares; break;
}
G4int i;
G4double a, fa, z, dz, t, dt = M_PI / 20.;
for (int iPolyMarker = 0; iPolyMarker < nPolyMarkers; iPolyMarker++) {
G4double x0 = 2000. * (G4UniformRand() - 0.5);
G4double y0 = 2000. * (G4UniformRand() - 0.5);
G4double z0 = 2000. * (G4UniformRand() - 0.5);
a = 1000. * G4UniformRand();
fa = 0.99 + 0.01 * G4UniformRand();
z = 500. * (G4UniformRand() - 0.5);
dz = 50. * (G4UniformRand() - 0.5);
G4Polymarker polymarker;
G4int nPoints = G4int (100 * G4UniformRand());
G4double tStart = twopi * G4UniformRand();
for (i = 0, t = tStart; i < nPoints; t += dt, a *= fa, z += dz, i++) {
polymarker.append (G4Point3D (x0 + a * cos (t),
y0 + a * sin (t), z0 + z));
}
G4double red = G4UniformRand();
G4double green = G4UniformRand();
G4double blue = G4UniformRand();
G4Colour c (red, green, blue);
G4VisAttributes a(c);
polymarker.SetVisAttributes(&a);
polymarker.SetMarkerType (realType);
fpVMan -> Draw (polymarker);
}
}
}
/////////////////////////////////////// /vis~/expert/draw_spiral ////
if (commandPath == "/vis~/expert/draw_spiral") {
if (ViewValid ()) {
G4Polyline line;
G4double t = 0., dt = M_PI / 50.;
G4double a = 2000., fa = 0.999;
G4double z = -500., dz = 1.;
for (int i = 0; i < 1000; t += dt, a *= fa, z += dz, i++) {
line.append (G4Point3D (a * cos (t), a * sin (t), z));
}
fpVMan -> Draw (line);
}
}
/////////////////////////////////////// /vis~/expert/draw_spirals ////
if (commandPath == "/vis~/expert/draw_spirals") {
if (ViewValid ()) {
int nSpirals;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> nSpirals;
G4int i;
G4double a, fa, z, dz, t, dt = M_PI / 50.;
G4Polyline line;
for (int iSpiral = 0; iSpiral < nSpirals; iSpiral++) {
G4double x0 = 2000. * (G4UniformRand() - 0.5);
G4double y0 = 2000. * (G4UniformRand() - 0.5);
G4double z0 = 2000. * (G4UniformRand() - 0.5);
a = 1000. * G4UniformRand();
fa = 0.9985 + 0.001 * G4UniformRand();
z = 500. * (G4UniformRand() - 0.5);
dz = 5. * (G4UniformRand() - 0.5);
G4int nPoints = G4int (1000 * G4UniformRand());
G4double tStart = twopi * G4UniformRand();
for (i = 0, t = tStart; i < nPoints; t += dt, a *= fa, z += dz, i++) {
line.append (G4Point3D (x0 + a * cos (t), y0 + a * sin (t), z0 + z));
}
G4Colour c (G4UniformRand(), G4UniformRand(), G4UniformRand());
G4VisAttributes a(c);
line.SetVisAttributes(&a);
fpVMan -> Draw (line);
line.clear ();
}
}
}
/////////////////////////////////////// /vis~/expert/draw_square ////
if (commandPath == "/vis~/expert/draw_square") {
if (ViewValid ()) {
G4double x, y, z, worldSize;
const char* aString = newValues;
istrstream is((char*) aString); is >> x >> y >> z >> worldSize;
G4Square Square = G4Square (G4Point3D (x, y, z));
// Set attributes - begin snippet.
Square.SetWorldSize (worldSize);
G4Colour c (1.0, 0.0, 0.0 );
G4VisAttributes a(c);
Square.SetVisAttributes(&a);
// Set attributes - end snippet.
fpVMan->Draw (Square);
}
}
}
@@ -0,0 +1,78 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessLights.cc,v 2.3 1998/07/13 17:12:35 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Lights sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4ios.hh"
void G4VisManMessenger::AddCommandLights () {
G4UIcommand* command;
G4UIparameter* param;
/////////////////////////////////////////////// /vis~/lights/direction ////
//lights \hline
//lights /vis~/lights/direction & $\theta$ $\phi$ &
//lights Set direction from target to light as
//lights $\theta$, $\phi$ (in degrees). \\%
command = new G4UIcommand ("/vis~/lights/direction", this);
command -> SetGuidance
(
"Set direction from target to light as "
"theta, phi (in degrees)."
);
param = new G4UIparameter ("theta", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (0.0);
command -> SetParameter (param);
param = new G4UIparameter ("phi", 'd', true);
param -> SetGuidance ("degrees");
param -> SetDefaultValue (0.0);
command -> SetParameter (param);
fCommandList.append (command);
}
void G4VisManMessenger::DoCommandLights (const G4String& commandPath,
G4String& newValues) {
//////////////////////////////////////// /vis~/lights/direction ////
if (commandPath == "/vis~/lights/direction") {
G4double theta, phi ;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> theta >> phi;
theta = theta * deg;
phi = phi * deg;
G4double x = sin (theta) * cos (phi);
G4double y = sin (theta) * sin (phi);
G4double z = cos (theta);
G4Vector3D lightpointDirection (x, y, z);
G4ViewParameters& viewParams = fpVMan -> SetCurrentViewParameters();
viewParams.SetLightpointDirection (lightpointDirection);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Lightpoint direction set to " << lightpointDirection << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
if (ViewValid ()) {
fpVMan -> GetCurrentView () -> ClearView (); // Clears buffer only.
fpVMan -> Draw ();
fpVMan -> Show ();
}
}
}
@@ -0,0 +1,678 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessSet.cc,v 2.5 1998/07/19 05:53:54 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
// Set sub-menu.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
void G4VisManMessenger::AddCommandSet () {
G4UIcommand* command;
G4UIparameter* param;
/////////////////////////////////////////// /vis~/set/cull_by_density ////
//set \hline
//set /vis~/set/cull\_by\_density & choice, density &
//set Cull (i.e., do not Draw) geometry objects with density less
//set than specified --- on/off and density (g / cm3). \\%
command = new G4UIcommand ("/vis~/set/cull_by_density", this);
command -> SetGuidance
(
"Cull (i.e., do not Draw) geometry objects with density less"
"\nthan specified - on/off and density (g / cm3)."
);
param = new G4UIparameter ("Selector", 'c', true);
param -> SetDefaultValue ("?");
command -> SetParameter (param);
param = new G4UIparameter ("density", 'd', true);
param -> SetDefaultValue (0.01);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/drawing_style ////
//set \hline
//set /vis~/set/drawing\_style & choice &
//set Style of drawing (wireframe, etc.). \\%
command = new G4UIcommand ("/vis~/set/drawing_style", this);
command -> SetGuidance
(
"Style of drawing (wireframe, etc.)."
);
param = new G4UIparameter ("Style selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/marker_choices ////
//set \hline
//set /vis~/set/marker\_choices & choice &
//set Choices for marker drawing (hidden by surfaces, etc.). \\%
command = new G4UIcommand ("/vis~/set/marker_choices", this);
command -> SetGuidance
(
"Chioces for marker drawing (hidden by surfaces, etc.)."
);
param = new G4UIparameter ("Style selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/rep_style ////
//set \hline
//set /vis~/set/rep\_style & choice &
//set Style of graphics representation for geometrical volumes
//set (polyhedron, NURBS,...). \\%
command = new G4UIcommand ("/vis~/set/rep_style", this);
command -> SetGuidance
(
"Style of graphics representation for geometrical volumes "
"(polyhedron, NURBS,...)."
);
param = new G4UIparameter ("Style selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/scene ////
//set \hline
//set /vis~/set/scene & choice &
//set Several ways of setting the scene.
//set For example, choosing a physical volume. \\%
command = new G4UIcommand ("/vis~/set/scene", this);
command -> SetGuidance
(
"Several ways of setting the scene."
" For example, choosing a physical volume."
);
param = new G4UIparameter ("Selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/section_plane ////
//set \hline
//set /vis~/set/section & choice, plane &
//set Set plane for drawing section (DCUT). Specify plane by
//set x y z units nx ny nz, e.g., for a y-z plane at x = 1 cm:
//set /vis~/set/section\_plane on 1 0 0 cm 1 0 0 \\%
command = new G4UIcommand ("/vis~/set/section_plane", this);
command -> SetGuidance
(
"Set plane for drawing section (DCUT). Specify plane by"
"\nx y z units nx ny nz, e.g., for a y-z plane at x = 1 cm:"
"\n/vis~/set/section_plane on 1 0 0 cm 1 0 0"
);
param = new G4UIparameter ("Selector", 'c', true);
param -> SetDefaultValue ("?");
command -> SetParameter (param);
param = new G4UIparameter ("x", 'd', true);
param -> SetDefaultValue (0);
param -> SetGuidance ("Coordinate of point on the plane.");
command -> SetParameter (param);
param = new G4UIparameter ("y", 'd', true);
param -> SetDefaultValue (0);
param -> SetGuidance ("Coordinate of point on the plane.");
command -> SetParameter (param);
param = new G4UIparameter ("z", 'd', true);
param -> SetDefaultValue (0);
param -> SetGuidance ("Coordinate of point on the plane.");
command -> SetParameter (param);
param = new G4UIparameter ("units", 's', true);
param -> SetDefaultValue ("mm");
param -> SetGuidance ("mm, cm, or m.");
command -> SetParameter (param);
param = new G4UIparameter ("nx", 'd', true);
param -> SetDefaultValue (1);
param -> SetGuidance ("Component of plane normal.");
command -> SetParameter (param);
param = new G4UIparameter ("ny", 'd', true);
param -> SetDefaultValue (0);
param -> SetGuidance ("Component of plane normal.");
command -> SetParameter (param);
param = new G4UIparameter ("nz", 'd', true);
param -> SetDefaultValue (0);
param -> SetGuidance ("Component of plane normal.");
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/sides ////
//set \hline
//set /vis~/set/sides & n &
//set Number of sides per circle in polygon approximation. \\%
command = new G4UIcommand ("/vis~/set/sides", this);
command -> SetGuidance
(
"Number of sides per circle in polygon approximation."
);
param = new G4UIparameter ("No. of sides", 'i', true);
param -> SetDefaultValue (24);
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/verbose //////
//set \hline
//set /vis~/set/verbose & integer &
//set Controls amount of printing (0 = quiet). \\%
command = new G4UIcommand ("/vis~/set/verbose", this);
command -> SetGuidance
(
"Controls amount of printing (0 = quiet)."
);
param = new G4UIparameter ("Verbosity level", 'i', true);
param -> SetDefaultValue (-1);
param -> SetGuidance ("0: quiet, >0: verbose");
command -> SetParameter (param);
fCommandList.append (command);
/////////////////////////////////////////// /vis~/set/view /////////
//set \hline
//set /vis~/set/view & choice &
//set Make this view current. \\%
command = new G4UIcommand ("/vis~/set/view", this);
command -> SetGuidance
(
"Make this view current."
);
param = new G4UIparameter ("View selector", 'i', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fCommandList.append (command);
}
void G4VisManMessenger::DoCommandSet (const G4String& commandPath,
G4String& newValues) {
/////////////////////////////////////////// /vis~/set/cull_by_density ////
if (commandPath == "/vis~/set/cull_by_density") {
G4String choice;
G4double density; // Units in this section are g / cm3 - WARNING!!!
const char* t = newValues;
istrstream is ((char*)t); is >> choice >> density;
G4int iSelector = -1;
if (choice.compareTo ("off",RWCString::ignoreCase) == 0) iSelector = 0;
if (choice.compareTo ("on",RWCString::ignoreCase) == 0) iSelector = 1;
if (iSelector < 0) {
G4cout << "Choice not recognised (on/off)." << endl;
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
G4cout << "Culling by density is currently: ";
if (getVP.IsDensityCulling ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nDensity cut is currently: "
<< getVP.GetVisibleDensity () * cm3 / g << " g/cm3.";
G4cout << endl;
}
else {
G4ViewParameters& setVP = fpVMan -> SetCurrentViewParameters ();
switch (iSelector) {
case 0:
setVP.SetDensityCulling (false);
break;
case 1:
setVP.SetDensityCulling (true);
setVP.SetVisibleDensity (density * g / cm3);
break;
default: G4cout << "Choice not recognised (on/off).\n"; break;
}
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
G4cout << "Culling by density is now: ";
if (getVP.IsDensityCulling ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nDensity cut is now: "
<< getVP.GetVisibleDensity () * cm3 / g << " g/cm3.";
G4cout << endl;
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (getVP);
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
/////////////////////////////////////////// /vis~/set/drawing_style ////
if (commandPath == "/vis~/set/drawing_style") {
G4int iStyle;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iStyle;
if (iStyle < 0 || iStyle > 3) {
G4cout << "Available drawing styles:";
G4cout << "\n 0) wireframe";
G4cout << "\n 1) hidden line removal";
G4cout << "\n 2) solid (hidden surface removal)";
G4cout << "\n 3) solids with edges (hidden line, hidden surface removal)";
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
//if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "\nDrawing style is currently"
<< getVP.GetDrawingStyle ();
G4cout << "\nCulling is currently ";
if (getVP.IsCulling ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nCulling of invisible objects is currently ";
if (getVP.IsCullingInvisible ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nDensity culling is currently ";
if (getVP.IsDensityCulling ()) {
G4cout << "on - invisible if density less than "
<< getVP.GetVisibleDensity () / (1. * g / cm3) << " g cm^-3";
}
else G4cout << "off";
G4cout << "\nCovered daughters are ";
if (getVP.IsCullingCovered ()) {
G4cout << "not";
}
G4cout << " drawn.";
G4cout << "\nTo override culling, /vis~/set/culling off."
"\nTo set/reset culling of invisible objects,"
"\n/vis~/set/cull_invisible_objects on/off."
"\nTo reset density culling, /vis~/set/cull_by_density off."
"\nTo set density culling, e.g., /vis~/set/cull_by_density on 0.01."
<< endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
//}
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
G4ViewParameters& setVP = fpVMan -> SetCurrentViewParameters ();
switch (iStyle) {
default:
case 0:
setVP.SetDrawingStyle (G4ViewParameters::wireframe);
break;
case 1:
setVP.SetDrawingStyle (G4ViewParameters::hlr);
break;
case 2:
setVP.SetDrawingStyle (G4ViewParameters::hsr);
break;
case 3:
setVP.SetDrawingStyle (G4ViewParameters::hlhsr);
break;
}
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
//if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Drawing style changed to "
<< getVP.GetDrawingStyle ();
G4cout << "\nCulling is now ";
if (getVP.IsCulling ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nCulling of invisible objects is now ";
if (getVP.IsCullingInvisible ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nDensity culling is now ";
if (getVP.IsDensityCulling ()) {
G4cout << "on - invisible if density less than "
<< getVP.GetVisibleDensity () / (1. * g / cm3) << " g cm^-3";
}
else G4cout << "off";
G4cout << "\nCovered daughters are ";
if (getVP.IsCullingCovered ()) {
G4cout << "not";
}
G4cout << " drawn.";
G4cout << "\nTo override culling, /vis~/set/culling off."
"\nTo set/reset culling of invisible objects,"
"\n/vis~/set/cull_invisible_objects on/off."
"\nTo reset density culling, /vis~/set/cull_by_density off."
"\nTo set density culling, e.g., /vis~/set/cull_by_density on 0.01."
<< endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
//}
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (getVP);
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
//////////////////////////////////////// /vis~/set/marker_choices ////
if (commandPath == "/vis~/set/marker_choices") {
G4int iChoice;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iChoice;
if (iChoice < 0 || iChoice > 1) {
G4cout << "Available marker choices:";
G4cout << "\n 0) not hidden";
G4cout << "\n 1) hidden by surfaces";
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
//if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "\nMarker choice is currently: ";
if (getVP.IsMarkerNotHidden ()) G4cout << "not";
G4cout << " hidden by surfaces.";
//}
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
G4ViewParameters& setVP = fpVMan -> SetCurrentViewParameters ();
switch (iChoice) {
default:
case 0:
setVP.SetMarkerNotHidden ();
break;
case 1:
setVP.SetMarkerHidden ();
break;
}
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
//if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Marker choice is now: ";
if (getVP.IsMarkerNotHidden ()) G4cout << "not";
G4cout << " hidden by surfaces." << endl;
//}
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (getVP);
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
/////////////////////////////////////////// /vis~/set/section_plane ////
if (commandPath == "/vis~/set/section_plane") {
G4String choice, unit;
G4double x, y, z, nx, ny, nz;
const char* t = newValues;
istrstream is ((char*)t); is >> choice >> x >> y >> z >> unit
>> nx >> ny >> nz;
G4int iSelector = -1;
if (choice.compareTo ("off",RWCString::ignoreCase) == 0) iSelector = 0;
if (choice.compareTo ("on",RWCString::ignoreCase) == 0) iSelector = 1;
if (iSelector < 0) {
G4cout << "Choice not recognised (on/off)." << endl;
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
G4cout << "Section drawing is currently: ";
if (getVP.IsSection ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nSection plane is currently: "
<< getVP.GetSectionPlane ();
G4cout << endl;
}
else {
G4ViewParameters& setVP = fpVMan -> SetCurrentViewParameters ();
G4double F;
switch (iSelector) {
case 0:
setVP.UnsetSectionPlane ();
break;
case 1:
F = G4UnitDefinition::GetValueOf (unit);
x *= F; y *= F; z *= F;
setVP.SetSectionPlane (G4Plane3D (G4Normal3D (nx, ny, nz),
G4Point3D (x, y, z)));
setVP.SetViewpointDirection (G4Normal3D (nx, ny, nz));
break;
default: G4cout << "Choice not recognised (on/off).\n"; break;
}
const G4ViewParameters& getVP = fpVMan -> GetCurrentViewParameters ();
G4cout << "Section drawing is now: ";
if (getVP.IsSection ()) G4cout << "on";
else G4cout << "off";
G4cout << "\nSection plane is now: "
<< getVP.GetSectionPlane ();
G4cout << endl;
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (getVP);
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
/////////////////////////////////////////// /vis~/set/sides ////
if (commandPath == "/vis~/set/sides") {
G4int nSides;
const char* t = newValues;
istrstream is ((char*)t); is >> nSides;
G4cout << "Number of sides per circle in polygon approximation is "
<< nSides << endl;
fpVMan -> SetCurrentViewParameters ().SetNoOfSides (nSides);
}
/////////////////////////////////////////// /vis~/set/rep_style ////
if (commandPath == "/vis~/set/rep_style") {
G4int iStyle;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iStyle;
if (iStyle < 0 || iStyle > 1) {
G4cout << "Available representation styles:";
G4cout << "\n 0) polyhedron";
G4cout << "\n 1) NURBS";
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
G4ViewParameters::RepStyle repStyle;
switch (iStyle) {
default:
case 0: repStyle = G4ViewParameters::polyhedron; break;
case 1: repStyle = G4ViewParameters::nurbs; break;
}
fpVMan -> SetCurrentViewParameters ().SetRepStyle (repStyle);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Representation style changed to " << repStyle << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
G4VView* pView = fpVMan -> GetCurrentView ();
if (pView) {
// Copy current view parameters into current view.
pView -> SetViewParameters (fpVMan -> GetCurrentViewParameters ());
// Recalculate projection matrices, etc.
pView -> SetView ();
}
G4cout << "Issue Draw or refresh to see effect." << endl;
}
}
/////////////////////////////////// /vis~/set/scene ////
if (commandPath == "/vis~/set/scene") {
static G4int iState = 0;
static G4int nOptions = 2;
G4int iSelector;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iSelector;
switch (iState) {
case 0:
if (iSelector < 0 || iSelector > nOptions) {
G4cout << "Available options:";
G4cout << "\n 0) reset selection algorithm";
G4cout << "\n 1) select physical volume";
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
switch (iSelector) {
default:
case 0:
G4cout << "Resetting from state " << iState << endl;
iState = 0; nOptions = 2;
break;
case 1:
G4cout << "Option " << iSelector
<< " selected from state " << iState << endl;
iState = 1; nOptions = 1;
break;
}
}
break;
case 1:
if (iSelector < 0 || iSelector > nOptions) {
G4cout << "Available options:";
G4cout << "\n 0) reset selection algorithm";
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
switch (iSelector) {
default:
case 0:
G4cout << "Resetting from state " << iState << endl;
iState = 0; nOptions = 2;
break;
}
}
break;
}
/****************************************************
cin.tie (&G4cout); // Tie streams together so output is
// flushed before any input.
G4cout << "Temporary algorithm..." << endl;
G4VPhysicalVolume* pVPV =
fpVMan -> GetCurrentSceneData ().GetPhysicalVolume ();
G4VPhysicalVolume* pNewVPV = 0;
if (pVPV) {
G4cout << "Current volume is " << pVPV -> GetName () << endl;
G4VPhysicalVolume* pMother = pVPV -> GetMother ();
if (pMother) {
char c;
do {
G4cout << "Its mother is " << pMother -> GetName ()
<< ". Select? [y/n]: ";
c = cin.get ();
if (c != '\n') while (cin.get () != '\n'); // Read on to newline.
} while (c != 'y' && c != 'Y' &&
c != 'n' && c != 'N');
if (c == 'y' || c == 'Y') {
pNewVPV = pMother;
}
}
if (!pNewVPV) {
G4int nDaughters = pVPV -> GetLogicalVolume () -> GetNoDaughters ();
G4int iDaughter;
if (nDaughters) {
do {
G4cout << "It has " << nDaughters << " daughters. Select [0-"
<< nDaughters - 1 << "] (<0 to abandon): ";
cin >> iDaughter;
while (cin.get () != '\n'); // Read on to newline.
} while (iDaughter >= nDaughters);
if (iDaughter >= 0) {
G4VPhysicalVolume* pDaughter =
pVPV -> GetLogicalVolume () -> GetDaughter (iDaughter);
pNewVPV = pDaughter;
}
}
}
if (pNewVPV) {
fpVMan -> AddToCurrentSceneData (pNewVPV);
fpVMan -> Clear (); // Comprehensive clear.
fpVMan -> Draw ();
fpVMan -> Show ();
}
else {
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Nothing selected; nothing changed." << endl;
}
}
}
else {
G4cerr << "No physical volume available." << endl;
}
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentScene ();
}
*********************************************************/
}
/////////////////////////////////////////// /vis~/set/verbose //////
if (commandPath == "/vis~/set/verbose") {
G4int vLevel;
const char* t = newValues;
istrstream is ((char*)t); is >> vLevel;
if (vLevel < 0 ) {
G4cout << "Verbosity is " << fpVMan -> GetVerboseLevel () << endl;
}
else {
fpVMan -> SetVerboseLevel (vLevel);
G4cout << "Verbosity set to " << fpVMan -> GetVerboseLevel () << endl;
}
}
/////////////////////////////////////////// /vis~/set/view /////////
if (commandPath == "/vis~/set/view") {
// Make List of available views.
RWTPtrOrderedVector<G4VView> vList;
const G4SceneList& gml = fpVMan -> GetAvailableScenes ();
G4int nViewTotal = 0;
G4int iGM, nScenes = gml.entries ();
for (iGM = 0; iGM < nScenes; iGM++) {
const G4VViewList& views = gml [iGM] -> GetViewList ();
int nViews = views.entries ();
for (int iView = 0; iView < nViews; iView++) {
G4VView* pView = views [iView];
vList.append (pView);
nViewTotal++;
}
}
if (nViewTotal == 0) {
G4cerr << "No views to select." << endl;
}
else {
// Select view and make it current.
G4int iSelect;
const char* aString = newValues;
istrstream is((char*) aString) ; is >> iSelect;
if (iSelect < 0 || iSelect >= nViewTotal) {
G4cout << "Available views:";
for (int iView = 0; iView < nViewTotal; iView++) {
const G4VView* pView = vList [iView];
const G4VScene* pScene = pView -> GetScene ();
const G4VGraphicsSystem* pSystem = pScene -> GetGraphicsSystem ();
G4cout << "\n " << iView << ") " << pView -> GetName ();
}
G4cout << "\nChoose by specifying integer parameter.";
G4cout << endl;
}
else {
G4VView* pView = vList[iSelect];
fpVMan -> SetCurrentView (pView);
if (fpVMan -> GetVerboseLevel () > 0) {
G4cout << "Current view now " << pView -> GetName () << endl;
if (fpVMan -> GetVerboseLevel () > 1) {
fpVMan -> PrintCurrentView ();
}
}
}
}
}
}
@@ -0,0 +1,119 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManMessenger.cc,v 2.6 1998/08/09 17:54:42 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Visualization Manager Messenger - John Allison 22nd July 1996.
#include "G4VisManMessenger.hh"
#include "G4VisManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
G4VisManMessenger::G4VisManMessenger (G4VisManager* pVMan):
fpVMan (pVMan)
{
G4UIcommand* command;
G4UIparameter* param;
///////////////////////////////////////////////// /vis~/... ////
command = new G4UIcommand ("/vis~/", this);
command -> SetGuidance ("Deprecated visualization commands.");
fCommandList.append (command);
////////////////////////////////////////////// /vis~/*/... ////
AddCommandCamera (); // Define the /vis~/camera/ sub-commands.
// AddCommandClear (); // Define the /vis~/clear/ sub-commands.
// AddCommandCopy (); // Define the /vis~/copy/ sub-commands.
// AddCommandCreateScene (); // Define the /vis~/create_scene/ sub-commands.
AddCommandCreateView (); // Define the /vis~/create_view/ sub-commands.
AddCommandDraw (); // Define the /vis~/draw/ sub-commands.
AddCommandLights (); // Define the /vis~/lights/ sub-commands.
// AddCommandPrint (); // Define the /vis~/print/ sub-commands.
// AddCommandRefresh (); // Define the /vis~/refresh/ sub-commands.
AddCommandSet (); // Define the /vis~/set/ sub-commands.
// AddCommandShow (); // Define the /vis~/show/ sub-commands.
AddCommandExpert (); // Define the /vis~/expert/ sub-commands.
}
G4VisManMessenger::~G4VisManMessenger () {
fCommandList.clearAndDestroy ();
}
void G4VisManMessenger::SetNewValue (G4UIcommand* command, G4String newValues)
{
G4String commandPath = command -> GetCommandPath ();
if (commandPath.contains ("/vis~/camera/")) {
DoCommandCamera (commandPath, newValues);
}
// if (commandPath.contains ("/vis~/clear/")) {
// DoCommandClear (commandPath, newValues);
// }
// if (commandPath.contains ("/vis~/copy/")) {
// DoCommandCopy (commandPath, newValues);
// }
// if (commandPath.contains ("/vis~/create_scene/")) {
// DoCommandCreateScene (commandPath, newValues);
// }
if (commandPath.contains ("/vis~/create_view/")) {
DoCommandCreateView (commandPath, newValues);
}
if (commandPath.contains ("/vis~/draw/")) {
DoCommandDraw (commandPath, newValues);
}
if (commandPath.contains ("/vis~/lights/")) {
DoCommandLights (commandPath, newValues);
}
// if (commandPath.contains ("/vis~/print/")) {
// DoCommandPrint (commandPath, newValues);
// }
// if (commandPath.contains ("/vis~/refresh/")) {
// DoCommandRefresh (commandPath, newValues);
// }
if (commandPath.contains ("/vis~/set/")) {
DoCommandSet (commandPath, newValues);
}
// if (commandPath.contains ("/vis~/show/")) {
// DoCommandShow (commandPath, newValues);
// }
if (commandPath.contains ("/vis~/expert/")) {
DoCommandExpert (commandPath, newValues);
}
}
G4String G4VisManMessenger::GetCurrentValue (G4UIcommand* command) {
return "";
}
G4bool G4VisManMessenger::ViewValid () {
if (fpVMan -> IsValidView ()) {
return true;
}
else {
G4cerr << "Invalid view (have you selected a graphics system?)" << endl;
return false;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,307 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisManagerRegisterMessengers.cc,v 2.10 1998/12/09 23:55:57 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// G4VisManager::RegisterMessengers - John Allison 30/July/1998.
#include "G4VisManager.hh"
#include "G4VVisCommand.hh"
#include "G4VisCommandsScene.hh"
#include "G4VisCommandsSceneAdd.hh"
#include "G4VisCommandsSceneInclude.hh"
#include "G4VisCommandsSceneHandler.hh"
#include "G4VisCommandsViewer.hh"
// OLD STYLE!!
#include "G4VisManMessenger.hh"
#include "G4VisCommandTemplates.hh"
#include "G4VisCommandsCamera.hh"
#include "G4VisCommandsClear.hh"
#include "G4VisCommandsCopy.hh"
#include "G4VisCommandsCreateScene.hh"
#include "G4VisCommandsCreateView.hh"
#include "G4VisCommandsDelete.hh"
#include "G4VisCommandsDraw.hh"
#include "G4VisCommandsLights.hh"
#include "G4VisCommandsPrint.hh"
#include "G4VisCommandsRefresh.hh"
#include "G4VisCommandsSet.hh"
#include "G4VisCommandsShow.hh"
#include "G4ios.hh"
#include <assert.h>
void G4VisManager::RegisterMessengers () {
/******************************************************************
(Extract for working note.)
Introduction
============
This note defines the concepts of scene, scene handler and viewers.
For reasons which are lost in history they correspond to confusingly
differently named objects in Geant4. What we would like to call a
scene is a G4SceneData object and a G4VScene object is a scene
handler. Similarly a viewer is represented by a G4VView object.
However, this is historical, and changing C++ names is a pain. I dont
plan to change names right now!!
The situation ca be summarised as follows:
Working Concept (Terms Used Below) Geant4 C++ Object
---------------------------------- -----------------
scene G4SceneData
scene handler Sub-class of G4VScene
viewer Sub-class of G4VView
Scenes
======
We introduce the concept of a graphics-system-independent scene, which
is a list of visualizable objects, such as detector components
(G4PhysicalVolumeModels), hits, trajectories. The G4VisManager
manages a list of scenes.
* means "not implemented yet".
/vis/scene/create [<scene-name>]
/vis/scene/list [-l] [<scene-name>]
/vis/scene/select [<scene-name>]
* /vis/scene/edit
/vis/scene/remove <scene-name>
/vis/scene/add/volume [<physical-volume-name>] [<copy-no>] [<depth>]
/vis/scene/add/ghosts [<particle>]
* /vis/scene/add/ghost [<particle>] [<physical-volume-name>]
[<copy-no>] [<depth>]
/vis/scene/include/hits [<sensitive-volume-name>] (argument not impl'd yet.)
/vis/scene/include/trajectories [<sensitive-volume-name>] (do.)
* /vis/scene/include/transientObjects
* /vis/scene/set/hitOption accumulate|byEvent
* /vis/scene/set/notifyOption immediate|delayed
* /vis/scene/set/modelingStyle [<modeling-style>]
* /vis/scene/notifyHandlers
Scene Handlers
==============
A scene handler is a graphics-system-specific thing that turns a scene
into something that the graphics system can understand.
The commands would look something like:
/vis/sceneHandler/create <graphics-system> [<scene-handler-name>]
/vis/sceneHandler/attach [<scene-name>]
/vis/sceneHandler/list
/vis/sceneHandler/select [<scene-handler-name>]
/vis/sceneHandler/remove <scene-handler-name>
* /vis/sceneHandler/processScene
* /vis/sceneHandler/notifyEndOfProcessiing
Viewers
=======
A viewer opens windows and draws to the screen, hardcopy, etc. It can
be dumb (a non-interactive window) or intelligent (respond to mouse
clicks, spawn other windows, change viewpoint, etc.).
/vis/viewer/create [<scene-handler>] [<viewer-name>]
/vis/viewer/list
/vis/viewer/select [<viewer-name>]
/vis/viewer/remove <viewer-name>
* /vis/viewer/set/style wireframe|surface|logical
* /vis/viewer/set/viewpoint
* /vis/viewer/set/notifyOption immediate|delayed
* /vis/viewer/notifyHandler
* /vis/viewer/clone
* /vis/viewer/update
Global Commands
===============
* /vis/copy/sceneAndView <from-viewer-name> <to-viewer-name>
Compound Commands
=================
* /vis/create/view OGLSXM
would be
/vis/scene/create
/vis/sceneHandler/create $1
/vis/sceneHandler/attach
/vis/viewer/create
and
* /vis/draw Calorimiter
would be
/vis/scene/add/volume $1
/vis/sceneHandler/processScene
/vis/sceneHandler/notifyEndOfProcessiing
/vis/viewer/update
or some such.
******************************************************************/
// Instantiate individual messengers/commands (usually one command
// per messenger).
//A The GEANT4 commands available with the GEANT4 Visualization
//A System.
// Introduction
//I The GEANT4 Visualization System consists of a Visualization
//I Manager and a Visualization Interface. The problem is to design
//I a set of commands which offer the GEANT4 user good functionality
//I and, at the same time, maximally exploit the power of modern
//I graphics systems. The chief concept is the scene, a
//I graphics-system-independent list of visualizable GEANT4 objects,
//I which can be rendered to any graphics system in a variety of
//I ways. If the graphics system has its own graphical database,
//I this is used.
G4VVisCommand::SetVisManager (this);
G4UIcommand* command;
command = new G4UIdirectory ("/vis/");
command -> SetGuidance ("Visualization commands.");
//S \subsection {Scenes}
//S
//S A GEANT4 scene is a set of visualizable objects which can be created,
//S edited and copied independent of any graphics system.
command = new G4UIdirectory ("/vis/scene/");
command -> SetGuidance ("Operations on Geant4 scenes.");
fMessengerList.append (new G4VisCommandSceneCreate);
fMessengerList.append (new G4VisCommandSceneList);
// fMessengerList.append (new G4VisCommandSceneNotifyHandlers); (Not ready!)
fMessengerList.append (new G4VisCommandSceneSelect);
fMessengerList.append (new G4VisCommandSceneRemove);
command = new G4UIdirectory ("/vis/scene/add/");
command -> SetGuidance ("Add model to current scene.");
fMessengerList.append (new G4VisCommandSceneAddVolume);
fMessengerList.append (new G4VisCommandSceneAddGhosts);
command = new G4UIdirectory ("/vis/scene/include/");
command -> SetGuidance ("Include drawing option in current scene.");
fMessengerList.append (new G4VisCommandSceneIncludeHits);
fMessengerList.append (new G4VisCommandSceneIncludeTrajectories);
command = new G4UIdirectory ("/vis/sceneHandler/");
command -> SetGuidance ("Operations on Geant4 scene handlers.");
fMessengerList.append (new G4VisCommandSceneHandlerAttach);
fMessengerList.append (new G4VisCommandSceneHandlerCreate);
fMessengerList.append (new G4VisCommandSceneHandlerList);
fMessengerList.append (new G4VisCommandSceneHandlerSelect);
fMessengerList.append (new G4VisCommandSceneHandlerRemove);
command = new G4UIdirectory ("/vis/viewer/");
command -> SetGuidance ("Operations on Geant4 viewers.");
fMessengerList.append (new G4VisCommandViewerCreate);
fMessengerList.append (new G4VisCommandViewerList);
fMessengerList.append (new G4VisCommandViewerSelect);
fMessengerList.append (new G4VisCommandViewerRemove);
// Camera - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandCamera>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCameraReset>);
// Clear - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandClear>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandClearScene>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandClearView>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandClearViewAndScene>);
// Copy - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandCopy>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCopyAll>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCopyScene>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCopyView>);
// Create Scene - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandCreateScene>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCreateSceneClear>);
// Create View - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandCreateView>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCreateViewNewScene>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandCreateViewNewView>);
// Delete - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandDelete>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandDeleteScene>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandDeleteView>);
// Draw - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandDraw>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandDrawCurrent>);
// Lights - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandLights>);
fMessengerList.append
(new G4VisButtonCommandMessenger <G4VisCommandLightsMoveWithCamera>);
// Print - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandPrint>);
// Refresh - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandRefresh>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandRefreshView>);
// Set - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandSet>);
fMessengerList.append
(new G4VisButtonCommandMessenger <G4VisCommandSetCulling>);
fMessengerList.append
(new G4VisButtonCommandMessenger <G4VisCommandSetCullCoveredDaughters>);
fMessengerList.append
(new G4VisButtonCommandMessenger <G4VisCommandSetCullInvisible>);
// Show - OLD STYLE!!
fMessengerList.append
(new G4VisCommandDirectoryMessenger <G4VisCommandShow>);
fMessengerList.append
(new G4VisSimpleCommandMessenger <G4VisCommandShowView>);
}
@@ -0,0 +1,79 @@
// This code implementation is the intellectual property of
// the RD44 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: G4VisToOldVisCommands.cc,v 1.1 1998/12/09 23:55:00 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Implements some /vis/ commands as /vis~/ temporarily.
// John Allison 9th December 1998.
#include "G4VisToOldVisCommands.hh"
#include "G4UImanager.hh"
#include "G4UIcommandTree.hh"
#include "G4UIdirectory.hh"
G4VisToOldVisCommands::G4VisToOldVisCommands () {
G4UIcommandTree* commandTree = G4UImanager::GetUIpointer () -> GetTree ();
G4UIcommandTree* oldVisCommandTree = commandTree -> GetTree ("/vis~/");
G4int nOldVisTreeEntries = oldVisCommandTree -> GetTreeEntry ();
int i;
for (i = 1; i <= nOldVisTreeEntries; i++) {
G4UIcommandTree* subTree = oldVisCommandTree -> GetTree (i);
G4String subTreeName = subTree -> GetPathName ();
G4String newDirectoryName = subTreeName.replace (0, 6, "/vis/");
newDirectoryName = newDirectoryName (0, newDirectoryName.last ('/') + 1);
// G4cout << "NewDirectoryName: " << newDirectoryName << endl;
new G4UIdirectory (newDirectoryName);
G4int nCommands = subTree -> GetCommandEntry ();
int j;
for (j = 1; j <= nCommands; j++) {
G4UIcommand* command = subTree -> GetCommand (j);
G4String commandPath = command -> GetCommandPath ();
// G4cout << "SubCommandPath: " << commandPath << endl;
G4String newCommandPath = commandPath.replace (0, 6, "/vis/");
// G4cout << "NewSubCommandPath: " << newCommandPath << endl;
G4UIcommand* newCommand = new G4UIcommand (newCommandPath, this);
newCommand -> SetRange (command -> GetRange ());
G4int nGuidances = command -> GetGuidanceEntries ();
int k;
for (k = 0; k < nGuidances; k++) {
newCommand -> SetGuidance (command -> GetGuidanceLine (k));
}
G4int nParameters = command -> GetParameterEntries ();
for (k = 0; k < nParameters; k++) {
newCommand -> SetParameter (command -> GetParameter (k));
}
}
}
}
G4VisToOldVisCommands::~G4VisToOldVisCommands () {}
void G4VisToOldVisCommands::SetNewValue
(G4UIcommand* command, G4String newValues) {
G4String commandPath = command -> GetCommandPath ();
if (commandPath == "/vis/create_view/new_graphics_system") {
G4cout <<
"Command superceded. Please use:"
"\n /vis/scene/create"
"\n /vis/sceneHandler/create " << newValues <<
"\n /vis/viewer/create"
"\nThis way you can also use \"/vis/scene/addVolume\" to select"
"\n sub-detector components. (The command is still available"
"\n as \"/vis~/create_view/new_graphics/system " << newValues <<
"\".)"
<< endl;
}
else {
G4String oldCommandPath = commandPath.replace (0, 5, "/vis~/");
G4UImanager::GetUIpointer () ->
ApplyCommand (oldCommandPath + " " + newValues);
}
}