G4GMocrenFileViewer.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 // Created:  Mar. 31, 2009  Akinori Kimura  
00031 //
00032 
00033 
00034 #define __G_ANSI_C__
00035 #define G4GMocrenFile_STRUCTURE_PRIORITY  1.
00036 
00037 #include "G4ios.hh"
00038 #include <cstdio>
00039 #include <cstring>
00040 #include <cassert>
00041 
00042 #include "G4VisManager.hh"
00043 #include "G4Scene.hh"
00044 #include "G4Vector3D.hh"
00045 #include "G4VisExtent.hh"
00046 #include "G4LogicalVolume.hh"
00047 #include "G4VSolid.hh"
00048 
00049 #include "G4GMocrenFile.hh"
00050 #include "G4GMocrenFileSceneHandler.hh"
00051 #include "G4GMocrenFileViewer.hh"
00052 #include "G4GMocrenMessenger.hh"
00053 
00054 
00055 //----- constants
00056 
00057 //-- for a debugging
00058 const bool GFDEBUG = false;
00059 
00060 //----- G4GMocrenFileViewer, constructor
00061 G4GMocrenFileViewer::G4GMocrenFileViewer (G4GMocrenFileSceneHandler& sceneHandler,
00062                                           G4GMocrenMessenger & messenger,
00063                                           const G4String& name)
00064   : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
00065     kSceneHandler (sceneHandler),
00066     kMessenger(messenger)
00067 {
00068   // Set a g4.gdd-file viewer 
00069   std::strncpy( kG4GddViewer, "gMocren", 7); 
00070   if( getenv( "G4GMocrenFile_VIEWER" ) != NULL ) {
00071     char * env = getenv( "G4GMocrenFile_VIEWER" );
00072     std::strncpy( kG4GddViewer, env, std::strlen(env));
00073     //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;                           
00074   } 
00075 
00076   // string for viewer invocation
00077   if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
00078                 
00079     //std::strcpy( kG4GddViewerInvocation, "" );
00080     kG4GddViewerInvocation[0] = '\0';
00081   } else {
00082 
00083     std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
00084     std::strncat( kG4GddViewerInvocation, " ", 1);
00085     const char * gddfname = kSceneHandler.GetGddFileName();
00086     std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname) );
00087   }
00088 
00089 }
00090 
00091 //----- G4GMocrenFileViewer, destructor
00092 G4GMocrenFileViewer::~G4GMocrenFileViewer () 
00093 {}
00094 
00095 //----- G4GMocrenFileViewer::SetView () 
00096 void G4GMocrenFileViewer::SetView () 
00097 {
00098   if(GFDEBUG)
00099     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00100       G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
00101 
00102   // Do nothing, since DAWN is running as a different process.
00103   // SendViewParameters () will do this job instead.
00104 }
00105 
00106 
00107 //----- G4GMocrenFileViewer::ClearView()
00108 void
00109 G4GMocrenFileViewer::ClearView( void )
00110 {
00111   if(GFDEBUG)
00112     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00113       G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
00114 
00115   //if(kSceneHandler.kGddDest) {
00116     //kSceneHandler.kGddDest.close();
00117     // Re-open with same filename...
00118     //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
00119     kSceneHandler.kFlagInModeling = false;
00120     kSceneHandler.GFBeginModeling();
00121     //}
00122 }
00123 
00124 
00125 //----- G4GMocrenFileViewer::DrawView () 
00126 void G4GMocrenFileViewer::DrawView () 
00127 {
00128   if(GFDEBUG)
00129     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00130       G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
00131 
00132   //----- 
00133   kSceneHandler.GFBeginModeling() ;
00134 
00135   //----- Always visit G4 kernel 
00136   NeedKernelVisit ();
00137                                    
00138   //----- Draw
00139   G4VViewer::ProcessView () ;
00140 
00141 } // G4GMocrenFileViewer::DrawView () 
00142 
00143 
00144 
00145 //----- G4GMocrenFileViewer::ShowView()
00146 void G4GMocrenFileViewer::ShowView( void )
00147 {
00148   if(GFDEBUG)
00149     if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00150       G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
00151 
00152   if( kSceneHandler.GFIsInModeling() ) 
00153     {
00154       //----- End of modeling
00155       // !EndModeling, !DrawAll, !CloseDevice,
00156       // close g4.gdd
00157       kSceneHandler.GFEndModeling();
00158 
00159       //----- Output DAWN GUI file 
00160       //SendViewParameters(); 
00161 
00162       //----- string for viewer invocation
00163       if ( !strcmp( kG4GddViewer, "NONE" ) ) {
00164                 
00165         kG4GddViewerInvocation[0] = '\0';
00166         //std::strcpy( kG4GddViewerInvocation, "" );
00167       } else {
00168 
00169         std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
00170         std::strncat( kG4GddViewerInvocation, " ", 1);
00171         const char * gddfname = kSceneHandler.GetGddFileName();
00172         std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname));
00173       }
00174 
00175     }
00176 
00177 } // G4GMocrenFileViewer::ShowView()
00178 

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