Geant4  10.00.p02
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: G4GMocrenFileViewer.cc 70733 2013-06-05 10:05:57Z gcosmo $
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
63  const G4String& name)
64  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
65  kSceneHandler (sceneHandler)
66 {
67  // Set a g4.gdd-file viewer
68  std::strncpy( kG4GddViewer, "gMocren", 8);
69  if( getenv( "G4GMocrenFile_VIEWER" ) != NULL ) {
70  char * env = getenv( "G4GMocrenFile_VIEWER" );
71  std::strncpy( kG4GddViewer, env, std::strlen(env));
72  //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;
73  }
74 
75  // string for viewer invocation
76  if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
77 
78  //std::strcpy( kG4GddViewerInvocation, "" );
79  kG4GddViewerInvocation[0] = '\0';
80  } else {
81 
82  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
83  std::strncat( kG4GddViewerInvocation, " ", 1);
84  const char * gddfname = kSceneHandler.GetGddFileName();
85  std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname) );
86  }
87 
88 }
89 
90 //----- G4GMocrenFileViewer, destructor
92 {}
93 
94 //----- G4GMocrenFileViewer::SetView ()
96 {
97  if(GFDEBUG)
99  G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
100 
101  // Do nothing, since DAWN is running as a different process.
102  // SendViewParameters () will do this job instead.
103 }
104 
105 
106 //----- G4GMocrenFileViewer::ClearView()
107 void
109 {
110  if(GFDEBUG)
112  G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
113 
114  //if(kSceneHandler.kGddDest) {
115  //kSceneHandler.kGddDest.close();
116  // Re-open with same filename...
117  //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
120  //}
121 }
122 
123 
124 //----- G4GMocrenFileViewer::DrawView ()
126 {
127  if(GFDEBUG)
129  G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
130 
131  //-----
133 
134  //----- Always visit G4 kernel
135  NeedKernelVisit ();
136 
137  //----- Draw
139 
140 } // G4GMocrenFileViewer::DrawView ()
141 
142 
143 
144 //----- G4GMocrenFileViewer::ShowView()
146 {
147  if(GFDEBUG)
149  G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
150 
152  {
153  //----- End of modeling
154  // !EndModeling, !DrawAll, !CloseDevice,
155  // close g4.gdd
157 
158  //----- Output DAWN GUI file
159  //SendViewParameters();
160 
161  //----- string for viewer invocation
162  if ( !strcmp( kG4GddViewer, "NONE" ) ) {
163 
164  kG4GddViewerInvocation[0] = '\0';
165  //std::strcpy( kG4GddViewerInvocation, "" );
166  } else {
167 
168  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
169  std::strncat( kG4GddViewerInvocation, " ", 1);
170  const char * gddfname = kSceneHandler.GetGddFileName();
171  std::strncat( kG4GddViewerInvocation, gddfname, std::strlen(gddfname));
172  }
173 
174  }
175 
176 } // G4GMocrenFileViewer::ShowView()
177 
G4String name
Definition: TRTMaterials.hh:40
G4GMocrenFileViewer(G4GMocrenFileSceneHandler &scene, G4GMocrenMessenger &messenger, const G4String &name="")
G4GLOB_DLL std::ostream G4cout
G4GMocrenFileSceneHandler & kSceneHandler
const bool GFDEBUG
static Verbosity GetVerbosity()
void NeedKernelVisit()
Definition: G4VViewer.cc:86
#define G4endl
Definition: G4ios.hh:61
void ProcessView()
Definition: G4VViewer.cc:115