ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4VRML2FileViewer.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4VRML2FileViewer.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
//
28
// G4VRML2FileViewer.cc
29
// Satoshi Tanaka & Yasuhide Sawada
30
31
32
//#define DEBUG_FR_VIEW
33
34
#include <cmath>
35
36
#include "
G4VisManager.hh
"
37
#include "
G4Scene.hh
"
38
#include "
G4VRML2FileViewer.hh
"
39
#include "
G4VRML2FileSceneHandler.hh
"
40
#include "
G4VRML2File.hh
"
41
#include "
G4SystemOfUnits.hh
"
42
#include "
G4ios.hh
"
43
44
G4VRML2FileViewer::G4VRML2FileViewer
(
G4VRML2FileSceneHandler
& sceneHandler,
45
const
G4String
&
name
) :
46
G4VViewer
(sceneHandler,
47
sceneHandler.IncrementViewCount(),
48
name),
49
fSceneHandler(sceneHandler),
50
fDest(sceneHandler.fDest)
51
{
52
fViewHalfAngle
= 30. *
deg
;
53
fsin_VHA
= std::sin (
fViewHalfAngle
) ;
54
}
55
56
G4VRML2FileViewer::~G4VRML2FileViewer
()
57
{}
58
59
void
G4VRML2FileViewer::SetView
()
60
{
61
#if defined DEBUG_FR_VIEW
62
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
63
G4cout
<<
"***** G4VRML2FileViewer::SetView(): No effects"
<<
G4endl
;
64
#endif
65
66
// Do nothing, since VRML a browser is running as a different process.
67
// SendViewParameters () will do this job instead.
68
69
}
70
71
void
G4VRML2FileViewer::DrawView
()
72
{
73
#if defined DEBUG_FR_VIEW
74
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
75
G4cout
<<
"***** G4VRML2FileViewer::DrawView()"
<<
G4endl
;
76
#endif
77
78
fSceneHandler
.
VRMLBeginModeling
() ;
79
80
// Viewpoint node
81
SendViewParameters
();
82
83
// Here is a minimal DrawView() function.
84
NeedKernelVisit
();
85
ProcessView
();
86
FinishView
();
87
}
88
89
void
G4VRML2FileViewer::ClearView
(
void
)
90
{
91
#if defined DEBUG_FR_VIEW
92
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
93
G4cout
<<
"***** G4VRML2File1View::ClearView()"
<<
G4endl
;
94
#endif
95
if
(
fSceneHandler
.
fFlagDestOpen
) {
96
fSceneHandler
.
fDest
.close();
97
// Re-open with same filename...
98
fSceneHandler
.
fDest
.open(
fSceneHandler
.
fVRMLFileName
);
99
fSceneHandler
.
fDest
<<
"#VRML V2.0 utf8"
<<
"\n"
;
100
fSceneHandler
.
fDest
<<
"# Generated by VRML 2.0 driver of GEANT4\n"
<<
"\n"
;
101
}
102
}
103
104
void
G4VRML2FileViewer::ShowView
(
void
)
105
{
106
#if defined DEBUG_FR_VIEW
107
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
108
G4cout
<<
"***** G4VRML2FileViewer::ShowView()"
<<
G4endl
;
109
#endif
110
fSceneHandler
.
VRMLEndModeling
();
111
}
112
113
void
G4VRML2FileViewer::FinishView
(
void
)
114
{
115
#if defined DEBUG_FR_VIEW
116
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
117
G4cout
<<
"***** G4VRML2FileViewer::FinishView(): No effects"
<<
G4endl
;
118
#endif
119
}
120
121
void
G4VRML2FileViewer::SendViewParameters
()
122
{
123
// Calculates view representation based on extent of object being
124
// viewed and (initial) direction of camera. (Note: it can change
125
// later due to user interaction via visualization system's GUI.)
126
127
#if defined DEBUG_FR_VIEW
128
if
(
G4VisManager::GetVerbosity
() >=
G4VisManager::errors
)
129
G4cout
<<
"***** G4VRML2FileViewer::SendViewParameters()\n"
;
130
#endif
131
132
// error recovery
133
if
(
fsin_VHA
< 1.0
e
-6 ) {
return
; }
134
135
// camera distance
136
G4double
extent_radius =
fSceneHandler
.
GetScene
()->
GetExtent
().
GetExtentRadius
();
137
G4double
camera_distance = extent_radius /
fsin_VHA
;
138
139
// camera position on Z axis
140
const
G4Point3D
& target_point
141
=
fSceneHandler
.
GetScene
()->
GetStandardTargetPoint
()
142
+
fVP
.
GetCurrentTargetPoint
();
143
G4double
E_z = target_point.
z
() + camera_distance;
144
G4Point3D
E
(0.0, 0.0, E_z );
145
146
// VRML codes are generated below
147
fDest
<<
G4endl
;
148
fDest
<<
"#---------- CAMERA"
<<
G4endl
;
149
fDest
<<
"Viewpoint {"
<<
G4endl
;
150
fDest
<<
"\t"
<<
"position "
;
151
fDest
<< E.
x
() <<
" "
;
152
fDest
<< E.
y
() <<
" "
;
153
fDest
<< E.
z
() <<
G4endl
;
154
fDest
<<
"}"
<<
G4endl
;
155
fDest
<<
G4endl
;
156
157
}
geant4
tree
geant4-10.6-release
source
visualization
VRML
src
G4VRML2FileViewer.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:58
using
1.8.2 with
ECCE GitHub integration