Import Geant4 0.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:09:25 +02:00
parent b97f8d0df7
commit aaa409b6ee
2922 changed files with 55107 additions and 81674 deletions
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenInventor.cc,v 2.6 1998/12/08 09:51:38 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4OpenInventor.cc,v 1.5 1999/05/12 14:00:58 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifdef G4VIS_BUILD_OI_DRIVER
@@ -19,8 +19,8 @@
#include <HEPVis/nodekits/SoDetectorTreeKit.h>
#include "G4OpenInventor.hh"
#include "G4OpenInventorScene.hh"
#include "G4OpenInventorView.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
G4OpenInventor::G4OpenInventor (
@@ -32,29 +32,26 @@ G4OpenInventor::G4OpenInventor (
,interactorManager(NULL)
{
}
G4OpenInventor::~G4OpenInventor () {}
void G4OpenInventor::SetInteractorManager (G4VInteractorManager* im) {
interactorManager = im;
}
G4VInteractorManager* G4OpenInventor::GetInteractorManager () {
return interactorManager;
}
G4VScene* G4OpenInventor::CreateScene (const G4String& name) {
G4VScene* p = new G4OpenInventorScene (*this, name);
G4cout << G4OpenInventorScene::GetSceneCount ()
G4VSceneHandler* G4OpenInventor::CreateSceneHandler (const G4String& name) {
G4VSceneHandler* p = new G4OpenInventorSceneHandler (*this, name);
G4cout << G4OpenInventorSceneHandler::GetSceneCount ()
<< ' ' << fName << " scenes extanct." << endl;
return p;
}
G4VView* G4OpenInventor::CreateView (G4VScene& scene, const G4String& name)
G4VViewer* G4OpenInventor::CreateViewer (G4VSceneHandler& scene, const G4String& name)
{
G4OpenInventorScene* pScene = (G4OpenInventorScene*)&scene;
G4OpenInventorView* pView = new G4OpenInventorView (*pScene, name);
if (pView -> GetOIVisualFound ()) {
}
else {
delete pView;
pView = NULL;
}
G4OpenInventorSceneHandler* pScene = (G4OpenInventorSceneHandler*)&scene;
G4OpenInventorViewer* pView = new G4OpenInventorViewer (*pScene, name);
return pView;
}
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenInventorScene.cc,v 2.10 1998/12/04 13:18:10 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4OpenInventorSceneHandler.cc,v 1.3 1999/05/12 14:01:00 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -47,8 +47,8 @@
#include "G4NURBS.hh"
#include "G4OpenInventor.hh"
#include "G4OpenInventorScene.hh"
#include "G4OpenInventorView.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4OpenInventorTransform3D.hh"
#include "G4ThreeVector.hh"
#include "G4Point3D.hh"
@@ -70,29 +70,41 @@ typedef SoDetectorTreeKit SoG4DetectorTreeKit;
G4Point3D translation;
inline static unsigned pSolidHashFun
(const G4OpenInventorScene::G4VSolidPointer& pSolid) {
(const G4OpenInventorSceneHandler::G4VSolidPointer& pSolid) {
return (unsigned)pSolid;
}
inline static unsigned pVPhysicalVolumeHashFun
(const G4OpenInventorScene::G4VPhysicalVolumePointer & volume) {
(const G4OpenInventorSceneHandler::G4VPhysicalVolumePointer & volume) {
return (unsigned)(unsigned long)volume;
}
G4OpenInventorScene::G4OpenInventorScene (G4OpenInventor& system,
const G4String& name):
G4VScene (system, fSceneIdCount++, name),
fSolidDictionary (pSolidHashFun),
SeparatorSet(pVPhysicalVolumeHashFun),
root(NULL)
G4OpenInventorSceneHandler::G4OpenInventorSceneHandler (G4OpenInventor& system,
const G4String& name)
:G4VSceneHandler (system, fSceneIdCount++, name)
,fSolidDictionary (pSolidHashFun)
,SeparatorSet(pVPhysicalVolumeHashFun)
,root(NULL)
,staticRoot(NULL)
,transientRoot(NULL)
{
//
root = new SoSeparator;
root->ref();
root->setName("Root");
//
staticRoot = new SoSeparator;
staticRoot->setName("StaticRoot");
root->addChild(staticRoot);
//
transientRoot = new SoSeparator;
transientRoot->setName("TransientRoot");
root->addChild(transientRoot);
//
fSceneCount++;
}
G4OpenInventorScene::~G4OpenInventorScene ()
G4OpenInventorSceneHandler::~G4OpenInventorSceneHandler ()
{
root->unref();
fSceneCount--;
@@ -101,8 +113,8 @@ G4OpenInventorScene::~G4OpenInventorScene ()
//
// Method for handling G4Polyline objects (from tracking or wireframe).
//
void G4OpenInventorScene::AddPrimitive (const G4Polyline& line) {
G4int nPoints = line.entries () - 1;
void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline& line) {
G4int nPoints = line.entries();
SbVec3f* pCoords = new SbVec3f[nPoints];
SoCoordinate3 *polyCoords = new SoCoordinate3;
@@ -153,7 +165,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Polyline& line) {
//
// Method for handling G4Text objects
//
void G4OpenInventorScene::AddPrimitive (const G4Text& text) {
void G4OpenInventorSceneHandler::AddPrimitive (const G4Text& text) {
//
// Color
@@ -188,7 +200,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Text& text) {
//
// Method for handling G4Circle objects
//
void G4OpenInventorScene::AddPrimitive (const G4Circle& circle) {
void G4OpenInventorSceneHandler::AddPrimitive (const G4Circle& circle) {
//
// Color
//
@@ -202,7 +214,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Circle& circle) {
//
G4double userSpecified = circle.GetWorldSize() || circle.GetScreenSize();
const G4VMarker& defaultMarker =
fpView -> GetViewParameters().GetDefaultMarker();
fpViewer -> GetViewParameters().GetDefaultMarker();
G4double size = GetMarkerSize ( circle );
@@ -228,7 +240,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Circle& circle) {
//
// Method for handling G4Square objects - defaults to wireframe
//
void G4OpenInventorScene::AddPrimitive (const G4Square& Square) {
void G4OpenInventorSceneHandler::AddPrimitive (const G4Square& Square) {
//
// Color
@@ -263,7 +275,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Square& Square) {
//
// Method for handling G4Polyhedron objects for drawing solids.
//
void G4OpenInventorScene::AddPrimitive (const G4Polyhedron& polyhedron) {
void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
#define MAXPOLYH 32767
//
// Assume all facets are convex quadrilaterals.
@@ -367,7 +379,7 @@ void G4OpenInventorScene::AddPrimitive (const G4Polyhedron& polyhedron) {
// Method for handling G4NURBS objects for drawing solids.
// Knots and Ctrl Pnts MUST be arrays of GLfloats.
//
void G4OpenInventorScene::AddPrimitive (const G4NURBS& nurb) {
void G4OpenInventorSceneHandler::AddPrimitive (const G4NURBS& nurb) {
G4float *u_knot_array, *u_knot_array_ptr;
u_knot_array = u_knot_array_ptr = new G4float [nurb.GetnbrKnots(G4NURBS::U)];
@@ -435,10 +447,10 @@ void G4OpenInventorScene::AddPrimitive (const G4NURBS& nurb) {
//
// Generates prerequisites for primitives
//
void G4OpenInventorScene::BeginPrimitives
void G4OpenInventorSceneHandler::BeginPrimitives
(const G4Transform3D& objectTransformation) {
G4VScene::BeginPrimitives (objectTransformation);
G4VSceneHandler::BeginPrimitives (objectTransformation);
// Store away for future use, e.g.,
// AddPrimitive (const G4Polyhedron& polyhedron).
@@ -458,57 +470,62 @@ void G4OpenInventorScene::BeginPrimitives
//
if (fReadyForTransients) {
//
// set the destination to "root"
// set the destination to "transientRoot"
//
currentSeparator=root;
currentSeparator=transientRoot;
//
// place the transient object:
//
G4OpenInventorTransform3D oiTran (objectTransformation);
SoSFMatrix *oiMat = oiTran.GetOIMatrix();
SoMatrixTransform *rootXform = new SoMatrixTransform;
rootXform->matrix.setValue(oiMat->getValue());
SoMatrixTransform *xform = new SoMatrixTransform;
xform->matrix.setValue(oiMat->getValue());
//
// add a transform.
//
currentSeparator->addChild(new SoResetTransform);
currentSeparator->addChild(rootXform);
currentSeparator->addChild(xform);
}
}
void G4OpenInventorScene::EndPrimitives () {
G4VScene::EndPrimitives ();
void G4OpenInventorSceneHandler::EndPrimitives () {
G4VSceneHandler::EndPrimitives ();
}
void G4OpenInventorScene::EndModeling () {
void G4OpenInventorSceneHandler::EndModeling () {
}
void G4OpenInventorScene::ClearStore () {
void G4OpenInventorSceneHandler::ClearStore () {
staticRoot->removeAllChildren();
transientRoot->removeAllChildren();
}
void G4OpenInventorScene::RequestPrimitives (const G4VSolid& solid) {
void G4OpenInventorSceneHandler::ClearTransientStore () {
transientRoot->removeAllChildren();
}
void G4OpenInventorSceneHandler::RequestPrimitives (const G4VSolid& solid) {
// Stop-gap solution for display List re-use.
// A proper implementation would use geometry hierarchy.
//
G4VScene::RequestPrimitives (solid);
G4VSceneHandler::RequestPrimitives (solid);
}
G4int G4OpenInventorScene::fSceneIdCount = 0;
G4int G4OpenInventorSceneHandler::fSceneIdCount = 0;
G4int G4OpenInventorScene::fSceneCount = 0;
G4int G4OpenInventorSceneHandler::fSceneCount = 0;
//
// These methods add primitives using the HEPVis classes
//
void G4OpenInventorScene::AddThis (const G4Box & Box) {
void G4OpenInventorSceneHandler::AddThis (const G4Box & Box) {
SoCube *g4Box = new SoCube();
g4Box->width =2*Box.GetXHalfLength();
g4Box->height=2*Box.GetYHalfLength();
g4Box->depth =2*Box.GetZHalfLength();
currentSeparator->addChild(g4Box);
}
void G4OpenInventorScene::AddThis (const G4Tubs & Tubs) {
void G4OpenInventorSceneHandler::AddThis (const G4Tubs & Tubs) {
SoG4Tubs *g4Tubs = new SoG4Tubs();
g4Tubs->pRMin = Tubs.GetRMin();
g4Tubs->pRMax = Tubs.GetRMax();
@@ -517,7 +534,7 @@ void G4OpenInventorScene::AddThis (const G4Tubs & Tubs) {
g4Tubs->pDPhi = Tubs.GetDPhi();
currentSeparator->addChild(g4Tubs);
}
void G4OpenInventorScene::AddThis (const G4Cons &cons) {
void G4OpenInventorSceneHandler::AddThis (const G4Cons &cons) {
SoG4Cons *g4Cons = new SoG4Cons();
g4Cons->fRmin1 = cons.GetRmin1();
g4Cons->fRmin2 = cons.GetRmin2();
@@ -529,7 +546,7 @@ void G4OpenInventorScene::AddThis (const G4Cons &cons) {
currentSeparator->addChild(g4Cons);
}
void G4OpenInventorScene::AddThis (const G4Trap &trap) {
void G4OpenInventorSceneHandler::AddThis (const G4Trap &trap) {
G4ThreeVector SymAxis=trap.GetSymAxis();
SoG4Trap *g4Trap = new SoG4Trap();
@@ -545,7 +562,7 @@ void G4OpenInventorScene::AddThis (const G4Trap &trap) {
currentSeparator->addChild(g4Trap);
}
void G4OpenInventorScene::AddThis (const G4Trd &trd) {
void G4OpenInventorSceneHandler::AddThis (const G4Trd &trd) {
SoG4Trd *g4Trd = new SoG4Trd();
g4Trd->fDx1 = trd.GetXHalfLength1();
g4Trd->fDx2 = trd.GetXHalfLength2();
@@ -555,7 +572,7 @@ void G4OpenInventorScene::AddThis (const G4Trd &trd) {
currentSeparator->addChild(g4Trd);
}
void G4OpenInventorScene::PreAddThis
void G4OpenInventorSceneHandler::PreAddThis
(const G4Transform3D& objectTransformation,
const G4VisAttributes& visAttribs) {
@@ -563,7 +580,7 @@ void G4OpenInventorScene::PreAddThis
// G4VPhysicalVolume. This is true at present, but beware! We
// might have to think about the cast in the following code.
G4VScene::PreAddThis (objectTransformation, visAttribs);
G4VSceneHandler::PreAddThis (objectTransformation, visAttribs);
// Stores arguments away for future use, e.g., AddPrimitives.
// This routines prepares to add solids to the scene database.
@@ -584,7 +601,7 @@ void G4OpenInventorScene::PreAddThis
// First find the color attributes.
//
const G4VisAttributes* pVisAttribs =
fpView -> GetApplicableVisAttributes (&visAttribs);
fpViewer -> GetApplicableVisAttributes (&visAttribs);
const G4Colour& g4Col = pVisAttribs -> GetColour ();
const double red=g4Col.GetRed ();
const double green=g4Col.GetGreen ();
@@ -637,7 +654,7 @@ void G4OpenInventorScene::PreAddThis
}
MotherVolume=MotherVolume->GetMother();
}
if (!MotherVolume) root->addChild(g4DetectorTreeKit);
if (!MotherVolume) staticRoot->addChild(g4DetectorTreeKit);
currentSeparator = previewSeparator;
}
//
@@ -665,13 +682,13 @@ void G4OpenInventorScene::PreAddThis
}
//
// If the mother volume has no full separator, then the solid and its
// attributes will go under "root"
// attributes will go under "staticRoot"
//
if (!currentSeparator) {
SoMaterial* newColor = new SoMaterial();
newColor->diffuseColor.setValue(red,green,blue);
root->addChild(newColor);
currentSeparator=root;
staticRoot->addChild(newColor);
currentSeparator=staticRoot;
}
else {
SoMaterial* newColor = new SoMaterial();
@@ -684,23 +701,23 @@ void G4OpenInventorScene::PreAddThis
//
G4OpenInventorTransform3D oiTran (objectTransformation);
SoSFMatrix* oiMat = oiTran.GetOIMatrix();
SoMatrixTransform* rootXform = new SoMatrixTransform;
rootXform->matrix.setValue(oiMat->getValue());
SoMatrixTransform* xform = new SoMatrixTransform;
xform->matrix.setValue(oiMat->getValue());
currentSeparator->addChild(new SoResetTransform);
currentSeparator->addChild(rootXform);
currentSeparator->addChild(xform);
}
G4double G4OpenInventorScene::GetMarkerSize ( const G4VMarker& mark )
G4double G4OpenInventorSceneHandler::GetMarkerSize ( const G4VMarker& mark )
{
//----- return value ( marker radius in 3d units)
G4double size = 1.0 ; // initialization
//----- parameters to calculate 3d size from 2d size
const double HALF_SCREEN_SIZE_2D = 300.0 ; // pixels
double zoom_factor = fpView->GetViewParameters().GetZoomFactor() ;
double zoom_factor = fpViewer->GetViewParameters().GetZoomFactor() ;
if ( zoom_factor <= 0.0 ) { zoom_factor = 1.0 ; }
double extent_radius_3d = GetSceneData().GetExtent().GetExtentRadius() ;
double extent_radius_3d = GetScene()->GetExtent().GetExtentRadius() ;
if ( extent_radius_3d <= 0.0 ) { extent_radius_3d = 1.0 ; }
//----- get marker radius in 3D units
@@ -722,7 +739,7 @@ G4double G4OpenInventorScene::GetMarkerSize ( const G4VMarker& mark )
} else {
// local
double mark_radius_2d \
= fpView->GetViewParameters().GetDefaultMarker().GetScreenSize();
= fpViewer->GetViewParameters().GetDefaultMarker().GetScreenSize();
// get mark radius in 3D units
size \
@@ -731,10 +748,10 @@ G4double G4OpenInventorScene::GetMarkerSize ( const G4VMarker& mark )
}
//----- global rescaling
size *= fpView->GetViewParameters().GetGlobalMarkerScale();
size *= fpViewer->GetViewParameters().GetGlobalMarkerScale();
//----- return size
return size ;
} // G4OpenInventorScene::GetMarkerSize ()
} // G4OpenInventorSceneHandler::GetMarkerSize ()
#endif
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenInventorTransform3D.cc,v 2.2 1998/09/19 14:09:50 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4OpenInventorTransform3D.cc,v 1.2 1999/01/09 16:25:16 allison Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// jck 17 Dec 1996
@@ -1,235 +0,0 @@
// 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: G4OpenInventorView.cc,v 2.10 1998/12/04 13:18:12 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
/*
* jck 05 Feb 1997 - Initial Implementation
* jck 21 Apr 1997
* Mods for SoXtHepViewer
*
*/
#ifdef G4VIS_BUILD_OI_DRIVER
#ifndef WIN32 //SoXtHepViewer not ported on Windows/NT.
#define HEP_VIEWER
#endif
#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoSelection.h>
#ifdef HEP_VIEWER
#include <HEPVis/Xt/viewers/SoXtHepViewer.h>
#else
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#endif
#include "G4OpenInventor.hh"
#include "G4OpenInventorView.hh"
#include "G4OpenInventorScene.hh"
#include "G4VInteractorManager.hh"
//
// Global variables
//
//static void SecondaryLoopPostAction ();
void G4OpenInventorView::FinishView () {
#ifdef HEP_VIEWER
((SoXtHepViewer*)G4OIViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)G4OIViewer)->getCurrentViewer()->saveHomePosition();
#else
((SoXtViewer*)G4OIViewer)->viewAll();
((SoXtViewer*)G4OIViewer)->saveHomePosition();
#endif
}
//
// Exit
//
int quitCB(void* interactorManager) {
((G4VInteractorManager*)interactorManager) ->
RequireExitSecondaryLoop (OIV_EXIT_CODE);
return 0;
}
//static void SecondaryLoopPostAction ()
//{
// Display *display = G4OIViewer->getDisplay();
// XSync(display, False);
// if(interactorManager -> GetExitSecondaryLoopCode ()==OIV_EXIT_CODE) {
// if (G4OIShell!=NULL) XtRealizeWidget(G4OIShell);
// }
//}
void G4OpenInventorView::KernelVisitDecision () {
//
// Trigger a display List refresh if necessary. This is a checklist
// of relevant view parameters.
//
static G4ViewParameters lastVP; // Initialised to default.
G4bool need = false;
if (
(lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
(lastVP.GetRepStyle () != fVP.GetRepStyle ()) ||
(lastVP.IsCulling () != fVP.IsCulling ()) ||
(lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
(lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) ||
(lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) ||
(lastVP.IsSection () != fVP.IsSection ()) ||
(lastVP.IsCutaway () != fVP.IsCutaway ()) ||
(lastVP.GetCutawayPlanes ().entries () !=
fVP.GetCutawayPlanes ().entries ()) ||
(lastVP.IsExplode () != fVP.IsExplode ()) ||
(lastVP.GetNoOfSides () != fVP.GetNoOfSides ())
) {
need = true;;
}
if (!need && lastVP.IsDensityCulling () &&
(lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ()))
need = true;
if (!need && lastVP.IsExplode () &&
(lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
need = true;
if (need) {
lastVP = fVP;
NeedKernelVisit ();
}
}
G4OpenInventorView::G4OpenInventorView (G4OpenInventorScene& scene,
const G4String& name):
G4VView (scene, scene.IncrementViewCount (), name),
fScene (scene),
OIvisualfound (false),
G4OIViewer(NULL),
G4OIShell(NULL)
{
interactorManager = ((G4OpenInventor*)fScene.GetGraphicsSystem()) ->
GetInteractorManager ();
Widget toplevel = (Widget)interactorManager->GetMainInteractor ();
//interactorManager->
//AddSecondaryLoopPostAction ((G4SecondaryLoopAction)SecondaryLoopPostAction);
OIvisualfound = true;
G4cout << "Window name: " << fName << endl;
//
// Selection
//
G4OISelection = new SoSelection;
G4OISelection->policy = SoSelection::SINGLE;
G4OISelection->ref();
G4OISelection->addChild(fScene.root);
Widget parent = (Widget)interactorManager->GetParentInteractor ();
SbBool buildInsideParent;
char charOIName[100];
strncpy (charOIName, fName, 100);
char* wname = charOIName;
if(parent==NULL) { //Ask Inventor to create a viewer in its own shell.
parent = toplevel;
buildInsideParent = FALSE;
} else { //Ask Inventor to create a viewer in the given parent.
buildInsideParent = TRUE;
char* str = interactorManager->GetCreationString ();
if(str!=NULL) wname = str;
}
//
// Create and Customize the Viewer
//
#ifdef HEP_VIEWER
G4OIViewer = new SoXtHepViewer (parent,wname,buildInsideParent);
((SoXtHepViewer*)G4OIViewer)->hideTextArea();
((SoXtHepViewer*)G4OIViewer)->resizeMain(550,550);
((SoXtHepViewer*)G4OIViewer)->setQuitCallback(quitCB, interactorManager);
((SoXtHepViewer*)G4OIViewer)->setSceneGraph(G4OISelection);
((SoXtHepViewer*)G4OIViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)G4OIViewer)->getCurrentViewer()->saveHomePosition();
#else
G4OIViewer = new SoXtExaminerViewer(parent,wname,buildInsideParent);
G4OIViewer->setSize(SbVec2s(550,550));
((SoXtViewer*)G4OIViewer)->setSceneGraph(G4OISelection);
((SoXtViewer*)G4OIViewer)->viewAll();
((SoXtViewer*)G4OIViewer)->saveHomePosition();
#endif
G4OIViewer->setTitle(fName);
G4OIViewer->show();
#if defined(WIN32) && !defined(SoFreePackage)
// buildInsideParent==FALSE, isTopLevel, getShellWidget
// do not work with Inventor-2.4 on Win32 !
// All viewers are going to be put in the same shell window !
if(buildInsideParent==FALSE) {
G4OIShell = toplevel;
interactorManager->AddShell (G4OIShell);
SoXt::show(G4OIShell);
interactorManager->FlushAndWaitExecution ();
}
#else
if(G4OIViewer->isTopLevelShell()==TRUE) {
G4OIShell = G4OIViewer -> getShellWidget();
if(G4OIShell!=NULL) {
interactorManager->AddShell (G4OIShell);
SoXt::show(G4OIShell);
interactorManager->FlushAndWaitExecution ();
}
}
#endif
interactorManager->SetCreatedInteractor (G4OIViewer -> getWidget());
}
G4OpenInventorView::~G4OpenInventorView () {
if(G4OIShell!=NULL) {
interactorManager -> RemoveShell (G4OIShell);
}
#ifdef HEP_VIEWER
delete ((SoXtHepViewer*)G4OIViewer);
#else
delete ((SoXtExaminerViewer*)G4OIViewer);
#endif
if(G4OISelection!=NULL) {
G4OISelection->unref();
}
}
void G4OpenInventorView::ClearView () {
}
void G4OpenInventorView::SetView () {
}
void G4OpenInventorView::DrawView () {
KernelVisitDecision ();
ProcessView ();
FinishView ();
}
void G4OpenInventorView::ShowView () {
interactorManager -> SecondaryLoop ();
}
#endif
@@ -0,0 +1,222 @@
// 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: G4OpenInventorViewer.cc,v 1.2 1999/05/12 14:01:02 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
/*
* jck 05 Feb 1997 - Initial Implementation
* jck 21 Apr 1997
* Mods for SoXtHepViewer
* gb : on Win32 use an SoXtExaminerViewer.
*/
#ifdef G4VIS_BUILD_OI_DRIVER
#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/nodes/SoSelection.h>
#include <HEPVis/viewers/SoWindow.h>
#ifdef WIN32
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#else
#include <HEPVis/Xt/viewers/SoXtHepViewer.h>
#endif
#include "G4OpenInventor.hh"
#include "G4OpenInventorViewer.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4VInteractorManager.hh"
//
// Global variables
//
//static void SecondaryLoopPostAction ();
void G4OpenInventorViewer::FinishView () {
if(fViewer==NULL) return;
#ifdef WIN32
((SoXtViewer*)fViewer)->viewAll();
((SoXtViewer*)fViewer)->saveHomePosition();
#else
((SoXtHepViewer*)fViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)fViewer)->getCurrentViewer()->saveHomePosition();
#endif
}
//
// Exit
//
int quitCB(void* interactorManager) {
((G4VInteractorManager*)interactorManager) ->
RequireExitSecondaryLoop (OIV_EXIT_CODE);
return 0;
}
//static void SecondaryLoopPostAction ()
//{
// Display *display = fViewer->getDisplay();
// XSync(display, False);
// if(interactorManager -> GetExitSecondaryLoopCode ()==OIV_EXIT_CODE) {
// if (fShell!=NULL) XtRealizeWidget(fShell);
// }
//}
void G4OpenInventorViewer::KernelVisitDecision () {
//
// Trigger a display List refresh if necessary. This is a checklist
// of relevant view parameters.
//
static G4ViewParameters lastVP; // Initialised to default.
G4bool need = false;
if (
(lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
(lastVP.GetRepStyle () != fVP.GetRepStyle ()) ||
(lastVP.IsCulling () != fVP.IsCulling ()) ||
(lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
(lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) ||
(lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) ||
(lastVP.IsSection () != fVP.IsSection ()) ||
(lastVP.IsCutaway () != fVP.IsCutaway ()) ||
(lastVP.GetCutawayPlanes ().entries () !=
fVP.GetCutawayPlanes ().entries ()) ||
(lastVP.IsExplode () != fVP.IsExplode ()) ||
(lastVP.GetNoOfSides () != fVP.GetNoOfSides ())
) {
need = true;;
}
if (!need && lastVP.IsDensityCulling () &&
(lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ()))
need = true;
if (!need && lastVP.IsExplode () &&
(lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
need = true;
if (need) {
lastVP = fVP;
NeedKernelVisit ();
}
}
G4OpenInventorViewer::G4OpenInventorViewer (G4OpenInventorSceneHandler& scene,
const G4String& name)
:G4VViewer (scene, scene.IncrementViewCount(), name)
,fSceneHandler(scene)
,fShell(NULL)
,fWindow(NULL)
,fViewer(NULL)
,fSelection(NULL)
,fInteractorManager(NULL)
{
fInteractorManager =
((G4OpenInventor*)fSceneHandler.GetGraphicsSystem())->
GetInteractorManager();
Widget toplevel = (Widget)fInteractorManager->GetMainInteractor ();
//fInteractorManager->
//AddSecondaryLoopPostAction ((G4SecondaryLoopAction)SecondaryLoopPostAction);
G4cout << "Window name: " << fName << endl;
//
// Selection
//
fSelection = new SoSelection;
fSelection->policy = SoSelection::SINGLE;
fSelection->ref();
fSelection->addChild(fSceneHandler.root);
Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
G4String wName = fName;
const char* wname = wName.data();
#define SIZE 400
if(parent==NULL) { //Create a shell window :
fWindow = new SoWindow(wname);
fWindow->setTitle(wname);
fWindow->setSize(SbVec2s(SIZE,SIZE));
fShell = parent = fWindow->getWidget();
fInteractorManager->AddShell(fShell);
} else {
char* str = fInteractorManager->GetCreationString ();
if(str!=NULL) wname = str;
}
//
// Create and Customize the Viewer
//
#ifdef WIN32
fViewer = new SoXtExaminerViewer(parent,wname,TRUE);
fViewer->setSize(SbVec2s(SIZE,SIZE));
((SoXtViewer*)fViewer)->setSceneGraph(fSelection);
((SoXtViewer*)fViewer)->viewAll();
((SoXtViewer*)fViewer)->saveHomePosition();
#else
fViewer = new SoXtHepViewer (parent,wname,TRUE);
((SoXtHepViewer*)fViewer)->hideTextArea();
((SoXtHepViewer*)fViewer)->resizeMain(SIZE,SIZE);
((SoXtHepViewer*)fViewer)->setQuitCallback(quitCB, fInteractorManager);
((SoXtHepViewer*)fViewer)->setSceneGraph(fSelection);
((SoXtHepViewer*)fViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)fViewer)->getCurrentViewer()->saveHomePosition();
#endif
fViewer->setTitle(fName);
fViewer->show();
if(fWindow!=NULL) {
fWindow->show();
fInteractorManager->FlushAndWaitExecution ();
}
fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
}
G4OpenInventorViewer::~G4OpenInventorViewer () {
if(fShell!=NULL) fInteractorManager -> RemoveShell (fShell);
if(fViewer!=NULL) {
#ifdef WIN32
delete ((SoXtExaminerViewer*)fViewer);
#else
delete ((SoXtHepViewer*)fViewer);
#endif
}
if(fWindow!=NULL) delete fWindow;
if(fSelection!=NULL) fSelection->unref();
}
void G4OpenInventorViewer::ClearView () {
}
void G4OpenInventorViewer::SetView () {
}
void G4OpenInventorViewer::DrawView () {
G4cout << "debug Iv::DrawViewer " <<endl;
KernelVisitDecision ();
ProcessView ();
FinishView ();
}
void G4OpenInventorViewer::ShowView () {
fInteractorManager -> SecondaryLoop ();
}
#endif
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenInventorWin32.cc,v 2.7 1998/12/08 09:51:39 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4OpenInventorWin32.cc,v 1.3 1999/05/10 15:39:01 johna Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// OpenInventor graphics system factory.
@@ -16,8 +16,8 @@
#include "G4OpenInventorWin32.hh"
#include "G4OpenInventorScene.hh"
#include "G4OpenInventorView.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4Win32.hh"
@@ -35,4 +35,6 @@ G4OpenInventorWin32::G4OpenInventorWin32 ()
InitHEPVis();
}
G4OpenInventorWin32::~G4OpenInventorWin32 () {}
#endif
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenInventorX.cc,v 2.6 1998/12/08 09:51:40 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4OpenInventorX.cc,v 1.3 1999/05/10 15:39:02 johna Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -17,8 +17,8 @@
#include <Inventor/Xt/SoXt.h>
#include "G4OpenInventorX.hh"
#include "G4OpenInventorScene.hh"
#include "G4OpenInventorView.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4Xt.hh"
@@ -38,4 +38,6 @@ G4OpenInventorX::G4OpenInventorX ()
InitHEPVis();
}
G4OpenInventorX::~G4OpenInventorX () {}
#endif