Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenInventorViewer.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26
27// 03-MAY-2021 F.W. Jones: removed the camera sensor which is redundant
28// since the group node sensor receives all camera motion events and
29// can update the view parameters, irrespective of any changes to the
30// camera type.
31
32// this :
34
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>
42
47
48#include "G4OpenInventor.hh"
51#include "G4Scene.hh"
52#include "Geant4_SoPolyhedron.h"
53#include "G4AttValue.hh"
54#include "G4AttDef.hh"
55#include "G4AttCheck.hh"
56#include "G4AttHolder.hh"
57
59 G4OpenInventorSceneHandler& sceneHandler
60,const G4String& name)
61:G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
62,fG4OpenInventorSceneHandler(sceneHandler)
66,fGL2PSAction(0) //To be set be suclass.
68 //,fCameraSensor(0)
69{
70 fVP.SetAutoRefresh(true);
71 fDefaultVP.SetAutoRefresh(true);
72 fVP.SetPicking(true);
73 fDefaultVP.SetPicking(true);
74
75 //FIXME : G.Barrand : not convinced that we have to rm culling.
76 // For viewing of all objects by default :
77 //fDefaultVP.SetCulling(false);
78 //fVP.SetCulling(false);
79
81 ((G4OpenInventor*)fG4OpenInventorSceneHandler.GetGraphicsSystem())->
82 GetInteractorManager();
83
84 // Main user scene graph root sent to the viewers.
85 fSoSelection = new SoSelection;
86 fSoSelection->ref();
87 fSoSelection->addSelectionCallback(SelectionCB,this);
88 //fSoSelection->addDeselectionCallback(DeselectionCB,this);
89 fSoSelection->policy = SoSelection::SINGLE;
90
91 SoGroup* group = new SoGroup;
92 fSoSelection->addChild(group);
93
94 // Have a camera under fSoSelection in order
95 // that the below SceneGraphSensor be notifed
96 // when the viewer changes the camera type.
97 // But we put the camera under a SoGroup so that
98 // the SceneGraphSensor be not triggered at each change
99 // under the fG4OpenInventorSceneHandler.fRoot.
100 SoOrthographicCamera* camera = new SoOrthographicCamera;
101 camera->viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
102 //camera->aspectRatio.setValue(10);
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);
110
111 {SoInput soInput;
112 if(soInput.openFile("g4view.iv",TRUE)) {
113 SoSeparator* separator = SoDB::readAll(&soInput);
114 if(separator) fSoSelection->addChild(separator);
115 }}
116
118
119 // SoImageWriter should be the last.
121 fSoImageWriter->fileName.setValue("g4out.ps");
122 fSoSelection->addChild(fSoImageWriter);
123
124 // Sensors :
125 // To detect that the viewer had changed the camera type :
126 fGroupCameraSensor = new SoNodeSensor(GroupCameraSensorCB,this);
127 fGroupCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
128 fGroupCameraSensor->attach(group);
129 // FWJ Upgraded the group sensor so the camera sensor is not needed
130 // fCameraSensor = new SoNodeSensor(CameraSensorCB,this);
131 // fCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
132 // fCameraSensor->attach(camera);
133}
134
136 // fCameraSensor->detach();
137 // delete fCameraSensor;
138 fGroupCameraSensor->detach();
139 delete fGroupCameraSensor;
140 fSoSelection->unref();
141}
142
144
145 // If there's a significant difference with the last view parameters
146 // of either the scene handler or this viewer, trigger a rebuild.
147
148 if (
149 //??fG4OpenInventorSceneHandler.fPODLList.size() == 0 ||
150 // We need a test for empty scene graph, such as
151 // staticRoot.size() or something?????????? See temporary fix
152 // in contructor. (John Allison Aug 2001)
153 CompareForKernelVisit(fLastVP)) {
155 }
156}
157
158G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
159
160 if (
161 (vp.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
163 (vp.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
164 (vp.IsCulling () != fVP.IsCulling ()) ||
166 (vp.IsDensityCulling () != fVP.IsDensityCulling ()) ||
167 (vp.IsCullingCovered () != fVP.IsCullingCovered ()) ||
168 (vp.GetCBDAlgorithmNumber() !=
170 (vp.IsSection () != fVP.IsSection ()) ||
171 (vp.IsCutaway () != fVP.IsCutaway ()) ||
172 // This assumes use of generic clipping (sectioning, slicing,
173 // DCUT, cutaway). If a decision is made to implement locally,
174 // this will need changing. See G4OpenGLViewer::SetView,
175 // G4OpenGLStoredViewer.cc::CompareForKernelVisit and
176 // G4OpenGLStoredSceneHander::CreateSection/CutawayPolyhedron.
177 (vp.IsExplode () != fVP.IsExplode ()) ||
178 (vp.GetNoOfSides () != fVP.GetNoOfSides ()) ||
187 (vp.IsPicking () != fVP.IsPicking ()) ||
188 // Scaling for Open Inventor is done by the scene handler so it
189 // needs a kernel visit. (In this respect, it differs from the
190 // OpenGL drivers, where it's done in SetView.)
191 (vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
196 (vp.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
197 (vp.GetDotsSize() != fVP.GetDotsSize())
198 )
199 return true;
200
201 if (vp.IsDensityCulling () &&
203 return true;
204
205 if (vp.GetCBDAlgorithmNumber() > 0) {
206 if (vp.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
207 else if (vp.GetCBDParameters() != fVP.GetCBDParameters()) return true;
208 }
209
210 if (vp.IsSection () &&
211 (vp.GetSectionPlane () != fVP.GetSectionPlane ()))
212 return true;
213
214 if (vp.IsCutaway ()) {
215 if (vp.GetCutawayMode() != fVP.GetCutawayMode()) return true;
216 if (vp.GetCutawayPlanes ().size () !=
217 fVP.GetCutawayPlanes ().size ()) return true;
218 for (size_t i = 0; i < vp.GetCutawayPlanes().size(); ++i)
219 if (vp.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
220 return true;
221 }
222
223 if (vp.IsExplode () &&
224 (vp.GetExplodeFactor () != fVP.GetExplodeFactor ()))
225 return true;
226
227 if (vp.IsSpecialMeshRendering() &&
228 (vp.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
229 return true;
230
231 if (vp.GetTransparencyByDepth() > 0. &&
232 vp.GetTransparencyByDepthOption() != fVP.GetTransparencyByDepthOption())
233 return true;
234
235 return false;
236}
237
238G4bool G4OpenInventorViewer::CompareForTransientsRedraw(G4ViewParameters& vp)
239{
240 if (vp.GetTimeParameters() != fVP.GetTimeParameters()) {
241 return fTransientsNeedRedrawing = true;
242 }
243 return false;
244}
245
248
250
251 // Get G4 camera infos :
252 const G4Point3D target
253 = fSceneHandler.GetScene()->GetStandardTargetPoint()
254 + fVP.GetCurrentTargetPoint ();
255 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
256 if(radius<=0.) radius = 1.;
257 const G4double cameraDistance = fVP.GetCameraDistance (radius);
258 const G4Vector3D& direction = fVP.GetViewpointDirection().unit();
259 const G4Point3D cameraPosition = target + cameraDistance * direction;
260 //const G4double pnear = fVP.GetNearDistance (cameraDistance, radius);
261 //const G4double pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
262 const G4Normal3D& up = fVP.GetUpVector ();
263
264/*
265 printf("debug : target : %g %g %g\n",target.x(),
266 target.y(),
267 target.z());
268 printf("debug : dir : %g %g %g\n",direction.x(),
269 direction.y(),
270 direction.z());
271 printf("debug : pos : %g %g %g\n",cameraPosition.x(),
272 cameraPosition.y(),
273 cameraPosition.z());
274 //printf("debug : near %g far %g\n",pnear,pfar);
275*/
276
277 SoCamera* camera = GetCamera();
278 if(!camera) return;
279
280 // viewer camera setup :
281 camera->position.setValue((float)cameraPosition.x(),
282 (float)cameraPosition.y(),
283 (float)cameraPosition.z());
284
285 SbVec3f sbTarget((float)target.x(),
286 (float)target.y(),
287 (float)target.z());
288 SbVec3f sbUp((float)up.x(),
289 (float)up.y(),
290 (float)up.z());
291 sbUp.normalize();
292 // Need Coin's camera->pointAt(sbTarget,sbUp); not in the SGI API
293 // Stole Coin's code...
294 pointAt(camera,sbTarget,sbUp);
295
296 //camera->height.setValue(10);
297 //camera->nearDistance.setValue((float)pnear);
298 //camera->farDistance.setValue((float)pfar);
299 //camera->focalDistance.setValue((float)cameraDistance);
300
301 if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
302 if (fVP.GetFieldHalfAngle() == 0.) {
303 //FIXME : ((SoOrthographicCamera*)camera)->height.setValue();
304 //FIXME : (Don't think we have to do that.)
305 } else {
306 //FIXME : Have to set a perspective camera !
307 //FIXME : viewer->setCameraType(SoPerspectiveCamera::getClassTypeId())
308 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
309 //FIXME : (2.*fVP.GetFieldHalfAngle());
310 }
311 } else if(camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
312 if (fVP.GetFieldHalfAngle() == 0.) {
313 //FIXME : Have to set an orthographic camera !
314 //FIXME : viewer->setCameraType(SoOrthographicCamera::getClassTypeId())
315 } else {
316 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
317 //FIXME : (2.*fVP.GetFieldHalfAngle());
318 }
319 }
320}
321
322//COIN_FUNCTION_EXTENSION
323void
324G4OpenInventorViewer::pointAt(SoCamera* camera,const SbVec3f & targetpoint, const SbVec3f & upvector)
325{
326 SbVec3f dir = targetpoint - camera->position.getValue();
327 if (dir.normalize() == 0.0f) return;
328 lookAt(camera,dir, upvector);
329}
330
331//COIN_FUNCTION
332// Private method that calculates a new orientation based on camera
333// direction and camera up vector. Vectors must be unit length.
334void
335G4OpenInventorViewer::lookAt(SoCamera* camera,const SbVec3f & dir, const SbVec3f & up)
336{
337 SbVec3f z = -dir;
338 SbVec3f y = up;
339 SbVec3f x = y.cross(z);
340
341 // recompute y to create a valid coordinate system
342 y = z.cross(x);
343
344 // normalize x and y to create an orthonormal coord system
345 y.normalize();
346 x.normalize();
347
348 // create a rotation matrix
349 SbMatrix rot = SbMatrix::identity();
350 rot[0][0] = x[0];
351 rot[0][1] = x[1];
352 rot[0][2] = x[2];
353
354 rot[1][0] = y[0];
355 rot[1][1] = y[1];
356 rot[1][2] = y[2];
357
358 rot[2][0] = z[0];
359 rot[2][1] = z[1];
360 rot[2][2] = z[2];
361
362 camera->orientation.setValue(SbRotation(rot));
363}
364
365void
366G4OpenInventorViewer::lookedAt(SoCamera* camera,SbVec3f & dir, SbVec3f & up)
367{
368 SbRotation rot = camera->orientation.getValue();
369 SbMatrix mrot; rot.getValue(mrot);
370
371 SbVec3f x, y, z;
372
373 // create a rotation matrix
374 x[0] = mrot[0][0];
375 x[1] = mrot[0][1];
376 x[2] = mrot[0][2];
377
378 y[0] = mrot[1][0];
379 y[1] = mrot[1][1];
380 y[2] = mrot[1][2];
381
382 z[0] = mrot[2][0];
383 z[1] = mrot[2][1];
384 z[2] = mrot[2][2];
385
386 dir = -z;
387 dir.normalize();
388 up = SbVec3f(0.f,1.f,0.f); // Choose y-axis if possible.
389 if (std::abs(up.dot(z)) > 1.e-6) {
390 up = y;
391 up.normalize();
392 }
393}
394
396 //G4cout << "debug Iv::DrawViewer " <<G4endl;
398 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
399
400 ProcessView (); // Clears store and processes scene only if necessary.
401
402 if (kernelVisitWasNeeded) {
403 // We might need to do something if the kernel was visited.
404 } else { // Or even if it was not!
405 if (!fTransientsNeedRedrawing) CompareForTransientsRedraw(fLastVP);
408 }
409 }
410
411 fLastVP = fVP;
412
413 FinishView();
414}
415
417 fInteractorManager -> SecondaryLoop ();
418}
419
420// FWJ This sensor now performs the fVP updates
421void G4OpenInventorViewer::GroupCameraSensorCB(void* aThis, SoSensor* aSensor)
422{
424
425 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
426 // printf("debug : GroupCameraSensorCB %s\n",
427 // node->getTypeId().getName().getString());
428
429 if(node->isOfType(SoCamera::getClassTypeId())) {
430 SoCamera* camera = (SoCamera*)node;
431
432 // FWJ DEBUG
433 // G4cout << " UPDATING fVP FROM CAMERA " << camera << G4endl;
434 SbVec3f direction, up;
435 lookedAt(camera, direction, up);
437 (G4Vector3D(-direction[0], -direction[1], -direction[2]));
438 This->fVP.SetUpVector(G4Vector3D(up[0], up[1], up[2]));
439
440 SbVec3f pos = camera->position.getValue();
441 SbVec3f target = pos + direction * camera->focalDistance.getValue();
442
443 This->fVP.SetCurrentTargetPoint(G4Point3D(target[0], target[1], target[2]));
444
445 // FWJ camera sensor no longer needed
446 // Viewer had changed the camera type,
447 // attach the fCameraSensor to the new camera.
448 // FWJ DEBUG
449 // G4cout << " SWITCHING TO CAMERA " << camera << G4endl;
450 // This->fCameraSensor->detach();
451 // This->fCameraSensor->attach(camera);
452 }
453
454}
455
456/* FWJ This sensor is no longer needed
457void G4OpenInventorViewer::CameraSensorCB(void* aThis,SoSensor* aSensor) {
458 G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
459
460 // printf("debug : CameraSensorCB\n");
461
462 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
463// printf("debug : CameraSensorCB %s\n",
464// node->getTypeId().getName().getString());
465
466 if(node->isOfType(SoCamera::getClassTypeId())) {
467 SoCamera* camera = (SoCamera*)node;
468
469 SbVec3f direction, up;
470 lookedAt(camera,direction, up);
471 This->fVP.SetViewpointDirection
472 (G4Vector3D(-direction[0],-direction[1],-direction[2]));
473 This->fVP.SetUpVector(G4Vector3D(up[0],up[1],up[2]));
474
475 SbVec3f pos = camera->position.getValue();
476 SbVec3f target = pos + direction * camera->focalDistance.getValue();
477
478 This->fVP.SetCurrentTargetPoint(G4Point3D(target[0],target[1],target[2]));
479 }
480}
481*/
482
484 void* aThis
485,SoPath* aPath
486)
487{
489 SoNode* node = ((SoFullPath*)aPath)->getTail();
490 G4AttHolder* attHolder = dynamic_cast<G4AttHolder*>(node);
491 if(attHolder && attHolder->GetAttDefs().size()) {
492 for (size_t i = 0; i < attHolder->GetAttDefs().size(); ++i) {
493 G4cout << G4AttCheck(attHolder->GetAttValues()[i],
494 attHolder->GetAttDefs()[i]);
495 }
496 } else {
497 G4String name((char*)node->getName().getString());
498 G4String cls((char*)node->getTypeId().getName().getString());
499 G4cout << "SoNode : " << node
500 << " SoType : " << cls
501 << " name : " << name
502 << G4endl;
503 G4cout << "No attributes attached." << G4endl;
504 }
505 /*FIXME : to explore (need different button - this is used for picking.
506 if(node->isOfType(Geant4_SoPolyhedron::getClassTypeId())) {
507 Geant4_SoPolyhedron* polyhedron = (Geant4_SoPolyhedron*)node;
508 if(polyhedron->solid.getValue()==FALSE)
509 polyhedron->solid.setValue(TRUE);
510 else
511 polyhedron->solid.setValue(FALSE);
512 }*/
513 This->fSoSelection->deselectAll();
514}
515/*
516void G4OpenInventorViewer::DeselectionCB(
517 void* aThis
518,SoPath* aPath
519)
520{
521 //G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
522 G4String name((char*)aPath->getTail()->getTypeId().getName().getString());
523 G4cout << "Deselect : " << name << G4endl;
524}
525*/
526
527void G4OpenInventorViewer::DrawDetector() {
528 /* Replace this... - JA
529 // DrawView does a ClearStore. Do not clear the transient store :
530 SoSeparator* tmp = fG4OpenInventorSceneHandler.fTransientRoot;
531 fG4OpenInventorSceneHandler.fTransientRoot = new SoSeparator;
532 if (!fNeedKernelVisit) KernelVisitDecision();
533 ProcessView();
534 fG4OpenInventorSceneHandler.fTransientRoot->unref();
535 fG4OpenInventorSceneHandler.fTransientRoot = tmp;
536 */
537 // ...by this... - JA
538 DrawView();
539}
540
541//////////////////////////////////////////////////////////////////////////////
542/// Menu items callbacks /////////////////////////////////////////////////////
543//////////////////////////////////////////////////////////////////////////////
544
546 G4cout << "Escape..." <<G4endl;
547 fInteractorManager->RequireExitSecondaryLoop (OIV_EXIT_CODE);
548}
549
551 if(!fGL2PSAction) return;
552 fGL2PSAction->setFileName(aFile.c_str());
553 fGL2PSAction->setExportImageFormat_EPS();
554 fGL2PSAction->setTitleAndProducer("Geant4 output","Geant4");
555 G4cout << "Produce " << aFile << "..." << G4endl;
556 if (fGL2PSAction->enableFileWriting()) {
557 ViewerRender();
558 fGL2PSAction->disableFileWriting();
559 }
560}
561
563 if(!fGL2PSAction) return;
564 fGL2PSAction->setFileName(aFile.c_str());
565 fGL2PSAction->setExportImageFormat_PDF();
566 fGL2PSAction->setTitleAndProducer("Geant4 output","Geant4");
567 G4cout << "Produce " << aFile << "..." << G4endl;
568 if (fGL2PSAction->enableFileWriting()) {
569 ViewerRender();
570 fGL2PSAction->disableFileWriting();
571 }
572}
573
575 fSoImageWriter->fileName.setValue(aFile.c_str());
576 //imageWriter->format.setValue(SoImageWriter::POST_SCRIPT);
577 fSoImageWriter->enable();
578 ViewerRender();
579 fSoImageWriter->disable();
580 if(fSoImageWriter->getStatus()) {
581 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
582 << " produced."
583 << G4endl;
584 } else {
585 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
586 << " not produced."
587 << G4endl;
588 }
589}
590
592 G4cout << "Produce " << aFile << "..." << G4endl;
593
594 SbBool genAlternateRep = TRUE;
595 //SbBool binary = FALSE;
596 SbBool binary = TRUE;
597 SoAlternateRepAction alternateRepAction;
598 if(genAlternateRep==TRUE) {
599 alternateRepAction.setGenerate(TRUE); //Clear alternate reps.
600 alternateRepAction.apply(fSoSelection);
601 }
602
603 SoWriteAction writeAction;
604 writeAction.getOutput()->openFile(aFile.c_str());
605 writeAction.getOutput()->setBinary(binary);
606 writeAction.apply(fSoSelection);
607 writeAction.getOutput()->closeFile();
608
609 if(genAlternateRep==TRUE) {
610 alternateRepAction.setGenerate(FALSE); //Clear alternate reps.
611 alternateRepAction.apply(fSoSelection);
612 }
613
614
615
616}
617
623
624static void CountTrianglesCB(
625 void* userData
626,SoCallbackAction*
627,const SoPrimitiveVertex*
628,const SoPrimitiveVertex*,
629const SoPrimitiveVertex*)
630{
631 Counter* counter = (Counter*)userData;
632 counter->fTriangles++;
633}
634
635static void CountLineSegmentsCB(
636 void* userData
637,SoCallbackAction*
638,const SoPrimitiveVertex*
639,const SoPrimitiveVertex*)
640{
641 Counter* counter = (Counter*)userData;
642 counter->fLineSegments++;
643}
644
645static void CountPointsCB(
646 void* userData
647,SoCallbackAction*
648,const SoPrimitiveVertex*)
649{
650 Counter* counter = (Counter*)userData;
651 counter->fPoints++;
652}
653
656 counter.fTriangles = 0;
657 counter.fLineSegments = 0;
658 counter.fPoints = 0;
659
660 SoCallbackAction callbackAction;
661 callbackAction.addTriangleCallback
662 (SoShape::getClassTypeId(),CountTrianglesCB,(void*)&counter);
663 callbackAction.addLineSegmentCallback
664 (SoShape::getClassTypeId(),CountLineSegmentsCB,(void*)&counter);
665 callbackAction.addPointCallback
666 (SoShape::getClassTypeId(),CountPointsCB,(void*)&counter);
667 callbackAction.apply(fSoSelection);
668
669 SoCounterAction counterAction;
670 counterAction.apply(fSoSelection);
671 int nodes = counterAction.getCount();
672
673 counterAction.setLookFor(SoCounterAction::TYPE);
674 counterAction.setType(SoShape::getClassTypeId());
675 counterAction.apply(fSoSelection);
676 int shapes = counterAction.getCount();
677
678 G4cout << "Number of triangles : " << counter.fTriangles << G4endl;
679 G4cout << "Number of line segments : " << counter.fLineSegments << G4endl;
680 G4cout << "Number of points : " << counter.fPoints << G4endl;
681 G4cout << "Number of nodes : " << nodes << G4endl;
682 G4cout << "Number of shapes : " << shapes << G4endl;
683}
684
686 fG4OpenInventorSceneHandler.fDetectorRoot->removeAllChildren();
687}
689 fG4OpenInventorSceneHandler.fTransientRoot->removeAllChildren();
690}
691
693 fG4OpenInventorSceneHandler.fPreviewAndFull = true;
694
696 DrawDetector();
697}
698
700 fG4OpenInventorSceneHandler.fPreviewAndFull = false;
701
703 DrawDetector();
704}
705
706// When ViewParameter <-> SoCamera mapping ready
707// uncomment the below
708//#define USE_SET_VIEW
709
713 //From G4VisCommandsViewerSet : /vis/viewer/set/style solid.
714 switch (existingStyle) {
717 break;
720 break;
722 break;
724 break;
727 break;
728 }
730 DrawDetector();
731}
735 switch (existingStyle) {
737 break;
739 break;
742 break;
745 break;
748 break;
749 }
751 DrawDetector();
752}
753
754
757
758 // Set the wire frame kind :
759 vp.SetAuxEdgeVisible(!aValue);
760
761 // Set wire frame :
763 switch (existingStyle) {
765 break;
767 break;
770 break;
773 break;
776 break;
777 }
779 NeedKernelVisit(); // Just in case it was alread in wire framw.
780 DrawDetector();
781}
782
784 /* Replace this... - JA
785 fG4OpenInventorSceneHandler.ClearStore();
786 ClearView();
787 if (!fNeedKernelVisit) KernelVisitDecision();
788 ProcessView();
789 ShowView();
790 */
791 // ...by this - JA
793 DrawView();
794}
796 if(aTopic=="controls") {
797 return G4String("\
798Controls on an Inventor examiner viewer are :\n\
799- in picking mode (cursor is the upper left arrow)\n\
800 Ctrl + pick a volume : see daughters.\n\
801 Shift + pick a volume : see mother.\n\
802- in viewing mode (cursor is the hand)\n\
803 Left-button + pointer move : rotate.\n\
804 Ctrl+Left-button + pointer move : pan.\n\
805 Ctrl+Shift+Left-button + pointer move : scale.\n\
806 Middle-button + pointer move : pan.\n\
807 Right-button : popup menu.\n");
808 } else {
809 return "";
810 }
811}
HepGeom::Normal3D< G4double > G4Normal3D
Definition G4Normal3D.hh:34
HepGeom::Point3D< G4double > G4Point3D
Definition G4Point3D.hh:34
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
#define OIV_EXIT_CODE
HepGeom::Vector3D< G4double > G4Vector3D
Definition G4Vector3D.hh:34
#define G4endl
Definition G4ios.hh:67
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
void WriteInventor(const G4String &file="g4out.iv")
virtual void ViewerRender()=0
void WritePostScript(const G4String &file="g4out.ps")
void Escape()
Menu items callbacks /////////////////////////////////////////////////////.
G4OpenInventorSceneHandler & fG4OpenInventorSceneHandler
G4OpenInventorViewer(G4OpenInventorSceneHandler &scene, const G4String &name="")
G4VInteractorManager * fInteractorManager
void WritePixmapPostScript(const G4String &file="g4out.ps")
static void SelectionCB(void *, SoPath *)
void WritePDF(const G4String &file="g4out.pdf")
Geant4_SoImageWriter * fSoImageWriter
Geant4_SoGL2PSAction * fGL2PSAction
G4bool fNeedKernelVisit
Definition G4VViewer.hh:280
const G4ViewParameters & GetViewParameters() const
void ProcessView()
Definition G4VViewer.cc:112
G4VSceneHandler & fSceneHandler
Definition G4VViewer.hh:268
void ProcessTransients()
Definition G4VViewer.cc:133
void NeedKernelVisit()
Definition G4VViewer.cc:85
G4ViewParameters fDefaultVP
Definition G4VViewer.hh:273
G4bool fTransientsNeedRedrawing
Definition G4VViewer.hh:281
G4ViewParameters fVP
Definition G4VViewer.hh:272
virtual void FinishView()
Definition G4VViewer.cc:108
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition G4VViewer.cc:49
void SetViewParameters(const G4ViewParameters &vp)
Definition G4VViewer.cc:216
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Vector3D & GetScaleFactor() const
G4int GetNoOfSides() const
G4bool IsSpecialMeshRendering() const
CutawayMode GetCutawayMode() const
G4double GetExplodeFactor() const
const G4ModelingParameters::TimeParameters & GetTimeParameters() const
G4int GetNumberOfCloudPoints() const
G4bool IsMarkerNotHidden() const
G4double GetGlobalLineWidthScale() const
G4bool IsCutaway() const
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
const G4Colour & GetBackgroundColour() const
G4bool IsSection() const
G4bool IsPicking() const
G4bool IsDotsSmooth() const
G4bool IsCulling() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4bool IsExplode() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4int GetTransparencyByDepthOption() 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
G4double GetDotsSize() const
void SetAuxEdgeVisible(G4bool)
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4double GetTransparencyByDepth() const
G4bool IsAuxEdgeVisible() const
const G4Colour & GetColour() const
void setGenerate(SbBool)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setLookFor(LookFor)
void setType(const SoType, SbBool=TRUE)
#define TRUE
Definition globals.hh:41
#define FALSE
Definition globals.hh:38