Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4GMocrenFileViewer.cc
이 파일의 문서화 페이지로 가기
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 110513 2018-05-28 07:37:38Z 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, sizeof(kG4GddViewer) - 1);
78  kG4GddViewer[sizeof(kG4GddViewer) - 1] = '\0';
79  //std::strcpy( kG4GddViewer, getenv( "G4GMocrenFile_VIEWER" ) ) ;
80  }
81 
82  // string for viewer invocation
83  if ( !std::strcmp( kG4GddViewer, "NONE" ) ) {
84 
85  //std::strcpy( kG4GddViewerInvocation, "" );
86  kG4GddViewerInvocation[0] = '\0';
87  } else {
88 
89  std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
90  sizeof(kG4GddViewerInvocation) - 1);
92  std::strncat( kG4GddViewerInvocation, " ",
93  sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
94  const char * gddfname = kSceneHandler.GetGddFileName();
95  int len = std::strlen(gddfname);
96  if(len >= 64) {
97  G4Exception("G4GMocrenFileViewer::G4GMocrenFileViewer(*)",
98  "gMocren1001", FatalException,
99  "Invalid length of the GDD file name");
100  }
101  std::strncat( kG4GddViewerInvocation, gddfname,
102  sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
103  }
104 
105 }
106 
107 //----- G4GMocrenFileViewer, destructor
109 {}
110 
111 //----- G4GMocrenFileViewer::SetView ()
113 {
114  if(GFDEBUG)
116  G4cout << "***** G4GMocrenFileViewer::SetView(): No effects" << G4endl;
117 
118  // Do nothing, since DAWN is running as a different process.
119  // SendViewParameters () will do this job instead.
120 }
121 
122 
123 //----- G4GMocrenFileViewer::ClearView()
124 void
126 {
127  if(GFDEBUG)
129  G4cout << "***** G4GMocrenFileViewer::ClearView (): No effects " << G4endl;
130 
131  //if(kSceneHandler.kGddDest) {
132  //kSceneHandler.kGddDest.close();
133  // Re-open with same filename...
134  //kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
137  //}
138 }
139 
140 
141 //----- G4GMocrenFileViewer::DrawView ()
143 {
144  if(GFDEBUG)
146  G4cout << "***** G4GMocrenFileViewer::DrawView () " << G4endl;
147 
148  //-----
150 
151  //----- Always visit G4 kernel
152  NeedKernelVisit ();
153 
154  //----- Draw
156 
157 } // G4GMocrenFileViewer::DrawView ()
158 
159 
160 
161 //----- G4GMocrenFileViewer::ShowView()
163 {
164  if(GFDEBUG)
166  G4cout << "***** G4GMocrenFileViewer::ShowView () " << G4endl;
167 
169  {
170  //----- End of modeling
171  // !EndModeling, !DrawAll, !CloseDevice,
172  // close g4.gdd
174 
175  //----- Output DAWN GUI file
176  //SendViewParameters();
177 
178  //----- string for viewer invocation
179  if ( !strcmp( kG4GddViewer, "NONE" ) ) {
180 
181  kG4GddViewerInvocation[0] = '\0';
182  //std::strcpy( kG4GddViewerInvocation, "" );
183  } else {
184 
185  std::strncpy( kG4GddViewerInvocation, kG4GddViewer,
186  sizeof(kG4GddViewerInvocation) - 1);
188  std::strncat( kG4GddViewerInvocation, " ",
189  sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
190  const char * gddfname = kSceneHandler.GetGddFileName();
191  int len = std::strlen(gddfname);
192  if(len >= 64) {
193  G4Exception("G4GMocrenFileViewer::ShowView()",
194  "gMocren1002", FatalException,
195  "Invalid length of the GDD file name");
196  }
197  std::strncat( kG4GddViewerInvocation, gddfname,
198  sizeof(kG4GddViewerInvocation) - std::strlen(kG4GddViewerInvocation) - 1);
199  }
200 
201  }
202 
203 } // G4GMocrenFileViewer::ShowView()
204 
const XML_Char int len
Definition: expat.h:262
const G4bool GFDEBUG
const XML_Char * name
Definition: expat.h:151
#define G4endl
Definition: G4ios.hh:61
void NeedKernelVisit()
Definition: G4VViewer.cc:78
G4GMocrenFileViewer(G4GMocrenFileSceneHandler &scene, G4GMocrenMessenger &messenger, const G4String &name="")
static Verbosity GetVerbosity()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
void ProcessView()
Definition: G4VViewer.cc:105
G4GMocrenFileSceneHandler & kSceneHandler
G4GLOB_DLL std::ostream G4cout