Geant4-11
source
visualization
gMocren
src
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
//
28
//
29
// Created: Mar. 31, 2009 Akinori Kimura
30
//
31
32
33
#define __G_ANSI_C__
34
#define G4GMocrenFile_STRUCTURE_PRIORITY 1.
35
36
#include "
G4ios.hh
"
37
#include <cstdio>
38
#include <cstring>
39
#include <cassert>
40
41
#include "
G4VisManager.hh
"
42
#include "
G4Scene.hh
"
43
#include "
G4Vector3D.hh
"
44
#include "
G4VisExtent.hh
"
45
#include "
G4LogicalVolume.hh
"
46
#include "
G4VSolid.hh
"
47
48
#include "
G4GMocrenFile.hh
"
49
#include "
G4GMocrenFileSceneHandler.hh
"
50
#include "
G4GMocrenFileViewer.hh
"
51
#include "
G4GMocrenMessenger.hh
"
52
53
54
//----- constants
55
56
//-- for a debugging
57
const
G4bool
GFDEBUG
=
false
;
58
59
//----- G4GMocrenFileViewer, constructor
60
G4GMocrenFileViewer::G4GMocrenFileViewer
(
G4GMocrenFileSceneHandler
& sceneHandler,
61
G4GMocrenMessenger
&,
62
const
G4String
&
name
)
63
:
G4VViewer
(sceneHandler, sceneHandler.IncrementViewCount (),
name
),
64
kSceneHandler (sceneHandler)
65
{
66
// Set a g4.gdd-file viewer
67
std::strncpy(
kG4GddViewer
,
"gMocren"
, 8);
68
if
( std::getenv(
"G4GMocrenFile_VIEWER"
) != NULL ) {
69
char
* env = std::getenv(
"G4GMocrenFile_VIEWER"
);
70
G4int
len = std::strlen(env);
71
if
(len >= 32) {
72
G4Exception
(
"G4GMocrenFileViewer::G4GMocrenFileViewer(*)"
,
73
"gMocren1000"
,
FatalException
,
74
"Invalid length of string set in G4GMocrenFile_VIEWER"
);
75
}
76
std::strncpy(
kG4GddViewer
, env,
sizeof
(
kG4GddViewer
) - 1);
77
kG4GddViewer
[
sizeof
(
kG4GddViewer
) - 1] =
'\0'
;
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
,
89
sizeof
(
kG4GddViewerInvocation
) - 1);
90
kG4GddViewerInvocation
[
sizeof
(
kG4GddViewerInvocation
) - 1] =
'\0'
;
91
G4int
n
=
sizeof
(
kG4GddViewerInvocation
)
92
- std::strlen(
kG4GddViewerInvocation
) - 1;
93
std::strncat(
kG4GddViewerInvocation
,
" "
,
n
);
94
const
char
* gddfname =
kSceneHandler
.
GetGddFileName
();
95
G4int
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
n
=
sizeof
(
kG4GddViewerInvocation
)
102
- std::strlen(
kG4GddViewerInvocation
) - 1;
103
std::strncat(
kG4GddViewerInvocation
, gddfname,
n
);
104
}
105
106
}
107
108
//----- G4GMocrenFileViewer, destructor
109
G4GMocrenFileViewer::~G4GMocrenFileViewer
()
110
{}
111
112
//----- G4GMocrenFileViewer::SetView ()
113
void
G4GMocrenFileViewer::SetView
()
114
{
115
if
(
GFDEBUG
)
116
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
117
G4cout
<<
"***** G4GMocrenFileViewer::SetView(): No effects"
<<
G4endl
;
118
119
// Do nothing, since DAWN is running as a different process.
120
// SendViewParameters () will do this job instead.
121
}
122
123
124
//----- G4GMocrenFileViewer::ClearView()
125
void
126
G4GMocrenFileViewer::ClearView
(
void
)
127
{
128
if
(
GFDEBUG
) {
129
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
) {
130
G4cout
<<
"***** G4GMocrenFileViewer::ClearView (): No effects "
<<
G4endl
;
131
}
132
}
133
//if(kSceneHandler.kGddDest) {
134
//kSceneHandler.kGddDest.close();
135
// Re-open with same filename...
136
//kSceneHandler.kGddDest.open(kSceneHandler.kGddFileName);
137
kSceneHandler
.
kFlagInModeling
=
false
;
138
kSceneHandler
.
GFBeginModeling
();
139
//}
140
}
141
142
143
//----- G4GMocrenFileViewer::DrawView ()
144
void
G4GMocrenFileViewer::DrawView
()
145
{
146
if
(
GFDEBUG
)
147
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
148
G4cout
<<
"***** G4GMocrenFileViewer::DrawView () "
<<
G4endl
;
149
150
//-----
151
kSceneHandler
.
GFBeginModeling
() ;
152
153
//----- Always visit G4 kernel
154
NeedKernelVisit
();
155
156
//----- Draw
157
G4VViewer::ProcessView
() ;
158
159
}
// G4GMocrenFileViewer::DrawView ()
160
161
162
163
//----- G4GMocrenFileViewer::ShowView()
164
void
G4GMocrenFileViewer::ShowView
(
void
)
165
{
166
if
(
GFDEBUG
)
167
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
168
G4cout
<<
"***** G4GMocrenFileViewer::ShowView () "
<<
G4endl
;
169
170
if
(
kSceneHandler
.
GFIsInModeling
() )
171
{
172
//----- End of modeling
173
// !EndModeling, !DrawAll, !CloseDevice,
174
// close g4.gdd
175
kSceneHandler
.
GFEndModeling
();
176
177
//----- Output DAWN GUI file
178
//SendViewParameters();
179
180
//----- string for viewer invocation
181
if
( !strcmp(
kG4GddViewer
,
"NONE"
) ) {
182
183
kG4GddViewerInvocation
[0] =
'\0'
;
184
//std::strcpy( kG4GddViewerInvocation, "" );
185
}
else
{
186
187
std::strncpy(
kG4GddViewerInvocation
,
kG4GddViewer
,
188
sizeof
(
kG4GddViewerInvocation
) - 1);
189
kG4GddViewerInvocation
[
sizeof
(
kG4GddViewerInvocation
) - 1] =
'\0'
;
190
G4int
n
=
sizeof
(
kG4GddViewerInvocation
)
191
- std::strlen(
kG4GddViewerInvocation
) - 1;
192
std::strncat(
kG4GddViewerInvocation
,
" "
,
n
);
193
const
char
* gddfname =
kSceneHandler
.
GetGddFileName
();
194
G4int
len = std::strlen(gddfname);
195
if
(len >= 64) {
196
G4Exception
(
"G4GMocrenFileViewer::ShowView()"
,
197
"gMocren1002"
,
FatalException
,
198
"Invalid length of the GDD file name"
);
199
}
200
n
=
sizeof
(
kG4GddViewerInvocation
)
201
- std::strlen(
kG4GddViewerInvocation
) - 1;
202
std::strncat(
kG4GddViewerInvocation
, gddfname,
n
);
203
}
204
205
}
206
207
}
// G4GMocrenFileViewer::ShowView()
208
FatalException
@ FatalException
Definition:
G4ExceptionSeverity.hh:61
G4Exception
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition:
G4Exception.cc:35
G4GMocrenFileSceneHandler.hh
GFDEBUG
const G4bool GFDEBUG
Definition:
G4GMocrenFileViewer.cc:57
G4GMocrenFileViewer.hh
G4GMocrenFile.hh
G4GMocrenMessenger.hh
G4LogicalVolume.hh
G4Scene.hh
G4bool
bool G4bool
Definition:
G4Types.hh:86
G4int
int G4int
Definition:
G4Types.hh:85
G4VSolid.hh
G4Vector3D.hh
G4VisExtent.hh
G4VisManager.hh
G4ios.hh
G4endl
#define G4endl
Definition:
G4ios.hh:57
G4cout
G4GLOB_DLL std::ostream G4cout
G4GMocrenFileSceneHandler
Definition:
G4GMocrenFileSceneHandler.hh:53
G4GMocrenFileSceneHandler::GFIsInModeling
G4bool GFIsInModeling()
Definition:
G4GMocrenFileSceneHandler.hh:103
G4GMocrenFileSceneHandler::GetGddFileName
const char * GetGddFileName()
Definition:
G4GMocrenFileSceneHandler.hh:111
G4GMocrenFileSceneHandler::GFEndModeling
void GFEndModeling()
Definition:
G4GMocrenFileSceneHandler.cc:787
G4GMocrenFileSceneHandler::GFBeginModeling
void GFBeginModeling()
Definition:
G4GMocrenFileSceneHandler.cc:510
G4GMocrenFileSceneHandler::kFlagInModeling
G4bool kFlagInModeling
Definition:
G4GMocrenFileSceneHandler.hh:183
G4GMocrenFileViewer::~G4GMocrenFileViewer
virtual ~G4GMocrenFileViewer()
Definition:
G4GMocrenFileViewer.cc:109
G4GMocrenFileViewer::kG4GddViewerInvocation
char kG4GddViewerInvocation[64]
Definition:
G4GMocrenFileViewer.hh:64
G4GMocrenFileViewer::G4GMocrenFileViewer
G4GMocrenFileViewer(G4GMocrenFileSceneHandler &scene, G4GMocrenMessenger &messenger, const G4String &name="")
Definition:
G4GMocrenFileViewer.cc:60
G4GMocrenFileViewer::ClearView
void ClearView()
Definition:
G4GMocrenFileViewer.cc:126
G4GMocrenFileViewer::DrawView
void DrawView()
Definition:
G4GMocrenFileViewer.cc:144
G4GMocrenFileViewer::ShowView
void ShowView()
Definition:
G4GMocrenFileViewer.cc:164
G4GMocrenFileViewer::kSceneHandler
G4GMocrenFileSceneHandler & kSceneHandler
Definition:
G4GMocrenFileViewer.hh:61
G4GMocrenFileViewer::kG4GddViewer
char kG4GddViewer[32]
Definition:
G4GMocrenFileViewer.hh:63
G4GMocrenFileViewer::SetView
void SetView()
Definition:
G4GMocrenFileViewer.cc:113
G4GMocrenMessenger
Definition:
G4GMocrenMessenger.hh:45
G4String
Definition:
G4String.hh:62
G4VViewer
Definition:
G4VViewer.hh:45
G4VViewer::ProcessView
void ProcessView()
Definition:
G4VViewer.cc:105
G4VViewer::NeedKernelVisit
void NeedKernelVisit()
Definition:
G4VViewer.cc:78
G4VisManager::errors
@ errors
Definition:
G4VisManager.hh:140
G4VisManager::GetVerbosity
static Verbosity GetVerbosity()
Definition:
G4VisManager.cc:2450
CLHEP::detail::n
n
Definition:
Ranlux64Engine.cc:90
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:76
Generated by
1.9.3