00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef WIN32
00033
00034
00035 #ifdef G4VIS_BUILD_VRML_DRIVER
00036
00037
00038
00039
00040
00041 #include <cmath>
00042
00043 #include "G4VisManager.hh"
00044 #include "G4Scene.hh"
00045 #include "G4VRML2Viewer.hh"
00046 #include "G4VRML2SceneHandler.hh"
00047 #include "G4VRML2.hh"
00048 #include "G4ios.hh"
00049
00050 G4VRML2Viewer::G4VRML2Viewer(G4VRML2SceneHandler& sceneHandler, const G4String& name) :
00051 G4VViewer(sceneHandler,
00052 sceneHandler.IncrementViewCount(),
00053 name),
00054 fSceneHandler(sceneHandler),
00055 fDest(sceneHandler.fDest)
00056 {
00057 fViewHalfAngle = 0.5 * 0.785398 ;
00058 fsin_VHA = std::sin ( fViewHalfAngle ) ;
00059 }
00060
00061 G4VRML2Viewer::~G4VRML2Viewer()
00062 {}
00063
00064 void G4VRML2Viewer::SetView()
00065 {
00066 #if defined DEBUG_FR_VIEW
00067 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00068 G4cout << "***** G4VRML2Viewer::SetView(): No effects" << G4endl;
00069 #endif
00070
00071
00072
00073
00074 }
00075
00076
00077 void G4VRML2Viewer::DrawView()
00078 {
00079 #if defined DEBUG_FR_VIEW
00080 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00081 G4cout << "***** G4VRML2Viewer::DrawView()" << G4endl;
00082 #endif
00083 fSceneHandler.VRMLBeginModeling() ;
00084
00085
00086 SendViewParameters();
00087
00088
00089 NeedKernelVisit();
00090 ProcessView();
00091 FinishView();
00092 }
00093
00094 void G4VRML2Viewer::ClearView(void)
00095 {
00096 #if defined DEBUG_FR_VIEW
00097 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00098 G4cout << "***** G4VRML2Viewer::ClearView(): No effects" << G4endl;
00099 #endif
00100 }
00101
00102 void G4VRML2Viewer::ShowView(void)
00103 {
00104 #if defined DEBUG_FR_VIEW
00105 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00106 G4cout << "***** G4VRML2Viewer::ShowView()" << G4endl;
00107 #endif
00108 fSceneHandler.VRMLEndModeling();
00109 }
00110
00111 void G4VRML2Viewer::FinishView(void)
00112 {
00113 #if defined DEBUG_FR_VIEW
00114 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00115 G4cout << "***** G4VRML2Viewer::FinishView(): No effects" << G4endl;
00116 #endif
00117 }
00118
00119 void G4VRML2Viewer::SendViewParameters ()
00120 {
00121
00122
00123
00124
00125 #if defined DEBUG_FR_VIEW
00126 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00127 G4cout << "***** G4VRML2Viewer::SendViewParameters()\n";
00128 #endif
00129
00130 if ( fsin_VHA < 1.0e-6 ) { return ; }
00131
00132
00133 G4double extent_radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
00134 G4double camera_distance = extent_radius / fsin_VHA ;
00135
00136
00137 const G4Point3D& target_point
00138 = fSceneHandler.GetScene()->GetStandardTargetPoint()
00139 + fVP.GetCurrentTargetPoint();
00140 G4double E_z = target_point.z() + camera_distance;
00141 G4Point3D E(0.0, 0.0, E_z );
00142
00143
00144 fDest << "\n";
00145 fDest << "#---------- CAMERA" << "\n";
00146 fDest << "Viewpoint {" << "\n";
00147 fDest << "\t" << "position " ;
00148 fDest << E.x() << " " ;
00149 fDest << E.y() << " " ;
00150 fDest << E.z() << "\n" ;
00151 fDest << "}" << "\n";
00152 fDest << "\n";
00153
00154 }
00155
00156
00157
00158 #endif
00159 #endif //WIN32