source: trunk/source/visualization/FukuiRenderer/src/G4FukuiRendererSceneHandler.cc@ 1350

Last change on this file since 1350 was 1347, checked in by garnier, 15 years ago

geant4 tag 9.4

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