[834] | 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.14 2006/06/29 21:17:00 gunter Exp $ |
---|
[944] | 28 | // GEANT4 tag $Name: $ |
---|
[834] | 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 "G4FRConst.hh" |
---|
| 49 | #include "G4FukuiRenderer.hh" |
---|
| 50 | #include "G4FukuiRendererSceneHandler.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 | |
---|
| 75 | /////////////////////////// |
---|
| 76 | // Driver-dependent part // |
---|
| 77 | /////////////////////////// |
---|
| 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 |
---|
| 127 | G4cerr << "***** ~G4FukuiRendererSceneHandler" << G4endl; |
---|
| 128 | #endif |
---|
| 129 | ClearStore (); // clear current scene |
---|
| 130 | |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | //----- |
---|
| 134 | void G4FukuiRendererSceneHandler::FRBeginModeling( void ) |
---|
| 135 | { |
---|
| 136 | if( !FRIsInModeling() ) |
---|
| 137 | { |
---|
| 138 | #if defined DEBUG_FR_SCENE |
---|
| 139 | G4cerr << "***** 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 |
---|
| 175 | G4cerr << "***** (!SetCamera in FRBeginModeling())" << G4endl; |
---|
| 176 | #endif |
---|
| 177 | SendStr( FR_SET_CAMERA ); |
---|
| 178 | |
---|
| 179 | //----- open device |
---|
| 180 | // !OpenDevice |
---|
| 181 | #if defined DEBUG_FR_SCENE |
---|
| 182 | G4cerr << "***** (!OpenDevice in FRBeginModeling())" << G4endl; |
---|
| 183 | #endif |
---|
| 184 | SendStr( FR_OPEN_DEVICE ); |
---|
| 185 | |
---|
| 186 | //----- begin sending primitives |
---|
| 187 | // !BeginModeling |
---|
| 188 | #if defined DEBUG_FR_SCENE |
---|
| 189 | G4cerr << "***** (!BeginModeling in FRBeginModeling())" << G4endl; |
---|
| 190 | #endif |
---|
| 191 | SendStr( FR_BEGIN_MODELING ); FRflag_in_modeling = true ; |
---|
| 192 | |
---|
| 193 | } // if |
---|
| 194 | |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | ///////////////////////////////////////// |
---|
| 198 | // Common to DAWN and DAWNFILE drivers // |
---|
| 199 | ///////////////////////////////////////// |
---|
| 200 | |
---|
| 201 | #define G4FRSCENEHANDLER G4FukuiRendererSceneHandler |
---|
| 202 | #include "G4FRSceneFunc.icc" |
---|
| 203 | #undef G4FRSCENEHANDLER |
---|
| 204 | |
---|
| 205 | ////////////////////// |
---|
| 206 | // static variables // |
---|
| 207 | ////////////////////// |
---|
| 208 | |
---|
| 209 | //----- static variables |
---|
| 210 | G4int G4FukuiRendererSceneHandler::fSceneIdCount = 0; |
---|
| 211 | |
---|
| 212 | #endif // G4VIS_BUILD_DAWN_DRIVER |
---|