Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: G4GMocrenFileViewer.cc 87360 2014-12-01 16:07:16Z 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  int len = std::strlen(env);
72  if(len >= 32) {
73  G4Exception("G4GMocrenFileViewer::G4GMocrenFileViewer(*)",
74  "gMocren1000", FatalException,
75  "Invalid length of string set in G4GMocrenFile_VIEWER");
76  }
77  std::strncpy( kG4GddViewer, env, len);
78  //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;
79  }
80 
81  // string for viewer invocation
82  if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
83 
84  //std::strcpy( kG4GddViewerInvocation, "" );
85  kG4GddViewerInvocation[0] = '\0';
86  } else {
87 
88  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
89  std::strncat( kG4GddViewerInvocation, " ", 1);
90  const char * gddfname = kSceneHandler.GetGddFileName();
91  int len = std::strlen(gddfname);
92  if(len >= 64) {
93  G4Exception("G4GMocrenFileViewer::G4GMocrenFileViewer(*)",
94  "gMocren1001", FatalException,
95  "Invalid length of the GDD file name");
96  }
97  std::strncat( kG4GddViewerInvocation, gddfname, len );
98  }
99 
100 }
101 
102 //----- G4GMocrenFileViewer, destructor
104 {}
105 
106 //----- G4GMocrenFileViewer::SetView ()
108 {
109  if(GFDEBUG)
111  G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
112 
113  // Do nothing, since DAWN is running as a different process.
114  // SendViewParameters () will do this job instead.
115 }
116 
117 
118 //----- G4GMocrenFileViewer::ClearView()
119 void
121 {
122  if(GFDEBUG)
124  G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
125 
126  //if(kSceneHandler.kGddDest) {
127  //kSceneHandler.kGddDest.close();
128  // Re-open with same filename...
129  //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
130  kSceneHandler.kFlagInModeling = false;
131  kSceneHandler.GFBeginModeling();
132  //}
133 }
134 
135 
136 //----- G4GMocrenFileViewer::DrawView ()
138 {
139  if(GFDEBUG)
141  G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
142 
143  //-----
144  kSceneHandler.GFBeginModeling() ;
145 
146  //----- Always visit G4 kernel
147  NeedKernelVisit ();
148 
149  //----- Draw
151 
152 } // G4GMocrenFileViewer::DrawView ()
153 
154 
155 
156 //----- G4GMocrenFileViewer::ShowView()
158 {
159  if(GFDEBUG)
161  G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
162 
163  if( kSceneHandler.GFIsInModeling() )
164  {
165  //----- End of modeling
166  // !EndModeling, !DrawAll, !CloseDevice,
167  // close g4.gdd
168  kSceneHandler.GFEndModeling();
169 
170  //----- Output DAWN GUI file
171  //SendViewParameters();
172 
173  //----- string for viewer invocation
174  if ( !strcmp( kG4GddViewer, "NONE" ) ) {
175 
176  kG4GddViewerInvocation[0] = '\0';
177  //std::strcpy( kG4GddViewerInvocation, "" );
178  } else {
179 
180  std::strncpy( kG4GddViewerInvocation, kG4GddViewer, std::strlen(kG4GddViewer));
181  std::strncat( kG4GddViewerInvocation, " ", 1);
182  const char * gddfname = kSceneHandler.GetGddFileName();
183  int len = std::strlen(gddfname);
184  if(len >= 64) {
185  G4Exception("G4GMocrenFileViewer::ShowView()",
186  "gMocren1002", FatalException,
187  "Invalid length of the GDD file name");
188  }
189  std::strncat( kG4GddViewerInvocation, gddfname, len);
190  }
191 
192  }
193 
194 } // G4GMocrenFileViewer::ShowView()
195 
const XML_Char int len
Definition: expat.h:262
const XML_Char * name
Definition: expat.h:151
G4GMocrenFileViewer(G4GMocrenFileSceneHandler &scene, G4GMocrenMessenger &messenger, const G4String &name="")
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static Verbosity GetVerbosity()
void NeedKernelVisit()
Definition: G4VViewer.cc:78
const G4bool GFDEBUG
#define G4endl
Definition: G4ios.hh:61
void ProcessView()
Definition: G4VViewer.cc:105