Geant4-11
G4VRML2SceneHandlerFunc.icc
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//
28// G4VRML2SceneHandlerFunc.icc
29// Satoshi Tanaka & Yasuhide Sawada
30
31//#define DEBUG_SCENE_FUNC
32
33#include "G4VisManager.hh"
34
35#include <sstream>
36
37void G4VRML2SCENEHANDLER::AddSolid(const G4Trd& trd)
38{
39#if defined DEBUG_SCENE_FUNC
40 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
41 G4cout << "***** AddSolid trd"
42 << "\n";
43#endif
44 VRMLBeginModeling();
45 G4VSceneHandler::AddSolid(trd);
46}
47
48void G4VRML2SCENEHANDLER::AddSolid(const G4Trap& trap)
49{
50#if defined DEBUG_SCENE_FUNC
51 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
52 G4cout << "***** AddSolid trap"
53 << "\n";
54#endif
55 VRMLBeginModeling();
56 G4VSceneHandler::AddSolid(trap);
57}
58
59void G4VRML2SCENEHANDLER::AddSolid(const G4Para& para)
60{
61#if defined DEBUG_SCENE_FUNC
62 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
63 G4cout << "***** AddSolid para"
64 << "\n";
65#endif
66 VRMLBeginModeling();
67 G4VSceneHandler::AddSolid(para);
68}
69
70void G4VRML2SCENEHANDLER::AddSolid(const G4Torus& torus)
71{
72#if defined DEBUG_SCENE_FUNC
73 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
74 G4cout << "***** AddSolid torus"
75 << "\n";
76#endif
77 VRMLBeginModeling();
78 G4VSceneHandler::AddSolid(torus);
79}
80
81void G4VRML2SCENEHANDLER::AddSolid(const G4VSolid& vsolid)
82{
83#if defined DEBUG_SCENE_FUNC
84 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
85 G4cout << "***** AddSolid vsolid"
86 << "\n";
87#endif
88 VRMLBeginModeling();
89 G4VSceneHandler::AddSolid(vsolid);
90}
91
92void G4VRML2SCENEHANDLER::AddSolid(const G4Tubs& tubs)
93{
94#if defined DEBUG_SCENE_FUNC
95 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
96 G4cout << "***** AddSolid tubs"
97 << "\n";
98#endif
99 VRMLBeginModeling();
100 G4VSceneHandler::AddSolid(tubs);
101}
102
103void G4VRML2SCENEHANDLER::AddSolid(const G4Cons& cons)
104{
105#if defined DEBUG_SCENE_FUNC
106 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
107 G4cout << "***** AddSolid cons"
108 << "\n";
109#endif
110 VRMLBeginModeling();
111 G4VSceneHandler::AddSolid(cons);
112}
113
114void G4VRML2SCENEHANDLER::AddSolid(const G4Box& box)
115{
116#if defined DEBUG_SCENE_FUNC
117 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
118 G4cout << "***** AddSolid box"
119 << "\n";
120#endif
121 VRMLBeginModeling();
122 G4VSceneHandler::AddSolid(box);
123}
124
125void G4VRML2SCENEHANDLER::AddSolid(const G4Sphere& sphere)
126{
127#if defined DEBUG_SCENE_FUNC
128 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
129 G4cout << "***** AddSolid sphere"
130 << "\n";
131#endif
132 VRMLBeginModeling();
133 G4VSceneHandler::AddSolid(sphere);
134}
135
136void G4VRML2SCENEHANDLER::AddPrimitive(const G4Polyline& polyline)
137{
138#if defined DEBUG_SCENE_FUNC
139 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
140 G4cout << "***** AddPrimitive polyline"
141 << "\n";
142#endif
143
144 if(fProcessing2D)
145 {
146 static G4bool warned = false;
147 if(!warned)
148 {
149 warned = true;
150 G4Exception("G4VRML2SCENEHANDLER::AddPrimitive (const G4Polyline&)",
151 "VRML-2001", JustWarning,
152 "2D polylines not implemented. Ignored.");
153 }
154 return;
155 }
156
157 VRMLBeginModeling();
158
159 // VRML codes are generated below
160
161 fDest << "#---------- POLYLINE"
162 << "\n";
163 fDest << "Shape {"
164 << "\n";
165
166 SendLineColor(polyline.GetVisAttributes());
167
168 fDest << "\t"
169 << "geometry IndexedLineSet {"
170 << "\n";
171
172 fDest << "\t\t"
173 << "coord Coordinate {"
174 << "\n";
175 fDest << "\t\t\t"
176 << "point ["
177 << "\n";
178 G4int e, i;
179 for(i = 0, e = polyline.size(); e; i++, e--)
180 {
181 G4Point3D point = polyline[i];
182 point.transform(fObjectTransformation);
183
184 fDest << "\t\t\t\t";
185 fDest << point.x() << " ";
186 fDest << point.y() << " ";
187 fDest << point.z() << ","
188 << "\n";
189
190 } // for
191
192 fDest << "\t\t\t"
193 << "]"
194 << "\n"; // point
195 fDest << "\t\t"
196 << "}"
197 << "\n"; // coord
198
199 fDest << "\t\t"
200 << "coordIndex [";
201 for(i = 0, e = polyline.size(); e; i++, e--)
202 {
203 if(i % 10 == 0)
204 fDest << "\n"
205 << "\t\t\t";
206 fDest << i << ", ";
207 }
208 fDest << "-1"
209 << "\n";
210 fDest << "\t\t"
211 << "]"
212 << "\n"; // coordIndex
213 fDest << "\t"
214 << "}"
215 << "\n"; // geometry IndexedLineSet
216
217 fDest << "}"
218 << "\n"; // Shape
219}
220
221void G4VRML2SCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron)
222{
223#if defined DEBUG_SCENE_FUNC
224 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
225 G4cout << "***** AddPrimitive(G4Polyhedron)"
226 << "\n";
227#endif
228
229 if(polyhedron.GetNoFacets() == 0)
230 return;
231
232 if(fProcessing2D)
233 {
234 static G4bool warned = false;
235 if(!warned)
236 {
237 warned = true;
238 G4Exception("G4VRML2SCENEHANDLER::AddPrimitive (const G4Polyhedron&)",
239 "VRML-2002", JustWarning,
240 "2D polyhedra not implemented. Ignored.");
241 }
242 return;
243 }
244
245 VRMLBeginModeling();
246
247 // Transparency checking: If completely transparent, skip drawing
248 if(GetPVTransparency() > 0.99)
249 {
250 return;
251 }
252
253 // Current Model
254 const G4VModel* pv_model = GetModel();
255 G4String pv_name = "No model";
256 if(pv_model)
257 pv_name = pv_model->GetCurrentTag();
258
259 // VRML codes are generated below
260
261 fDest << "#---------- SOLID: " << pv_name << "\n";
262
263 if(IsPVPickable())
264 {
265 fDest << "Anchor {"
266 << "\n";
267 fDest << " description "
268 << "\"" << pv_name << "\""
269 << "\n";
270 fDest << " url \"\" "
271 << "\n";
272 fDest << " children ["
273 << "\n";
274 }
275
276 fDest << "\t";
277 fDest << "Shape {"
278 << "\n";
279
280 SendMaterialNode();
281
282 fDest << "\t\t"
283 << "geometry IndexedFaceSet {"
284 << "\n";
285
286 fDest << "\t\t\t"
287 << "coord Coordinate {"
288 << "\n";
289 fDest << "\t\t\t\t"
290 << "point ["
291 << "\n";
292 G4int i, j;
293 for(i = 1, j = polyhedron.GetNoVertices(); j; j--, i++)
294 {
295 G4Point3D point = polyhedron.GetVertex(i);
296
297 point.transform(fObjectTransformation);
298
299 fDest << "\t\t\t\t\t";
300 fDest << point.x() << " ";
301 fDest << point.y() << " ";
302 fDest << point.z() << ","
303 << "\n";
304 }
305 fDest << "\t\t\t\t"
306 << "]"
307 << "\n"; // point
308 fDest << "\t\t\t"
309 << "}"
310 << "\n"; // coord
311
312 fDest << "\t\t\t"
313 << "coordIndex ["
314 << "\n";
315
316 // facet loop
317 G4int f;
318 for(f = polyhedron.GetNoFacets(); f; f--)
319 {
320 // edge loop
321 G4bool notLastEdge;
322 G4int index = -1, edgeFlag = 1;
323 fDest << "\t\t\t\t";
324 do
325 {
326 notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
327 fDest << index - 1 << ", ";
328 } while(notLastEdge);
329 fDest << "-1,"
330 << "\n";
331 }
332 fDest << "\t\t\t"
333 << "]"
334 << "\n"; // coordIndex
335
336 fDest << "\t\t\t"
337 << "solid FALSE"
338 << "\n"; // draw backfaces
339
340 fDest << "\t\t"
341 << "}"
342 << "\n"; // IndexFaceSet
343 fDest << "\t"
344 << "}"
345 << "\n"; // Shape
346
347 if(IsPVPickable())
348 {
349 fDest << " ]"
350 << "\n"; // children
351 fDest << "}"
352 << "\n"; // Anchor
353 }
354}
355
356void G4VRML2SCENEHANDLER::AddPrimitive(const G4Text&)
357{
358#if defined DEBUG_SCENE_FUNC
359 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
360 G4cout << "***** AddPrimitive text"
361 << "\n";
362#endif
363 /*** You might need this
364 if (fProcessing2D) {
365 static G4bool warned = false;
366 if (!warned) {
367 warned = true;
368 G4Exception
369 ("G4VRML2SCENEHANDLER::AddPrimitive (const G4Text&)",
370 "VRML-2003", JustWarning,
371 "2D text not implemented. Ignored.");
372 }
373 return;
374 }
375 ***/
376
377 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
378 G4cout
379 << "***** void G4VRML2SCENEHANDLER::AddPrimitive( const G4Text& text )"
380 " not implemented yet."
381 << "\n";
382
383 VRMLBeginModeling();
384}
385
386void G4VRML2SCENEHANDLER::AddPrimitive(const G4Circle& circle)
387{
388#if defined DEBUG_SCENE_FUNC
389 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
390 G4cout << "***** AddPrimitive circle"
391 << "\n";
392#endif
393
394 if(fProcessing2D)
395 {
396 static G4bool warned = false;
397 if(!warned)
398 {
399 warned = true;
400 G4Exception("G4VRML2SCENEHANDLER::AddPrimitive (const G4Circle&)",
401 "VRML-2004", JustWarning,
402 "2D circles not implemented. Ignored.");
403 }
404 return;
405 }
406
407 VRMLBeginModeling();
408
409 // Information
410 // const char* info = NULL ;
411 const char* info = circle.GetInfo();
412
413 // Position and half size of circle
414 G4double X, Y, Z;
415 GetMarkerWorldPosition(circle, &X, &Y, &Z);
416 G4double radius = GetMarkerHalfSize(circle);
417
418 // VRML codes are generated below
419 fDest << "#---------- 3D MARKER (Circle)"
420 << "\n";
421 fDest << "Anchor {"
422 << "\n";
423
424 if(circle.GetInfo().empty())
425 {
426 fDest << " description "
427 << "\"(" << X << " ";
428 fDest << Y << " ";
429 fDest << Z << ")\""
430 << "\n";
431 }
432 else
433 {
434 fDest << " description "
435 << "\"" << info << "\""
436 << "\n";
437 }
438
439 fDest << " url \"\" "
440 << "\n";
441
442 fDest << " children ["
443 << "\n";
444
445 fDest << " Transform {"
446 << "\n";
447
448 fDest << " translation ";
449 fDest << X << " " << Y << " " << Z << "\n";
450
451 fDest << " children ["
452 << "\n";
453
454 fDest << "\t"
455 << "Shape {"
456 << "\n";
457
458 SendMarkerColor(circle);
459
460 // send shape with size
461 fDest << "\t\t"
462 << "geometry Sphere {"
463 << "\n";
464 fDest << "\t\t\t"
465 << "radius " << radius << "\n";
466 fDest << "\t\t"
467 << "}"
468 << "\n";
469
470 fDest << "\t"
471 << "}"
472 << "\n"; // Shape
473
474 fDest << " ]"
475 << "\n"; // children
476 fDest << " }"
477 << "\n"; // Transform
478
479 fDest << " ]"
480 << "\n"; // children
481 fDest << "}"
482 << "\n"; // Anchor
483}
484
485void G4VRML2SCENEHANDLER::AddPrimitive(const G4Square& square)
486{
487#if defined DEBUG_SCENE_FUNC
488 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
489 G4cout << "***** AddPrimitive square"
490 << "\n";
491#endif
492
493 if(fProcessing2D)
494 {
495 static G4bool warned = false;
496 if(!warned)
497 {
498 warned = true;
499 G4Exception("G4VRML2SCENEHANDLER::AddPrimitive (const G4Square&)",
500 "VRML-2005", JustWarning,
501 "2D squares not implemented. Ignored.");
502 }
503 return;
504 }
505
506 VRMLBeginModeling();
507
508 // Information
509 // const char* info = NULL ;
510 const char* info = square.GetInfo();
511
512 // Position and size of square
513 G4double X, Y, Z;
514 GetMarkerWorldPosition(square, &X, &Y, &Z);
515 G4double radius = GetMarkerHalfSize(square);
516 G4double diameter = 2.0 * radius;
517
518 // VRML codes are generated below
519 fDest << "#---------- 3D MARKER (Square)"
520 << "\n";
521 fDest << "Anchor {"
522 << "\n";
523
524 if(square.GetInfo().empty())
525 {
526 fDest << " description "
527 << "\"(" << X << " ";
528 fDest << Y << " ";
529 fDest << Z << ")\""
530 << "\n";
531 }
532 else
533 {
534 fDest << " description "
535 << "\"" << info << "\""
536 << "\n";
537 }
538
539 fDest << " url \"\" "
540 << "\n";
541
542 fDest << " children ["
543 << "\n";
544
545 fDest << " Transform {"
546 << "\n";
547
548 fDest << " translation ";
549 fDest << X << " " << Y << " " << Z << "\n";
550
551 fDest << " children ["
552 << "\n";
553
554 fDest << "\t"
555 << "Shape {"
556 << "\n";
557
558 SendMarkerColor(square);
559
560 // send shape with size
561 fDest << "\t\t"
562 << "geometry Box {"
563 << "\n";
564 fDest << "\t\t\t"
565 << "size " << diameter << " ";
566 fDest << diameter << " ";
567 fDest << diameter << "\n";
568 fDest << "\t\t"
569 << "}"
570 << "\n";
571
572 fDest << "\t"
573 << "}"
574 << "\n"; // Shape
575
576 fDest << " ]"
577 << "\n"; // children
578 fDest << " }"
579 << "\n"; // Transform
580
581 fDest << " ]"
582 << "\n"; // children
583 fDest << "}"
584 << "\n"; // Anchor
585}
586
587void G4VRML2SCENEHANDLER::BeginModeling()
588{
589#if defined DEBUG_SCENE_FUNC
590 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
591 G4cout << "***** BeginModeling"
592 << "\n";
593#endif
594 G4VSceneHandler::BeginModeling();
595}
596
597void G4VRML2SCENEHANDLER::EndModeling()
598{
599#if defined DEBUG_SCENE_FUNC
600 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
601 G4cout << "***** EndModeling "
602 << "\n";
603#endif
604 G4VSceneHandler::EndModeling();
605}
606
607void G4VRML2SCENEHANDLER::BeginPrimitives(
608 const G4Transform3D& objectTransformation)
609{
610 G4VSceneHandler::BeginPrimitives(objectTransformation);
611#if defined DEBUG_SCENE_FUNC
612 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
613 G4cout << "***** BeginPrimitives "
614 << "\n";
615#endif
616 VRMLBeginModeling();
617}
618
619void G4VRML2SCENEHANDLER::EndPrimitives()
620{
621#if defined DEBUG_SCENE_FUNC
622 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
623 G4cout << "***** EndPrimitives "
624 << "\n";
625#endif
626 G4VSceneHandler::EndPrimitives();
627}
628
629void G4VRML2SCENEHANDLER::SendMaterialNode(const G4VisAttributes* pVA)
630{
631 // Initialization of drawing parameters
632 G4bool flagWF = false;
633 G4double TRANSPARENCY = GetPVTransparency();
634
635 // Wireframe or not
636 const G4ViewParameters& cur_view_param = fpViewer->GetViewParameters();
637 if(pVA)
638 {
639 if(pVA->IsForceDrawingStyle() &&
640 (pVA->GetForcedDrawingStyle() == G4VisAttributes::wireframe))
641 {
642 // wireframe style is assigned to this object
643 flagWF = true;
644 }
645 else if(cur_view_param.GetDrawingStyle() == G4ViewParameters::wireframe)
646 {
647 // current viewing style is wireframe
648 flagWF = true;
649 }
650 }
651
652 // VRML codes are generated below
653 if(!pVA)
654 {
655 // Error recovery: Use default values of VRML browser
656 fDest << "\t\t";
657 fDest << "appearance Appearance { material Material {} }";
658 fDest << "\n";
659 }
660 else
661 {
662 const G4Color& color = pVA->GetColor();
663
664 fDest << "\t\t"
665 << "appearance Appearance {"
666 << "\n";
667 fDest << "\t\t\t"
668 << "material Material {"
669 << "\n";
670
671 // diffuse color
672 fDest << "\t\t\t\t"
673 << "diffuseColor ";
674 fDest << color.GetRed() << " ";
675 fDest << color.GetGreen() << " ";
676 fDest << color.GetBlue() << "\n";
677
678 // emmisive color
679 // fDest << "\t\t\t\t" << "emissiveColor ";
680 // fDest << color.GetRed() << " " ;
681 // fDest << color.GetGreen() << " " ;
682 // fDest << color.GetBlue() << "\n";
683 //
684
685 // wireframe is expressed as transparency
686 if(flagWF)
687 {
688 fDest << "\t\t\t\t"
689 << "transparency " << TRANSPARENCY << "\n";
690 }
691
692 fDest << "\t\t\t"
693 << "}"
694 << "\n"; // material
695 fDest << "\t\t"
696 << "}"
697 << "\n"; // appearance
698 }
699}
700
701void G4VRML2SCENEHANDLER::SendMaterialNode()
702{
703 SendMaterialNode(fpViewer->GetApplicableVisAttributes(fpVisAttribs));
704}
705
706void G4VRML2SCENEHANDLER::VRMLBeginModeling()
707{
708 if(!IS_CONNECTED)
709 {
710#if defined DEBUG_SCENE_FUNC
711 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
712 G4cout << "***** VRMLBeginModeling (started)"
713 << "\n";
714#endif
715 this->connectPort();
716 fDest << "#VRML V2.0 utf8"
717 << "\n";
718 fDest << "# Generated by VRML 2.0 driver of GEANT4\n"
719 << "\n";
720 }
721}
722
723void G4VRML2SCENEHANDLER::VRMLEndModeling()
724{
725 if(IS_CONNECTED)
726 {
727#if defined DEBUG_SCENE_FUNC
728 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
729 G4cout << "***** VRMLEndModeling (started)"
730 << "\n";
731#endif
732 fDest << "#End of file."
733 << "\n";
734 this->closePort();
735 }
736}
737
738void G4VRML2SCENEHANDLER::SendMarkerColor(const G4VMarker& marker)
739{
740 fpVisAttribs = marker.GetVisAttributes();
741 const G4Color& color = GetColor();
742
743 fDest << "\t\t"
744 << "appearance Appearance {"
745 << "\n";
746 fDest << "\t\t\t"
747 << "material Material {"
748 << "\n";
749 fDest << "\t\t\t\t"
750 << "diffuseColor ";
751 fDest << color.GetRed() << " ";
752 fDest << color.GetGreen() << " ";
753 fDest << color.GetBlue() << "\n";
754 fDest << "\t\t\t\t"
755 << "emissiveColor ";
756 fDest << color.GetRed() << " ";
757 fDest << color.GetGreen() << " ";
758 fDest << color.GetBlue() << "\n";
759 fDest << "\t\t\t"
760 << "}"
761 << "\n"; // material
762 fDest << "\t\t"
763 << "}"
764 << "\n"; // appearance
765}
766
767void G4VRML2SCENEHANDLER::SendMarkerWorldPosition(const G4VMarker& mark)
768{
769 G4Point3D point = mark.GetPosition();
770
771 point.transform(fObjectTransformation);
772
773 fDest << " translation ";
774 fDest << point.x() << " " << point.y() << " " << point.z() << "\n";
775}
776
777void G4VRML2SCENEHANDLER::GetMarkerWorldPosition(const G4VMarker& mark,
778 double* pX, double* pY,
779 double* pZ)
780{
781 G4Point3D point = mark.GetPosition();
782
783 point.transform(fObjectTransformation);
784
785 *pX = point.x();
786 *pY = point.y();
787 *pZ = point.z();
788}
789
790G4double G4VRML2SCENEHANDLER::GetMarkerHalfSize(const G4VMarker& mark)
791{
792 //----- return value ( marker radius in 3d units)
793 G4double size = 1.0; // initialization
794
795 //----- parameters to calculate 3d size from 2d size
796 const double HALF_SCREEN_SIZE_2D = 300.0; // pixels
797 double zoom_factor = fpViewer->GetViewParameters().GetZoomFactor();
798 if(zoom_factor <= 0.0)
799 {
800 zoom_factor = 1.0;
801 }
802 double extent_radius_3d = GetScene()->GetExtent().GetExtentRadius();
803 if(extent_radius_3d <= 0.0)
804 {
805 extent_radius_3d = 1.0;
806 }
807
808 //----- get marker radius in 3D units
809 if(mark.GetWorldSize() > 0.0)
810 {
811 // get mark radius in 3D units
812 size = 0.5 * mark.GetWorldSize();
813 }
814 else if(mark.GetScreenSize() > 0.0)
815 {
816 // local
817 double mark_radius_2d = 0.5 * mark.GetScreenSize();
818
819 // get mark radius in 3D units
820 size = extent_radius_3d * (mark_radius_2d / HALF_SCREEN_SIZE_2D);
821 size *= zoom_factor;
822 }
823 else
824 {
825 // local
826 double mark_radius_2d =
827 fpViewer->GetViewParameters().GetDefaultMarker().GetScreenSize();
828 mark_radius_2d *= 0.1; // Magic number?
829
830 // get mark radius in 3D units
831 size = extent_radius_3d * (mark_radius_2d / HALF_SCREEN_SIZE_2D);
832 size *= zoom_factor;
833 }
834
835 //----- global rescaling
836 size *= fpViewer->GetViewParameters().GetGlobalMarkerScale();
837
838 //----- return size
839 return size;
840}
841
842void G4VRML2SCENEHANDLER::SendLineColor(const G4VisAttributes* pVA)
843{
844 const G4Color& color = pVA->GetColor();
845
846 fDest << "\t"
847 << "appearance Appearance {"
848 << "\n";
849 fDest << "\t\t"
850 << "material Material {"
851 << "\n";
852 fDest << "\t\t\t"
853 << "diffuseColor ";
854 fDest << color.GetRed() << " ";
855 fDest << color.GetGreen() << " ";
856 fDest << color.GetBlue() << "\n";
857 fDest << "\t\t\t"
858 << "emissiveColor ";
859 fDest << color.GetRed() << " ";
860 fDest << color.GetGreen() << " ";
861 fDest << color.GetBlue() << "\n";
862 fDest << "\t\t"
863 << "}"
864 << "\n"; // material
865 fDest << "\t"
866 << "}"
867 << "\n"; // appearance
868}
869
870G4double G4VRML2SCENEHANDLER::SetPVTransparency()
871{
872 G4double TRANSPARENCY = 0.7; // initialization
873
874 if(std::getenv("G4VRML_TRANSPARENCY") != NULL)
875 {
876 // get a value from the env value
877 // sscanf( getenv("G4VRML_TRANSPARENCY"), "%lg", &TRANSPARENCY ) ;
878 std::istringstream iss(std::getenv("G4VRML_TRANSPARENCY"));
879 iss >> TRANSPARENCY;
880
881 // truncation
882 TRANSPARENCY = std::fabs(TRANSPARENCY);
883 if(TRANSPARENCY > 1.0)
884 {
885 TRANSPARENCY = 1.0;
886 }
887 }
888
889 fPVTransparency = TRANSPARENCY;
890
891 return fPVTransparency;
892}
893
894void G4VRML2SCENEHANDLER::ClearTransientStore()
895{
896 // This is typically called after an update and before drawing hits
897 // of the next event. To simulate the clearing of "transients"
898 // (hits, etc.) the detector is redrawn...
899 if(fpViewer)
900 {
901 fpViewer->SetView();
902 fpViewer->ClearView();
903 fpViewer->DrawView();
904 }
905}
906
907// End of file.