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
+471
View File
@@ -0,0 +1,471 @@
// 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: G4GoScene.cc,v 2.3 1998/11/06 13:42:07 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo stored scene - creates Wo display lists.
//#define DEBUG
#ifdef G4VIS_BUILD_OPACS_DRIVER
//Co
#include <CPrinter.h>
#include <CString.h>
//Go
#include <Go.h>
//G4
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4Polyhedron.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Text.hh"
#include "G4NURBS.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4VPhysicalVolume.hh"
//This
#include "G4GoScene.hh"
static G4Transform3D transformation;
G4int G4GoScene::fSceneIdCount = 0;
G4int G4GoScene::fSceneCount = 0;
ONode G4GoScene::fGoNode = NULL;
OColormap G4GoScene::fOColormap = NULL;
/***************************************************************************/
G4GoScene::G4GoScene (
G4VGraphicsSystem& system,
const G4String& name
)
/***************************************************************************/
// Creator.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
:
G4VScene (system, fSceneIdCount++, name),
fSystem (system),
fRootGoNode (NULL),
nodeName (NULL)
/*.........................................................................*/
{
#ifdef DEBUG
G4cout << "G4GoScene::G4GoScene" << endl;
#endif
fSceneCount++;
}
/***************************************************************************/
G4GoScene::~G4GoScene (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(ONodeIsValid(fRootGoNode)==1) ONodeDelete (fRootGoNode); //fRootGoNode could be deleted by an XoCamera popup "Erase".
fRootGoNode = NULL;
fSceneCount--;
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polyline& line
)
/***************************************************************************/
// Method for handling G4Polyline objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polyline&) " << line.entries () << endl;
#endif
SetColour (GetColour(line));
int nPoints = line.entries ();
OPointList points;
points = OPointListCreate(nPoints);
for (int iPoint = 0; iPoint < nPoints; iPoint++) {
OPointListSetIthEntry (points,iPoint,
line(iPoint).x(),
line(iPoint).y(),
line(iPoint).z());
}
GoAddLinesToNode (fGoNode,points);
OPointListDelete (points);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polymarker& line
)
/***************************************************************************/
// Method for handling G4Polymarker objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polymarker&) " << line.entries () << endl;
#endif
SetColour (GetColour(line));
int nPoints = line.entries ();
OPointList points;
points = OPointListCreate(nPoints);
for (int iPoint = 0; iPoint < nPoints; iPoint++) {
OPointListSetIthEntry (points,iPoint,
line(iPoint).x(),
line(iPoint).y(),
line(iPoint).z());
}
GoAddMarkersToNode (fGoNode,points);
OPointListDelete (points);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Circle& circle
)
/***************************************************************************/
// Method for handling G4Circle objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(circle));
G4Point3D center = circle.GetPosition();
G4double radius = circle.GetWorldSize();
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Circle&) : center : "
<< " x : " << center.x()
<< " y : " << center.y()
<< " z : " << center.z()
<< " ,radius : " << radius << endl;
#endif
// Direction of circle ?
//GoAddCircleToNode (fGoNode,radius,center.x(),center.y(),center.z(),0.,0.,1.);
GoAddMarkerToNode (fGoNode,center.x(),center.y(),center.z());
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polyhedron& polyhedron
)
/***************************************************************************/
// Method for handling G4Polyhedron objects for drawing solids.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polyhedron&) " << endl;
#endif
SetColour (GetColour(polyhedron));
OModeling modeling = OModelingWireFrame;
switch (GetDrawingStyle (polyhedron)) {
case (G4ViewParameters::hlhsr):
case (G4ViewParameters::hsr):
modeling = OModelingSolid;
break;
case (G4ViewParameters::hlr):
case (G4ViewParameters::wireframe):
default:
modeling = OModelingWireFrame;
break;
}
G4bool notLastFace;
G4Normal3D SurfaceNormal;
double xs[5];
double ys[5];
double zs[5];
do
{
G4bool notLastEdge;
G4Point3D vertex;
G4int edgeFlag = 1;
int iPoint;
iPoint = 0;
notLastFace = polyhedron.GetNextNormal (SurfaceNormal);
do
{
notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
xs[iPoint] = vertex.x();
ys[iPoint] = vertex.y();
zs[iPoint] = vertex.z();
iPoint++;
} while (notLastEdge);
if( (iPoint!=3) && (iPoint!=4) )
{
CWarnF ("G4GoScene::AddPrimitive G4Polyhedron : not a quad or a triangle : %d\n",iPoint);
}
else
{
if (modeling==OModelingWireFrame)
{
xs[iPoint] = xs[0];
ys[iPoint] = ys[0];
zs[iPoint] = zs[0];
iPoint++;
ONodeAddLines (fGoNode,OContextGetStaticInstance(),iPoint,xs,ys,zs);
}
else if (modeling==OModelingSolid)
{
ONodeAddPolygon (fGoNode,OContextGetStaticInstance(),iPoint,xs,ys,zs);
}
}
} while (notLastFace);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Text& text
)
/***************************************************************************/
// Method for handling G4Text objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetTextColour(text));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Text&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4Text : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Square& Square
)
/***************************************************************************/
// Method for handling G4Square objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(Square));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Square&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4Square : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4NURBS& nurb
)
/***************************************************************************/
//Method for handling G4NURBS objects for drawing solids.
//Knots and Ctrl Pnts MUST be arrays of GLfloats.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(nurb));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4NURBS&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4NURBS : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Box& box
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (box);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Cons& cons
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (cons);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Tubs& tubs
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (tubs);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Trd& trd
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (trd);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Trap& trap
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (trap);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Sphere& sphere
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (sphere);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Para& para
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (para);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Torus& torus
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (torus);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4VSolid& solid
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (solid);
}
/***************************************************************************/
void G4GoScene::PreAddThis (
const G4Transform3D& objectTransformation,
const G4VisAttributes& visAttribs
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::PreAddThis (objectTransformation, visAttribs);
CStringDelete (nodeName);
nodeName = NULL;
const G4VPhysicalVolume* currentPhysicalVolume = fpCurrentPV;
if(currentPhysicalVolume==NULL) return;
nodeName = CStringCreateF (15+64,"PhysicalVolume/%lu",currentPhysicalVolume );
#ifdef DEBUG
G4cout << "G4GoScene::PreAddThis : " << nodeName << endl;
#endif
}
/***************************************************************************/
void G4GoScene::PostAddThis (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::PostAddThis" << endl;
#endif
CStringDelete (nodeName);
nodeName = NULL;
G4VScene::PostAddThis();
}
/***************************************************************************/
void G4GoScene::BeginPrimitives (
const G4Transform3D& objectTransformation
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::BeginPrimitives" << endl;
#endif
G4VScene::BeginPrimitives (objectTransformation);
transformation = objectTransformation;
fGoNode = nodeName!=NULL ? ONodeCreate (nodeName) : ONodeMake ();
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = ONodeMake ();
ONodeAddChild (fRootGoNode,fGoNode);
}
/***************************************************************************/
void G4GoScene::EndPrimitives (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::EndPrimitives" << endl;
#endif
G4double g4angle;
G4ThreeVector g4axis;
G4ThreeVector g4trans;
transformation.getRotation().getAngleAxis(g4angle,g4axis);
g4trans = transformation.getTranslation();
OMatrix orot = OMatrixCreate (OMatrixRotationAxis,g4angle,g4axis.x(),g4axis.y(),g4axis.z());
OMatrix otra = OMatrixCreate (OMatrixTranslation,g4trans.x(),g4trans.y(),g4trans.z());
OMatrix omatrix = OMatrixMultiply (otra,orot);
ONodeSetMatrix (fGoNode,omatrix);
OMatrixDelete (omatrix);
OMatrixDelete (orot);
OMatrixDelete (otra);
fGoNode = NULL;
G4VScene::EndPrimitives ();
}
/***************************************************************************/
void G4GoScene::ClearStore (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::ClearStore" << endl;
#endif
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = NULL;
ONodeDestroyChildren (fRootGoNode);
}
/***************************************************************************/
void G4GoScene::RequestPrimitives (
const G4VSolid& solid
)
/***************************************************************************/
// Stop-gap solution for display List re-use.
// A proper implementation would use geometry hierarchy.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::RequestPrimitives" << endl;
#endif
G4VScene::RequestPrimitives (solid);
}
/***************************************************************************/
ONode G4GoScene::GetRootNode (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::RequestPrimitives" << endl;
#endif
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = NULL;
return fRootGoNode;
}
/***************************************************************************/
void G4GoScene::SetColour (
const G4Colour& a_colour
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fOColormap==NULL) fOColormap = OColormapGetIdentifier("ocolormap_X");
int index = OColormapGetRGB_Index(fOColormap,a_colour.GetRed (), a_colour.GetGreen (), a_colour.GetBlue ());
#ifdef DEBUG
G4cout << "G4GoScene::SetColour : red : " << a_colour.GetRed () <<
" green : " << a_colour.GetGreen () <<
" blue : " << a_colour.GetBlue () <<
" index : " << index << endl;
#endif
OContextSetColorIndex (OContextGetStaticInstance(),index);
}
#endif
+78
View File
@@ -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: G4Wo.cc,v 2.1 1998/11/06 13:42:08 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifdef G4VIS_BUILD_OPACS_DRIVER
//Co
#include <CPrinter.h>
#include <Wo.h>
//G4
#include "G4Xt.hh"
#include "G4WoView.hh"
#include "G4GoScene.hh"
//This
#include "G4Wo.hh"
static G4VInteractorManager* interactorManager = NULL;
/***************************************************************************/
G4Wo::G4Wo (
)
:G4VGraphicsSystem ("Wo",G4VGraphicsSystem::threeD)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*.........................................................................*/
{
interactorManager = G4Xt::getInstance ();
}
/***************************************************************************/
G4Wo::~G4Wo (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
G4VInteractorManager* G4Wo::GetInteractorManager (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
return interactorManager;
}
/***************************************************************************/
G4VScene* G4Wo::CreateScene (
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = new G4GoScene (*this, name);
return pScene;
}
/***************************************************************************/
G4VView* G4Wo::CreateView (
G4VScene& scene,
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = (G4GoScene*)&scene;
G4VView* pView = new G4WoView (*pScene, name);
return pView;
}
#endif
+201
View File
@@ -0,0 +1,201 @@
// 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: G4WoView.cc,v 2.8 1998/11/09 15:51:38 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
/*Co*/
#include <CPrinter.h>
#include <CString.h>
/*Xx*/
#include <XWidget.h>
/*Go*/
#include <OCamera.h>
/*Wo*/
#include <OWidget.h>
#include <Wo.h>
//G4
#include "G4VInteractorManager.hh"
#include "G4Wo.hh"
#include "G4GoScene.hh"
//This
#include "G4WoView.hh"
/***************************************************************************/
G4WoView::G4WoView (
G4GoScene& scene,
const G4String& name
)
:G4VView (scene, scene.IncrementViewCount(), name)
,fScene (scene)
,fGoCamera (NULL)
,fXoCamera (NULL)
,fShell (NULL)
/***************************************************************************/
// Constructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4WoView::G4WoView" << endl;
#endif
if(WoIsInitialized()==0) {
CWarn ("G4WoView : Wo is not initialized !\n");
return;
}
char* defName = CStringDuplicate((char*)fName.data());
CStringReplacePart (&defName,"-","_");
fGoCamera = OCameraGetIdentifier (defName);
if(fGoCamera!=NULL) {
return; //OCamera could have been created
//by loading an odb file at Wo startup.
}
G4VInteractorManager* interactorManager = G4Wo::GetInteractorManager();
Widget parent = (Widget)interactorManager->GetParentInteractor ();
char* wname = NULL;
if(parent==NULL) { //Create a shell widget.
wname = CStringCreateF (6+strlen(defName),"shell_%s",defName);
#ifdef HAS_XM
fShell = OWidgetCreate (wname,XWidgetGetTop(),"XmFormDialog",False);
#else
fShell = OWidgetCreate (wname,XWidgetGetTop(),"TopLevelShell",False);
#endif
CStringDelete (wname);
parent = fShell;
wname = CStringDuplicate (defName);
} else {
char* str = interactorManager->GetCreationString ();
if(str==NULL) {
wname = CStringDuplicate (defName);
} else {
wname = CStringDuplicate (str);
}
}
fXoCamera = OWidgetCreate (wname,parent,"XoCamera",False);
if(fShell!=NULL) {
#ifdef HAS_XM
OWidgetSetResourceFromString (fShell,"dialogTitle",wname,False);
OWidgetSetResourceFromString (fXoCamera,"topAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"leftAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"rightAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"bottomAttachment","attach_form",False);
#else
OWidgetSetResourceFromString (fShell,"title",wname,False);
#endif
XWidgetMap (fShell);
}
fGoCamera = OCameraGetIdentifier (wname);
if(fGoCamera==NULL) {
CWarnF ("Can't find/create OCamera %s\n",wname);
}
CStringDelete (wname);
CStringDelete (defName);
interactorManager->SetCreatedInteractor (fXoCamera);
}
/***************************************************************************/
G4WoView::~G4WoView (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fShell!=NULL) {
OWidgetDelete (fShell,False);
} else if(fXoCamera!=NULL) {
OWidgetDelete (fXoCamera,False);
}
}
/***************************************************************************/
void G4WoView::ClearView (
)
/***************************************************************************/
{
}
/***************************************************************************/
void G4WoView::SetView (
)
/***************************************************************************/
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
const G4Point3D target = fVP.GetCurrentTargetPoint ();
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
if(radius<=0.) radius = 1. * m;
const G4double cameraDistance = fVP.GetCameraDistance (radius);
const G4Point3D& pCamera =
target + cameraDistance * fVP.GetViewpointDirection().unit();
#ifdef DEBUG
G4cout << "G4WoView::SetView : target.x " << target.x() << " target.y " << target.y() << " target.z " << target.z() << endl;
G4cout << "G4WoView::SetView : dir.x " << fVP.GetViewpointDirection().unit().x() <<
" dir.y " << fVP.GetViewpointDirection().unit().y() <<
" dir.z " << fVP.GetViewpointDirection().unit().z() << endl;
G4cout << "G4WoView::SetView : cameraDistance " << cameraDistance << endl;
G4cout << "G4WoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
G4cout << "G4WoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
#endif
OCameraSetCenter (fGoCamera,target.x() ,target.y() ,target.z());
OCameraSetDefaultVRP (fGoCamera,pCamera.x(),pCamera.y(),pCamera.z());
OCameraSetDefaultUpVector (fGoCamera,0.,1.,0.);
OCameraSetField (fGoCamera,-radius,radius);
}
/***************************************************************************/
void G4WoView::DrawView (
)
/***************************************************************************/
{
NeedKernelVisit ();
ProcessView ();
ShowView ();
}
/***************************************************************************/
void G4WoView::ShowView (
)
/***************************************************************************/
{
OCameraViewNode (fGoCamera,fScene.GetRootNode());
}
/***************************************************************************/
OCamera G4WoView::GetCamera (
)
/***************************************************************************/
{
return fGoCamera;
}
/***************************************************************************/
void G4WoView::FinishView (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
#endif
+88
View File
@@ -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: G4Xo.cc,v 2.2 1998/11/06 13:42:10 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
#include <stddef.h>
//Co
#include <CPrinter.h>
//Xx
#include <XWidget.h>
//G4
#include "G4Xt.hh"
#include "G4XoView.hh"
#include "G4GoScene.hh"
//This
#include "G4Xo.hh"
static G4VInteractorManager* interactorManager = NULL;
/***************************************************************************/
G4Xo::G4Xo (
)
:G4VGraphicsSystem ("Xo",G4VGraphicsSystem::threeD)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*.........................................................................*/
{
interactorManager = G4Xt::getInstance ();
Widget top = (Widget)interactorManager->GetMainInteractor ();
if(top==NULL) {
CWarn ("G4Xo : Unable to init Xt.\n");
return;
}
XWidgetSetTop (top);
XDisplayPutFileInResourceDatabase (XtDisplay(top),"G4Xo.xrm");
}
/***************************************************************************/
G4Xo::~G4Xo (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
G4VInteractorManager* G4Xo::GetInteractorManager (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
return interactorManager;
}
/***************************************************************************/
G4VScene* G4Xo::CreateScene (
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = new G4GoScene (*this, name);
return pScene;
}
/***************************************************************************/
G4VView* G4Xo::CreateView (
G4VScene& scene,
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = (G4GoScene*)&scene;
G4VView* pView = new G4XoView (*pScene, name);
return pView;
}
#endif
+263
View File
@@ -0,0 +1,263 @@
// 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: G4XoView.cc,v 2.7 1998/11/06 13:42:11 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
//X11
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
/*Co*/
#include <CPrinter.h>
#include <CString.h>
#include <CList.h>
/*Xx*/
#include <XWidget.h>
/*Go*/
#include <OCamera.h>
/*Xo*/
#include <XoCamera.h>
//G4
#include "G4GoScene.hh"
#include "G4Xo.hh"
#include "G4VInteractorManager.hh"
//This
#include "G4XoView.hh"
static Bool WaitForNotify (Display*,XEvent*,char*);
static void ActivateCallback (Widget,XtPointer,XtPointer);
static void CollectCallback (Widget,XtPointer,XtPointer);
/***************************************************************************/
G4XoView::G4XoView (
G4GoScene& scene,
const G4String& name
)
:G4VView (scene, scene.IncrementViewCount(), name)
,fScene (scene)
,fGoCamera (NULL)
,fXoCamera (NULL)
,fShell (NULL)
/***************************************************************************/
// Constructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4XoView::G4XoView" << endl;
#endif
G4VInteractorManager* interactorManager = G4Xo::GetInteractorManager();
Widget top = (Widget)interactorManager->GetMainInteractor ();
if(top==NULL) {
CWarn ("Xt is not initialized !\n");
return;
}
char* defName = CStringDuplicate((char*)fName.data());
CStringReplacePart (&defName,"-","_");
Arg args[1];
char* wname = NULL;
Widget parent = (Widget)interactorManager->GetParentInteractor ();
if(parent==NULL) {
// Create a shell widget.
// Add WMClose does not works on ApplicationShell, then use a TopLevelShell.
char* cname;
wname = CStringCreateF (6+strlen(defName),"shell_%s",defName);
cname = CStringCreateF (6+strlen(defName),"Shell_%s",defName);
fShell = XtAppCreateShell (wname,cname,topLevelShellWidgetClass,XtDisplay(top),args,0);
CStringDelete (wname);
CStringDelete (cname);
interactorManager->AddShell (fShell);
parent = fShell;
wname = CStringDuplicate(defName);
} else {
char* str = interactorManager->GetCreationString ();
if(str==NULL) {
wname = CStringDuplicate (defName);
} else {
wname = CStringDuplicate (str);
}
}
fXoCamera = XtCreateManagedWidget (wname,xoCameraWidgetClass ,parent, args, 0);
fGoCamera = (OCamera) XoCameraGetCamera (fXoCamera);
XoCameraAddPopupEntry (fXoCamera,"Escape",ActivateCallback,NULL);
XtAddCallback (fXoCamera,XoNcollectCallback,CollectCallback,NULL);
if(fShell!=NULL) {
XtRealizeWidget (fShell);
XtMapWidget (fShell);
XEvent event;
XIfEvent (XtDisplay(fShell), &event, WaitForNotify, (char*)XtWindow(fShell));
}
if(fGoCamera==NULL) {
CWarnF ("Can't create OCamera %s\n",wname);
fXoCamera = NULL;
fGoCamera = NULL;
}
// g++ wants the cast !!!
interactorManager->AddSecondaryLoopPreAction ((G4SecondaryLoopAction)XoCameraEnablePopup);
interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)XoCameraDisablePopup);
interactorManager->SetCreatedInteractor (fXoCamera);
CStringDelete (wname);
CStringDelete (defName);
}
/***************************************************************************/
G4XoView::~G4XoView (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fShell!=NULL) {
G4Xo::GetInteractorManager()->RemoveShell (fShell);
XtDestroyWidget (fShell);
} else if(fXoCamera!=NULL) {
XtDestroyWidget (fXoCamera);
}
fXoCamera = NULL;
fGoCamera = NULL;
}
/***************************************************************************/
void G4XoView::ClearView (
)
/***************************************************************************/
{
}
/***************************************************************************/
void G4XoView::SetView (
)
/***************************************************************************/
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
const G4Point3D target = fVP.GetCurrentTargetPoint ();
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
if(radius<=0.) radius = 1. * m;
const G4double cameraDistance = fVP.GetCameraDistance (radius);
const G4Point3D& pCamera =
target + cameraDistance * fVP.GetViewpointDirection().unit();
#ifdef DEBUG
G4cout << "G4XoView::SetView : target.x " << target.x() << " target.y " << target.y() << " target.z " << target.z() << endl;
G4cout << "G4XoView::SetView : dir.x " << fVP.GetViewpointDirection().unit().x() <<
" dir.y " << fVP.GetViewpointDirection().unit().y() <<
" dir.z " << fVP.GetViewpointDirection().unit().z() << endl;
G4cout << "G4XoView::SetView : cameraDistance " << cameraDistance << endl;
G4cout << "G4XoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
#endif
OCameraSetCenter (fGoCamera,target.x() ,target.y() ,target.z());
OCameraSetDefaultVRP (fGoCamera,pCamera.x(),pCamera.y(),pCamera.z());
OCameraSetDefaultUpVector (fGoCamera,0.,1.,0.);
OCameraSetField (fGoCamera,-radius,radius);
}
/***************************************************************************/
OCamera G4XoView::GetCamera (
)
/***************************************************************************/
{
return fGoCamera;
}
/***************************************************************************/
void G4XoView::DrawView (
)
/***************************************************************************/
{
NeedKernelVisit ();
ProcessView ();
FinishView ();
}
/***************************************************************************/
void G4XoView::FinishView (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
void G4XoView::ShowView (
)
/***************************************************************************/
{
OCameraViewNode (fGoCamera,fScene.GetRootNode());
G4Xo::GetInteractorManager() -> SecondaryLoop();
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
Bool WaitForNotify (
Display* d
,XEvent* e
,char* arg
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
/*.........................................................................*/
d = NULL;
return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
}
/***************************************************************************/
void ActivateCallback (
Widget This
,XtPointer a_tag
,XtPointer a_data
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4Xo::GetInteractorManager() -> RequireExitSecondaryLoop (XO_EXIT_CODE);
This = NULL;
a_tag = NULL;
a_data = NULL;
}
/***************************************************************************/
void CollectCallback (
Widget This
,XtPointer a_tag
,XtPointer a_data
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
OCamera camera;
ONode* nodes;
int noden,count;
/*.........................................................................*/
// collectCallback = osh> getCameraNodes `thisCamera` | collect ONode where highlight eq 1 | get - name | dump -
camera = (OCamera)XoCameraGetCamera (This);
nodes = OCameraCollect (camera,OCollectHighlighted);
noden = CListGetSize ((CList)nodes);
for(count=0;count<noden;count++)
{
char* name = ONodeGetName(nodes[count]);
CInfoF("%s\n",name==NULL ? "(nil)" : name);
}
CListDelete ((CList)nodes);
This = NULL;
a_tag = NULL;
a_data = NULL;
}
#endif