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