Geant4  10.03
G4FRSceneFunc.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: G4FRSceneFunc.icc 101714 2016-11-22 08:53:13Z gcosmo $
28 //
29 
30 #include <CLHEP/Units/PhysicalConstants.h>
31 
32 #include "G4VisManager.hh"
33 #include "G4PhysicalVolumeModel.hh"
34 #include "G4LogicalVolume.hh"
35 
36 //========== AddPrimitive() functions ==========//
37 
38 //----- Add polyline
39 void G4FRSCENEHANDLER::AddPrimitive (const G4Polyline& polyline)
40 {
41 #if defined DEBUG_FR_SCENE
42  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
43  G4cout << "***** AddPrimitive\n";
44 #endif
45  if (fProcessing2D) {
46  static G4bool warned = false;
47  if (!warned) {
48  warned = true;
49  G4Exception
50  ("G4FRSCENEHANDLER::AddPrimitive (const G4Polyline&)",
51  "dawn0001", JustWarning,
52  "2D polylines not implemented. Ignored.");
53  }
54  return;
55  }
56  //----- Initialize Fukui Renderer IF NECESSARY
57  FRBeginModeling();
58 
59  //----- local working variables
60  G4int nPoints = polyline.size ();
61  G4int i ;
62  const G4VisAttributes* pVA =
63  fpViewer->GetApplicableVisAttributes ( polyline.GetVisAttributes() );
64 
65  //----- skip drawing invisible primitive
66  if( pVA ){
67  if( !(pVA->IsVisible()) ) { return ; }
68  }
69 
70  //----- Attributes
71  if(!SendVisAttributes( pVA ) ) {
72  SendStr( FR_COLOR_RGB_RED ); // color
73  }
74 
75  //----- send coordinates to Fukui Renderer
76  SendTransformedCoordinates();
77 
78  //----- send beginning of polyline
79  SendStr( FR_POLYLINE );
80 
81  //----- vertices on polyline
82  for ( i = 0; i < nPoints; i++ ) {
83  SendStrDouble3( FR_PL_VERTEX , \
84  polyline[i].x(), \
85  polyline[i].y(), \
86  polyline[i].z() );
87  }
88 
89  //----- send ending of polyline
90  SendStr( FR_END_POLYLINE );
91 
92 } // G4FRSCENEHANDLER::AddPrimitive (polyline)
93 
94 
95 //----- Add text
96 void G4FRSCENEHANDLER::AddPrimitive ( const G4Text& text )
97 {
98  //-----
99 #if defined DEBUG_FR_SCENE
100  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
101  G4cout << "***** AddPrimitive( G4Text )\n";
102 #endif
103  //----- Initialize DAWN IF NECESSARY
104  FRBeginModeling();
105 
106  //----- send color
107  const G4Color& color = GetTextColor (text) ;
108  SendStrDouble3( FR_COLOR_RGB ,
109  color.GetRed (),
110  color.GetGreen(),
111  color.GetBlue () );
112 
113  //----- send body coordinates
114  SendTransformedCoordinates();
115 
116  //----- Calc size
117  MarkerSizeType size_type;
118  G4double fontsize = GetMarkerDiameter( text , size_type );
119 
120  //----- Calc position
121  const G4Point3D& position = text.GetPosition () ;
122 
123  //----- offset
124  G4double x_offset = text.GetXOffset();
125  G4double y_offset = text.GetYOffset();
126 
127  //----- get string to be visualized and Calc its length
128  const char* vis_text = text.GetText();
129  const int STR_LENGTH = strlen ( vis_text );
130 
131  //----- create buffer and copy the string there
132  int MAX_STR_LENGTH = COMMAND_BUF_SIZE - 100 ;
133  if ( MAX_STR_LENGTH <= 0 ) {
134  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
135  G4cout << "ERROR (FukuiRenderer) : Not enough buffer size for data transferring." << G4endl;
136  G4cout << " G4Text Visualization is aborted" << G4endl;
137  }
138  return ;
139  }
140  char* buf = new char [ (MAX_STR_LENGTH + 1) ] ;
141  if ( MAX_STR_LENGTH >= STR_LENGTH ) {
142  strcpy ( buf, vis_text ) ;
143  } else {
144  strncpy ( buf, vis_text, MAX_STR_LENGTH ) ;
145  }
146 
147  //----- select string command for 3D drawing
148  char text_command[32];
149  switch (size_type) {
150  case world:
151  strcpy ( text_command, FR_MARK_TEXT_2D );
152  break;
153  case screen:
154  default:
155  strcpy ( text_command, FR_MARK_TEXT_2DS );
156  break;
157  }
158 
159  //----- Send string command
160  if (fProcessing2D) {
161  // Map -1<x<1, -1<y<1 to 10<x<200, 53<y<243
162  G4double x_mm = 95. * position.x() + 105.;
163  G4double y_mm = 95. * position.y() + 148.;
164  SendStrDouble3Str( FR_TEXT_2DS,
165  x_mm, y_mm ,
166  fontsize ,
167  buf );
168  } else {
169  SendStrDouble6Str( text_command, \
170  position.x() , position.y() , position.z(),
171  fontsize , x_offset , y_offset ,
172  buf );
173  }
174 
175  //----- delete buffer
176  delete [] buf ;
177 
178 } // G4FRSCENEHANDLER::AddPrimitive ( text )
179 
180 
181 //----- Add circle
182 void G4FRSCENEHANDLER::AddPrimitive ( const G4Circle& mark_circle )
183 {
184  //-----
185 #if defined DEBUG_FR_SCENE
186  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
187  G4cout << "***** AddPrimitive( G4Circle )\n";
188 #endif
189  if (fProcessing2D) {
190  static G4bool warned = false;
191  if (!warned) {
192  warned = true;
193  G4Exception
194  ("G4FRSCENEHANDLER::AddPrimitive (const G4Circle&)",
195  "dawn0002", JustWarning,
196  "2D circles not implemented. Ignored.");
197  }
198  return;
199  }
200  //----- Initialize Fukui Renderer IF NECESSARY
201  FRBeginModeling();
202 
203  //----- send color
204  fpVisAttribs = mark_circle.GetVisAttributes();
205  const G4Color& color = GetColor () ;
206  SendStrDouble3( FR_COLOR_RGB ,
207  color.GetRed (),
208  color.GetGreen(),
209  color.GetBlue () );
210 
211  //----- send body coordinates
212  SendTransformedCoordinates();
213 
214  //----- Calc position
215  const G4Point3D& position = mark_circle.GetPosition () ;
216 
217  //----- Calc size
218  MarkerSizeType size_type;
219  G4double size = GetMarkerRadius( mark_circle , size_type );
220 
221  //----- send mark
222  switch (size_type) {
223  case world:
224  SendStrDouble4( FR_MARK_CIRCLE_2D, \
225  position.x() , position.y() , position.z(), size );
226  break;
227  default:
228  case screen:
229  SendStrDouble4( FR_MARK_CIRCLE_2DS, \
230  position.x() , position.y() , position.z(), size );
231  break;
232  }
233 
234 } // G4FRSCENEHANDLER::AddPrimitive ( mark_circle )
235 
236 
237 //----- Add square
238 void G4FRSCENEHANDLER::AddPrimitive (const G4Square& mark_square )
239 {
240  //-----
241 #if defined DEBUG_FR_SCENE
242  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
243  G4cout << "***** AddPrimitive( G4Square )\n";
244 #endif
245  if (fProcessing2D) {
246  static G4bool warned = false;
247  if (!warned) {
248  warned = true;
249  G4Exception
250  ("G4FRSCENEHANDLER::AddPrimitive (const G4Square&)",
251  "dawn0003", JustWarning,
252  "2D squares not implemented. Ignored.");
253  }
254  return;
255  }
256  //----- Initialize Fukui Renderer IF NECESSARY
257  FRBeginModeling();
258 
259  //----- send color
260  fpVisAttribs = mark_square.GetVisAttributes();
261  const G4Color& color = GetColor () ;
262  SendStrDouble3( FR_COLOR_RGB ,
263  color.GetRed (),
264  color.GetGreen(),
265  color.GetBlue () );
266 
267  //----- send body coordinates
268  SendTransformedCoordinates();
269 
270  //----- Calc position
271  const G4Point3D& position = mark_square.GetPosition () ;
272 
273  //----- Calc size
274  MarkerSizeType size_type;
275  G4double size = GetMarkerRadius( mark_square , size_type );
276 
277  //----- send mark
278  switch (size_type) {
279  case world:
280  SendStrDouble4( FR_MARK_SQUARE_2D, \
281  position.x() , position.y() , position.z(), size );
282  break;
283  default:
284  case screen:
285  SendStrDouble4( FR_MARK_SQUARE_2DS, \
286  position.x() , position.y() , position.z(), size );
287  break;
288  }
289 
290 } // G4FRSCENEHANDLER::AddPrimitive ( mark_square )
291 
292 
293 //----- Add polyhedron
294 void G4FRSCENEHANDLER::AddPrimitive ( const G4Polyhedron& polyhedron )
295 {
296  //-----
297 #if defined DEBUG_FR_SCENE
298  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
299  G4cout << "***** AddPrimitive( G4Polyhedron )\n";
300 #endif
301  if (fProcessing2D) {
302  static G4bool warned = false;
303  if (!warned) {
304  warned = true;
305  G4Exception
306  ("G4FRSCENEHANDLER::AddPrimitive (const G4Polyhedron&)",
307  "dawn0004", JustWarning,
308  "2D polyhedrons not implemented. Ignored.");
309  }
310  return;
311  }
312 
313  if (polyhedron.GetNoFacets() == 0) return;
314 
315  //----- Initialize Fukui Renderer IF NECESSARY
316  FRBeginModeling();
317 
318  //----- Attributes
319  if(!SendVisAttributes( fpViewer->GetApplicableVisAttributes
320  (polyhedron.GetVisAttributes() ) ) ) {
321  SendStr( FR_COLOR_RGB_RED ); // color
322  }
323 
324  //----- Coordinates
325  SendTransformedCoordinates();
326 
327  //----- Brep data
328 
329  //---------- (1) Declare beginning of Brep data
330  SendStr(FR_POLYHEDRON);
331 
332  //---------- (2) Vertex block
333  for (G4int i = 1, j = polyhedron.GetNoVertices(); j; j--, i++){
334  G4Point3D point = polyhedron.GetVertex(i);
335  SendStrDouble3( FR_VERTEX, point.x (), point.y (), point.z ());
336  }
337 
338  //---------- (3) Facet block
339  for (G4int f = polyhedron.GetNoFacets(); f; f--){
340  G4int notLastEdge;
341  G4int index = -1; // initialization
342  G4int edgeFlag = 1;
343  //G4int preedgeFlag = 1; Not used - comment out to prevent warnings (JA).
344  G4int work[4], i = 0;
345  do {
346  //preedgeFlag = edgeFlag; Not used - comment out to prevent warnings (JA).
347  notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
348  work[i++] = index;
349  }while (notLastEdge);
350  switch (i){
351  case 3:
352  SendStrInt3(FR_FACET, work[0], work[1], work[2] );
353  break;
354  case 4:
355  SendStrInt4(FR_FACET, work[0], work[1], work[2], work[3] );
356  break;
357  default:
358  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
359  G4cout <<
360  "ERROR G4FRSCENEHANDLER::AddPrimitive(G4Polyhedron)\n";
361  G4PhysicalVolumeModel* pPVModel =
362  dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
363  if (pPVModel)
364  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
365  G4cout <<
366  "Volume " << pPVModel->GetCurrentPV()->GetName() <<
367  ", Solid " << pPVModel->GetCurrentLV()->GetSolid()->GetName() <<
368  " (" << pPVModel->GetCurrentLV()->GetSolid()->GetEntityType();
369  G4cout <<
370  "\nG4Polyhedron facet with " << i << " edges" << G4endl;
371  }
372  }
373  }
374 
375  //---------- (4) Declare ending of Brep data
376  SendStr(FR_END_POLYHEDRON);
377 
378 } // G4FRSCENEHANDLER::AddPrimitive (polyhedron)
379 
380 
381 //-----
382 void G4FRSCENEHANDLER::SendNdiv ( void )
383 {
384 //////////////////////////////////////////////////
385 //#if defined DEBUG_FR_SCENE
386 // G4cout << "***** SendNdiv() (/Ndiv)" << G4endl;
387 //#endif
388 //////////////////////////////////////////////////
389 
390  //----- local
391  G4int num_division = FR_DEFALUT_NDIV_VALUE ;
392 
393  //----- number used for dividing a curved surface, Ndiv
394  // if ( GetModel() ) { ?? Why test for model. Can be zero. JA ??
395  const G4VisAttributes* pVisAttribs =
396  fpViewer -> GetApplicableVisAttributes (fpVisAttribs);
397  num_division = GetNoOfSides(pVisAttribs);
398  // } else {
399 #if defined DEBUG_FR_SCENE
400  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
401  G4cout << "WARNING: GetNoOfSides() failed. " ;
402  G4cout << "The default value " << num_division ;
403  G4cout << " is assigned." << G4endl;
404  }
405 #endif
406  //}
407 
408  //---------- Error recovery for too small Ndiv
409  num_division = ( num_division < 3 ? 3 : num_division );
410 
411 //////////////////////////////////////////////////
412 //#if defined DEBUG_FR_SCENE
413 // G4cout << "Ndiv = " << num_division << G4endl;
414 //#endif
415 //////////////////////////////////////////////////
416 
417  //----- Send resultant Ndiv
418  this->SendStrInt( FR_NDIV, num_division );
419 
420 
421 }
422 
423 //-----
424 void G4FRSCENEHANDLER::FREndModeling ()
425 {
426  //-----
427 #if defined DEBUG_FR_SCENE
428  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
429  G4cout << "***** FREndModeling (called)" << G4endl;
430 #endif
431  if( FRIsInModeling() ) {
432 
433 #if defined DEBUG_FR_SCENE
434  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
435  G4cout << "***** FREndModeling (started) " ;
436  G4cout << "(/EndModeling, /DrawAll, /CloseDevice)" << G4endl;
437  }
438 #endif
439 
440  SendStr( "#--------------------" );
441 
442  //----- !EndModeling
443  SendStr( FR_END_MODELING );
444 
445  //----- !DrawAll
446  SendStr( FR_DRAW_ALL );
447 
448  //----- !CloseDevice
449  SendStr( FR_CLOSE_DEVICE );
450 
451  //----- End saving data to g4.prim
452  EndSavingG4Prim() ;
453 
454  //------ Reset flag
455  FRflag_in_modeling = false ;
456  }
457 }
458 
459 
460 //-----
461 void G4FRSCENEHANDLER::BeginPrimitives (const G4Transform3D& objectTransformation)
462 {
463 #if defined DEBUG_FR_SCENE
464  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
465  G4cout << "***** BeginPrimitives \n";
466 #endif
467 
468  FRBeginModeling();
469 
470  G4VSceneHandler::BeginPrimitives (objectTransformation);
471 }
472 
473 
474 //-----
475 void G4FRSCENEHANDLER::EndPrimitives ()
476 {
477 #if defined DEBUG_FR_SCENE
478  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
479  G4cout << "***** EndPrimitives \n";
480 #endif
481  G4VSceneHandler::EndPrimitives ();
482 }
483 
484 
485 //========== AddSolid() functions ==========//
486 
487 //----- Add box
488 void G4FRSCENEHANDLER::AddSolid( const G4Box& box )
489 {
490 #if defined DEBUG_FR_SCENE
491  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
492  G4cout << "***** AddSolid ( box )\n";
493 #endif
494 
495  //----- skip drawing invisible primitive
496  if( !IsVisible() ) { return ; }
497 
498  //----- Initialize Fukui Renderer IF NECESSARY
499  FRBeginModeling();
500 
501  //----- Send Name
502  SendPhysVolName();
503 
504  //----- Send Ndiv
505  // SendNdiv();
506 
507  //----- Attributes
508  if(!SendVisAttributes
509  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
510  SendStr( FR_COLOR_RGB_GREEN ); // color
511  }
512 
513  //----- parameters (half lengths of box)
514  G4double dx = box.GetXHalfLength ();
515  G4double dy = box.GetYHalfLength ();
516  G4double dz = box.GetZHalfLength ();
517 
518  //----- send coordinates to Fukui Renderer
519  SendTransformedCoordinates();
520 
521  //----- send box to Fukui Renderer
522  SendStrDouble3( FR_BOX, dx, dy, dz );
523 
524 } // void G4FRSCENEHANDLER::AddSolid( const G4Box& box )
525 
526 
527 //----- Add tubes
528 void
529 G4FRSCENEHANDLER::AddSolid( const G4Tubs& tubes )
530 {
531 #if defined DEBUG_FR_SCENE
532  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
533  G4cout << "***** AddSolid ( tubes )\n";
534 #endif
535  //----- skip drawing invisible primitive
536  if( !IsVisible() ) { return ; }
537 
538  //----- Initialize Fukui Renderer IF NECESSARY
539  FRBeginModeling();
540 
541  //----- Send Name
542  SendPhysVolName();
543 
544  //----- Send Ndiv
545  SendNdiv();
546 
547  //----- Attributes
548  if(!SendVisAttributes
549  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
550  SendStr( FR_COLOR_RGB_BLUE ); // color
551  }
552 
553  //----- parameters
554  const G4double R = tubes.GetOuterRadius() ; // outside radius
555  const G4double r = tubes.GetInnerRadius() ; // inside radius
556  const G4double dz = tubes.GetZHalfLength() ; // half length in z
557  const G4double sphi = tubes.GetStartPhiAngle() ; // starting angle
558  const G4double dphi = tubes.GetDeltaPhiAngle() ; // angle width
559 
560  //----- send coordinates to Fukui Renderer
561  SendTransformedCoordinates();
562 
563  //----- send tubes to Fukui Renderer
564  SendStrDouble5( FR_TUBS, r, R, dz , sphi, dphi );
565 
566 } // void G4FRSCENEHANDLER::AddSolid( const G4Tubs& )
567 
568 
569 
570 //----- Add cons
571 void
572 G4FRSCENEHANDLER::AddSolid( const G4Cons& cons )
573 {
574 #if defined DEBUG_FR_SCENE
575  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
576  G4cout << "***** AddSolid ( cons )\n";
577 #endif
578  //----- skip drawing invisible primitive
579  if( !IsVisible() ) { return ; }
580 
581  //----- Initialize Fukui Renderer IF NECESSARY
582  FRBeginModeling();
583 
584  //----- Send Name
585  SendPhysVolName();
586 
587  //----- Send Ndiv
588  SendNdiv();
589 
590  //----- Attributes
591  if(!SendVisAttributes
592  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
593  SendStr( FR_COLOR_RGB_CYAN ); // color
594  }
595 
596  //----- parameters
597  const G4double r1 = cons.GetInnerRadiusMinusZ() ; // inside radius at -dz
598  const G4double R1 = cons.GetOuterRadiusMinusZ() ; // outside radius at -dz
599  const G4double r2 = cons.GetInnerRadiusPlusZ() ; // inside radius at +dz
600  const G4double R2 = cons.GetOuterRadiusPlusZ() ; // outside radius at +dz
601  const G4double dz = cons.GetZHalfLength () ; // half length in z
602  const G4double sphi = cons.GetStartPhiAngle() ; // starting angle
603  const G4double dphi = cons.GetDeltaPhiAngle() ; // angle width
604 
605  //----- send coordinates to Fukui Renderer
606  SendTransformedCoordinates();
607 
608  //----- send cons to Fukui Renderer
609  SendStrDouble7( FR_CONS, r1, R1, r2, R2, dz , sphi, dphi );
610 
611 }// G4FRSCENEHANDLER::AddSolid( cons )
612 
613 
614 //----- Add trd
615 void G4FRSCENEHANDLER::AddSolid ( const G4Trd& trd )
616 {
617 #if defined DEBUG_FR_SCENE
618  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
619  G4cout << "***** AddSolid ( trd )\n";
620 #endif
621 
622  //----- skip drawing invisible primitive
623  if( !IsVisible() ) { return ; }
624 
625  //----- Initialize Fukui Renderer IF NECESSARY
626  FRBeginModeling();
627 
628  //----- Send Name
629  SendPhysVolName();
630 
631  //----- Send Ndiv
632  // SendNdiv();
633 
634  //----- Attributes
635  if(!SendVisAttributes
636  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
637  SendStr( FR_COLOR_RGB_MAGENTA ); // color
638  }
639 
640  //----- parameters
641  G4double dx1 = trd.GetXHalfLength1 ();
642  G4double dx2 = trd.GetXHalfLength2 ();
643  G4double dy1 = trd.GetYHalfLength1 ();
644  G4double dy2 = trd.GetYHalfLength2 ();
645  G4double dz = trd.GetZHalfLength ();
646 
647  //----- send coordinates to Fukui Renderer
648  SendTransformedCoordinates();
649 
650  //----- send trd to Fukui Renderer
651  SendStrDouble5( FR_TRD, dx1, dx2, dy1, dy2, dz );
652 
653 } // G4FRSCENEHANDLER::AddSolid ( trd )
654 
655 
656 //----- Add sphere
657 void G4FRSCENEHANDLER::AddSolid ( const G4Sphere& sphere )
658 {
659 #if defined DEBUG_FR_SCENE
660  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
661  G4cout << "***** AddSolid ( sphere )\n";
662 #endif
663  //----- skip drawing invisible primitive
664  if( !IsVisible() ) { return ; }
665 
666  //----- Initialize Fukui Renderer IF NECESSARY
667  FRBeginModeling();
668 
669  //----- Send Name
670  SendPhysVolName();
671 
672  //----- Send Ndiv
673  SendNdiv();
674 
675  //----- Attributes
676  if(!SendVisAttributes
677  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
678  SendStr( FR_COLOR_RGB_YELLOW ); // color
679  }
680 
681  //----- parameters
682 // const G4double rmin = sphere.GetInnerRadius();
683  const G4double rmax = sphere.GetOuterRadius();
684 // const G4double sphi = sphere.GetStartPhiAngle();
685  const G4double dphi = sphere.GetDeltaPhiAngle();
686 // const G4double stheta = sphere.GetStartThetaAngle();
687  const G4double dtheta = sphere.GetDeltaThetaAngle();
688 
689  //----- send coordinates to Fukui Renderer
690  SendTransformedCoordinates();
691 
692  //----- send sphere to Fukui Renderer
693  const G4double PI_minus = 0.9999 * CLHEP::pi ;
694  const G4double PI2_minus = 1.9999 * CLHEP::pi ;
695  if( dphi > PI2_minus && dtheta > PI_minus ) {
696  //----- full sphere
697  SendStrDouble ( FR_SPHERE, rmax );
698  } else {
699 
700  //----- call AddPrimitives( G4Polyhedron )
701  //...... For sphere "segment",
702  //...... G4Polyhedron is used for visualization.
703  //...... Visualization attributes and
704  //...... local coordinates are resent and overwritten.
705  G4VSceneHandler::AddSolid( sphere ) ;
706 
707 ////////////////////////////////////////////////////////////////
708 // //----- sphere segment
709 // SendStrDouble6( FR_SPHERE_SEG, rmin, rmax, stheta, dtheta, sphi, dphi );
710 ////////////////////////////////////////////////////////////////
711 
712  }
713 
714 } // G4FRSCENEHANDLER::AddSolid ( sphere )
715 
716 
717 //----- Add para
718 void G4FRSCENEHANDLER::AddSolid (const G4Para& para)
719 {
720 #if defined DEBUG_FR_SCENE
721  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
722  G4cout << "***** AddSolid ( para )\n";
723 #endif
724 
725  //----- skip drawing invisible primitive
726  if( !IsVisible() ) { return ; }
727 
728  //----- Initialize Fukui Renderer IF NECESSARY
729  FRBeginModeling();
730 
731  //----- Send Name
732  SendPhysVolName();
733 
734  //----- Send Ndiv
735  // SendNdiv();
736 
737  //----- Attributes
738  if(!SendVisAttributes
739  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
740  SendStr( FR_COLOR_RGB_RED ); // color
741  }
742 
743  //----- local
744  const G4double epsilon = 1.0e-5 ;
745 
746  //----- parameters preprocessing
747  G4double cosTheta = para.GetSymAxis().z() ;
748  if( cosTheta < epsilon ) {
749  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
750  G4cout << "WARNING from FukuiRenderer (DAWN) driver:" << G4endl;
751  G4cout << " Invalid parameter for parallelepiped." << G4endl;
752  G4cout << " Drawing is skipped." << G4endl;
753  }
754  return ;
755  }
756  G4double tanTheta_cosPhi_cosTheta = para.GetSymAxis().x() ;
757  G4double tanTheta_sinPhi_cosTheta = para.GetSymAxis().y() ;
758 
759  //----- parameters
760  G4double dx = para.GetXHalfLength ();
761  G4double dy = para.GetYHalfLength ();
762  G4double dz = para.GetZHalfLength ();
763  G4double tanAlpha = para.GetTanAlpha();
764  G4double tanTheta_cosPhi = tanTheta_cosPhi_cosTheta / cosTheta ;
765  G4double tanTheta_sinPhi = tanTheta_sinPhi_cosTheta / cosTheta ;
766 
767  //----- send coordinates to Fukui Renderer
768  SendTransformedCoordinates();
769 
770  //----- send data to Fukui Renderer
771  SendStrDouble6 ( FR_PARA, dx, dy, dz, tanAlpha, tanTheta_cosPhi, tanTheta_sinPhi );
772 
773 } // G4FRSCENEHANDLER::AddSolid ( para )
774 
775 
776 //----- Add trap
777 void G4FRSCENEHANDLER::AddSolid (const G4Trap& trap)
778 {
779 #if defined DEBUG_FR_SCENE
780  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
781  G4cout << "***** AddSolid ( trap )\n";
782 #endif
783 
784  //----- skip drawing invisible primitive
785  if( !IsVisible() ) { return ; }
786 
787  //----- Initialize Fukui Renderer IF NECESSARY
788  FRBeginModeling();
789 
790  //----- Send Name
791  SendPhysVolName();
792 
793  //----- Send Ndiv
794  // SendNdiv();
795 
796  //----- Attributes
797  if(!SendVisAttributes
798  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
799  SendStr( FR_COLOR_RGB_GREEN ); // color
800  }
801 
802  //----- local
803  const G4double epsilon = 1.0e-5 ;
804 
805  //----- parameters preprocessing
806  G4double cosTheta = trap.GetSymAxis().z() ;
807  if( cosTheta < epsilon ) {
808  if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
809  G4cout << "WARNING from FukuiRenderer (DAWN) driver:" << G4endl;
810  G4cout << " Invalid parameter for trap, 1" << G4endl;
811  G4cout << " Drawing is skipped." << G4endl;
812  }
813  return ;
814  }
815 
816  G4double nx = trap.GetSymAxis().x() ;
817  G4double ny = trap.GetSymAxis().y() ;
818 
819  //----- parameters (half lengths of box)
820  G4double dz = trap.GetZHalfLength ();
821  G4double theta = std::acos( cosTheta ) ;
822  G4double phi;
823  if ( ny==0. && nx ==0.) {
824  phi = 0.; // std::atan2(0.,0.) gives undefined value of phi
825  } else {
826  phi = std::atan2( ny, nx ) ; if( phi < 0. ) { phi += CLHEP::twopi ; }
827  // -PI < std::atan() < PI
828  }
829 /////////////////////////////////////////////////
830 // G4double phi = std::atan2( ny, nx ) ;
831 // if( phi < 0.0 ) { phi += CLHEP::twopi ; }
832 // // -PI < std::atan() < PI
833 /////////////////////////////////////////////////
834 
835  G4double h1 = trap.GetYHalfLength1 ();
836  G4double bl1 = trap.GetXHalfLength1 ();
837  G4double tl1 = trap.GetXHalfLength2 ();
838  G4double alpha1 = std::atan( trap.GetTanAlpha1()) ;
839  G4double h2 = trap.GetYHalfLength2 ();
840  G4double bl2 = trap.GetXHalfLength3 ();
841  G4double tl2 = trap.GetXHalfLength4 ();
842  G4double alpha2 = std::atan( trap.GetTanAlpha2()) ;
843 
844  //----- send coordinates to Fukui Renderer
845  SendTransformedCoordinates();
846 
847  //----- Change sign of alpha for compatibility
848  // with the DAWN format
849  G4double alpha_sign = -1.0 ;
850  alpha1 *= alpha_sign ; alpha2 *= alpha_sign ;
851 
852  //----- send box to Fukui Renderer
853  SendStrDouble11( FR_TRAP ,
854  dz ,
855  theta ,
856  phi ,
857  h1 ,
858  bl1 ,
859  tl1 ,
860  alpha1 ,
861  h2 ,
862  bl2 ,
863  tl2 ,
864  alpha2 );
865 
866 } // G4FRSCENEHANDLER::AddSolid (const G4Trap& trap)
867 
868 
869 //----- Add torus
870 void
871 G4FRSCENEHANDLER::AddSolid( const G4Torus& torus )
872 {
873 #if defined DEBUG_FR_SCENE
874  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
875  G4cout << "***** AddSolid ( torus )\n";
876 #endif
877  //----- skip drawing invisible primitive
878  if( !IsVisible() ) { return ; }
879 
880  //----- Initialize Fukui Renderer IF NECESSARY
881  FRBeginModeling();
882 
883  //----- Send Name
884  SendPhysVolName();
885 
886  //----- Send Ndiv
887  SendNdiv();
888 
889  //----- Attributes
890  if(!SendVisAttributes
891  ( fpViewer->GetApplicableVisAttributes( fpVisAttribs ) ) ) {
892  SendStr( FR_COLOR_RGB_BLUE ); // color
893  }
894 
895  //----- parameters
896  const G4double r = torus.GetRmin() ;
897  const G4double R = torus.GetRmax() ;
898  const G4double t = torus.GetRtor() ;
899  const G4double sphi = torus.GetSPhi() ;
900  const G4double dphi = torus.GetDPhi() ;
901 
902  //----- send coordinates to Fukui Renderer
903  SendTransformedCoordinates();
904 
905  //----- send torus to Fukui Renderer
906  SendStrDouble5( FR_TORUS, r, R, t , sphi, dphi );
907 
908 } // void G4FRSCENEHANDLER::AddSolid( const G4Torus& )
909 
910 
911 
912 //----- Add a shape which is not treated above
913 void G4FRSCENEHANDLER::AddSolid ( const G4VSolid& solid )
914 {
915  //----- skip drawing invisible primitive
916  if( !IsVisible() ) { return ; }
917 
918  //----- Initialize Fukui Renderer IF NECESSARY
919  FRBeginModeling();
920 
921  //----- Send Name
922  SendPhysVolName() ;
923 
924  //----- Send Ndiv
925  // SendNdiv();
926 
927  //----- Send a primitive
928  G4VSceneHandler::AddSolid( solid ) ;
929 
930 } //G4FRSCENEHANDLER::AddSolid ( const G4VSolid& )
931 
932 
933 //-----
934 G4bool
935 G4FRSCENEHANDLER::SendVisAttributes ( const G4VisAttributes* pAV )
936 {
937 
938  // Have a look at G4VSceneHandler::GetDrawingStyle (const G4Visible&). (John)
939 
940  G4bool status = true ; // initialization
941  const G4double ALPHA_MIN = 0.001 ; // min of alpha factor of color
942 
943  if( pAV == NULL ) {
944  // No attribute is given.
945  // Do nothing. Status is "fail".
946  status = false ;
947 
948  } else {
949  // Send attributes. Status is "success".
950  status = true ;
951  const G4Color& color = pAV->GetColor();
952  SendStrDouble3( FR_COLOR_RGB,
953  color.GetRed (),
954  color.GetGreen(),
955  color.GetBlue () );
956  if ( color.GetAlpha() < ALPHA_MIN ) {
957  SendStr( FR_FORCE_WIREFRAME_ON ) ;
958  }
959  else if ( pAV->IsForceDrawingStyle () &&
960  (pAV->GetForcedDrawingStyle () == G4VisAttributes::wireframe)) {
961  SendStr( FR_FORCE_WIREFRAME_ON ) ;
962  } else {
963  SendStr( FR_FORCE_WIREFRAME_OFF ) ;
964  }
965  }
966 
967  return status ;
968 
969 } // G4FRSCENEHANDLER::SendVisAttributes ()
970 
971 
972 //-----
973 G4bool G4FRSCENEHANDLER::IsVisible()
974 {
975  //-----
976  G4bool visibility = true ;
977 
978  //-----
979  const G4VisAttributes* pVisAttribs =
980  fpViewer->GetApplicableVisAttributes( fpVisAttribs );
981 
982  //-----
983  if( ( getenv( FR_ENV_CULL_INVISIBLE_OBJECTS ) != NULL ) && \
984  ( strcmp( getenv( FR_ENV_CULL_INVISIBLE_OBJECTS ),"0" ) ) && \
985  ( pVisAttribs ) )
986  {
987  visibility = pVisAttribs->IsVisible();
988  }
989 
990  //-----
991  return visibility ;
992 
993 } // G4FRSCENEHANDLER::IsVisible()
994 
995 
996 //-----
997 void G4FRSCENEHANDLER::SendBoundingBox( void )
998 {
999 #if defined DEBUG_FR_SCENE
1000  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1001  G4cout << "***** SendBoundingBox () (/BoundingBox)" << G4endl;
1002 #endif
1003 
1004  //----- (1A) CALC bounding box of the bounding sphere
1005  const G4VisExtent& extent = GetScene()->GetExtent();
1006  const G4Point3D& center = extent.GetExtentCenter();
1007  const G4double radius = extent.GetExtentRadius();
1008 
1009  G4double xmin = center.x() - radius ;
1010  G4double ymin = center.y() - radius ;
1011  G4double zmin = center.z() - radius ;
1012 
1013  G4double xmax = center.x() + radius ;
1014  G4double ymax = center.y() + radius ;
1015  G4double zmax = center.z() + radius ;
1016 
1017 ////////////////////////////////////////////
1018 // G4double xmin = extent.GetXmin ();
1019 // G4double ymin = extent.GetYmin ();
1020 // G4double zmin = extent.GetZmin ();
1021 // G4double xmax = extent.GetXmax ();
1022 // G4double ymax = extent.GetYmax ();
1023 // G4double zmax = extent.GetZmax ();
1024 ////////////////////////////////////////////
1025 
1026  //----- (1B) SEND bounding box
1027  SendStrDouble6( FR_BOUNDING_BOX,
1028  xmin, ymin, zmin,
1029  xmax, ymax, zmax );
1030 
1031 } // G4FRSCENEHANDLER::SendBoundingBox()
1032 
1033 
1034 //-----
1035 void
1036 G4FRSCENEHANDLER::SendTransformedCoordinates()
1037 {
1038  //----- coord info
1039  G4Point3D zero ( 0.0 , 0.0 , 0.0 );
1040  G4Point3D x1 ( 1.0 , 0.0 , 0.0 );
1041  G4Point3D y1 ( 0.0 , 1.0 , 0.0 );
1042  G4Vector3D x_unit_vec( 1.0 , 0.0 , 0.0 );
1043  G4Vector3D y_unit_vec( 0.0 , 1.0 , 0.0 );
1044 
1045  //----- transformed origin
1046  zero.transform( fObjectTransformation );
1047 
1048  //----- transformed base vectors
1049  x1.transform( fObjectTransformation );
1050  x_unit_vec = x1 - zero ;
1051  y1.transform( fObjectTransformation );
1052  y_unit_vec = y1 - zero ;
1053 
1054  //----- send transformed origin
1055  SendStrDouble3( FR_ORIGIN , (zero.x()), (zero.y()), (zero.z()) ) ;
1056 
1057  //----- send transformed base vectors
1058  SendStrDouble6( FR_BASE_VECTOR , \
1059  (x_unit_vec.x()), (x_unit_vec.y()), (x_unit_vec.z()) , \
1060  (y_unit_vec.x()), (y_unit_vec.y()), (y_unit_vec.z()) ) ;
1061 
1062 } // G4FRSCENEHANDLER::SendTransformedCoordinates()
1063 
1064 
1065 //-----
1066 void G4FRSCENEHANDLER::SendPhysVolName ( void )
1067 {
1068  // Local
1069  G4int i ;
1070 
1071  // Current Model
1072  const G4VModel* pv_model = GetModel();
1073  if (!pv_model) { return ; }
1074 
1075  G4PhysicalVolumeModel* pPVModel =
1076  dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1077  if (!pPVModel) { return ; }
1078 
1079  // Current Physical volume name
1080  G4String pv_name = pPVModel->GetCurrentTag() ;
1081 
1082  // Current depth of volume
1083  G4int cur_depth = pPVModel->GetCurrentDepth() ;
1084 
1085  // Make a string to be sent
1086  // e.g. experimental_Hall.1, where "1" is the copy number
1087  G4String name_comment ( FR_PHYSICAL_VOLUME_NAME );
1088  name_comment += " " ;
1089 
1090  for ( i = 0 ; i < cur_depth; i++) {
1091  // Make tree
1092  name_comment += " " ;
1093  }
1094  name_comment += pv_name ;
1095 
1096  // Send physical volume name
1097  SendStr ( "#--------------------" );
1098  SendStr ( name_comment );
1099 
1100 } // G4FRSCENEHANDLER::SendPhysVolName ()
1101 
1102 
1103 //-----
1104 void G4FRSCENEHANDLER::SendStr( const char* char_string )
1105 {
1106  fPrimDest.SendLine( char_string );
1107 }
1108 
1109 
1110 //-----
1111 void G4FRSCENEHANDLER::SendStrInt( const char* char_string ,
1112  G4int ival )
1113 {
1114  //----- make command char_string and send
1115  G4int num_char ;
1116  char* command = new char [ COMMAND_BUF_SIZE ];
1117 
1118  num_char = sprintf( command, "%s %d", char_string , ival ) ;
1119  if( num_char < 0 ) {
1120  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1121  G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n" ;
1122  }
1123  SendStr( command );
1124  delete [] command ;
1125 } // G4FRSCENEHANDLER::SendStrInt()
1126 
1127 
1128 //-----
1129 void
1130 G4FRSCENEHANDLER::SendStrInt3( const char* char_string ,
1131  G4int ival1 ,
1132  G4int ival2 ,
1133  G4int ival3 )
1134 {
1135  //----- make command char_string and send
1136  G4int num_char ;
1137  char* command = new char [ COMMAND_BUF_SIZE ];
1138 
1139  num_char = \
1140  sprintf( command, "%s %d %d %d", char_string , ival1, ival2, ival3 ) ;
1141 
1142  if( num_char < 0 ) {
1143  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1144  G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt3(), 1\n" ;
1145  }
1146  SendStr( command );
1147  delete [] command ;
1148 
1149 } // G4FRSCENEHANDLER::SendStrInt3()
1150 
1151 
1152 //-----
1153 void
1154 G4FRSCENEHANDLER::SendStrInt4( const char* char_string ,
1155  G4int ival1 ,
1156  G4int ival2 ,
1157  G4int ival3 ,
1158  G4int ival4 )
1159 {
1160  //----- make command char_string and send
1161  G4int num_char ;
1162  char* command = new char [ COMMAND_BUF_SIZE ];
1163 
1164  num_char = \
1165  sprintf( command, "%s %d %d %d %d", char_string , ival1, ival2, ival3, ival4 ) ;
1166 
1167  if( num_char < 0 ) {
1168  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1169  G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt4(), 1\n" ;
1170  }
1171  SendStr( command );
1172  delete [] command ;
1173 
1174 } // G4FRSCENEHANDLER::SendStrInt4()
1175 
1176 //-----
1177 void G4FRSCENEHANDLER::SendStrDouble( const char* char_string ,
1178  G4double dval )
1179 {
1180  //----- make command char_string and send
1181  G4int num_char ;
1182  char* command = new char [ COMMAND_BUF_SIZE ];
1183 
1184  num_char = sprintf( command, "%s %*.*g", \
1185  char_string , \
1186  fPrec2, fPrec, dval ) ;
1187  if( num_char < 0 ) {
1188  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1189  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble(), 1\n" ;
1190  }
1191  SendStr( command );
1192  delete [] command ;
1193 
1194 } // G4FRSCENEHANDLER::SendStrDouble()
1195 
1196 
1197 //-----
1198 void
1199 G4FRSCENEHANDLER::SendStrDouble2( const char* char_string ,
1200  G4double dval1 ,
1201  G4double dval2 )
1202 {
1203  //----- make command char_string and send
1204  G4int num_char ;
1205  char* command = new char [ COMMAND_BUF_SIZE ];
1206 
1207  num_char = sprintf( command, "%s %*.*g %*.*g", char_string , \
1208  fPrec2, fPrec, dval1, \
1209  fPrec2, fPrec, dval2 ) ;
1210  if( num_char < 0 ) {
1211  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1212  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble2(), 1\n" ;
1213  }
1214  SendStr( command );
1215  delete [] command ;
1216 
1217 } // G4FRSCENEHANDLER::SendStrDouble2()
1218 
1219 
1220 //-----
1221 void
1222 G4FRSCENEHANDLER::SendStrDouble3( const char* char_string ,
1223  G4double dval1 ,
1224  G4double dval2 ,
1225  G4double dval3 )
1226 {
1227  //----- make command char_string and send
1228  G4int num_char ;
1229  char* command = new char [ COMMAND_BUF_SIZE ];
1230 
1231  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g", \
1232  char_string , \
1233  fPrec2, fPrec, dval1, \
1234  fPrec2, fPrec, dval2, \
1235  fPrec2, fPrec, dval3 ) ;
1236  if( num_char < 0 ) {
1237  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1238  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble3(), 1\n" ;
1239  }
1240  SendStr( command );
1241  delete [] command ;
1242 
1243 } // G4FRSCENEHANDLER::SendStrDouble3()
1244 
1245 
1246 //-----
1247 void
1248 G4FRSCENEHANDLER::SendStrDouble4( const char* char_string ,
1249  G4double dval1 ,
1250  G4double dval2 ,
1251  G4double dval3 ,
1252  G4double dval4 )
1253 {
1254  //----- make command char_string and send
1255  G4int num_char ;
1256  char* command = new char [ COMMAND_BUF_SIZE ];
1257 
1258  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g", \
1259  char_string , \
1260  fPrec2, fPrec, dval1, \
1261  fPrec2, fPrec, dval2, \
1262  fPrec2, fPrec, dval3, \
1263  fPrec2, fPrec, dval4) ;
1264  if( num_char < 0 ) {
1265  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1266  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble4(), 1\n" ;
1267  }
1268  SendStr( command );
1269  delete [] command ;
1270 
1271 } // G4FRSCENEHANDLER::SendStrDouble4()
1272 
1273 
1274 //-----
1275 void
1276 G4FRSCENEHANDLER::SendStrDouble5( const char* char_string ,
1277  G4double dval1 ,
1278  G4double dval2 ,
1279  G4double dval3 ,
1280  G4double dval4 ,
1281  G4double dval5 )
1282 {
1283  //----- make command char_string and send
1284  G4int num_char ;
1285  char* command = new char [ COMMAND_BUF_SIZE ];
1286 
1287  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g", \
1288  char_string , \
1289  fPrec2, fPrec, dval1, \
1290  fPrec2, fPrec, dval2, \
1291  fPrec2, fPrec, dval3, \
1292  fPrec2, fPrec, dval4, \
1293  fPrec2, fPrec, dval5 ) ;
1294  if( num_char < 0 ) {
1295  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1296  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble5(), 1\n" ;
1297  }
1298  SendStr( command );
1299  delete [] command ;
1300 
1301 } // G4FRSCENEHANDLER::SendStrDouble5()
1302 
1303 
1304 //-----
1305 void
1306 G4FRSCENEHANDLER::SendStrDouble6( const char* char_string ,
1307  G4double dval1 ,
1308  G4double dval2 ,
1309  G4double dval3 ,
1310  G4double dval4 ,
1311  G4double dval5 ,
1312  G4double dval6 )
1313 {
1314  //----- make command char_string and send
1315  G4int num_char ;
1316  char* command = new char [ COMMAND_BUF_SIZE ];
1317 
1318  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g", \
1319  char_string , \
1320  fPrec2, fPrec, dval1, \
1321  fPrec2, fPrec, dval2, \
1322  fPrec2, fPrec, dval3, \
1323  fPrec2, fPrec, dval4, \
1324  fPrec2, fPrec, dval5, \
1325  fPrec2, fPrec, dval6 ) ;
1326  if( num_char < 0 ) {
1327  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1328  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6(), 1\n" ;
1329  }
1330  SendStr( command );
1331  delete [] command ;
1332 
1333 } // G4FRSCENEHANDLER::SendStrDouble6()
1334 
1335 
1336 //-----
1337 void
1338 G4FRSCENEHANDLER::SendStrDouble7( const char* char_string ,
1339  G4double dval1 ,
1340  G4double dval2 ,
1341  G4double dval3 ,
1342  G4double dval4 ,
1343  G4double dval5 ,
1344  G4double dval6 ,
1345  G4double dval7 )
1346 {
1347  //----- make command char_string and send
1348  G4int num_char ;
1349  char* command = new char [ COMMAND_BUF_SIZE ];
1350 
1351  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g", \
1352  char_string , \
1353  fPrec2, fPrec, dval1,\
1354  fPrec2, fPrec, dval2,\
1355  fPrec2, fPrec, dval3,\
1356  fPrec2, fPrec, dval4,\
1357  fPrec2, fPrec, dval5,\
1358  fPrec2, fPrec, dval6,\
1359  fPrec2, fPrec, dval7 ) ;
1360  if( num_char < 0 ) {
1361  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1362  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble7(), 1\n" ;
1363  }
1364  SendStr( command );
1365  delete [] command ;
1366 
1367 } // G4FRSCENEHANDLER::SendStrDouble7()
1368 
1369 
1370 //-----
1371 void
1372 G4FRSCENEHANDLER::SendStrDouble11( const char* char_string ,
1373  G4double dval1 ,
1374  G4double dval2 ,
1375  G4double dval3 ,
1376  G4double dval4 ,
1377  G4double dval5 ,
1378  G4double dval6 ,
1379  G4double dval7 ,
1380  G4double dval8 ,
1381  G4double dval9 ,
1382  G4double dval10 ,
1383  G4double dval11 )
1384 {
1385  //----- make command char_string and send
1386  G4int num_char ;
1387  char* command = new char [ COMMAND_BUF_SIZE ];
1388 
1389  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g", \
1390  char_string ,\
1391  fPrec2, fPrec, dval1, \
1392  fPrec2, fPrec, dval2, \
1393  fPrec2, fPrec, dval3, \
1394  fPrec2, fPrec, dval4, \
1395  fPrec2, fPrec, dval5, \
1396  fPrec2, fPrec, dval6, \
1397  fPrec2, fPrec, dval7, \
1398  fPrec2, fPrec, dval8, \
1399  fPrec2, fPrec, dval9, \
1400  fPrec2, fPrec, dval10,\
1401  fPrec2, fPrec, dval11 ) ;
1402  if( num_char < 0 ) {
1403  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1404  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble11(), 1\n" ;
1405  }
1406  SendStr( command );
1407  delete [] command ;
1408 
1409 } // G4FRSCENEHANDLER::SendStrDouble11()
1410 
1411 
1412 //-----
1413 void
1414 G4FRSCENEHANDLER::SendIntDouble3( G4int ival ,
1415  G4double dval1 ,
1416  G4double dval2 ,
1417  G4double dval3 )
1418 {
1419  //----- make command char_string and send
1420  G4int num_char ;
1421  char* command = new char [ COMMAND_BUF_SIZE ];
1422 
1423  num_char = sprintf( command, "%d %*.*g %*.*g %*.*g", \
1424  ival , \
1425  fPrec2, fPrec, dval1, \
1426  fPrec2, fPrec, dval2, \
1427  fPrec2, fPrec, dval3 ) ;
1428  if( num_char < 0 ) {
1429  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1430  G4cout << "ERROR G4FRSCENEHANDLER::SendIntDouble3(),1\n" ;
1431  }
1432  SendStr( command );
1433  delete [] command ;
1434 }
1435 
1436 //-----
1437 void
1438 G4FRSCENEHANDLER::SendInt3Str( G4int ival1 ,
1439  G4int ival2 ,
1440  G4int ival3 ,
1441  const char* char_string )
1442 {
1443  //----- make command char_string and send
1444  G4int num_char ;
1445  char* command = new char [ COMMAND_BUF_SIZE ];
1446 
1447  num_char = sprintf( command, "%d %d %d %s", \
1448  ival1, ival2, ival3, char_string ) ;
1449  if( num_char < 0 ) {
1450  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1451  G4cout << "ERROR G4FRSCENEHANDLER::SendInt3Str(),1\n" ;
1452  }
1453  SendStr( command );
1454  delete [] command ;
1455 }
1456 
1457 //-----
1458 void
1459 G4FRSCENEHANDLER::SendInt4Str( G4int ival1 ,
1460  G4int ival2 ,
1461  G4int ival3 ,
1462  G4int ival4 ,
1463  const char* char_string )
1464 {
1465  //----- make command char_string and send
1466  G4int num_char ;
1467  char* command = new char [ COMMAND_BUF_SIZE ];
1468 
1469  num_char = sprintf( command, "%d %d %d %d %s", \
1470  ival1, ival2, ival3, ival4, char_string ) ;
1471  if( num_char < 0 ) {
1472  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1473  G4cout << "ERROR G4FRSCENEHANDLER::SendInt4Str(),1\n" ;
1474  }
1475  SendStr( command );
1476  delete [] command ;
1477 }
1478 
1479 //-----
1480 void
1481 G4FRSCENEHANDLER::SendStrDouble3Str( const char* char_string1 ,
1482  G4double dval1 ,
1483  G4double dval2 ,
1484  G4double dval3 ,
1485  const char* char_string2 )
1486 {
1487  //----- make command char_string and send
1488  G4int num_char ;
1489  char* command = new char [ COMMAND_BUF_SIZE ];
1490 
1491  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %s", \
1492  char_string1,\
1493  fPrec2, fPrec, dval1 , \
1494  fPrec2, fPrec, dval2 , \
1495  fPrec2, fPrec, dval3 , \
1496  char_string2 );
1497  if( num_char < 0 ) {
1498  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1499  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6Str(), 1\n" ;
1500  }
1501  SendStr( command );
1502  delete [] command ;
1503 
1504 }
1505 
1506 
1507 //-----
1508 void
1509 G4FRSCENEHANDLER::SendStrDouble6Str( const char* char_string1 ,
1510  G4double dval1 ,
1511  G4double dval2 ,
1512  G4double dval3 ,
1513  G4double dval4 ,
1514  G4double dval5 ,
1515  G4double dval6 ,
1516  const char* char_string2 )
1517 {
1518  //----- make command char_string and send
1519  G4int num_char ;
1520  char* command = new char [ COMMAND_BUF_SIZE ];
1521 
1522  num_char = sprintf( command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %s", \
1523  char_string1,\
1524  fPrec2, fPrec, dval1 , \
1525  fPrec2, fPrec, dval2 , \
1526  fPrec2, fPrec, dval3 , \
1527  fPrec2, fPrec, dval4 , \
1528  fPrec2, fPrec, dval5 , \
1529  fPrec2, fPrec, dval6, \
1530  char_string2 );
1531  if( num_char < 0 ) {
1532  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1533  G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6Str(), 1\n" ;
1534  }
1535  SendStr( command );
1536  delete [] command ;
1537 
1538 }
1539 
1540 
1541 //-----
1542 void G4FRSCENEHANDLER::SendInt( G4int val )
1543 {
1544  //----- make command char_string and send
1545  G4int num_char ;
1546  char* command = new char [ COMMAND_BUF_SIZE ];
1547 
1548  num_char = sprintf( command, "%d", val ) ;
1549  if( num_char < 0 ) {
1550  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1551  G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n" ;
1552  }
1553  SendStr( command );
1554  delete [] command ;
1555 } // G4FRSCENEHANDLER::SendStrInt()
1556 
1557 
1558 //-----
1559 void G4FRSCENEHANDLER::SendDouble( G4double val )
1560 {
1561  //----- make command char_string and send
1562  G4int num_char ;
1563  char* command = new char [ COMMAND_BUF_SIZE ];
1564 
1565  num_char = sprintf( command, "%*.*g", fPrec2, fPrec, val ) ;
1566  if( num_char < 0 ) {
1567  if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
1568  G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n" ;
1569  }
1570  SendStr( command );
1571  delete [] command ;
1572 } // G4FRSCENEHANDLER::SendStrInt()
1573 
1574 //-----
1575 void G4FRSCENEHANDLER::ClearTransientStore()
1576 {
1577  // This is typically called after an update and before drawing hits
1578  // of the next event. To simulate the clearing of "transients"
1579  // (hits, etc.) the detector is redrawn...
1580  if (fpViewer) {
1581  fpViewer -> SetView ();
1582  fpViewer -> ClearView ();
1583  fpViewer -> DrawView ();
1584  }
1585 }
1586