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