35#include <Inventor/nodes/SoSelection.h>
36#include <Inventor/nodes/SoShape.h>
37#include <Inventor/nodes/SoOrthographicCamera.h>
38#include <Inventor/nodes/SoPerspectiveCamera.h>
39#include <Inventor/actions/SoCallbackAction.h>
40#include <Inventor/actions/SoWriteAction.h>
41#include <Inventor/sensors/SoNodeSensor.h>
61:
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
62,fG4OpenInventorSceneHandler(sceneHandler)
82 GetInteractorManager();
91 SoGroup* group =
new SoGroup;
100 SoOrthographicCamera* camera =
new SoOrthographicCamera;
101 camera->viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
103 camera->position.setValue(0,0,10);
104 camera->orientation.setValue(SbRotation(SbVec3f(0,1,0),0));
105 camera->height.setValue(10);
106 camera->nearDistance.setValue(1);
107 camera->farDistance.setValue(100);
108 camera->focalDistance.setValue(10);
109 group->addChild(camera);
112 if(soInput.openFile(
"g4view.iv",
TRUE)) {
113 SoSeparator* separator = SoDB::readAll(&soInput);
153 CompareForKernelVisit(fLastVP)) {
244 if(radius<=0.) radius = 1.;
247 const G4Point3D cameraPosition = target + cameraDistance * direction;
269 camera->position.setValue((
float)cameraPosition.
x(),
270 (
float)cameraPosition.
y(),
271 (
float)cameraPosition.
z());
273 SbVec3f sbTarget((
float)target.
x(),
276 SbVec3f sbUp((
float)up.
x(),
282 pointAt(camera,sbTarget,sbUp);
289 if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
299 }
else if(camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
312G4OpenInventorViewer::pointAt(SoCamera* camera,
const SbVec3f & targetpoint,
const SbVec3f & upvector)
314 SbVec3f dir = targetpoint - camera->position.getValue();
315 if (dir.normalize() == 0.0f)
return;
316 lookAt(camera,dir, upvector);
323G4OpenInventorViewer::lookAt(SoCamera* camera,
const SbVec3f & dir,
const SbVec3f & up)
327 SbVec3f x = y.cross(z);
337 SbMatrix rot = SbMatrix::identity();
350 camera->orientation.setValue(SbRotation(rot));
354G4OpenInventorViewer::lookedAt(SoCamera* camera,SbVec3f & dir, SbVec3f & up)
356 SbRotation rot = camera->orientation.getValue();
357 SbMatrix mrot; rot.getValue(mrot);
376 up = SbVec3f(0.f,1.f,0.f);
377 if (std::abs(up.dot(z)) > 1.e-6) {
396void G4OpenInventorViewer::GroupCameraSensorCB(
void* aThis, SoSensor* aSensor)
400 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
404 if(node->isOfType(SoCamera::getClassTypeId())) {
405 SoCamera* camera = (SoCamera*)node;
409 SbVec3f direction, up;
410 lookedAt(camera, direction, up);
412 (
G4Vector3D(-direction[0], -direction[1], -direction[2]));
415 SbVec3f pos = camera->position.getValue();
416 SbVec3f target = pos + direction * camera->focalDistance.getValue();
464 SoNode* node = ((SoFullPath*)aPath)->getTail();
466 if(attHolder && attHolder->
GetAttDefs().size()) {
467 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
472 G4String name((
char*)node->getName().getString());
473 G4String cls((
char*)node->getTypeId().getName().getString());
474 G4cout <<
"SoNode : " << node
475 <<
" SoType : " << cls
476 <<
" name : " << name
502void G4OpenInventorViewer::DrawDetector() {
529 fGL2PSAction->setTitleAndProducer(
"Geant4 output",
"Geant4");
541 fGL2PSAction->setTitleAndProducer(
"Geant4 output",
"Geant4");
569 SbBool genAlternateRep =
TRUE;
571 SbBool binary =
TRUE;
573 if(genAlternateRep==
TRUE) {
578 SoWriteAction writeAction;
579 writeAction.getOutput()->openFile(aFile.c_str());
580 writeAction.getOutput()->setBinary(binary);
582 writeAction.getOutput()->closeFile();
584 if(genAlternateRep==
TRUE) {
599static void CountTrianglesCB(
602,
const SoPrimitiveVertex*
603,
const SoPrimitiveVertex*,
604const SoPrimitiveVertex*)
610static void CountLineSegmentsCB(
613,
const SoPrimitiveVertex*
614,
const SoPrimitiveVertex*)
620static void CountPointsCB(
623,
const SoPrimitiveVertex*)
635 SoCallbackAction callbackAction;
636 callbackAction.addTriangleCallback
637 (SoShape::getClassTypeId(),CountTrianglesCB,(
void*)&counter);
638 callbackAction.addLineSegmentCallback
639 (SoShape::getClassTypeId(),CountLineSegmentsCB,(
void*)&counter);
640 callbackAction.addPointCallback
641 (SoShape::getClassTypeId(),CountPointsCB,(
void*)&counter);
646 int nodes = counterAction.
getCount();
649 counterAction.
setType(SoShape::getClassTypeId());
651 int shapes = counterAction.
getCount();
689 switch (existingStyle) {
710 switch (existingStyle) {
738 switch (existingStyle) {
771 if(aTopic==
"controls") {
773Controls on an Inventor examiner viewer are :\n\
774- in picking mode (cursor is the upper left arrow)\n\
775 Ctrl + pick a volume : see daughters.\n\
776 Shift + pick a volume : see mother.\n\
777- in viewing mode (cursor is the hand)\n\
778 Left-button + pointer move : rotate.\n\
779 Ctrl+Left-button + pointer move : pan.\n\
780 Ctrl+Shift+Left-button + pointer move : scale.\n\
781 Middle-button + pointer move : pan.\n\
782 Right-button : popup menu.\n");
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
G4GLOB_DLL std::ostream G4cout
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
G4String Help(const G4String &topic="controls")
virtual SoCamera * GetCamera()=0
SoNodeSensor * fGroupCameraSensor
void WriteInventor(const G4String &file="g4out.iv")
virtual void ViewerRender()=0
SoSelection * fSoSelection
void WritePostScript(const G4String &file="g4out.ps")
void Escape()
Menu items callbacks /////////////////////////////////////////////////////.
G4OpenInventorSceneHandler & fG4OpenInventorSceneHandler
void SceneGraphStatistics()
virtual void KernelVisitDecision()
G4OpenInventorViewer(G4OpenInventorSceneHandler &scene, const G4String &name="")
virtual ~G4OpenInventorViewer()
G4VInteractorManager * fInteractorManager
void WritePixmapPostScript(const G4String &file="g4out.ps")
static void SelectionCB(void *, SoPath *)
void WritePDF(const G4String &file="g4out.pdf")
Geant4_SoImageWriter * fSoImageWriter
void SetReducedWireFrame(bool)
Geant4_SoGL2PSAction * fGL2PSAction
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
void RequireExitSecondaryLoop(int)
G4VGraphicsSystem * GetGraphicsSystem() const
G4Scene * GetScene() const
const G4ViewParameters & GetViewParameters() const
G4VSceneHandler & fSceneHandler
G4ViewParameters fDefaultVP
virtual void FinishView()
void SetViewParameters(const G4ViewParameters &vp)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Vector3D & GetScaleFactor() const
void SetAutoRefresh(G4bool)
G4int GetNoOfSides() const
G4bool IsSpecialMeshRendering() const
CutawayMode GetCutawayMode() const
G4double GetCameraDistance(G4double radius) const
G4double GetExplodeFactor() const
G4int GetNumberOfCloudPoints() const
G4bool IsMarkerNotHidden() const
G4double GetGlobalLineWidthScale() const
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetViewpointDirection() const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFieldHalfAngle() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
const G4Vector3D & GetUpVector() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4double GetGlobalMarkerScale() const
G4bool IsCullingInvisible() const
const G4VisAttributes * GetDefaultVisAttributes() const
void SetUpVector(const G4Vector3D &upVector)
const G4Planes & GetCutawayPlanes() const
G4bool IsDensityCulling() const
G4double GetVisibleDensity() const
SMROption GetSpecialMeshRenderingOption() const
void SetAuxEdgeVisible(G4bool)
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
const G4Colour & GetColour() const
G4double GetExtentRadius() const
BasicVector3D< T > unit() const
void setGenerate(SbBool)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setType(const SoType, SbBool=TRUE)