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);
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(),
289 if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
299 }
else if(camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
314 SbVec3f dir = targetpoint - camera->position.getValue();
315 if (dir.normalize() == 0.0f)
return;
316 lookAt(camera,dir, upvector);
327 SbVec3f x = y.cross(z);
337 SbMatrix rot = SbMatrix::identity();
350 camera->orientation.setValue(SbRotation(rot));
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) {
400 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
404 if(node->isOfType(SoCamera::getClassTypeId())) {
405 SoCamera* camera = (SoCamera*)node;
409 SbVec3f 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) {
473 G4String cls((
char*)node->getTypeId().getName().getString());
474 G4cout <<
"SoNode : " << node
475 <<
" SoType : " << cls
476 <<
" name : " <<
name
573 SbBool genAlternateRep =
TRUE;
575 SbBool binary =
TRUE;
577 if(genAlternateRep==
TRUE) {
582 SoWriteAction writeAction;
583 writeAction.getOutput()->openFile(aFile.c_str());
584 writeAction.getOutput()->setBinary(binary);
586 writeAction.getOutput()->closeFile();
588 if(genAlternateRep==
TRUE) {
606,
const SoPrimitiveVertex*
607,
const SoPrimitiveVertex*,
608const SoPrimitiveVertex*)
617,
const SoPrimitiveVertex*
618,
const SoPrimitiveVertex*)
627,
const SoPrimitiveVertex*)
639 SoCallbackAction callbackAction;
640 callbackAction.addTriangleCallback
642 callbackAction.addLineSegmentCallback
644 callbackAction.addPointCallback
653 counterAction.
setType(SoShape::getClassTypeId());
655 int shapes = counterAction.
getCount();
693 switch (existingStyle) {
714 switch (existingStyle) {
742 switch (existingStyle) {
775 if(aTopic==
"controls") {
777Controls on an Inventor examiner viewer are :\n\
778- in picking mode (cursor is the upper left arrow)\n\
779 Ctrl + pick a volume : see daughters.\n\
780 Shift + pick a volume : see mother.\n\
781- in viewing mode (cursor is the hand)\n\
782 Left-button + pointer move : rotate.\n\
783 Ctrl+Left-button + pointer move : pan.\n\
784 Ctrl+Shift+Left-button + pointer move : scale.\n\
785 Middle-button + pointer move : pan.\n\
786 Right-button : popup menu.\n");
static const G4double pos
static void CountLineSegmentsCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *, const SoPrimitiveVertex *)
static void CountPointsCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *)
static void CountTrianglesCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *, const SoPrimitiveVertex *, const SoPrimitiveVertex *)
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
SoSeparator * fTransientRoot
SoSeparator * fDetectorRoot
G4String Help(const G4String &topic="controls")
virtual SoCamera * GetCamera()=0
SoNodeSensor * fGroupCameraSensor
void WriteInventor(const G4String &file="g4out.iv")
static void pointAt(SoCamera *, const SbVec3f &targetpoint, const SbVec3f &upvector)
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()
static void lookedAt(SoCamera *, SbVec3f &dir, SbVec3f &up)
G4OpenInventorViewer(G4OpenInventorSceneHandler &scene, const G4String &name="")
virtual ~G4OpenInventorViewer()
static void lookAt(SoCamera *, const SbVec3f &dir, const SbVec3f &up)
G4VInteractorManager * fInteractorManager
void WritePixmapPostScript(const G4String &file="g4out.ps")
static void SelectionCB(void *, SoPath *)
G4bool CompareForKernelVisit(G4ViewParameters &)
void WritePDF(const G4String &file="g4out.pdf")
Geant4_SoImageWriter * fSoImageWriter
void SetReducedWireFrame(bool)
static void GroupCameraSensorCB(void *, SoSensor *)
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
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
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)
const char * name(G4int ptype)