Geant4  10.00.p03
G4FukuiRendererSceneHandler.cc
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: G4FukuiRendererSceneHandler.cc 66373 2012-12-18 09:41:34Z gcosmo $
28 //
29 //
30 // Satoshi TANAKA, Fri Jun 28 11:34:24 JST 1996
31 // FukuiRenderer scene.
32 
33 
34 //=================//
35 #ifdef G4VIS_BUILD_DAWN_DRIVER
36 //=================//
37 
38 
39 #define __G_ANSI_C__
40 
41 // #define DEBUG_FR_SCENE
42 
43  //----- header files
44 #include <fstream>
45 #include <string.h>
46 #include "globals.hh"
47 #include "G4VisManager.hh"
48 #include "G4FRConst.hh"
49 #include "G4FukuiRenderer.hh"
51 #include "G4FukuiRendererViewer.hh"
52 #include "G4Point3D.hh"
53 #include "G4VisAttributes.hh"
54 #include "G4Scene.hh"
55 #include "G4Transform3D.hh"
56 #include "G4Polyhedron.hh"
57 #include "G4Box.hh"
58 #include "G4Cons.hh"
59 #include "G4Polyline.hh"
60 #include "G4Trd.hh"
61 #include "G4Tubs.hh"
62 #include "G4Trap.hh"
63 #include "G4Torus.hh"
64 #include "G4Sphere.hh"
65 #include "G4Para.hh"
66 #include "G4Text.hh"
67 #include "G4Circle.hh"
68 #include "G4Square.hh"
69 #include "G4VPhysicalVolume.hh"
70 
71 //----- constants
72 const char FR_ENV_CULL_INVISIBLE_OBJECTS [] = "G4DAWN_CULL_INVISIBLE_OBJECTS";
73 const char FR_ENV_MULTI_WINDOW[] = "G4DAWN_MULTI_WINDOW" ;
74 
76 // Driver-dependent part //
78 
79 
80  //----- G4FukuiRendererSceneHandler, constructor
81 G4FukuiRendererSceneHandler::G4FukuiRendererSceneHandler (G4FukuiRenderer& system,
82  const G4String& name):
83 G4VSceneHandler (system, fSceneIdCount++, name) ,
84 fSystem (system) ,
85 fPrimDest (system.GetPrimDest() ) ,
86 FRflag_in_modeling (false) ,
87 flag_saving_g4_prim (false) ,
88 COMMAND_BUF_SIZE (G4FRClientServer::SEND_BUFMAX),
89 fPrec (9), fPrec2 (16)
90 {
91 
92  //----- Connection to FukuiRenderer is set in the first scene
93  if( !fSystem.IsConnected() )
94  {
95  if ( getenv( FR_ENV_NAMED_PIPE_CONNECTION ) != NULL &&\
96  strcmp( getenv( FR_ENV_NAMED_PIPE_CONNECTION ), "0" ) )
97  {
98  // Invoke DAWN locally and make connection
99  // via named pipe (not supported in AIX etc)
100  fSystem.UseBSDUnixDomainAuto();
101  } else if( getenv( FR_ENV_SERVER_HOST_NAME ) == NULL )
102  {
103  // Invoke DAWN locally and make connection
104  // via socket
105  fSystem.UseInetDomainAuto();
106  } else {
107  // Connect to remote DAWN via socket
108  fSystem.UseInetDomain();
109  }
110  }
111 
112  //----- precision control
113  if( getenv( "G4DAWN_PRECISION" ) != NULL ) {
114  sscanf( getenv("G4DAWN_PRECISION"), "%d", &fPrec ) ;
115  } else {
116  fPrec = 9 ;
117  }
118  fPrec2 = fPrec + 7 ;
119 
120 } // G4FukuiRendererSceneHandler, constructor
121 
122 
123  //----- G4FukuiRendererSceneHandler, destructor
124 G4FukuiRendererSceneHandler::~G4FukuiRendererSceneHandler ()
125 {
126 #if defined DEBUG_FR_SCENE
128  G4cout << "***** ~G4FukuiRendererSceneHandler" << G4endl;
129 #endif
130 }
131 
132 //-----
133 void G4FukuiRendererSceneHandler::FRBeginModeling( void )
134 {
135  if( !FRIsInModeling() )
136  {
137 #if defined DEBUG_FR_SCENE
139  G4cout << "***** G4FukuiRendererSceneHandler::FRBeginModeling (called & started)" << G4endl;
140 #endif
141 
142  //----- Begin Saving g4.prim file
143  // open g4.prim, ##
144  BeginSavingG4Prim();
145 
146  //----- Send Bounding Box
147  // /BoundingBox
148  SendBoundingBox();
149 
150  //----- drawing device
151  // !Device
152  // (Note: Not saved in g4.prim)
153  if( ( getenv( FR_ENV_MULTI_WINDOW ) != NULL ) && \
154  ( strcmp( getenv( FR_ENV_MULTI_WINDOW ),"0" ) ) )
155  {
156  ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_XWIN ) ;
157  } else {
158  ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_PS ) ;
159  }
160 
161  //----- drawing style
162  // /WireFrame, /Surface etc
163  // (Note: Not saved in g4.prim)
164  ((G4FukuiRendererViewer*)fpViewer)->SendDrawingStyle() ;
165 
166  //----- set view parameters
167  // /CameraPosition, /TargetPoint,
168  // /ZoomFactor, /FocalDistance,
169  // !GraphicalUserInterface
170  ((G4FukuiRendererViewer*)fpViewer)->SendViewParameters();
171 
172  //----- send SET_CAMERA command
173  // !SetCamera
174 #if defined DEBUG_FR_SCENE
176  G4cout << "***** (!SetCamera in FRBeginModeling())" << G4endl;
177 #endif
178  SendStr( FR_SET_CAMERA );
179 
180  //----- open device
181  // !OpenDevice
182 #if defined DEBUG_FR_SCENE
184  G4cout << "***** (!OpenDevice in FRBeginModeling())" << G4endl;
185 #endif
186  SendStr( FR_OPEN_DEVICE );
187 
188  //----- begin sending primitives
189  // !BeginModeling
190 #if defined DEBUG_FR_SCENE
192  G4cout << "***** (!BeginModeling in FRBeginModeling())" << G4endl;
193 #endif
194  SendStr( FR_BEGIN_MODELING ); FRflag_in_modeling = true ;
195 
196  } // if
197 
198 }
199 
201 // Common to DAWN and DAWNFILE drivers //
203 
204 #define G4FRSCENEHANDLER G4FukuiRendererSceneHandler
205 #include "G4FRSceneFunc.icc"
206 #undef G4FRSCENEHANDLER
207 
209 // static variables //
211 
212  //----- static variables
213 G4int G4FukuiRendererSceneHandler::fSceneIdCount = 0;
214 
215 #endif // G4VIS_BUILD_DAWN_DRIVER
const char FR_BEGIN_MODELING[]
Definition: G4FRConst.hh:64
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
const char FR_ENV_MULTI_WINDOW[]
G4GLOB_DLL std::ostream G4cout
const char FR_OPEN_DEVICE[]
Definition: G4FRConst.hh:46
const char FR_SET_CAMERA[]
Definition: G4FRConst.hh:45
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
const char FR_ENV_CULL_INVISIBLE_OBJECTS[]