Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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// $Id$
27
28#ifdef G4VIS_BUILD_OI_DRIVER
29
30// this :
32
33#include <Inventor/nodes/SoSelection.h>
34#include <Inventor/nodes/SoShape.h>
35#include <Inventor/nodes/SoOrthographicCamera.h>
36#include <Inventor/nodes/SoPerspectiveCamera.h>
37#include <Inventor/actions/SoCallbackAction.h>
38#include <Inventor/actions/SoWriteAction.h>
39#include <Inventor/sensors/SoNodeSensor.h>
40
45
46#include "G4OpenInventor.hh"
49#include "G4Scene.hh"
50#include "Geant4_SoPolyhedron.h"
51#include "G4AttValue.hh"
52#include "G4AttDef.hh"
53#include "G4AttCheck.hh"
54#include "G4AttHolder.hh"
55
56G4OpenInventorViewer::G4OpenInventorViewer(
57 G4OpenInventorSceneHandler& sceneHandler
58,const G4String& name)
59:G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
60,fG4OpenInventorSceneHandler(sceneHandler)
61,fInteractorManager(0)
62,fSoSelection(0)
63,fSoImageWriter(0)
64,fGL2PSAction(0) //To be set be suclass.
65,fGroupCameraSensor(0)
66,fCameraSensor(0)
67{
68 fNeedKernelVisit = true; //?? Temporary, until KernelVisitDecision fixed.
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
80 fInteractorManager =
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
117 fSoSelection->addChild(fG4OpenInventorSceneHandler.fRoot);
118
119 // SoImageWriter should be the last.
120 fSoImageWriter = new SoImageWriter();
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
130 fCameraSensor = new SoNodeSensor(CameraSensorCB,this);
131 fCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
132}
133
134G4OpenInventorViewer::~G4OpenInventorViewer () {
135 fCameraSensor->detach();
136 delete fCameraSensor;
137 fGroupCameraSensor->detach();
138 delete fGroupCameraSensor;
139 fSoSelection->unref();
140}
141
142void G4OpenInventorViewer::KernelVisitDecision () {
143
144 // If there's a significant difference with the last view parameters
145 // of either the scene handler or this viewer, trigger a rebuild.
146
147 if (
148 //??fG4OpenInventorSceneHandler.fPODLList.size() == 0 ||
149 // We need a test for empty scene graph, such as
150 // staticRoot.size() or something?????????? See temporary fix
151 // in contructor. (John Allison Aug 2001)
152 CompareForKernelVisit(fLastVP)) {
153 NeedKernelVisit ();
154 }
155 fLastVP = fVP;
156}
157
158G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
159
160 if (
161 (vp.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
162 (vp.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
163 (vp.GetRepStyle () != fVP.GetRepStyle ()) ||
164 (vp.IsCulling () != fVP.IsCulling ()) ||
165 (vp.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
166 (vp.IsDensityCulling () != fVP.IsDensityCulling ()) ||
167 (vp.IsCullingCovered () != fVP.IsCullingCovered ()) ||
168 (vp.IsSection () != fVP.IsSection ()) ||
169 (vp.IsCutaway () != fVP.IsCutaway ()) ||
170 // This assumes use of generic clipping (sectioning, slicing,
171 // DCUT, cutaway). If a decision is made to implement locally,
172 // this will need changing. See G4OpenGLViewer::SetView,
173 // G4OpenGLStoredViewer.cc::CompareForKernelVisit and
174 // G4OpenGLStoredSceneHander::CreateSection/CutawayPolyhedron.
175 (vp.IsExplode () != fVP.IsExplode ()) ||
176 (vp.GetNoOfSides () != fVP.GetNoOfSides ()) ||
177 (vp.IsMarkerNotHidden () != fVP.IsMarkerNotHidden ()) ||
179 fVP.GetDefaultVisAttributes()->GetColour()) ||
181 fVP.GetDefaultTextVisAttributes()->GetColour()) ||
182 (vp.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
183 (vp.IsPicking () != fVP.IsPicking ()) ||
184 // Scaling for Open Inventor is done by the scene handler so it
185 // needs a kernel visit. (In this respect, it differs from the
186 // OpenGL drivers, where it's done in SetView.)
187 (vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
188 (vp.GetVisAttributesModifiers().size() !=
189 fVP.GetVisAttributesModifiers().size())
190 )
191 return true;
192
193 if (vp.IsDensityCulling () &&
194 (vp.GetVisibleDensity () != fVP.GetVisibleDensity ()))
195 return true;
196
197 if (vp.IsSection () &&
198 (vp.GetSectionPlane () != fVP.GetSectionPlane ()))
199 return true;
200
201 if (vp.IsCutaway ()) {
202 if (vp.GetCutawayPlanes ().size () !=
203 fVP.GetCutawayPlanes ().size ()) return true;
204 for (size_t i = 0; i < vp.GetCutawayPlanes().size(); ++i)
205 if (vp.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
206 return true;
207 }
208
209 if (vp.IsExplode () &&
210 (vp.GetExplodeFactor () != fVP.GetExplodeFactor ()))
211 return true;
212
213 return false;
214}
215
216void G4OpenInventorViewer::ClearView () {
217}
218
219void G4OpenInventorViewer::SetView () {
220
221 // Get G4 camera infos :
222 const G4Point3D target
223 = fSceneHandler.GetScene()->GetStandardTargetPoint()
224 + fVP.GetCurrentTargetPoint ();
225 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
226 if(radius<=0.) radius = 1.;
227 const G4double cameraDistance = fVP.GetCameraDistance (radius);
228 const G4Vector3D& direction = fVP.GetViewpointDirection().unit();
229 const G4Point3D cameraPosition = target + cameraDistance * direction;
230 //const G4double pnear = fVP.GetNearDistance (cameraDistance, radius);
231 //const G4double pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
232 const G4Normal3D& up = fVP.GetUpVector ();
233
234/*
235 printf("debug : target : %g %g %g\n",target.x(),
236 target.y(),
237 target.z());
238 printf("debug : dir : %g %g %g\n",direction.x(),
239 direction.y(),
240 direction.z());
241 printf("debug : pos : %g %g %g\n",cameraPosition.x(),
242 cameraPosition.y(),
243 cameraPosition.z());
244 //printf("debug : near %g far %g\n",pnear,pfar);
245*/
246
247 SoCamera* camera = GetCamera();
248 if(!camera) return;
249
250 // viewer camera setup :
251 camera->position.setValue((float)cameraPosition.x(),
252 (float)cameraPosition.y(),
253 (float)cameraPosition.z());
254
255 SbVec3f sbTarget((float)target.x(),
256 (float)target.y(),
257 (float)target.z());
258 SbVec3f sbUp((float)up.x(),
259 (float)up.y(),
260 (float)up.z());
261 sbUp.normalize();
262 // Need Coin's camera->pointAt(sbTarget,sbUp); not in the SGI API
263 // Stole Coin's code...
264 pointAt(camera,sbTarget,sbUp);
265
266 //camera->height.setValue(10);
267 //camera->nearDistance.setValue((float)pnear);
268 //camera->farDistance.setValue((float)pfar);
269 //camera->focalDistance.setValue((float)cameraDistance);
270
271 if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
272 if (fVP.GetFieldHalfAngle() == 0.) {
273 //FIXME : ((SoOrthographicCamera*)camera)->height.setValue();
274 //FIXME : (Don't think we have to do that.)
275 } else {
276 //FIXME : Have to set a perspective camera !
277 //FIXME : viewer->setCameraType(SoPerspectiveCamera::getClassTypeId())
278 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
279 //FIXME : (2.*fVP.GetFieldHalfAngle());
280 }
281 } else if(camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
282 if (fVP.GetFieldHalfAngle() == 0.) {
283 //FIXME : Have to set an orthographic camera !
284 //FIXME : viewer->setCameraType(SoOrthographicCamera::getClassTypeId())
285 } else {
286 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
287 //FIXME : (2.*fVP.GetFieldHalfAngle());
288 }
289 }
290}
291
292//COIN_FUNCTION_EXTENSION
293void
294G4OpenInventorViewer::pointAt(SoCamera* camera,const SbVec3f & targetpoint, const SbVec3f & upvector)
295{
296 SbVec3f dir = targetpoint - camera->position.getValue();
297 if (dir.normalize() == 0.0f) return;
298 lookAt(camera,dir, upvector);
299}
300
301//COIN_FUNCTION
302// Private method that calculates a new orientation based on camera
303// direction and camera up vector. Vectors must be unit length.
304void
305G4OpenInventorViewer::lookAt(SoCamera* camera,const SbVec3f & dir, const SbVec3f & up)
306{
307 SbVec3f z = -dir;
308 SbVec3f y = up;
309 SbVec3f x = y.cross(z);
310
311 // recompute y to create a valid coordinate system
312 y = z.cross(x);
313
314 // normalize x and y to create an orthonormal coord system
315 y.normalize();
316 x.normalize();
317
318 // create a rotation matrix
319 SbMatrix rot = SbMatrix::identity();
320 rot[0][0] = x[0];
321 rot[0][1] = x[1];
322 rot[0][2] = x[2];
323
324 rot[1][0] = y[0];
325 rot[1][1] = y[1];
326 rot[1][2] = y[2];
327
328 rot[2][0] = z[0];
329 rot[2][1] = z[1];
330 rot[2][2] = z[2];
331
332 camera->orientation.setValue(SbRotation(rot));
333}
334
335void
336G4OpenInventorViewer::lookedAt(SoCamera* camera,SbVec3f & dir, SbVec3f & up)
337{
338 SbRotation rot = camera->orientation.getValue();
339 SbMatrix mrot; rot.getValue(mrot);
340
341 SbVec3f x, y, z;
342
343 // create a rotation matrix
344 x[0] = mrot[0][0];
345 x[1] = mrot[0][1];
346 x[2] = mrot[0][2];
347
348 y[0] = mrot[1][0];
349 y[1] = mrot[1][1];
350 y[2] = mrot[1][2];
351
352 z[0] = mrot[2][0];
353 z[1] = mrot[2][1];
354 z[2] = mrot[2][2];
355
356 dir = -z;
357 dir.normalize();
358 up = SbVec3f(0.f,1.f,0.f); // Choose y-axis if possible.
359 if (std::abs(up.dot(z)) > 1.e-6) {
360 up = y;
361 up.normalize();
362 }
363}
364
365void G4OpenInventorViewer::DrawView () {
366 //G4cout << "debug Iv::DrawViewer " <<G4endl;
367 if (!fNeedKernelVisit) KernelVisitDecision();
368 ProcessView();
369 FinishView();
370}
371
372void G4OpenInventorViewer::ShowView () {
373 fInteractorManager -> SecondaryLoop ();
374}
375
376void G4OpenInventorViewer::GroupCameraSensorCB(void* aThis,SoSensor* aSensor){
377 G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
378
379 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
380 //printf("debug : GroupCameraSensorCB %s\n",
381 //node->getTypeId().getName().getString());
382
383 if(node->isOfType(SoCamera::getClassTypeId())) {
384 // Viewer had changed the camera type,
385 // attach the fCameraSensor to the new camera.
386 SoCamera* camera = (SoCamera*)node;
387 This->fCameraSensor->detach();
388 This->fCameraSensor->attach(camera);
389 }
390
391}
392
393void G4OpenInventorViewer::CameraSensorCB(void* aThis,SoSensor* aSensor) {
394 G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
395
396 //printf("debug : CameraSensorCB\n");
397
398 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
399
400 if(node->isOfType(SoCamera::getClassTypeId())) {
401 SoCamera* camera = (SoCamera*)node;
402
403 SbVec3f direction, up;
404 lookedAt(camera,direction, up);
405 This->fVP.SetViewpointDirection
406 (G4Vector3D(-direction[0],-direction[1],-direction[2]));
407 This->fVP.SetUpVector(G4Vector3D(up[0],up[1],up[2]));
408
409 SbVec3f pos = camera->position.getValue();
410 SbVec3f target = pos + direction * camera->focalDistance.getValue();
411
412 This->fVP.SetCurrentTargetPoint(G4Point3D(target[0],target[1],target[2]));
413 }
414}
415
416void G4OpenInventorViewer::SelectionCB(
417 void* aThis
418,SoPath* aPath
419)
420{
421 G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
422 SoNode* node = ((SoFullPath*)aPath)->getTail();
423 G4AttHolder* attHolder = dynamic_cast<G4AttHolder*>(node);
424 if(attHolder && attHolder->GetAttDefs().size()) {
425 for (size_t i = 0; i < attHolder->GetAttDefs().size(); ++i) {
426 G4cout << G4AttCheck(attHolder->GetAttValues()[i],
427 attHolder->GetAttDefs()[i]);
428 }
429 } else {
430 G4String name((char*)node->getName().getString());
431 G4String cls((char*)node->getTypeId().getName().getString());
432 G4cout << "SoNode : " << node
433 << " SoType : " << cls
434 << " name : " << name
435 << G4endl;
436 G4cout << "No attributes attached." << G4endl;
437 }
438 /*FIXME : to explore (need different button - this is used for picking.
439 if(node->isOfType(Geant4_SoPolyhedron::getClassTypeId())) {
440 Geant4_SoPolyhedron* polyhedron = (Geant4_SoPolyhedron*)node;
441 if(polyhedron->solid.getValue()==FALSE)
442 polyhedron->solid.setValue(TRUE);
443 else
444 polyhedron->solid.setValue(FALSE);
445 }*/
446 This->fSoSelection->deselectAll();
447}
448/*
449void G4OpenInventorViewer::DeselectionCB(
450 void* aThis
451,SoPath* aPath
452)
453{
454 //G4OpenInventorViewer* This = (G4OpenInventorViewer*)aThis;
455 G4String name((char*)aPath->getTail()->getTypeId().getName().getString());
456 G4cout << "Deselect : " << name << G4endl;
457}
458*/
459
460void G4OpenInventorViewer::DrawDetector() {
461 /* Replace this... - JA
462 // DrawView does a ClearStore. Do not clear the transient store :
463 SoSeparator* tmp = fG4OpenInventorSceneHandler.fTransientRoot;
464 fG4OpenInventorSceneHandler.fTransientRoot = new SoSeparator;
465 if (!fNeedKernelVisit) KernelVisitDecision();
466 ProcessView();
467 fG4OpenInventorSceneHandler.fTransientRoot->unref();
468 fG4OpenInventorSceneHandler.fTransientRoot = tmp;
469 */
470 // ...by this... - JA
471 DrawView();
472}
473
474//////////////////////////////////////////////////////////////////////////////
475/// Menu items callbacks /////////////////////////////////////////////////////
476//////////////////////////////////////////////////////////////////////////////
477
478void G4OpenInventorViewer::Escape(){
479 G4cout << "Escape..." <<G4endl;
480 fInteractorManager->RequireExitSecondaryLoop (OIV_EXIT_CODE);
481}
482
483void G4OpenInventorViewer::WritePostScript(const G4String& aFile) {
484 if(!fGL2PSAction) return;
485 fGL2PSAction->setFileName(aFile.c_str());
486 G4cout << "Produce " << aFile << "..." << G4endl;
487 if (fGL2PSAction->enableFileWriting()) {
488 ViewerRender();
489 fGL2PSAction->disableFileWriting();
490 }
491}
492
493void G4OpenInventorViewer::WritePixmapPostScript(const G4String& aFile) {
494 fSoImageWriter->fileName.setValue(aFile.c_str());
495 //imageWriter->format.setValue(SoImageWriter::POST_SCRIPT);
496 fSoImageWriter->enable();
497 ViewerRender();
498 fSoImageWriter->disable();
499 if(fSoImageWriter->getStatus()) {
500 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
501 << " produced."
502 << G4endl;
503 } else {
504 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
505 << " not produced."
506 << G4endl;
507 }
508}
509
510void G4OpenInventorViewer::WriteInventor(const G4String& aFile) {
511 G4cout << "Produce " << aFile << "..." << G4endl;
512
513 SbBool genAlternateRep = TRUE;
514 //SbBool binary = FALSE;
515 SbBool binary = TRUE;
516 SoAlternateRepAction alternateRepAction;
517 if(genAlternateRep==TRUE) {
518 alternateRepAction.setGenerate(TRUE); //Clear alternate reps.
519 alternateRepAction.apply(fSoSelection);
520 }
521
522 SoWriteAction writeAction;
523 writeAction.getOutput()->openFile(aFile.c_str());
524 writeAction.getOutput()->setBinary(binary);
525 writeAction.apply(fSoSelection);
526 writeAction.getOutput()->closeFile();
527
528 if(genAlternateRep==TRUE) {
529 alternateRepAction.setGenerate(FALSE); //Clear alternate reps.
530 alternateRepAction.apply(fSoSelection);
531 }
532
533
534
535}
536
537struct Counter {
538 int fTriangles;
539 int fLineSegments;
540 int fPoints;
541};
542
543static void CountTrianglesCB(
544 void* userData
545,SoCallbackAction*
546,const SoPrimitiveVertex*
547,const SoPrimitiveVertex*,
548const SoPrimitiveVertex*)
549{
550 Counter* counter = (Counter*)userData;
551 counter->fTriangles++;
552}
553
554static void CountLineSegmentsCB(
555 void* userData
556,SoCallbackAction*
557,const SoPrimitiveVertex*
558,const SoPrimitiveVertex*)
559{
560 Counter* counter = (Counter*)userData;
561 counter->fLineSegments++;
562}
563
564static void CountPointsCB(
565 void* userData
566,SoCallbackAction*
567,const SoPrimitiveVertex*)
568{
569 Counter* counter = (Counter*)userData;
570 counter->fPoints++;
571}
572
573void G4OpenInventorViewer::SceneGraphStatistics() {
574 Counter counter;
575 counter.fTriangles = 0;
576 counter.fLineSegments = 0;
577 counter.fPoints = 0;
578
579 SoCallbackAction callbackAction;
580 callbackAction.addTriangleCallback
581 (SoShape::getClassTypeId(),CountTrianglesCB,(void*)&counter);
582 callbackAction.addLineSegmentCallback
583 (SoShape::getClassTypeId(),CountLineSegmentsCB,(void*)&counter);
584 callbackAction.addPointCallback
585 (SoShape::getClassTypeId(),CountPointsCB,(void*)&counter);
586 callbackAction.apply(fSoSelection);
587
588 SoCounterAction counterAction;
589 counterAction.apply(fSoSelection);
590 int nodes = counterAction.getCount();
591
592 counterAction.setLookFor(SoCounterAction::TYPE);
593 counterAction.setType(SoShape::getClassTypeId());
594 counterAction.apply(fSoSelection);
595 int shapes = counterAction.getCount();
596
597 G4cout << "Number of triangles : " << counter.fTriangles << G4endl;
598 G4cout << "Number of line segments : " << counter.fLineSegments << G4endl;
599 G4cout << "Number of points : " << counter.fPoints << G4endl;
600 G4cout << "Number of nodes : " << nodes << G4endl;
601 G4cout << "Number of shapes : " << shapes << G4endl;
602}
603
604void G4OpenInventorViewer::EraseDetector() {
605 fG4OpenInventorSceneHandler.fDetectorRoot->removeAllChildren();
606}
607void G4OpenInventorViewer::EraseEvent() {
608 fG4OpenInventorSceneHandler.fTransientRoot->removeAllChildren();
609}
610
611void G4OpenInventorViewer::SetPreviewAndFull() {
612 fG4OpenInventorSceneHandler.fPreviewAndFull = true;
613
614 NeedKernelVisit();
615 DrawDetector();
616}
617
618void G4OpenInventorViewer::SetPreview() {
619 fG4OpenInventorSceneHandler.fPreviewAndFull = false;
620
621 NeedKernelVisit();
622 DrawDetector();
623}
624
625// When ViewParameter <-> SoCamera mapping ready
626// uncomment the below
627//#define USE_SET_VIEW
628
629void G4OpenInventorViewer::SetSolid() {
630 G4ViewParameters vp = GetViewParameters();
632 //From G4VisCommandsViewerSet : /vis/viewer/set/style solid.
633 switch (existingStyle) {
636 break;
639 break;
641 break;
643 break;
644 }
645 SetViewParameters(vp);
646 DrawDetector();
647}
648void G4OpenInventorViewer::SetWireFrame() {
649 G4ViewParameters vp = GetViewParameters();
651 switch (existingStyle) {
653 break;
655 break;
658 break;
661 break;
662 }
663 SetViewParameters(vp);
664 DrawDetector();
665}
666
667
668void G4OpenInventorViewer::SetReducedWireFrame(bool aValue) {
669 G4ViewParameters vp = GetViewParameters();
670
671 // Set the wire frame kind :
672 vp.SetAuxEdgeVisible(!aValue);
673
674 // Set wire frame :
676 switch (existingStyle) {
678 break;
680 break;
683 break;
686 break;
687 }
688 SetViewParameters(vp);
689 NeedKernelVisit(); // Just in case it was alread in wire framw.
690 DrawDetector();
691}
692
693void G4OpenInventorViewer::UpdateScene() {
694 /* Replace this... - JA
695 fG4OpenInventorSceneHandler.ClearStore();
696 ClearView();
697 if (!fNeedKernelVisit) KernelVisitDecision();
698 ProcessView();
699 ShowView();
700 */
701 // ...by this - JA
702 NeedKernelVisit();
703 DrawView();
704}
705G4String G4OpenInventorViewer::Help(const G4String& aTopic) {
706 if(aTopic=="controls") {
707 return G4String("\
708Controls on an Inventor examiner viewer are :\n\
709- in picking mode (cursor is the upper left arrow)\n\
710 Ctrl + pick a volume : see daughters.\n\
711 Shift + pick a volume : see mother.\n\
712- in viewing mode (cursor is the hand)\n\
713 Left-button + pointer move : rotate.\n\
714 Ctrl+Left-button + pointer move : pan.\n\
715 Ctrl+Shift+Left-button + pointer move : scale.\n\
716 Middle-button + pointer move : pan.\n\
717 Right-button : popup menu.\n");
718 } else {
719 return "";
720 }
721}
722
723#endif
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
#define OIV_EXIT_CODE
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
#define SoImageWriter
Definition: SoImageWriter.h:40
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
Definition: G4AttHolder.hh:60
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
Definition: G4AttHolder.hh:62
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:123
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Vector3D & GetScaleFactor() const
G4int GetNoOfSides() const
G4double GetExplodeFactor() const
G4bool IsMarkerNotHidden() const
G4bool IsCutaway() const
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
const G4Colour & GetBackgroundColour() const
G4bool IsSection() const
G4bool IsPicking() const
G4bool IsCulling() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4bool IsExplode() const
G4bool IsCullingInvisible() const
RepStyle GetRepStyle() const
const G4VisAttributes * GetDefaultVisAttributes() const
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
BasicVector3D< T > unit() const
void setGenerate(SbBool)
int getCount() const
void setLookFor(LookFor)
void setType(const SoType, SbBool=TRUE)
#define TRUE
Definition: globals.hh:55
#define FALSE
Definition: globals.hh:52
#define userData
Definition: xmlparse.cc:555