2// ********************************************************************
3// * License and Disclaimer *
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. *
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. *
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// ********************************************************************
29#include <CLHEP/Units/PhysicalConstants.h>
31#include "G4VisManager.hh"
32#include "G4PhysicalVolumeModel.hh"
33#include "G4LogicalVolume.hh"
35//========== AddPrimitive() functions ==========//
38void G4FRSCENEHANDLER::AddPrimitive(const G4Polyline& polyline)
40#if defined DEBUG_FR_SCENE
41 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
42 G4cout << "***** AddPrimitive\n";
46 static G4bool warned = false;
50 G4Exception("G4FRSCENEHANDLER::AddPrimitive (const G4Polyline&)",
51 "dawn0001", JustWarning,
52 "2D polylines not implemented. Ignored.");
56 //----- Initialize Fukui Renderer IF NECESSARY
59 //----- local working variables
60 G4int nPoints = polyline.size();
62 const G4VisAttributes* pVA =
63 fpViewer->GetApplicableVisAttributes(polyline.GetVisAttributes());
65 //----- skip drawing invisible primitive
68 if(!(pVA->IsVisible()))
75 if(!SendVisAttributes(pVA))
77 SendStr(FR_COLOR_RGB_RED); // color
80 //----- send coordinates to Fukui Renderer
81 SendTransformedCoordinates();
83 //----- send beginning of polyline
86 //----- vertices on polyline
87 for(i = 0; i < nPoints; i++)
89 SendStrDouble3(FR_PL_VERTEX, polyline[i].x(), polyline[i].y(),
93 //----- send ending of polyline
94 SendStr(FR_END_POLYLINE);
96} // G4FRSCENEHANDLER::AddPrimitive (polyline)
99void G4FRSCENEHANDLER::AddPrimitive(const G4Text& text)
102#if defined DEBUG_FR_SCENE
103 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
104 G4cout << "***** AddPrimitive( G4Text )\n";
106 //----- Initialize DAWN IF NECESSARY
110 const G4Color& color = GetTextColor(text);
111 SendStrDouble3(FR_COLOR_RGB, color.GetRed(), color.GetGreen(),
114 //----- send body coordinates
115 SendTransformedCoordinates();
118 MarkerSizeType size_type;
119 G4double fontsize = GetMarkerDiameter(text, size_type);
121 //----- Calc position
122 const G4Point3D& position = text.GetPosition();
125 G4double x_offset = text.GetXOffset();
126 G4double y_offset = text.GetYOffset();
128 //----- get string to be visualized and Calc its length
129 const char* vis_text = text.GetText();
130 const int STR_LENGTH = strlen(vis_text);
132 //----- create buffer and copy the string there
133 int MAX_STR_LENGTH = COMMAND_BUF_SIZE - 100;
134 if(MAX_STR_LENGTH <= 0)
136 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
138 G4cout << "ERROR (FukuiRenderer) : Not enough buffer size for data "
141 G4cout << " G4Text Visualization is aborted"
146 char* buf = new char[(MAX_STR_LENGTH + 1)];
147 if(MAX_STR_LENGTH >= STR_LENGTH)
149 strcpy(buf, vis_text);
153 strncpy(buf, vis_text, MAX_STR_LENGTH);
156 //----- select string command for 3D drawing
157 char text_command[32];
161 strcpy(text_command, FR_MARK_TEXT_2D);
165 strcpy(text_command, FR_MARK_TEXT_2DS);
169 //----- Send string command
172 // Map -1<x<1, -1<y<1 to 10<x<200, 53<y<243
173 G4double x_mm = 95. * position.x() + 105.;
174 G4double y_mm = 95. * position.y() + 148.;
175 SendStrDouble3Str(FR_TEXT_2DS, x_mm, y_mm, fontsize, buf);
179 SendStrDouble6Str(text_command, position.x(), position.y(), position.z(),
180 fontsize, x_offset, y_offset, buf);
183 //----- delete buffer
186} // G4FRSCENEHANDLER::AddPrimitive ( text )
189void G4FRSCENEHANDLER::AddPrimitive(const G4Circle& mark_circle)
192#if defined DEBUG_FR_SCENE
193 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
194 G4cout << "***** AddPrimitive( G4Circle )\n";
198 static G4bool warned = false;
202 G4Exception("G4FRSCENEHANDLER::AddPrimitive (const G4Circle&)",
203 "dawn0002", JustWarning,
204 "2D circles not implemented. Ignored.");
208 //----- Initialize Fukui Renderer IF NECESSARY
212 fpVisAttribs = mark_circle.GetVisAttributes();
213 const G4Color& color = GetColor();
214 SendStrDouble3(FR_COLOR_RGB, color.GetRed(), color.GetGreen(),
217 //----- send body coordinates
218 SendTransformedCoordinates();
220 //----- Calc position
221 const G4Point3D& position = mark_circle.GetPosition();
224 MarkerSizeType size_type;
225 G4double size = GetMarkerRadius(mark_circle, size_type);
231 SendStrDouble4(FR_MARK_CIRCLE_2D, position.x(), position.y(),
236 SendStrDouble4(FR_MARK_CIRCLE_2DS, position.x(), position.y(),
241} // G4FRSCENEHANDLER::AddPrimitive ( mark_circle )
244void G4FRSCENEHANDLER::AddPrimitive(const G4Square& mark_square)
247#if defined DEBUG_FR_SCENE
248 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
249 G4cout << "***** AddPrimitive( G4Square )\n";
253 static G4bool warned = false;
257 G4Exception("G4FRSCENEHANDLER::AddPrimitive (const G4Square&)",
258 "dawn0003", JustWarning,
259 "2D squares not implemented. Ignored.");
263 //----- Initialize Fukui Renderer IF NECESSARY
267 fpVisAttribs = mark_square.GetVisAttributes();
268 const G4Color& color = GetColor();
269 SendStrDouble3(FR_COLOR_RGB, color.GetRed(), color.GetGreen(),
272 //----- send body coordinates
273 SendTransformedCoordinates();
275 //----- Calc position
276 const G4Point3D& position = mark_square.GetPosition();
279 MarkerSizeType size_type;
280 G4double size = GetMarkerRadius(mark_square, size_type);
286 SendStrDouble4(FR_MARK_SQUARE_2D, position.x(), position.y(),
291 SendStrDouble4(FR_MARK_SQUARE_2DS, position.x(), position.y(),
296} // G4FRSCENEHANDLER::AddPrimitive ( mark_square )
298//----- Add polyhedron
299void G4FRSCENEHANDLER::AddPrimitive(const G4Polyhedron& polyhedron)
302#if defined DEBUG_FR_SCENE
303 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
304 G4cout << "***** AddPrimitive( G4Polyhedron )\n";
308 static G4bool warned = false;
312 G4Exception("G4FRSCENEHANDLER::AddPrimitive (const G4Polyhedron&)",
313 "dawn0004", JustWarning,
314 "2D polyhedrons not implemented. Ignored.");
319 if(polyhedron.GetNoFacets() == 0)
322 //----- Initialize Fukui Renderer IF NECESSARY
326 if(!SendVisAttributes(
327 fpViewer->GetApplicableVisAttributes(polyhedron.GetVisAttributes())))
329 SendStr(FR_COLOR_RGB_RED); // color
333 SendTransformedCoordinates();
337 //---------- (1) Declare beginning of Brep data
338 SendStr(FR_POLYHEDRON);
340 //---------- (2) Vertex block
341 for(G4int i = 1, j = polyhedron.GetNoVertices(); j; j--, i++)
343 G4Point3D point = polyhedron.GetVertex(i);
344 SendStrDouble3(FR_VERTEX, point.x(), point.y(), point.z());
347 //---------- (3) Facet block
348 for(G4int f = polyhedron.GetNoFacets(); f; f--)
351 G4int index = -1; // initialization
353 // G4int preedgeFlag = 1; Not used - comment out to prevent warnings (JA).
354 G4int work[4], i = 0;
357 // preedgeFlag = edgeFlag; Not used - comment out to prevent warnings
359 notLastEdge = polyhedron.GetNextVertexIndex(index, edgeFlag);
361 } while(notLastEdge);
365 SendStrInt3(FR_FACET, work[0], work[1], work[2]);
368 SendStrInt4(FR_FACET, work[0], work[1], work[2], work[3]);
371 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
372 G4cout << "ERROR G4FRSCENEHANDLER::AddPrimitive(G4Polyhedron)\n";
373 G4PhysicalVolumeModel* pPVModel =
374 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
376 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
378 G4cout << "Volume " << pPVModel->GetCurrentPV()->GetName()
380 << pPVModel->GetCurrentLV()->GetSolid()->GetName() << " ("
381 << pPVModel->GetCurrentLV()->GetSolid()->GetEntityType();
382 G4cout << "\nG4Polyhedron facet with " << i << " edges" << G4endl;
387 //---------- (4) Declare ending of Brep data
388 SendStr(FR_END_POLYHEDRON);
390} // G4FRSCENEHANDLER::AddPrimitive (polyhedron)
393void G4FRSCENEHANDLER::SendNdiv(void)
395 //////////////////////////////////////////////////
396 //#if defined DEBUG_FR_SCENE
397 // G4cout << "***** SendNdiv() (/Ndiv)" << G4endl;
399 //////////////////////////////////////////////////
402 G4int num_division = FR_DEFALUT_NDIV_VALUE;
404 //----- number used for dividing a curved surface, Ndiv
405 // if ( GetModel() ) { ?? Why test for model. Can be zero. JA ??
406 const G4VisAttributes* pVisAttribs =
407 fpViewer->GetApplicableVisAttributes(fpVisAttribs);
408 num_division = GetNoOfSides(pVisAttribs);
410#if defined DEBUG_FR_SCENE
411 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
413 G4cout << "WARNING: GetNoOfSides() failed. ";
414 G4cout << "The default value " << num_division;
415 G4cout << " is assigned." << G4endl;
420 //---------- Error recovery for too small Ndiv
421 num_division = (num_division < 3 ? 3 : num_division);
423 //////////////////////////////////////////////////
424 //#if defined DEBUG_FR_SCENE
425 // G4cout << "Ndiv = " << num_division << G4endl;
427 //////////////////////////////////////////////////
429 //----- Send resultant Ndiv
430 this->SendStrInt(FR_NDIV, num_division);
434void G4FRSCENEHANDLER::FREndModeling()
437#if defined DEBUG_FR_SCENE
438 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
439 G4cout << "***** FREndModeling (called)" << G4endl;
443#if defined DEBUG_FR_SCENE
444 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
446 G4cout << "***** FREndModeling (started) ";
447 G4cout << "(/EndModeling, /DrawAll, /CloseDevice)" << G4endl;
451 SendStr("#--------------------");
454 SendStr(FR_END_MODELING);
457 SendStr(FR_DRAW_ALL);
460 SendStr(FR_CLOSE_DEVICE);
462 //----- End saving data to g4.prim
466 FRflag_in_modeling = false;
471void G4FRSCENEHANDLER::BeginPrimitives(
472 const G4Transform3D& objectTransformation)
474#if defined DEBUG_FR_SCENE
475 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
476 G4cout << "***** BeginPrimitives \n";
481 G4VSceneHandler::BeginPrimitives(objectTransformation);
485void G4FRSCENEHANDLER::EndPrimitives()
487#if defined DEBUG_FR_SCENE
488 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
489 G4cout << "***** EndPrimitives \n";
491 G4VSceneHandler::EndPrimitives();
494//========== AddSolid() functions ==========//
497void G4FRSCENEHANDLER::AddSolid(const G4Box& box)
499#if defined DEBUG_FR_SCENE
500 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
501 G4cout << "***** AddSolid ( box )\n";
504 //----- skip drawing invisible primitive
510 //----- Initialize Fukui Renderer IF NECESSARY
520 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
522 SendStr(FR_COLOR_RGB_GREEN); // color
525 //----- parameters (half lengths of box)
526 G4double dx = box.GetXHalfLength();
527 G4double dy = box.GetYHalfLength();
528 G4double dz = box.GetZHalfLength();
530 //----- send coordinates to Fukui Renderer
531 SendTransformedCoordinates();
533 //----- send box to Fukui Renderer
534 SendStrDouble3(FR_BOX, dx, dy, dz);
536} // void G4FRSCENEHANDLER::AddSolid( const G4Box& box )
539void G4FRSCENEHANDLER::AddSolid(const G4Tubs& tubes)
541#if defined DEBUG_FR_SCENE
542 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
543 G4cout << "***** AddSolid ( tubes )\n";
545 //----- skip drawing invisible primitive
551 //----- Initialize Fukui Renderer IF NECESSARY
561 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
563 SendStr(FR_COLOR_RGB_BLUE); // color
567 const G4double R = tubes.GetOuterRadius(); // outside radius
568 const G4double r = tubes.GetInnerRadius(); // inside radius
569 const G4double dz = tubes.GetZHalfLength(); // half length in z
570 const G4double sphi = tubes.GetStartPhiAngle(); // starting angle
571 const G4double dphi = tubes.GetDeltaPhiAngle(); // angle width
573 //----- send coordinates to Fukui Renderer
574 SendTransformedCoordinates();
576 //----- send tubes to Fukui Renderer
577 SendStrDouble5(FR_TUBS, r, R, dz, sphi, dphi);
579} // void G4FRSCENEHANDLER::AddSolid( const G4Tubs& )
582void G4FRSCENEHANDLER::AddSolid(const G4Cons& cons)
584#if defined DEBUG_FR_SCENE
585 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
586 G4cout << "***** AddSolid ( cons )\n";
588 //----- skip drawing invisible primitive
594 //----- Initialize Fukui Renderer IF NECESSARY
604 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
606 SendStr(FR_COLOR_RGB_CYAN); // color
610 const G4double r1 = cons.GetInnerRadiusMinusZ(); // inside radius at -dz
611 const G4double R1 = cons.GetOuterRadiusMinusZ(); // outside radius at -dz
612 const G4double r2 = cons.GetInnerRadiusPlusZ(); // inside radius at +dz
613 const G4double R2 = cons.GetOuterRadiusPlusZ(); // outside radius at +dz
614 const G4double dz = cons.GetZHalfLength(); // half length in z
615 const G4double sphi = cons.GetStartPhiAngle(); // starting angle
616 const G4double dphi = cons.GetDeltaPhiAngle(); // angle width
618 //----- send coordinates to Fukui Renderer
619 SendTransformedCoordinates();
621 //----- send cons to Fukui Renderer
622 SendStrDouble7(FR_CONS, r1, R1, r2, R2, dz, sphi, dphi);
624} // G4FRSCENEHANDLER::AddSolid( cons )
627void G4FRSCENEHANDLER::AddSolid(const G4Trd& trd)
629#if defined DEBUG_FR_SCENE
630 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
631 G4cout << "***** AddSolid ( trd )\n";
634 //----- skip drawing invisible primitive
640 //----- Initialize Fukui Renderer IF NECESSARY
650 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
652 SendStr(FR_COLOR_RGB_MAGENTA); // color
656 G4double dx1 = trd.GetXHalfLength1();
657 G4double dx2 = trd.GetXHalfLength2();
658 G4double dy1 = trd.GetYHalfLength1();
659 G4double dy2 = trd.GetYHalfLength2();
660 G4double dz = trd.GetZHalfLength();
662 //----- send coordinates to Fukui Renderer
663 SendTransformedCoordinates();
665 //----- send trd to Fukui Renderer
666 SendStrDouble5(FR_TRD, dx1, dx2, dy1, dy2, dz);
668} // G4FRSCENEHANDLER::AddSolid ( trd )
671void G4FRSCENEHANDLER::AddSolid(const G4Sphere& sphere)
673#if defined DEBUG_FR_SCENE
674 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
675 G4cout << "***** AddSolid ( sphere )\n";
677 //----- skip drawing invisible primitive
683 //----- Initialize Fukui Renderer IF NECESSARY
693 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
695 SendStr(FR_COLOR_RGB_YELLOW); // color
699 // const G4double rmin = sphere.GetInnerRadius();
700 const G4double rmax = sphere.GetOuterRadius();
701 // const G4double sphi = sphere.GetStartPhiAngle();
702 const G4double dphi = sphere.GetDeltaPhiAngle();
703 // const G4double stheta = sphere.GetStartThetaAngle();
704 const G4double dtheta = sphere.GetDeltaThetaAngle();
706 //----- send coordinates to Fukui Renderer
707 SendTransformedCoordinates();
709 //----- send sphere to Fukui Renderer
710 const G4double PI_minus = 0.9999 * CLHEP::pi;
711 const G4double PI2_minus = 1.9999 * CLHEP::pi;
712 if(dphi > PI2_minus && dtheta > PI_minus)
715 SendStrDouble(FR_SPHERE, rmax);
719 //----- call AddPrimitives( G4Polyhedron )
720 //...... For sphere "segment",
721 //...... G4Polyhedron is used for visualization.
722 //...... Visualization attributes and
723 //...... local coordinates are resent and overwritten.
724 G4VSceneHandler::AddSolid(sphere);
726 ////////////////////////////////////////////////////////////////
727 // //----- sphere segment
728 // SendStrDouble6( FR_SPHERE_SEG, rmin, rmax, stheta, dtheta, sphi, dphi
730 ////////////////////////////////////////////////////////////////
733} // G4FRSCENEHANDLER::AddSolid ( sphere )
736void G4FRSCENEHANDLER::AddSolid(const G4Para& para)
738#if defined DEBUG_FR_SCENE
739 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
740 G4cout << "***** AddSolid ( para )\n";
743 //----- skip drawing invisible primitive
749 //----- Initialize Fukui Renderer IF NECESSARY
759 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
761 SendStr(FR_COLOR_RGB_RED); // color
765 const G4double epsilon = 1.0e-5;
767 //----- parameters preprocessing
768 G4double cosTheta = para.GetSymAxis().z();
769 if(cosTheta < epsilon)
771 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
773 G4cout << "WARNING from FukuiRenderer (DAWN) driver:" << G4endl;
774 G4cout << " Invalid parameter for parallelepiped." << G4endl;
775 G4cout << " Drawing is skipped." << G4endl;
779 G4double tanTheta_cosPhi_cosTheta = para.GetSymAxis().x();
780 G4double tanTheta_sinPhi_cosTheta = para.GetSymAxis().y();
783 G4double dx = para.GetXHalfLength();
784 G4double dy = para.GetYHalfLength();
785 G4double dz = para.GetZHalfLength();
786 G4double tanAlpha = para.GetTanAlpha();
787 G4double tanTheta_cosPhi = tanTheta_cosPhi_cosTheta / cosTheta;
788 G4double tanTheta_sinPhi = tanTheta_sinPhi_cosTheta / cosTheta;
790 //----- send coordinates to Fukui Renderer
791 SendTransformedCoordinates();
793 //----- send data to Fukui Renderer
794 SendStrDouble6(FR_PARA, dx, dy, dz, tanAlpha, tanTheta_cosPhi,
797} // G4FRSCENEHANDLER::AddSolid ( para )
800void G4FRSCENEHANDLER::AddSolid(const G4Trap& trap)
802#if defined DEBUG_FR_SCENE
803 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
804 G4cout << "***** AddSolid ( trap )\n";
807 //----- skip drawing invisible primitive
813 //----- Initialize Fukui Renderer IF NECESSARY
823 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
825 SendStr(FR_COLOR_RGB_GREEN); // color
829 const G4double epsilon = 1.0e-5;
831 //----- parameters preprocessing
832 G4double cosTheta = trap.GetSymAxis().z();
833 if(cosTheta < epsilon)
835 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
837 G4cout << "WARNING from FukuiRenderer (DAWN) driver:" << G4endl;
838 G4cout << " Invalid parameter for trap, 1" << G4endl;
839 G4cout << " Drawing is skipped." << G4endl;
844 G4double nx = trap.GetSymAxis().x();
845 G4double ny = trap.GetSymAxis().y();
847 //----- parameters (half lengths of box)
848 G4double dz = trap.GetZHalfLength();
849 G4double theta = std::acos(cosTheta);
851 if(ny == 0. && nx == 0.)
853 phi = 0.; // std::atan2(0.,0.) gives undefined value of phi
857 phi = std::atan2(ny, nx);
862 // -PI < std::atan() < PI
864 /////////////////////////////////////////////////
865 // G4double phi = std::atan2( ny, nx ) ;
866 // if( phi < 0.0 ) { phi += CLHEP::twopi ; }
867 // // -PI < std::atan() < PI
868 /////////////////////////////////////////////////
870 G4double h1 = trap.GetYHalfLength1();
871 G4double bl1 = trap.GetXHalfLength1();
872 G4double tl1 = trap.GetXHalfLength2();
873 G4double alpha1 = std::atan(trap.GetTanAlpha1());
874 G4double h2 = trap.GetYHalfLength2();
875 G4double bl2 = trap.GetXHalfLength3();
876 G4double tl2 = trap.GetXHalfLength4();
877 G4double alpha2 = std::atan(trap.GetTanAlpha2());
879 //----- send coordinates to Fukui Renderer
880 SendTransformedCoordinates();
882 //----- Change sign of alpha for compatibility
883 // with the DAWN format
884 G4double alpha_sign = -1.0;
885 alpha1 *= alpha_sign;
886 alpha2 *= alpha_sign;
888 //----- send box to Fukui Renderer
889 SendStrDouble11(FR_TRAP, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
892} // G4FRSCENEHANDLER::AddSolid (const G4Trap& trap)
895void G4FRSCENEHANDLER::AddSolid(const G4Torus& torus)
897#if defined DEBUG_FR_SCENE
898 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
899 G4cout << "***** AddSolid ( torus )\n";
901 //----- skip drawing invisible primitive
907 //----- Initialize Fukui Renderer IF NECESSARY
917 if(!SendVisAttributes(fpViewer->GetApplicableVisAttributes(fpVisAttribs)))
919 SendStr(FR_COLOR_RGB_BLUE); // color
923 const G4double r = torus.GetRmin();
924 const G4double R = torus.GetRmax();
925 const G4double t = torus.GetRtor();
926 const G4double sphi = torus.GetSPhi();
927 const G4double dphi = torus.GetDPhi();
929 //----- send coordinates to Fukui Renderer
930 SendTransformedCoordinates();
932 //----- send torus to Fukui Renderer
933 SendStrDouble5(FR_TORUS, r, R, t, sphi, dphi);
935} // void G4FRSCENEHANDLER::AddSolid( const G4Torus& )
937//----- Add a shape which is not treated above
938void G4FRSCENEHANDLER::AddSolid(const G4VSolid& solid)
940 //----- skip drawing invisible primitive
946 //----- Initialize Fukui Renderer IF NECESSARY
955 //----- Send a primitive
956 G4VSceneHandler::AddSolid(solid);
958} // G4FRSCENEHANDLER::AddSolid ( const G4VSolid& )
961G4bool G4FRSCENEHANDLER::SendVisAttributes(const G4VisAttributes* pAV)
963 // Have a look at G4VSceneHandler::GetDrawingStyle (const G4Visible&). (John)
965 G4bool status = true; // initialization
966 const G4double ALPHA_MIN = 0.001; // min of alpha factor of color
970 // No attribute is given.
971 // Do nothing. Status is "fail".
976 // Send attributes. Status is "success".
978 const G4Color& color = pAV->GetColor();
979 SendStrDouble3(FR_COLOR_RGB, color.GetRed(), color.GetGreen(),
981 if(color.GetAlpha() < ALPHA_MIN)
983 SendStr(FR_FORCE_WIREFRAME_ON);
985 else if(pAV->IsForceDrawingStyle() &&
986 (pAV->GetForcedDrawingStyle() == G4VisAttributes::wireframe))
988 SendStr(FR_FORCE_WIREFRAME_ON);
992 SendStr(FR_FORCE_WIREFRAME_OFF);
998} // G4FRSCENEHANDLER::SendVisAttributes ()
1001G4bool G4FRSCENEHANDLER::IsVisible()
1004 G4bool visibility = true;
1007 const G4VisAttributes* pVisAttribs =
1008 fpViewer->GetApplicableVisAttributes(fpVisAttribs);
1011 if((std::getenv(FR_ENV_CULL_INVISIBLE_OBJECTS) != NULL) &&
1012 (strcmp(std::getenv(FR_ENV_CULL_INVISIBLE_OBJECTS), "0")) && (pVisAttribs))
1014 visibility = pVisAttribs->IsVisible();
1020} // G4FRSCENEHANDLER::IsVisible()
1023void G4FRSCENEHANDLER::SendBoundingBox(void)
1025#if defined DEBUG_FR_SCENE
1026 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1027 G4cout << "***** SendBoundingBox () (/BoundingBox)" << G4endl;
1030 //----- (1A) CALC bounding box of the bounding sphere
1031 const G4VisExtent& extent = GetScene()->GetExtent();
1032 const G4Point3D& center = extent.GetExtentCenter();
1033 const G4double radius = extent.GetExtentRadius();
1035 G4double xmin = center.x() - radius;
1036 G4double ymin = center.y() - radius;
1037 G4double zmin = center.z() - radius;
1039 G4double xmax = center.x() + radius;
1040 G4double ymax = center.y() + radius;
1041 G4double zmax = center.z() + radius;
1043 ////////////////////////////////////////////
1044 // G4double xmin = extent.GetXmin ();
1045 // G4double ymin = extent.GetYmin ();
1046 // G4double zmin = extent.GetZmin ();
1047 // G4double xmax = extent.GetXmax ();
1048 // G4double ymax = extent.GetYmax ();
1049 // G4double zmax = extent.GetZmax ();
1050 ////////////////////////////////////////////
1052 //----- (1B) SEND bounding box
1053 SendStrDouble6(FR_BOUNDING_BOX, xmin, ymin, zmin, xmax, ymax, zmax);
1055} // G4FRSCENEHANDLER::SendBoundingBox()
1058void G4FRSCENEHANDLER::SendTransformedCoordinates()
1061 G4Point3D zero(0.0, 0.0, 0.0);
1062 G4Point3D x1(1.0, 0.0, 0.0);
1063 G4Point3D y1(0.0, 1.0, 0.0);
1064 G4Vector3D x_unit_vec(1.0, 0.0, 0.0);
1065 G4Vector3D y_unit_vec(0.0, 1.0, 0.0);
1067 //----- transformed origin
1068 zero.transform(fObjectTransformation);
1070 //----- transformed base vectors
1071 x1.transform(fObjectTransformation);
1072 x_unit_vec = x1 - zero;
1073 y1.transform(fObjectTransformation);
1074 y_unit_vec = y1 - zero;
1076 //----- send transformed origin
1077 SendStrDouble3(FR_ORIGIN, (zero.x()), (zero.y()), (zero.z()));
1079 //----- send transformed base vectors
1080 SendStrDouble6(FR_BASE_VECTOR, (x_unit_vec.x()), (x_unit_vec.y()),
1081 (x_unit_vec.z()), (y_unit_vec.x()), (y_unit_vec.y()),
1084} // G4FRSCENEHANDLER::SendTransformedCoordinates()
1087void G4FRSCENEHANDLER::SendPhysVolName(void)
1093 const G4VModel* pv_model = GetModel();
1099 G4PhysicalVolumeModel* pPVModel =
1100 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1106 // Current Physical volume name
1107 G4String pv_name = pPVModel->GetCurrentTag();
1109 // Current depth of volume
1110 G4int cur_depth = pPVModel->GetCurrentDepth();
1112 // Make a string to be sent
1113 // e.g. experimental_Hall.1, where "1" is the copy number
1114 G4String name_comment(FR_PHYSICAL_VOLUME_NAME);
1115 name_comment += " ";
1117 for(i = 0; i < cur_depth; i++)
1120 name_comment += " ";
1122 name_comment += pv_name;
1124 // Send physical volume name
1125 SendStr("#--------------------");
1126 SendStr(name_comment);
1128} // G4FRSCENEHANDLER::SendPhysVolName ()
1131void G4FRSCENEHANDLER::SendStr(const char* char_string)
1133 fPrimDest.SendLine(char_string);
1137void G4FRSCENEHANDLER::SendStrInt(const char* char_string, G4int ival)
1139 //----- make command char_string and send
1141 char* command = new char[COMMAND_BUF_SIZE];
1143 num_char = sprintf(command, "%s %d", char_string, ival);
1146 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1147 G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n";
1151} // G4FRSCENEHANDLER::SendStrInt()
1154void G4FRSCENEHANDLER::SendStrInt3(const char* char_string, G4int ival1,
1155 G4int ival2, G4int ival3)
1157 //----- make command char_string and send
1159 char* command = new char[COMMAND_BUF_SIZE];
1162 sprintf(command, "%s %d %d %d", char_string, ival1, ival2, ival3);
1166 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1167 G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt3(), 1\n";
1172} // G4FRSCENEHANDLER::SendStrInt3()
1175void G4FRSCENEHANDLER::SendStrInt4(const char* char_string, G4int ival1,
1176 G4int ival2, G4int ival3, G4int ival4)
1178 //----- make command char_string and send
1180 char* command = new char[COMMAND_BUF_SIZE];
1182 num_char = sprintf(command, "%s %d %d %d %d", char_string, ival1, ival2,
1187 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1188 G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt4(), 1\n";
1193} // G4FRSCENEHANDLER::SendStrInt4()
1196void G4FRSCENEHANDLER::SendStrDouble(const char* char_string, G4double dval)
1198 //----- make command char_string and send
1200 char* command = new char[COMMAND_BUF_SIZE];
1202 num_char = sprintf(command, "%s %*.*g", char_string, fPrec2, fPrec, dval);
1205 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1206 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble(), 1\n";
1211} // G4FRSCENEHANDLER::SendStrDouble()
1214void G4FRSCENEHANDLER::SendStrDouble2(const char* char_string, G4double dval1,
1217 //----- make command char_string and send
1219 char* command = new char[COMMAND_BUF_SIZE];
1221 num_char = sprintf(command, "%s %*.*g %*.*g", char_string, fPrec2, fPrec,
1222 dval1, fPrec2, fPrec, dval2);
1225 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1226 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble2(), 1\n";
1231} // G4FRSCENEHANDLER::SendStrDouble2()
1234void G4FRSCENEHANDLER::SendStrDouble3(const char* char_string, G4double dval1,
1235 G4double dval2, G4double dval3)
1237 //----- make command char_string and send
1239 char* command = new char[COMMAND_BUF_SIZE];
1241 num_char = sprintf(command, "%s %*.*g %*.*g %*.*g", char_string, fPrec2,
1242 fPrec, dval1, fPrec2, fPrec, dval2, fPrec2, fPrec, dval3);
1245 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1246 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble3(), 1\n";
1251} // G4FRSCENEHANDLER::SendStrDouble3()
1254void G4FRSCENEHANDLER::SendStrDouble4(const char* char_string, G4double dval1,
1255 G4double dval2, G4double dval3,
1258 //----- make command char_string and send
1260 char* command = new char[COMMAND_BUF_SIZE];
1262 num_char = sprintf(command, "%s %*.*g %*.*g %*.*g %*.*g", char_string,
1263 fPrec2, fPrec, dval1, fPrec2, fPrec, dval2, fPrec2, fPrec,
1264 dval3, fPrec2, fPrec, dval4);
1267 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1268 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble4(), 1\n";
1273} // G4FRSCENEHANDLER::SendStrDouble4()
1276void G4FRSCENEHANDLER::SendStrDouble5(const char* char_string, G4double dval1,
1277 G4double dval2, G4double dval3,
1278 G4double dval4, G4double dval5)
1280 //----- make command char_string and send
1282 char* command = new char[COMMAND_BUF_SIZE];
1285 sprintf(command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g", char_string,
1286 fPrec2, fPrec, dval1, fPrec2, fPrec, dval2, fPrec2, fPrec, dval3,
1287 fPrec2, fPrec, dval4, fPrec2, fPrec, dval5);
1290 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1291 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble5(), 1\n";
1296} // G4FRSCENEHANDLER::SendStrDouble5()
1299void G4FRSCENEHANDLER::SendStrDouble6(const char* char_string, G4double dval1,
1300 G4double dval2, G4double dval3,
1301 G4double dval4, G4double dval5,
1304 //----- make command char_string and send
1306 char* command = new char[COMMAND_BUF_SIZE];
1308 num_char = sprintf(command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g",
1309 char_string, fPrec2, fPrec, dval1, fPrec2, fPrec, dval2,
1310 fPrec2, fPrec, dval3, fPrec2, fPrec, dval4, fPrec2, fPrec,
1311 dval5, fPrec2, fPrec, dval6);
1314 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1315 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6(), 1\n";
1320} // G4FRSCENEHANDLER::SendStrDouble6()
1323void G4FRSCENEHANDLER::SendStrDouble7(const char* char_string, G4double dval1,
1324 G4double dval2, G4double dval3,
1325 G4double dval4, G4double dval5,
1326 G4double dval6, G4double dval7)
1328 //----- make command char_string and send
1330 char* command = new char[COMMAND_BUF_SIZE];
1332 num_char = sprintf(command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g",
1333 char_string, fPrec2, fPrec, dval1, fPrec2, fPrec, dval2,
1334 fPrec2, fPrec, dval3, fPrec2, fPrec, dval4, fPrec2, fPrec,
1335 dval5, fPrec2, fPrec, dval6, fPrec2, fPrec, dval7);
1338 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1339 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble7(), 1\n";
1344} // G4FRSCENEHANDLER::SendStrDouble7()
1347void G4FRSCENEHANDLER::SendStrDouble11(const char* char_string, G4double dval1,
1348 G4double dval2, G4double dval3,
1349 G4double dval4, G4double dval5,
1350 G4double dval6, G4double dval7,
1351 G4double dval8, G4double dval9,
1352 G4double dval10, G4double dval11)
1354 //----- make command char_string and send
1356 char* command = new char[COMMAND_BUF_SIZE];
1360 "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g",
1361 char_string, fPrec2, fPrec, dval1, fPrec2, fPrec, dval2, fPrec2, fPrec,
1362 dval3, fPrec2, fPrec, dval4, fPrec2, fPrec, dval5, fPrec2, fPrec, dval6,
1363 fPrec2, fPrec, dval7, fPrec2, fPrec, dval8, fPrec2, fPrec, dval9, fPrec2,
1364 fPrec, dval10, fPrec2, fPrec, dval11);
1367 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1368 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble11(), 1\n";
1373} // G4FRSCENEHANDLER::SendStrDouble11()
1376void G4FRSCENEHANDLER::SendIntDouble3(G4int ival, G4double dval1,
1377 G4double dval2, G4double dval3)
1379 //----- make command char_string and send
1381 char* command = new char[COMMAND_BUF_SIZE];
1383 num_char = sprintf(command, "%d %*.*g %*.*g %*.*g", ival, fPrec2, fPrec,
1384 dval1, fPrec2, fPrec, dval2, fPrec2, fPrec, dval3);
1387 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1388 G4cout << "ERROR G4FRSCENEHANDLER::SendIntDouble3(),1\n";
1395void G4FRSCENEHANDLER::SendInt3Str(G4int ival1, G4int ival2, G4int ival3,
1396 const char* char_string)
1398 //----- make command char_string and send
1400 char* command = new char[COMMAND_BUF_SIZE];
1402 num_char = sprintf(command, "%d %d %d %s", ival1, ival2, ival3, char_string);
1405 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1406 G4cout << "ERROR G4FRSCENEHANDLER::SendInt3Str(),1\n";
1413void G4FRSCENEHANDLER::SendInt4Str(G4int ival1, G4int ival2, G4int ival3,
1414 G4int ival4, const char* char_string)
1416 //----- make command char_string and send
1418 char* command = new char[COMMAND_BUF_SIZE];
1421 sprintf(command, "%d %d %d %d %s", ival1, ival2, ival3, ival4, char_string);
1424 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1425 G4cout << "ERROR G4FRSCENEHANDLER::SendInt4Str(),1\n";
1432void G4FRSCENEHANDLER::SendStrDouble3Str(const char* char_string1,
1433 G4double dval1, G4double dval2,
1435 const char* char_string2)
1437 //----- make command char_string and send
1439 char* command = new char[COMMAND_BUF_SIZE];
1442 sprintf(command, "%s %*.*g %*.*g %*.*g %s", char_string1, fPrec2, fPrec,
1443 dval1, fPrec2, fPrec, dval2, fPrec2, fPrec, dval3, char_string2);
1446 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1447 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6Str(), 1\n";
1454void G4FRSCENEHANDLER::SendStrDouble6Str(const char* char_string1,
1455 G4double dval1, G4double dval2,
1456 G4double dval3, G4double dval4,
1457 G4double dval5, G4double dval6,
1458 const char* char_string2)
1460 //----- make command char_string and send
1462 char* command = new char[COMMAND_BUF_SIZE];
1464 num_char = sprintf(command, "%s %*.*g %*.*g %*.*g %*.*g %*.*g %*.*g %s",
1465 char_string1, fPrec2, fPrec, dval1, fPrec2, fPrec, dval2,
1466 fPrec2, fPrec, dval3, fPrec2, fPrec, dval4, fPrec2, fPrec,
1467 dval5, fPrec2, fPrec, dval6, char_string2);
1470 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1471 G4cout << "ERROR G4FRSCENEHANDLER::SendStrDouble6Str(), 1\n";
1478void G4FRSCENEHANDLER::SendInt(G4int val)
1480 //----- make command char_string and send
1482 char* command = new char[COMMAND_BUF_SIZE];
1484 num_char = sprintf(command, "%d", val);
1487 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1488 G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n";
1492} // G4FRSCENEHANDLER::SendStrInt()
1495void G4FRSCENEHANDLER::SendDouble(G4double val)
1497 //----- make command char_string and send
1499 char* command = new char[COMMAND_BUF_SIZE];
1501 num_char = sprintf(command, "%*.*g", fPrec2, fPrec, val);
1504 if(G4VisManager::GetVerbosity() >= G4VisManager::errors)
1505 G4cout << "ERROR G4FRSCENEHANDLER::SendStrInt(), 1\n";
1509} // G4FRSCENEHANDLER::SendStrInt()
1512void G4FRSCENEHANDLER::ClearTransientStore()
1514 // This is typically called after an update and before drawing hits
1515 // of the next event. To simulate the clearing of "transients"
1516 // (hits, etc.) the detector is redrawn...
1519 fpViewer->SetView();
1520 fpViewer->ClearView();
1521 fpViewer->DrawView();