source: trunk/source/visualization/VRML/src/G4VRML1SceneHandlerFunc.icc@ 1357

Last change on this file since 1357 was 1347, checked in by garnier, 15 years ago

geant4 tag 9.4

File size: 19.1 KB
RevLine 
[834]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//
[1347]27// $Id: G4VRML1SceneHandlerFunc.icc,v 1.17 2010/11/11 00:14:50 akimura Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
[834]29//
30// G4VRML1SceneHandlerFunc.icc
31// Satoshi Tanaka & Yasuhide Sawada
32
[1347]33#include "G4VisManager.hh"
34
[834]35//#define DEBUG_SCENE_FUNC
36
37// MACRO
38#define ADDTHIS_WITH_NAME(Solid) \
39 fCurrentDEF = #Solid "_" + Solid.GetName(); \
40 RequestPrimitives(Solid); \
41 fCurrentDEF = "";
42
43// End of MACRO
44
45void G4VRML1SCENEHANDLER::AddSolid(const G4Trd& trd)
46{
47#if defined DEBUG_SCENE_FUNC
[1347]48 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
49 G4cout << "***** AddSolid trd" << "\n" ;
[834]50#endif
51 VRMLBeginModeling () ;
52 ADDTHIS_WITH_NAME(trd)
53}
54
55void G4VRML1SCENEHANDLER::AddSolid(const G4Trap& trap)
56{
57#if defined DEBUG_SCENE_FUNC
[1347]58 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
59 G4cout << "***** AddSolid trap" << "\n" ;
[834]60#endif
61 VRMLBeginModeling () ;
62 ADDTHIS_WITH_NAME(trap)
63}
64
65void G4VRML1SCENEHANDLER::AddSolid(const G4Para& para)
66{
67#if defined DEBUG_SCENE_FUNC
[1347]68 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
69 G4cout << "***** AddSolid para" << "\n" ;
[834]70#endif
71 VRMLBeginModeling () ;
72 ADDTHIS_WITH_NAME(para)
73}
74
75void G4VRML1SCENEHANDLER::AddSolid(const G4Torus& torus )
76{
77#if defined DEBUG_SCENE_FUNC
[1347]78 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
79 G4cout << "***** AddSolid torus" << "\n" ;
[834]80#endif
81 VRMLBeginModeling () ;
82 ADDTHIS_WITH_NAME(torus)
83}
84
85
86void G4VRML1SCENEHANDLER::AddSolid(const G4VSolid& vsolid)
87{
88#if defined DEBUG_SCENE_FUNC
[1347]89 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
90 G4cout << "***** AddSolid vsolid" << "\n" ;
[834]91#endif
92 VRMLBeginModeling () ;
93 ADDTHIS_WITH_NAME(vsolid)
94}
95
96void G4VRML1SCENEHANDLER::AddSolid(const G4Tubs& tubs)
97{
98#if defined DEBUG_SCENE_FUNC
[1347]99 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
100 G4cout << "***** AddSolid tubs" << "\n" ;
[834]101#endif
102 VRMLBeginModeling () ;
103
104 // set current name
105 fCurrentDEF = "tubs_" + tubs.GetName();
106
107 // Get data
108 const G4double R = tubs.GetRMax(); // outside radius
109 const G4double r = tubs.GetRMin(); // inside radius
110 const G4double dz = tubs.GetDz(); // half length in z
111 const G4double dp = tubs.GetDPhi(); // angle interval
112
113 // Send data
114 if ( r == 0.0 && dp >= 360. * deg ) {
115 // Send a built-in VRML node (Cylinder)
116 fDest << "Separator {" << "\n";
117 SendMatrixTransformNode( fpObjectTransformation );
118
119 fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
120 SendMaterialNode();
121 SendCylinderNode(R, dz * 2);
122 fDest << "\t" << "}" << "\n"; // DEF Separator
123 fDest << "}" << "\n"; // Separator
124 } else {
125 // call AddPrimitive(Polyhedron)
126 RequestPrimitives(tubs);
127 }
128
129 // reset current name to null
130 fCurrentDEF = "";
131}
132
133
134void G4VRML1SCENEHANDLER::AddSolid(const G4Cons& cons)
135{
136#if defined DEBUG_SCENE_FUNC
[1347]137 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
138 G4cout << "***** AddSolid cons" << "\n" ;
[834]139#endif
140 VRMLBeginModeling () ;
141
142 // set current name
143 fCurrentDEF = "cons_" + cons.GetName();
144
145 // Get data
146 const G4double r1 = cons.GetRmin1(); // inside radius at -dz
147 const G4double R1 = cons.GetRmax1(); // outside radius at -dz
148 const G4double r2 = cons.GetRmin2(); // inside radius at +dz
149 const G4double R2 = cons.GetRmax2(); // outside radius at +dz
150 const G4double dz = cons.GetDz(); // half length in z
151 //const G4double sp = cons.GetSPhi(); // starting angle
152 const G4double dp = cons.GetDPhi(); // angle width
153
154 // Send data
155 if ( r1 == 0.0 && r2 == 0.0 && R1 == R2 && dp >= 360. * deg) {
156 // Send a built-in VRML node (Cylinder)
157 fDest << "Separator {" << "\n";
158 SendMatrixTransformNode( fpObjectTransformation );
159
160 fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
161 SendMaterialNode();
162 SendCylinderNode(R1, dz * 2);
163 fDest << "\t" << "}" << "\n"; // DEF Separator
164 fDest << "}" << "\n"; // Separator
165 } else {
166 // call AddPrimitive(Polyhedron)
167 RequestPrimitives(cons);
168 }
169
170 // reset current name to null
171 fCurrentDEF = "";
172}
173
174void G4VRML1SCENEHANDLER::AddSolid(const G4Box& box)
175{
176#if defined DEBUG_SCENE_FUNC
[1347]177 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
178 G4cout << "***** AddSolid box" << "\n" ;
[834]179#endif
180 VRMLBeginModeling () ;
181
182 // set current name
183 fCurrentDEF = "box_" + box.GetName();
184
185 // Send a built-in VRML node (Cube)
186 fDest << "Separator {" << "\n";
187
188 //fDest << "\t" << "renderCulling ON" << "\n";
189 SendMatrixTransformNode( fpObjectTransformation );
190
191 fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
192 SendMaterialNode();
193 SendCubeNode(box.GetXHalfLength() * 2, box.GetYHalfLength() * 2, box.GetZHalfLength() * 2);
194 fDest << "\t" << "}" << "\n"; // DEF Separator
195
196 fDest << "}" << "\n"; // Separator
197
198 // reset current name to null
199 fCurrentDEF = "";
200}
201
202
203void G4VRML1SCENEHANDLER::AddSolid(const G4Sphere& sphere)
204{
205#if defined DEBUG_SCENE_FUNC
[1347]206 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
207 G4cout << "***** AddSolid sphere" << "\n" ;
[834]208#endif
209 VRMLBeginModeling () ;
210
211 // set current name
212 fCurrentDEF = "sphere_" + sphere.GetName();
213
214 // Get data
215 G4double dphi = sphere.GetDPhi () ;
216 G4double dtheta = sphere.GetDTheta() ;
217 G4double rmax = sphere.GetRmax () ;
218 G4double rmin = sphere.GetRmin () ;
219
220 // Send data
221 if ( (dphi >= 360. * deg) && (dtheta >= 180. * deg) && (rmin == 0.0) ) {
222 // Send a built-in VRML node (Sphere)
223 fDest << "Separator {" << "\n";
224 SendMatrixTransformNode( fpObjectTransformation );
225
226 fDest << "\t" << "DEF " << fCurrentDEF << " Separator {" << "\n";
227 SendMaterialNode();
228 SendSphereNode( rmax );
229 fDest << "\t" << "}" << "\n"; // DEF Separator
230 fDest << "}" << "\n"; // Separator
231 } else {
232 // call AddPrimitive(Polyhedron)
233 RequestPrimitives( sphere );
234 }
235
236 // reset current name to null
237 fCurrentDEF = "";
238}
239
240void G4VRML1SCENEHANDLER::AddPrimitive(const G4Polyline& polyline)
241{
242#if defined DEBUG_SCENE_FUNC
[1347]243 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
244 G4cout << "***** AddPrimitive polyline" << "\n" ;
[834]245#endif
246 VRMLBeginModeling () ;
247
248 fDest << "Separator {" << "\n";
249
250 SendMatrixTransformNode (fpObjectTransformation );
251
252 SendMaterialNode( polyline.GetVisAttributes() );
253
254 fDest << "\t" << "Coordinate3 {" << "\n";
255 fDest << "\t\t" << "point [" << "\n";
256 G4int e, i;
257 for (i = 0, e = polyline.size(); e; i++, e--) {
258 fDest << "\t\t\t";
259 fDest << polyline[i].x() << " ";
260 fDest << polyline[i].y() << " ";
261 fDest << polyline[i].z() << "," << "\n";
262 }
263 fDest << "\t\t" << "]" << "\n";
264 fDest << "\t" << "}" << "\n"; // Coordinate3
265
266 fDest << "\t" << "IndexedLineSet {" << "\n";
267 fDest << "\t\t" << "coordIndex [";
268 for (i = 0, e = polyline.size(); e; i++, e--) {
269 if (i % 10 == 0)
270 fDest << "\n" << "\t\t\t";
271 fDest << i << ", ";
272 }
273 fDest << "-1" << "\n";
274 fDest << "\t\t" << "]" << "\n";
275 fDest << "\t" << "}" << "\n"; // IndexedLineSet
276
277 fDest << "}" << "\n"; // Separator
278}
279
280void G4VRML1SCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron)
281{
282#if defined DEBUG_SCENE_FUNC
[1347]283 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
284 G4cout << "***** AddPrimitive(G4Polyhedron)" << "\n";
[834]285#endif
286
287 if (polyhedron.GetNoFacets() == 0) return;
288
289 VRMLBeginModeling () ;
290
291 fDest << "Separator {" << "\n";
292
293 SendMatrixTransformNode( fpObjectTransformation );
294
295 fDest << "\t";
296 if (fCurrentDEF != "")
297 fDest << "DEF " << fCurrentDEF << " ";
298
299 fDest << "Separator {" << "\n";
300
301 //fDest << "\t\t" << "renderCulling ON" << "\n";
302
303 fDest << "\t\t" << "ShapeHints {" << "\n";
304 fDest << "\t\t\t" << "vertexOrdering COUNTERCLOCKWISE" << "\n";
305 fDest << "\t\t\t" << "shapeType SOLID" << "\n";
306 fDest << "\t\t\t" << "faceType CONVEX" << "\n";
307 fDest << "\t\t" << "}" << "\n";
308
309 SendMaterialNode();
310
311 fDest << "\t\t" << "Coordinate3 {" << "\n";
312 fDest << "\t\t\t" << "point [" << "\n";
313 G4int i, j;
314 for (i = 1, j = polyhedron.GetNoVertices(); j; j--, i++) {
315 G4Point3D point = polyhedron.GetVertex(i);
316 fDest << "\t\t\t\t";
317 fDest << point.x() << " ";
318 fDest << point.y() << " ";
319 fDest << point.z() << "," << "\n";
320 }
321 fDest << "\t\t\t" << "]" << "\n";
322 fDest << "\t\t" << "}" << "\n"; // Coordinate3
323
324 fDest << "\t\t" << "IndexedFaceSet {" << "\n";
325 fDest << "\t\t\t" << "coordIndex [" << "\n";
326
327 // facet loop
328 G4int f;
329 for (f = polyhedron.GetNoFacets(); f; f--) {
330
331 // edge loop
332 G4bool notLastEdge;
333 G4int index = -1, edgeFlag = 1;
334 fDest << "\t\t\t\t";
335 do {
336 notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
337 fDest << index - 1 << ", ";
338 } while (notLastEdge);
339 fDest << "-1," << "\n";
340 }
341 fDest << "\t\t\t" << "]" << "\n";
342 fDest << "\t\t" << "}" << "\n"; // IndexFaceSet
343
344 fDest << "\t" << "}" << "\n"; // (DEF) Separator
345 fDest << "}" << "\n"; // Separator
346
347}
348
349
350void G4VRML1SCENEHANDLER::AddPrimitive(const G4NURBS&)
351{
352#if defined DEBUG_SCENE_FUNC
[1347]353 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
354 G4cout << "***** AddPrimitive nurbs" << "\n" ;
[834]355#endif
[1347]356 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
357 G4cout << "G4VRML1File::AddPrimitive(G4NURBS&): not implemented. " << "\n" ;
[834]358 VRMLBeginModeling () ;
359
360}
361
362void G4VRML1SCENEHANDLER::AddPrimitive( const G4Text& )
363{
364#if defined DEBUG_SCENE_FUNC
[1347]365 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
366 G4cout << "***** AddPrimitive text" << "\n" ;
[834]367#endif
[1347]368 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
369 G4cout <<
[834]370 "***** void G4VRML1SCENEHANDLER::AddPrimitive( const G4Text& text )"
371 " not implemented yet."
372 << "\n";
373
374 VRMLBeginModeling () ;
375}
376
377void G4VRML1SCENEHANDLER::AddPrimitive( const G4Circle& circle )
378{
379#if defined DEBUG_SCENE_FUNC
[1347]380 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
381 G4cout << "***** AddPrimitive circle" << "\n" ;
[834]382#endif
383
384 VRMLBeginModeling () ;
385
386 // begin sending a mark
387 fDest << "Separator {" << "\n";
388
389 // send color
390 SendMarkerColor ( circle ) ;
391
392 // position
393 SendMarkerWorldPosition ( circle ) ;
394
395 // Calc size
396 G4double size = GetMarkerHalfSize ( circle );
397
398 // send shape with size
399 fDest << "\t" << "Sphere {" << "\n";
400 fDest << "\t\t" << "radius " << size << "\n";
401 fDest << "\t" << "}" << "\n";
402
403 // end sending a mark
404 fDest << "}" << "\n"; // Separator
405}
406
407
408void G4VRML1SCENEHANDLER::AddPrimitive(const G4Square& square)
409{
410#if defined DEBUG_SCENE_FUNC
[1347]411 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
412 G4cout << "***** AddPrimitive square" << "\n" ;
[834]413#endif
414
415 VRMLBeginModeling () ;
416
417 // begin sending a mark
418 fDest << "Separator {" << "\n";
419
420 // send color
421 SendMarkerColor ( square );
422
423 // position
424 SendMarkerWorldPosition ( square );
425
426 // Calc size
427 G4double size = GetMarkerHalfSize ( square );
428 size *= 2.;
429
430 // send shape with size
431 fDest << "\t" << "Cube {" << "\n";
432 fDest << "\t\t" << "width " << size << "\n";
433 fDest << "\t\t" << "height " << size << "\n";
434 fDest << "\t\t" << "depth " << size << "\n";
435 fDest << "\t" << "}" << "\n";
436
437 // end sending a mark
438 fDest << "}" << "\n"; // Separator
439}
440
441void G4VRML1SCENEHANDLER::BeginModeling()
442{
443#if defined DEBUG_SCENE_FUNC
[1347]444 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
445 G4cout << "***** BeginModeling " << "\n" ;
[834]446#endif
447 G4VSceneHandler::BeginModeling();
448}
449
450void G4VRML1SCENEHANDLER::EndModeling()
451{
452#if defined DEBUG_SCENE_FUNC
[1347]453 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
454 G4cout << "***** EndModeling " << "\n" ;
[834]455#endif
456 G4VSceneHandler::EndModeling();
457}
458
459void G4VRML1SCENEHANDLER::BeginPrimitives(const G4Transform3D& objectTransformation)
460{
461 G4VSceneHandler::BeginPrimitives (objectTransformation);
462 fpObjectTransformation = &objectTransformation;
463#if defined DEBUG_SCENE_FUNC
[1347]464 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
465 G4cout << "***** BeginPrimitives " << "\n" ;
[834]466#endif
467 VRMLBeginModeling();
468}
469
470void G4VRML1SCENEHANDLER::EndPrimitives()
471{
472#if defined DEBUG_SCENE_FUNC
[1347]473 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
474 G4cout << "***** EndPrimitives " << "\n" ;
[834]475#endif
476 G4VSceneHandler::EndPrimitives();
477}
478
479void G4VRML1SCENEHANDLER::SendMaterialNode( const G4VisAttributes* pVA )
480{
481// const double TRANSPARENCY = 0.9 ;
482 const double TRANSPARENCY = 0.5 ;
483
484 if (!pVA)
485 return;
486
487 const G4Color& color = pVA->GetColor();
488
489 fDest << "\t\t" << "Material {" << "\n";
490
491 if (pVA->IsForceDrawingStyle() &&
492 (pVA->GetForcedDrawingStyle() == G4VisAttributes::wireframe)) {
493 fDest << "\t\t\t" << "transparency " << TRANSPARENCY << "\n";
494 }
495
496 fDest << "\t\t\t" << "diffuseColor";
497 fDest << " " << color.GetRed();
498 fDest << " " << color.GetGreen();
499 fDest << " " << color.GetBlue();
500 fDest << "\n";
501 fDest << "\t\t" << "}" << "\n";
502}
503
504
505void G4VRML1SCENEHANDLER::SendMaterialNode()
506{
507 SendMaterialNode
508 ( fpViewer->GetApplicableVisAttributes (fpVisAttribs) );
509}
510
511
512void G4VRML1SCENEHANDLER::SendMatrixTransformNode(const G4Transform3D *trans)
513{
514 G4Point3D B (0.0, 0.0, 0.0);
515
516 G4Point3D x1 (1.0, 0.0, 0.0);
517 G4Point3D y1 (0.0, 1.0, 0.0);
518
519 G4Vector3D e1 (1.0, 0.0, 0.0);
520 G4Vector3D e2 (0.0, 1.0, 0.0);
521 G4Vector3D e3 (0.0, 0.0, 1.0);
522
523 //----- transformed origin of body coord
524 B.transform(*trans);
525
526 //----- transformed base vectors of body coord
527 x1.transform(*trans);
528 e1 = x1 - B;
529
530 y1.transform(*trans);
531 e2 = y1 - B;
532
533 e3 = e1.cross(e2);
534
535 e1 = e1.unit(); // normalize again for accuracy
536 e2 = e2.unit(); //
537 e3 = e3.unit(); //
538
539 fDest << "\t" << "MatrixTransform {" << "\n";
540 fDest << "\t\t" << "matrix ";
541 fDest << e1.x() << " " << e1.y() << " " << e1.z() << " 0 ";
542 fDest << e2.x() << " " << e2.y() << " " << e2.z() << " 0 ";
543 fDest << e3.x() << " " << e3.y() << " " << e3.z() << " 0 ";
544 fDest << B.x() << " " << B.y() << " " << B.z() << " 1" << "\n";
545 fDest << "\t" << "}" << "\n";
546}
547
548void G4VRML1SCENEHANDLER::SendCubeNode(G4double w, G4double h, G4double d)
549{
550 fDest << "\t\t" << "Cube {" << "\n";
551 fDest << "\t\t\t" << "width " << w << "\n";
552 fDest << "\t\t\t" << "height " << h << "\n";
553 fDest << "\t\t\t" << "depth " << d << "\n";
554 fDest << "\t\t" << "}" << "\n";
555}
556
557void G4VRML1SCENEHANDLER::SendCylinderNode(G4double R, G4double h)
558{
559 fDest << "\t\t" << "Transform {" << "\n";
560 fDest << "\t\t\t" << "rotation 1 0 0 " << (90. * deg) << "\n";
561 fDest << "\t\t" << "}" << "\n";
562
563 fDest << "\t\t" << "Cylinder {" << "\n";
564 fDest << "\t\t\t" << "radius " << R << "\n";
565 fDest << "\t\t\t" << "height " << h << "\n";
566 fDest << "\t\t" << "}" << "\n";
567}
568
569void G4VRML1SCENEHANDLER::SendSphereNode(G4double R)
570{
571 fDest << "\t\t" << "Sphere {" << "\n";
572 fDest << "\t\t\t" << "radius " << R << "\n";
573 fDest << "\t\t" << "}" << "\n";
574}
575
576void G4VRML1SCENEHANDLER::VRMLBeginModeling()
577{
578 if (!IS_CONNECTED ) {
579#if defined DEBUG_SCENE_FUNC
[1347]580 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
581 G4cout << "***** VRMLBeginModeling() (started)" << "\n" ;
[834]582#endif
583 this->connectPort();
584 fDest << "#VRML V1.0 ascii" << "\n";
585 fDest << "# Generated by VRML 1.0 driver of GEANT4\n" << "\n";
586 }
587}
588
589void G4VRML1SCENEHANDLER::VRMLEndModeling()
590{
591 if ( IS_CONNECTED ) {
592#if defined DEBUG_SCENE_FUNC
[1347]593 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
594 G4cout << "***** VRMLEndModeling() (started)" << "\n" ;
[834]595#endif
596
597 fDest << "#End of file." << "\n";
598 this->closePort();
599 }
600}
601
602void G4VRML1SCENEHANDLER::SendMarkerColor ( const G4VMarker& mark )
603{
604 const G4Color& color = GetColor( mark );
605
606 fDest << "\t" << "Material {" << "\n";
607 fDest << "\t\t";
608 fDest << "ambientColor [] ";
609 fDest << "specularColor [] ";
610 fDest << "\t\t" << "diffuseColor";
611 fDest << " " << color.GetRed();
612 fDest << " " << color.GetGreen();
613 fDest << " " << color.GetBlue();
614 fDest << "\n";
615 fDest << "\t\t" << "emissiveColor";
616 fDest << " " << color.GetRed();
617 fDest << " " << color.GetGreen();
618 fDest << " " << color.GetBlue();
619 fDest << "\n";
620 fDest << "\t" << "}" << "\n";
621}
622
623void
624G4VRML1SCENEHANDLER::SendMarkerWorldPosition ( const G4VMarker& mark )
625{
626 G4Point3D point = mark.GetPosition();
627
628 SendMatrixTransformNode( fpObjectTransformation );
629
630 fDest << "\t\t" << "Transform {" << "\n";
631 fDest << "\t\t\t" << "translation ";
632 fDest << point.x() << " " << point.y() << " " << point.z() << "\n";
633 fDest << "\t\t" << "}" << "\n" ;
634}
635
636
637G4double G4VRML1SCENEHANDLER::GetMarkerHalfSize ( const G4VMarker& mark )
638{
639 //----- return value ( marker radius in 3d units)
640 G4double size = 1.0 ; // initialization
641
642 //----- parameters to calculate 3d size from 2d size
643 const double HALF_SCREEN_SIZE_2D = 300.0 ; // pixels
644 double zoom_factor = fpViewer->GetViewParameters().GetZoomFactor() ;
645 if ( zoom_factor <= 0.0 ) { zoom_factor = 1.0 ; }
646 double extent_radius_3d = GetScene()->GetExtent().GetExtentRadius() ;
647 if ( extent_radius_3d <= 0.0 ) { extent_radius_3d = 1.0 ; }
648
649 //----- get marker radius in 3D units
650 if ( mark.GetWorldSize() > 0.0 ) {
651 // get mark radius in 3D units
652 size = 0.5 * mark.GetWorldSize() ;
653
654 } else if ( mark.GetScreenSize() > 0.0 ) {
655 // local
656 double mark_radius_2d = 0.5 * mark.GetScreenSize() ;
657
658 // get mark radius in 3D units
659 size \
660 = extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
661 size *= zoom_factor ;
662
663 } else {
664 // local
665 double mark_radius_2d \
666 = fpViewer->GetViewParameters().GetDefaultMarker().GetScreenSize();
667 mark_radius_2d *= 0.1 ; // Magic number?
668
669 // get mark radius in 3D units
670 size \
671 = extent_radius_3d * ( mark_radius_2d / HALF_SCREEN_SIZE_2D );
672 size *= zoom_factor ;
673 }
674
675 //----- global rescaling
676 size *= fpViewer->GetViewParameters().GetGlobalMarkerScale();
677
678 //----- return size
679 return size ;
680
681}
682
683void G4VRML1SCENEHANDLER::ClearTransientStore()
684{
685 G4VSceneHandler::ClearTransientStore ();
686 // This is typically called after an update and before drawing hits
687 // of the next event. To simulate the clearing of "transients"
688 // (hits, etc.) the detector is redrawn...
689 if (fpViewer) {
690 fpViewer -> SetView ();
691 fpViewer -> ClearView ();
692 fpViewer -> DrawView ();
693 }
694}
695
696
697// #undef ADDTHIS_WITH_NAME(Solid)
698// #undef MAKE_NAME(Solid)
699// End of file.
Note: See TracBrowser for help on using the repository browser.