Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,339 @@
|
||||
// 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: G4o.cc,v 2.3 1998/09/16 12:08:41 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
/*
|
||||
#define DEBUG
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*GEANT4*/
|
||||
#include <G4VPhysicalVolume.hh>
|
||||
#include <G4LogicalVolume.hh>
|
||||
#include <G4PhysicalVolumeStore.hh>
|
||||
#include <G4PhysicalVolumeModel.hh>
|
||||
#include <G4ModelingParameters.hh>
|
||||
#include <G4RunManager.hh>
|
||||
|
||||
/*For G4UI.*/
|
||||
#include <G4UImanager.hh>
|
||||
//#include <G4ParticleTblMessenger.hh>
|
||||
#include <G4ParticleTable.hh>
|
||||
|
||||
/*Co*/
|
||||
#include <CPrinter.h>
|
||||
#include <CMemory.h>
|
||||
#include <CString.h>
|
||||
#include <CText.h>
|
||||
#include <CFile.h>
|
||||
#include <CList.h>
|
||||
#include <OType.h>
|
||||
#include <OShell.h>
|
||||
#include <OProcess.h>
|
||||
|
||||
/*Go*/
|
||||
#include <Go.h>
|
||||
#include <GoTypes.h>
|
||||
|
||||
/*G4o*/
|
||||
#include <G4oScene.hh>
|
||||
#include <G4oDrawer.hh>
|
||||
#include <G4o.h>
|
||||
|
||||
#include <G4oCommon.hh>
|
||||
|
||||
static void ClearClass ();
|
||||
static OIdentifier* GetPhysicalVolumeIdentifiers (OType);
|
||||
static int GetPhysicalVolumeProperty (OIdentifier,OType,OProperty,void*,int*);
|
||||
static ONode RepresentPhysicalVolume (OIdentifier,OType);
|
||||
|
||||
static OIdentifier* GetTrajectoryIdentifiers (OType);
|
||||
static int GetTrajectoryProperty (OIdentifier,OType,OProperty,void*,int*);
|
||||
static ONode RepresentTrajectory (OIdentifier,OType);
|
||||
|
||||
|
||||
typedef unsigned long Ulong;
|
||||
|
||||
static struct {
|
||||
void** extent;
|
||||
G4oScene* g4oScene;
|
||||
OShell osh;
|
||||
} Class = {NULL,NULL,NULL};
|
||||
/***************************************************************************/
|
||||
void ClearClass (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
CListDelete (Class.extent);
|
||||
Class.extent = NULL;
|
||||
if(Class.g4oScene!=NULL) delete Class.g4oScene;
|
||||
Class.g4oScene = NULL;
|
||||
Class.osh = NULL;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oAddCommands (
|
||||
void* a_osh
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*
|
||||
Some G4 commands :
|
||||
G4> /particle/
|
||||
G4> /particle/dump
|
||||
G4> /particle/Verbose
|
||||
The definitions of these commands ar in G4o/src/G4oMessenger.cc code.
|
||||
*/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(OCommandGetIdentifier("G4")!=NULL) return; /*Done*/
|
||||
|
||||
GoSetTypes ();
|
||||
SetTypes ();
|
||||
|
||||
if(OTypeGetIdentifier("PhysicalVolume")==NULL)
|
||||
{
|
||||
OType otype;
|
||||
otype = OTypeCreate ("PhysicalVolume");
|
||||
OTypeSetGetIdentifiersFunction (otype,GetPhysicalVolumeIdentifiers);
|
||||
OTypeSetGetPropertyFunction (otype,GetPhysicalVolumeProperty);
|
||||
OTypeSetClearClassFunction (otype,ClearClass);
|
||||
OTypeSetRepresentFunction (otype,(OTypeRepresentFunction)RepresentPhysicalVolume);
|
||||
OTypeAddNewProperty (otype,"identifier" ,OPropertyUnsignedLong ,NULL);
|
||||
OTypeAddNewProperty (otype,"name" ,OPropertyString ,NULL);
|
||||
|
||||
otype = OTypeCreate ("Trajectory");
|
||||
OTypeSetGetIdentifiersFunction (otype,GetTrajectoryIdentifiers);
|
||||
OTypeSetGetPropertyFunction (otype,GetTrajectoryProperty);
|
||||
OTypeSetRepresentFunction (otype,
|
||||
(OTypeRepresentFunction)RepresentTrajectory);
|
||||
OTypeAddNewProperty (otype,"identifier" ,OPropertyUnsignedLong,NULL);
|
||||
OTypeAddNewProperty (otype,"trackID" ,OPropertyInteger ,NULL);
|
||||
OTypeAddNewProperty (otype,"parentID" ,OPropertyInteger ,NULL);
|
||||
OTypeAddNewProperty (otype,"particleName",OPropertyString ,NULL);
|
||||
OTypeAddNewProperty (otype,"charge" ,OPropertyDouble ,NULL);
|
||||
}
|
||||
|
||||
|
||||
OShellAddNewCommand ((OShell)a_osh,"G4o/G4",Execute_G4);
|
||||
|
||||
Class.osh = (OShell)a_osh;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oExecuteScript (
|
||||
char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
ExecuteScript (a_string);
|
||||
}
|
||||
/***************************************************************************/
|
||||
OShell G4oGetShell (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return Class.osh;
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
OIdentifier* GetPhysicalVolumeIdentifiers (
|
||||
OType a_type
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
int objn = G4PhysicalVolumeStore::GetInstance()->entries();
|
||||
#ifdef DEBUG
|
||||
printf ("debug: GetPhysicalVolumeIdentifiers : %d objects.\n",objn);
|
||||
#endif
|
||||
if(objn<=0) return NULL;
|
||||
CListDelete (Class.extent);
|
||||
Class.extent = CListCreate(objn);
|
||||
if(Class.extent==NULL) return NULL;
|
||||
for(int count=0;count<objn;count++) {
|
||||
Class.extent[count] = (OIdentifier)(count+1);
|
||||
}
|
||||
a_type = NULL;
|
||||
return Class.extent;
|
||||
}
|
||||
/***************************************************************************/
|
||||
int GetPhysicalVolumeProperty (
|
||||
OIdentifier a_obj
|
||||
,OType This
|
||||
,OProperty a_prop
|
||||
,void* a_addr
|
||||
,int* a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_number!=NULL) *a_number = 0;
|
||||
if(This==NULL) return 0;
|
||||
char* name = OPropertyGetName (a_prop);
|
||||
if(name==NULL) return 0;
|
||||
|
||||
if(strcmp(name,"identifier")==0) {
|
||||
*((Ulong*)a_addr) = (Ulong)a_obj;
|
||||
} else if(strcmp(name,"name")==0) {
|
||||
*((char**)a_addr) = CStringDuplicate((char*)(G4PhysicalVolumeStore::GetInstance()->at((size_t)a_obj-1)->GetName().data()));
|
||||
return FREE_BLOCK;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/***************************************************************************/
|
||||
ONode RepresentPhysicalVolume (
|
||||
OIdentifier a_obj
|
||||
,OType This
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(This==NULL) return NULL;
|
||||
|
||||
G4VPhysicalVolume* physicalVolume =
|
||||
G4PhysicalVolumeStore::GetInstance()->at((size_t)a_obj-1);
|
||||
|
||||
if(Class.g4oScene==NULL) {
|
||||
Class.g4oScene = new G4oScene;
|
||||
if(Class.g4oScene==NULL) return NULL;
|
||||
}
|
||||
|
||||
char* string = CStringCreateF (15+64,"PhysicalVolume/%lu",a_obj);
|
||||
Class.g4oScene->SetNodeName (string);
|
||||
CStringDelete (string);
|
||||
|
||||
G4ModelingParameters mParams (G4ModelingParameters::wireframe,
|
||||
true, // Global culling.
|
||||
true, // Cull invisible volumes.
|
||||
false, // Density culling.
|
||||
0., // Density (not relevant if density
|
||||
// culling false).
|
||||
true, // Cull daughters of opaque mothers.
|
||||
24); // No of sides (not relevant for
|
||||
// this operation).
|
||||
|
||||
G4PhysicalVolumeModel model (physicalVolume,
|
||||
G4PhysicalVolumeModel::UNLIMITED,
|
||||
G4Transform3D::Identity,
|
||||
&mParams);
|
||||
model.DescribeYourselfTo (*Class.g4oScene);
|
||||
|
||||
return Class.g4oScene->GetNode();
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
OIdentifier* GetTrajectoryIdentifiers (
|
||||
OType a_type
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
const G4Event* event = G4RunManager::GetRunManager() -> GetCurrentEvent();
|
||||
if(event==NULL) return 0;
|
||||
G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer();
|
||||
if(trajectoryContainer==NULL) return 0;
|
||||
int objn = trajectoryContainer->entries();
|
||||
#ifdef DEBUG
|
||||
printf ("debug: GetTrajectoryIdentifiers : event : %lu, %d objects.\n",
|
||||
event,objn);
|
||||
#endif
|
||||
if(objn<=0) return NULL;
|
||||
CListDelete (Class.extent);
|
||||
Class.extent = CListCreate(objn);
|
||||
if(Class.extent==NULL) return NULL;
|
||||
for(int count=0;count<objn;count++) {
|
||||
Class.extent[count] = (OIdentifier)(count+1);
|
||||
}
|
||||
a_type = NULL;
|
||||
return Class.extent;
|
||||
}
|
||||
/***************************************************************************/
|
||||
int GetTrajectoryProperty (
|
||||
OIdentifier a_obj
|
||||
,OType This
|
||||
,OProperty a_prop
|
||||
,void* a_addr
|
||||
,int* a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_number!=NULL) *a_number = 0;
|
||||
if(This==NULL) return 0;
|
||||
char* name = OPropertyGetName (a_prop);
|
||||
if(name==NULL) return 0;
|
||||
const G4Event* event = G4RunManager::GetRunManager() -> GetCurrentEvent();
|
||||
if(event==NULL) return 0;
|
||||
G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer();
|
||||
if(trajectoryContainer==NULL) return 0;
|
||||
|
||||
G4Trajectory* trajectory = (*trajectoryContainer)[(size_t)a_obj-1];
|
||||
|
||||
if(strcmp(name,"identifier")==0) {
|
||||
*((Ulong*)a_addr) = (Ulong)a_obj;
|
||||
} else if(strcmp(name,"trackID")==0) {
|
||||
*((int*)a_addr) = trajectory->GetTrackID();
|
||||
} else if(strcmp(name,"parentID")==0) {
|
||||
*((int*)a_addr) = trajectory->GetParentID();
|
||||
} else if(strcmp(name,"particleName")==0) {
|
||||
*((char**)a_addr) = CStringDuplicate(
|
||||
(char*)(trajectory->GetParticleName().data()));
|
||||
return FREE_BLOCK;
|
||||
} else if(strcmp(name,"charge")==0) {
|
||||
*((double*)a_addr) = trajectory->GetCharge();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/***************************************************************************/
|
||||
ONode RepresentTrajectory (
|
||||
OIdentifier a_obj
|
||||
,OType This
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(This==NULL) return NULL;
|
||||
const G4Event* event = G4RunManager::GetRunManager() -> GetCurrentEvent();
|
||||
if(event==NULL) return NULL;
|
||||
G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer();
|
||||
if(trajectoryContainer==NULL) return NULL;
|
||||
G4oDrawer* drawer = G4oDrawer::GetInstance();
|
||||
if(drawer==NULL) return NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("debug: RepresentTrajectory : %d.\n",a_obj);
|
||||
#endif
|
||||
|
||||
ONode node = ONodeCreateF (11+64,"Trajectory/%lu",a_obj);
|
||||
|
||||
drawer->SetNode (node);
|
||||
G4Trajectory* trajectory = (*trajectoryContainer)[(size_t)a_obj-1];
|
||||
|
||||
trajectory->DrawTrajectory(0);
|
||||
|
||||
return node;
|
||||
}
|
||||
#include <G4oCommon.icc>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
// 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: G4oDrawer.cc,v 2.2 1998/09/16 12:08:44 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
/*
|
||||
From geant4/visualization/management/src/G4VisManager.cc.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
|
||||
#include <G4oDrawer.hh>
|
||||
|
||||
/*G4*/
|
||||
#include <G4Polyline.hh>
|
||||
#include <G4VisAttributes.hh>
|
||||
|
||||
/*Go*/
|
||||
#include <Go.h>
|
||||
|
||||
G4oDrawer* G4oDrawer::fpInstance = 0;
|
||||
ONode G4oDrawer::node = NULL;
|
||||
OColormap G4oDrawer::colormap = NULL;
|
||||
|
||||
/***************************************************************************/
|
||||
G4oDrawer* G4oDrawer::GetInstance (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if (!fpInstance)
|
||||
{
|
||||
fpInstance = new G4oDrawer;
|
||||
fpConcreteInstance = fpInstance;
|
||||
}
|
||||
return fpInstance;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4oDrawer::G4oDrawer (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4oDrawer::~G4oDrawer (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::SetWorldVolume (
|
||||
G4VPhysicalVolume* world
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::EventBegins (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::EventEnded (
|
||||
G4Event * pEvent
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Polyline& line
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
SetColour (line.GetVisAttributes()->GetColour());
|
||||
|
||||
G4int nPoints = line.entries ();
|
||||
if(nPoints<=0) return;
|
||||
OPointList points = OPointListCreate (nPoints);
|
||||
for (G4int iPoint = 0; iPoint < nPoints; iPoint++)
|
||||
{
|
||||
OPointListSetIthEntry (points,iPoint,
|
||||
(double)line(iPoint).x(),
|
||||
(double)line(iPoint).y(),
|
||||
(double)line(iPoint).z());
|
||||
}
|
||||
if(nPoints==1)
|
||||
GoAddMarkersToNode (node,points);
|
||||
else
|
||||
GoAddLinesToNode (node,points);
|
||||
OPointListDelete (points);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Text& text
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Circle& circle
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Square& Square
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Polymarker& polymarker
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4Polyhedron& polyhedron
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4NURBS& nurbs
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4VSolid& solid
|
||||
,const G4VisAttributes& attribs
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4LogicalVolume& logicalVol
|
||||
,const G4VisAttributes& attribs
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::Draw (
|
||||
const G4VPhysicalVolume& physicalVol
|
||||
,const G4VisAttributes& attribs
|
||||
,const G4Transform3D& objectTransform
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::SetNode (
|
||||
ONode a_node
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
node = a_node;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::SetColour (
|
||||
const G4Colour& a_colour
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(colormap==NULL) colormap = OColormapGetIdentifier("ocolormap_X");
|
||||
int index = OColormapGetRGB_Index(colormap,a_colour.GetRed (), a_colour.GetGreen (), a_colour.GetBlue ());
|
||||
OContextSetColorIndex (OContextGetStaticInstance(),index);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oDrawer::GeometryHasChanged (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
// 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: G4oScene.cc,v 2.2 1998/07/12 02:37:06 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
/* +---------------------- Copyright notice -------------------------------+ */
|
||||
/* | Copyright (C) 1995, Guy Barrand, LAL Orsay, (barrand@lal.in2p3.fr) | */
|
||||
/* | Permission to use, copy, modify, and distribute this software | */
|
||||
/* | and its documentation for any purpose and without fee is hereby | */
|
||||
/* | granted, provided that the above copyright notice appear in all | */
|
||||
/* | copies and that both that copyright notice and this permission | */
|
||||
/* | notice appear in supporting documentation. This software is | */
|
||||
/* | provided "as is" without express or implied warranty. | */
|
||||
/* +---------------------- Copyright notice -------------------------------+ */
|
||||
/*
|
||||
#define DEBUG
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/*Co*/
|
||||
#include <CPrinter.h>
|
||||
#include <CString.h>
|
||||
#include <OMatrix.h>
|
||||
|
||||
/*Go*/
|
||||
#include <Go.h>
|
||||
#include <OCamera.h>
|
||||
|
||||
#include <G4Box.hh>
|
||||
#include <G4Tubs.hh>
|
||||
#include <G4Cons.hh>
|
||||
#include <G4Trd.hh>
|
||||
#include <G4Trap.hh>
|
||||
#include <G4Sphere.hh>
|
||||
#include <G4Para.hh>
|
||||
#include <G4Torus.hh>
|
||||
#include <G4Polyhedron.hh>
|
||||
#include <G4Polyline.hh>
|
||||
#include <G4Transform3D.hh>
|
||||
#include <G4PhysicalVolumeModel.hh>
|
||||
|
||||
#include <G4oScene.hh>
|
||||
|
||||
ONode G4oScene::node = NULL;
|
||||
char* G4oScene::nodeName = NULL;
|
||||
/***************************************************************************/
|
||||
G4oScene::G4oScene (
|
||||
)
|
||||
:fpAccTransf(NULL)
|
||||
,fCurrentDepth(0)
|
||||
,fpCurrentPV(NULL)
|
||||
,fpCurrentLV(NULL)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4oScene::~G4oScene (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
CStringDelete (nodeName);
|
||||
nodeName = NULL;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::PreAddThis (
|
||||
const G4Transform3D& objectTransformation
|
||||
,const G4VisAttributes& /*visAttribs*/
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
fpAccTransf = &objectTransformation;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::PostAddThis (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::EstablishSpecials (
|
||||
G4PhysicalVolumeModel& a_model
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
a_model.DefinePointersToWorkingSpace (&fCurrentDepth,
|
||||
&fpCurrentPV,
|
||||
&fpCurrentLV);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Box& box
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : box.\n");
|
||||
#endif
|
||||
AddPolyhedron (box.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Cons& cons
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : cons.\n");
|
||||
#endif
|
||||
AddPolyhedron (cons.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Tubs& tubs
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : tubs.\n");
|
||||
#endif
|
||||
AddPolyhedron (tubs.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Trd& trd
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : trd.\n");
|
||||
#endif
|
||||
AddPolyhedron (trd.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Trap& trap
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : trap.\n");
|
||||
#endif
|
||||
AddPolyhedron (trap.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Sphere& sphere
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : sphere.\n");
|
||||
#endif
|
||||
AddPolyhedron (sphere.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Para& para
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : para.\n");
|
||||
#endif
|
||||
AddPolyhedron (para.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4Torus& torus
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : torus.\n");
|
||||
#endif
|
||||
AddPolyhedron (torus.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddThis (
|
||||
const G4VSolid& solid
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : solid.\n");
|
||||
#endif
|
||||
AddPolyhedron (solid.CreatePolyhedron());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::SetNodeName (
|
||||
char* a_name
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
CStringDelete (nodeName);
|
||||
nodeName = CStringDuplicate (a_name);
|
||||
}
|
||||
/***************************************************************************/
|
||||
ONode G4oScene::GetNode (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
return node;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oScene::AddPolyhedron (
|
||||
G4Polyhedron* a_polyhedron
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*
|
||||
Loop to get vertices from G4OpenGLScene::AddPrimitive.
|
||||
*/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4bool notLastFace;
|
||||
G4Normal3D SurfaceUnitNormal;
|
||||
double xs[5];
|
||||
double ys[5];
|
||||
double zs[5];
|
||||
/*.........................................................................*/
|
||||
#ifdef DEBUG
|
||||
printf ("debug : G4oScene::AddPolyhedron : ONode : %s\n",nodeName);
|
||||
#endif
|
||||
node = ONodeCreate (nodeName);
|
||||
do
|
||||
{
|
||||
G4int notLastEdge;
|
||||
G4Point3D vertex;
|
||||
G4int edgeFlag (true);
|
||||
int iPoint;
|
||||
iPoint = 0;
|
||||
notLastFace = a_polyhedron->GetNextNormal (SurfaceUnitNormal);
|
||||
do
|
||||
{
|
||||
notLastEdge = a_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 ("G4oScene::AddPolyhedron : not a quad or a triangle : %d\n",iPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OContextGetModeling(OContextGetStaticInstance())==OModelingWireFrame)
|
||||
{
|
||||
xs[iPoint] = xs[0];
|
||||
ys[iPoint] = ys[0];
|
||||
zs[iPoint] = zs[0];
|
||||
iPoint++;
|
||||
ONodeAddLines (node,OContextGetStaticInstance(),iPoint,xs,ys,zs);
|
||||
}
|
||||
else if (OContextGetModeling(OContextGetStaticInstance())==OModelingSolid)
|
||||
{
|
||||
ONodeAddPolygon (node,OContextGetStaticInstance(),iPoint,xs,ys,zs);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf ("debug : G4oScene::AddPrimitive : AddLines : %d\n",iPoint);
|
||||
#endif
|
||||
}
|
||||
} while (notLastFace);
|
||||
|
||||
if(fpAccTransf==NULL) {
|
||||
CWarnF ("G4oScene::AddPolyhedron : no transformation given !\n");
|
||||
} else {
|
||||
G4double g4angle;
|
||||
G4ThreeVector g4axis;
|
||||
G4ThreeVector g4trans;
|
||||
fpAccTransf->getRotation().getAngleAxis(g4angle,g4axis);
|
||||
g4trans = fpAccTransf->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 (node,omatrix);
|
||||
OMatrixDelete (omatrix);
|
||||
OMatrixDelete (orot);
|
||||
OMatrixDelete (otra);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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: G4oState.cc,v 2.2 1998/07/13 17:29:32 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//#define DEBUG
|
||||
|
||||
//#include "G4ios.hh"
|
||||
|
||||
//G4
|
||||
#include <globals.hh>
|
||||
#include <G4UImanager.hh>
|
||||
#include <G4StateManager.hh>
|
||||
|
||||
//OPACS
|
||||
#include <CPrinter.h>
|
||||
#include <Wo.h>
|
||||
|
||||
#include <G4o.h>
|
||||
#include <G4oState.hh>
|
||||
|
||||
/***************************************************************************/
|
||||
G4oState::G4oState(
|
||||
G4String a_name
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
name = a_name;
|
||||
G4UImanager::GetUIpointer()->SetSession(this); //So that Pause works..
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4bool G4oState::Notify (
|
||||
G4ApplicationState requestedState
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4StateManager* statM = G4StateManager::GetStateManager();
|
||||
G4ApplicationState previousState = statM->GetPreviousState();
|
||||
|
||||
if(previousState==Idle && requestedState==GeomClosed) { //beginOfRun
|
||||
G4String string = "RunBegin.osh";
|
||||
OShellExecuteFile (G4oGetShell(),(char*)(name + string).data());
|
||||
} else if(previousState==GeomClosed && requestedState==Idle) { //endOfRun
|
||||
G4String string = "RunEnd.osh";
|
||||
OShellExecuteFile (G4oGetShell(),(char*)(name + string).data());
|
||||
} else if(previousState==GeomClosed && requestedState==EventProc) { //beginOfEvent
|
||||
G4String string = "EventBegin.osh";
|
||||
OShellExecuteFile (G4oGetShell(),(char*)(name + string).data());
|
||||
} else if(previousState==EventProc && requestedState==GeomClosed) { // EndOfEvent
|
||||
G4String string = "EventEnd.osh";
|
||||
OShellExecuteFile (G4oGetShell(),(char*)(name + string).data());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4oState::PauseSessionStart (
|
||||
G4String a_message
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_message=="G4_pause> ") {
|
||||
WoProcessEvents ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user