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
G4XXXFileViewer.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4XXXFileViewer.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
//
29
// John Allison 7th March 2006
30
// A template for a file-writing graphics driver.
31
//?? Lines beginning like this require specialisation for your driver.
32
33
#include "
G4XXXFileViewer.hh
"
34
35
#include "
G4VSceneHandler.hh
"
36
#include "
G4XXXFileSceneHandler.hh
"
37
#include <sstream>
38
39
void
G4XXXFileViewer::FileWriter::Close
()
40
{
41
if
(
fOpen
) {
42
G4cout
<<
"Closing file "
<<
fFileName
<<
G4endl
;
43
fFile
.close();
44
fOpen
=
false
;
45
}
46
}
47
48
void
G4XXXFileViewer::FileWriter::WriteItem
(
const
G4String
& item)
49
{
50
if
(!fOpen)
51
{
52
std::ifstream ifs;
53
std::ostringstream oss;
54
G4int
i = 0;
55
do
{
56
oss.str(
""
);
57
oss <<
"g4_"
<< i <<
".XXXFile"
;
58
ifs.open(oss.str().c_str());
59
if
(!ifs)
break
;
// Doesn't exist, so can open a new file.
60
else
ifs.close();
61
++i;
62
}
while
(
true
);
63
fFileName = oss.str();
64
G4cout
<<
"Opening file "
<< fFileName <<
G4endl
;
65
fFile.open(fFileName.c_str());
66
fOpen =
true
;
67
}
68
if
(fFile.good()) fFile << item << std::endl;
69
else
G4cout
<<
"G4XXXFileViewer::FileWriter::WriteItem: ERROR"
<<
G4endl
;
70
}
71
72
G4XXXFileViewer::G4XXXFileViewer
73
(
G4VSceneHandler
& sceneHandler,
const
G4String
&
name
):
74
G4VViewer
(sceneHandler, sceneHandler.
IncrementViewCount
(),
name
)
75
{}
76
77
G4XXXFileViewer::~G4XXXFileViewer
()
78
{
79
fFileWriter
.
Close
();
80
}
81
82
void
G4XXXFileViewer::SetView
() {
83
#ifdef G4XXXFileDEBUG
84
G4cout
<<
"G4XXXFileViewer::SetView() called."
<<
G4endl
;
85
#endif
86
}
87
88
void
G4XXXFileViewer::ClearView
() {
89
#ifdef G4XXXFileDEBUG
90
G4cout
<<
"G4XXXFileViewer::ClearView() called."
<<
G4endl
;
91
#endif
92
fFileWriter
.
Rewind
();
93
}
94
95
void
G4XXXFileViewer::DrawView
() {
96
#ifdef G4XXXFileDEBUG
97
G4cout
<<
"G4XXXFileViewer::DrawView() called."
<<
G4endl
;
98
#endif
99
100
// First, a view should decide when to re-visit the G4 kernel.
101
// Sometimes it might not be necessary, e.g., if the scene is stored
102
// in a graphical database (e.g., OpenGL's display lists) and only
103
// the viewing angle has changed. But graphics systems without a
104
// graphical database will always need to visit the G4 kernel.
105
106
NeedKernelVisit
();
// Default is - always visit G4 kernel.
107
// Note: this routine sets the fNeedKernelVisit flag of *all* the
108
// views of the scene.
109
110
ProcessView
();
// The basic logic is here.
111
112
// Then a view may have more to do, e.g., display the graphical
113
// database. That code should come here...
114
115
// ...before finally...
116
FinishView
();
// Flush streams and/or swap buffers.
117
}
118
119
void
G4XXXFileViewer::ShowView
() {
120
#ifdef G4XXXFileDEBUG
121
G4cout
<<
"G4XXXFileViewer::ShowView() called."
<<
G4endl
;
122
#endif
123
fFileWriter
.
Close
();
124
}
geant4
tree
geant4-10.6-release
source
visualization
XXX
src
G4XXXFileViewer.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:58
using
1.8.2 with
ECCE GitHub integration