ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4FukuiRendererSceneHandler.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4FukuiRendererSceneHandler.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // Satoshi TANAKA, Fri Jun 28 11:34:24 JST 1996
30 // FukuiRenderer scene.
31 
32 
33 //=================//
34 #ifdef G4VIS_BUILD_DAWN_DRIVER
35 //=================//
36 
37 
38 #define __G_ANSI_C__
39 
40 // #define DEBUG_FR_SCENE
41 
42  //----- header files
43 #include <fstream>
44 #include <string.h>
45 #include "globals.hh"
46 #include "G4VisManager.hh"
47 #include "G4FRConst.hh"
48 #include "G4FukuiRenderer.hh"
50 #include "G4FukuiRendererViewer.hh"
51 #include "G4Point3D.hh"
52 #include "G4VisAttributes.hh"
53 #include "G4Scene.hh"
54 #include "G4Transform3D.hh"
55 #include "G4Polyhedron.hh"
56 #include "G4Box.hh"
57 #include "G4Cons.hh"
58 #include "G4Polyline.hh"
59 #include "G4Trd.hh"
60 #include "G4Tubs.hh"
61 #include "G4Trap.hh"
62 #include "G4Torus.hh"
63 #include "G4Sphere.hh"
64 #include "G4Para.hh"
65 #include "G4Text.hh"
66 #include "G4Circle.hh"
67 #include "G4Square.hh"
68 #include "G4VPhysicalVolume.hh"
69 
70 //----- constants
71 const char FR_ENV_CULL_INVISIBLE_OBJECTS [] = "G4DAWN_CULL_INVISIBLE_OBJECTS";
72 const char FR_ENV_MULTI_WINDOW[] = "G4DAWN_MULTI_WINDOW" ;
73 
75 // Driver-dependent part //
77 
78 
79  //----- G4FukuiRendererSceneHandler, constructor
80 G4FukuiRendererSceneHandler::G4FukuiRendererSceneHandler (G4FukuiRenderer& system,
81  const G4String& name):
82 G4VSceneHandler (system, fSceneIdCount++, name) ,
83 fSystem (system) ,
84 fPrimDest (system.GetPrimDest() ) ,
85 FRflag_in_modeling (false) ,
86 flag_saving_g4_prim (false) ,
87 COMMAND_BUF_SIZE (G4FRClientServer::SEND_BUFMAX),
88 fPrec (9), fPrec2 (16)
89 {
90 
91  //----- Connection to FukuiRenderer is set in the first scene
92  if( !fSystem.IsConnected() )
93  {
94  if ( std::getenv( FR_ENV_NAMED_PIPE_CONNECTION ) != NULL &&\
95  strcmp( std::getenv( FR_ENV_NAMED_PIPE_CONNECTION ), "0" ) )
96  {
97  // Invoke DAWN locally and make connection
98  // via named pipe (not supported in AIX etc)
99  fSystem.UseBSDUnixDomainAuto();
100  } else if( std::getenv( FR_ENV_SERVER_HOST_NAME ) == NULL )
101  {
102  // Invoke DAWN locally and make connection
103  // via socket
104  fSystem.UseInetDomainAuto();
105  } else {
106  // Connect to remote DAWN via socket
107  fSystem.UseInetDomain();
108  }
109  }
110 
111  //----- precision control
112  if( std::getenv( "G4DAWN_PRECISION" ) != NULL ) {
113  sscanf( std::getenv("G4DAWN_PRECISION"), "%d", &fPrec ) ;
114  } else {
115  fPrec = 9 ;
116  }
117  fPrec2 = fPrec + 7 ;
118 
119 } // G4FukuiRendererSceneHandler, constructor
120 
121 
122  //----- G4FukuiRendererSceneHandler, destructor
123 G4FukuiRendererSceneHandler::~G4FukuiRendererSceneHandler ()
124 {
125 #if defined DEBUG_FR_SCENE
127  G4cout << "***** ~G4FukuiRendererSceneHandler" << G4endl;
128 #endif
129 }
130 
131 //-----
132 void G4FukuiRendererSceneHandler::FRBeginModeling( void )
133 {
134  if( !FRIsInModeling() )
135  {
136 #if defined DEBUG_FR_SCENE
138  G4cout << "***** G4FukuiRendererSceneHandler::FRBeginModeling (called & started)" << G4endl;
139 #endif
140 
141  //----- Begin Saving g4.prim file
142  // open g4.prim, ##
143  BeginSavingG4Prim();
144 
145  //----- Send Bounding Box
146  // /BoundingBox
147  SendBoundingBox();
148 
149  //----- drawing device
150  // !Device
151  // (Note: Not saved in g4.prim)
152  if( ( std::getenv( FR_ENV_MULTI_WINDOW ) != NULL ) && \
153  ( strcmp( std::getenv( FR_ENV_MULTI_WINDOW ),"0" ) ) )
154  {
155  ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_XWIN ) ;
156  } else {
157  ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_PS ) ;
158  }
159 
160  //----- drawing style
161  // /WireFrame, /Surface etc
162  // (Note: Not saved in g4.prim)
163  ((G4FukuiRendererViewer*)fpViewer)->SendDrawingStyle() ;
164 
165  //----- set view parameters
166  // /CameraPosition, /TargetPoint,
167  // /ZoomFactor, /FocalDistance,
168  // !GraphicalUserInterface
169  ((G4FukuiRendererViewer*)fpViewer)->SendViewParameters();
170 
171  //----- send SET_CAMERA command
172  // !SetCamera
173 #if defined DEBUG_FR_SCENE
175  G4cout << "***** (!SetCamera in FRBeginModeling())" << G4endl;
176 #endif
177  SendStr( FR_SET_CAMERA );
178 
179  //----- open device
180  // !OpenDevice
181 #if defined DEBUG_FR_SCENE
183  G4cout << "***** (!OpenDevice in FRBeginModeling())" << G4endl;
184 #endif
185  SendStr( FR_OPEN_DEVICE );
186 
187  //----- begin sending primitives
188  // !BeginModeling
189 #if defined DEBUG_FR_SCENE
191  G4cout << "***** (!BeginModeling in FRBeginModeling())" << G4endl;
192 #endif
193  SendStr( FR_BEGIN_MODELING ); FRflag_in_modeling = true ;
194 
195  } // if
196 
197 }
198 
200 // Common to DAWN and DAWNFILE drivers //
202 
203 #define G4FRSCENEHANDLER G4FukuiRendererSceneHandler
204 #include "G4FRSceneFunc.icc"
205 #undef G4FRSCENEHANDLER
206 
208 // static variables //
210 
211  //----- static variables
212 G4int G4FukuiRendererSceneHandler::fSceneIdCount = 0;
213 
214 #endif // G4VIS_BUILD_DAWN_DRIVER