Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GMocrenFileViewer.cc
Go to the documentation of this file.
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$
28 //
29 //
30 // Created: Mar. 31, 2009 Akinori Kimura
31 //
32 
33 
34 #define __G_ANSI_C__
35 #define G4GMocrenFile_STRUCTURE_PRIORITY 1.
36 
37 #include "G4ios.hh"
38 #include <cstdio>
39 #include <cstring>
40 #include <cassert>
41 
42 #include "G4VisManager.hh"
43 #include "G4Scene.hh"
44 #include "G4Vector3D.hh"
45 #include "G4VisExtent.hh"
46 #include "G4LogicalVolume.hh"
47 #include "G4VSolid.hh"
48 
49 #include "G4GMocrenFile.hh"
51 #include "G4GMocrenFileViewer.hh"
52 #include "G4GMocrenMessenger.hh"
53 
54 
55 //----- constants
56 
57 //-- for a debugging
58 const bool GFDEBUG = false;
59 
60 //----- G4GMocrenFileViewer, constructor
62  G4GMocrenMessenger & messenger,
63  const G4String& name)
64  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
65  kSceneHandler (sceneHandler),
66  kMessenger(messenger)
67 {
68  // Set a g4.gdd-file viewer
69  std::strncpy( kG4GddViewer, "gMocren", 7);
70  if( getenv( "G4GMocrenFile_VIEWER" ) != NULL ) {
71  char * env = getenv( "G4GMocrenFile_VIEWER" );
72  std::strncpy( kG4GddViewer, env, std::strlen(env));
73  //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;
74  }
75 
76  // string for viewer invocation
77  if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
78 
79  //std::strcpy( kG4GddViewerInvocation, "" );
80  kG4GddViewerInvocation[0] = '\0';
81  } else {
82 
83  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
84  std::strncat( kG4GddViewerInvocation, " ", 1);
85  const char * gddfname = kSceneHandler.GetGddFileName();
86  std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname) );
87  }
88 
89 }
90 
91 //----- G4GMocrenFileViewer, destructor
93 {}
94 
95 //----- G4GMocrenFileViewer::SetView ()
97 {
98  if(GFDEBUG)
100  G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
101 
102  // Do nothing, since DAWN is running as a different process.
103  // SendViewParameters () will do this job instead.
104 }
105 
106 
107 //----- G4GMocrenFileViewer::ClearView()
108 void
110 {
111  if(GFDEBUG)
113  G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
114 
115  //if(kSceneHandler.kGddDest) {
116  //kSceneHandler.kGddDest.close();
117  // Re-open with same filename...
118  //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
119  kSceneHandler.kFlagInModeling = false;
120  kSceneHandler.GFBeginModeling();
121  //}
122 }
123 
124 
125 //----- G4GMocrenFileViewer::DrawView ()
127 {
128  if(GFDEBUG)
130  G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
131 
132  //-----
133  kSceneHandler.GFBeginModeling() ;
134 
135  //----- Always visit G4 kernel
136  NeedKernelVisit ();
137 
138  //----- Draw
140 
141 } // G4GMocrenFileViewer::DrawView ()
142 
143 
144 
145 //----- G4GMocrenFileViewer::ShowView()
147 {
148  if(GFDEBUG)
150  G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
151 
152  if( kSceneHandler.GFIsInModeling() )
153  {
154  //----- End of modeling
155  // !EndModeling, !DrawAll, !CloseDevice,
156  // close g4.gdd
157  kSceneHandler.GFEndModeling();
158 
159  //----- Output DAWN GUI file
160  //SendViewParameters();
161 
162  //----- string for viewer invocation
163  if ( !strcmp( kG4GddViewer, "NONE" ) ) {
164 
165  kG4GddViewerInvocation[0] = '\0';
166  //std::strcpy( kG4GddViewerInvocation, "" );
167  } else {
168 
169  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
170  std::strncat( kG4GddViewerInvocation, " ", 1);
171  const char * gddfname = kSceneHandler.GetGddFileName();
172  std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname));
173  }
174 
175  }
176 
177 } // G4GMocrenFileViewer::ShowView()
178