G4FukuiRendererSceneHandler.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // Satoshi TANAKA, Fri Jun 28 11:34:24 JST 1996
00031 // FukuiRenderer scene.
00032 
00033 
00034 //=================//
00035 #ifdef G4VIS_BUILD_DAWN_DRIVER
00036 //=================//
00037 
00038 
00039 #define __G_ANSI_C__
00040 
00041 // #define DEBUG_FR_SCENE
00042 
00043      //----- header files
00044 #include <fstream>
00045 #include <string.h>
00046 #include "globals.hh"
00047 #include "G4VisManager.hh"
00048 #include "G4FRConst.hh"
00049 #include "G4FukuiRenderer.hh"
00050 #include "G4FukuiRendererSceneHandler.hh"
00051 #include "G4FukuiRendererViewer.hh"
00052 #include "G4Point3D.hh"
00053 #include "G4VisAttributes.hh"
00054 #include "G4Scene.hh"
00055 #include "G4Transform3D.hh"
00056 #include "G4Polyhedron.hh"
00057 #include "G4Box.hh"
00058 #include "G4Cons.hh"
00059 #include "G4Polyline.hh"
00060 #include "G4Trd.hh"
00061 #include "G4Tubs.hh"
00062 #include "G4Trap.hh"
00063 #include "G4Torus.hh"
00064 #include "G4Sphere.hh"
00065 #include "G4Para.hh"
00066 #include "G4Text.hh"
00067 #include "G4Circle.hh"
00068 #include "G4Square.hh"
00069 #include "G4VPhysicalVolume.hh"
00070 
00071 //----- constants
00072 const char  FR_ENV_CULL_INVISIBLE_OBJECTS [] = "G4DAWN_CULL_INVISIBLE_OBJECTS";
00073 const char  FR_ENV_MULTI_WINDOW[]            = "G4DAWN_MULTI_WINDOW" ;
00074 
00076 // Driver-dependent part //
00078 
00079 
00080         //----- G4FukuiRendererSceneHandler, constructor
00081 G4FukuiRendererSceneHandler::G4FukuiRendererSceneHandler (G4FukuiRenderer& system,
00082                                             const G4String& name):
00083 G4VSceneHandler  (system, fSceneIdCount++, name) ,
00084 fSystem   (system)                  ,
00085 fPrimDest (system.GetPrimDest() )   ,
00086 FRflag_in_modeling     (false)      ,
00087 flag_saving_g4_prim    (false)      ,
00088 COMMAND_BUF_SIZE       (G4FRClientServer::SEND_BUFMAX),
00089 fPrec (9), fPrec2 (16)
00090 {
00091 
00092                 //----- Connection to FukuiRenderer is set in the first scene
00093         if( !fSystem.IsConnected() ) 
00094         {
00095                 if ( getenv( FR_ENV_NAMED_PIPE_CONNECTION ) != NULL &&\
00096                      strcmp( getenv( FR_ENV_NAMED_PIPE_CONNECTION ), "0" ) )
00097                 { 
00098                                 // Invoke DAWN locally and make connection
00099                                 // via named pipe (not supported in AIX etc)
00100                         fSystem.UseBSDUnixDomainAuto();
00101                 } else if( getenv( FR_ENV_SERVER_HOST_NAME ) == NULL  ) 
00102                 {
00103                                 // Invoke DAWN locally and make connection
00104                                 // via socket
00105                         fSystem.UseInetDomainAuto();
00106                 } else {
00107                                 // Connect to remote DAWN via socket
00108                         fSystem.UseInetDomain();
00109                 }
00110         }
00111 
00112                 //----- precision control
00113         if( getenv( "G4DAWN_PRECISION" ) != NULL ) {
00114                 sscanf( getenv("G4DAWN_PRECISION"), "%d", &fPrec ) ;
00115         } else {
00116                 fPrec = 9 ;
00117         }
00118         fPrec2 = fPrec + 7 ;
00119 
00120 } // G4FukuiRendererSceneHandler, constructor
00121 
00122 
00123         //----- G4FukuiRendererSceneHandler, destructor
00124 G4FukuiRendererSceneHandler::~G4FukuiRendererSceneHandler () 
00125 {
00126 #if defined DEBUG_FR_SCENE
00127   if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00128         G4cout << "***** ~G4FukuiRendererSceneHandler" << G4endl;
00129 #endif 
00130 }
00131 
00132 //-----
00133 void G4FukuiRendererSceneHandler::FRBeginModeling( void )
00134 {
00135         if( !FRIsInModeling() )         
00136         {
00137 #if defined DEBUG_FR_SCENE
00138           if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00139             G4cout << "***** G4FukuiRendererSceneHandler::FRBeginModeling (called & started)" << G4endl;
00140 #endif
00141 
00142           //----- Begin Saving g4.prim file
00143           // open g4.prim, ##
00144           BeginSavingG4Prim();
00145 
00146           //----- Send Bounding Box
00147           // /BoundingBox
00148           SendBoundingBox();
00149 
00150           //----- drawing device
00151           // !Device 
00152           // (Note: Not saved in g4.prim) 
00153           if( ( getenv( FR_ENV_MULTI_WINDOW ) != NULL      )   && \
00154               ( strcmp( getenv( FR_ENV_MULTI_WINDOW ),"0"  )      )  )
00155             {
00156               ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_XWIN ) ; 
00157             } else {
00158               ((G4FukuiRendererViewer*)fpViewer)->SendDevice( G4FukuiRendererViewer::FRDEV_PS ) ; 
00159             }
00160 
00161           //----- drawing style
00162           // /WireFrame, /Surface etc
00163           // (Note: Not saved in g4.prim) 
00164           ((G4FukuiRendererViewer*)fpViewer)->SendDrawingStyle() ; 
00165 
00166           //----- set view parameters
00167           //   /CameraPosition, /TargetPoint, 
00168           //   /ZoomFactor, /FocalDistance, 
00169           //   !GraphicalUserInterface
00170           ((G4FukuiRendererViewer*)fpViewer)->SendViewParameters(); 
00171 
00172           //----- send SET_CAMERA command 
00173           //   !SetCamera
00174 #if defined DEBUG_FR_SCENE
00175           if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00176                 G4cout << "*****   (!SetCamera in FRBeginModeling())" << G4endl;
00177 #endif
00178           SendStr( FR_SET_CAMERA );
00179 
00180           //----- open device
00181           //   !OpenDevice
00182 #if defined DEBUG_FR_SCENE
00183           if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00184                 G4cout << "*****   (!OpenDevice in FRBeginModeling())" << G4endl;
00185 #endif
00186           SendStr( FR_OPEN_DEVICE      );
00187 
00188           //----- begin sending primitives
00189           //   !BeginModeling
00190 #if defined DEBUG_FR_SCENE
00191           if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00192           G4cout << "*****   (!BeginModeling in FRBeginModeling())" << G4endl;
00193 #endif
00194           SendStr( FR_BEGIN_MODELING );  FRflag_in_modeling = true ;
00195 
00196         } // if
00197 
00198 }
00199 
00201 // Common to DAWN and DAWNFILE drivers //
00203 
00204 #define  G4FRSCENEHANDLER  G4FukuiRendererSceneHandler
00205 #include "G4FRSceneFunc.icc"
00206 #undef   G4FRSCENEHANDLER
00207 
00209 // static variables //
00211 
00212         //----- static variables
00213 G4int G4FukuiRendererSceneHandler::fSceneIdCount = 0; 
00214 
00215 #endif // G4VIS_BUILD_DAWN_DRIVER

Generated on Mon May 27 17:48:18 2013 for Geant4 by  doxygen 1.4.7