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
G4XXXStoredViewer.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4XXXStoredViewer.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 graphics driver with a store/database.
31
//?? Lines beginning like this require specialisation for your driver.
32
33
#include "
G4XXXStoredViewer.hh
"
34
35
#include "
G4VSceneHandler.hh
"
36
#include "
G4XXXStoredSceneHandler.hh
"
37
38
#include <fstream>
39
#include <sstream>
40
41
G4XXXStoredViewer::G4XXXStoredViewer
42
(
G4VSceneHandler
& sceneHandler,
const
G4String
&
name
):
43
G4VViewer
(sceneHandler, sceneHandler.
IncrementViewCount
(),
name
)
44
{}
45
46
G4XXXStoredViewer::~G4XXXStoredViewer
() {}
47
48
void
G4XXXStoredViewer::SetView
() {
49
#ifdef G4XXXStoredDEBUG
50
G4cout
<<
"G4XXXStoredViewer::SetView() called."
<<
G4endl
;
51
#endif
52
}
53
54
void
G4XXXStoredViewer::ClearView
() {
55
#ifdef G4XXXStoredDEBUG
56
G4cout
<<
"G4XXXStoredViewer::ClearView() called."
<<
G4endl
;
57
#endif
58
}
59
60
void
G4XXXStoredViewer::DrawView
() {
61
#ifdef G4XXXStoredDEBUG
62
G4cout
<<
"G4XXXStoredViewer::DrawView() called."
<<
G4endl
;
63
#endif
64
65
// First, a view should decide when to re-visit the G4 kernel.
66
// Sometimes it might not be necessary, e.g., if the scene is stored
67
// in a graphical database (e.g., OpenGL's display lists) and only
68
// the viewing angle has changed. But graphics systems without a
69
// graphical database will always need to visit the G4 kernel.
70
71
// The fNeedKernelVisit flag might have been set by the user in
72
// /vis/viewer/rebuild, but if not, make decision and set flag only
73
// if necessary...
74
if
(!
fNeedKernelVisit
)
KernelVisitDecision
();
75
G4bool
kernelVisitWasNeeded =
fNeedKernelVisit
;
// Keep (ProcessView resets).
76
77
ProcessView
();
// Clears store and processes scene only if necessary.
78
79
if
(kernelVisitWasNeeded) {
80
// Some systems, notably OpenGL, can draw while re-building, so
81
// there might not be a need to draw from store again here. But
82
// in this case...
83
DrawFromStore
();
84
}
else
{
85
DrawFromStore
();
86
}
87
88
// ...before finally...
89
FinishView
();
// Flush streams and/or swap buffers.
90
}
91
92
void
G4XXXStoredViewer::ShowView
() {
93
#ifdef G4XXXStoredDEBUG
94
G4cout
<<
"G4XXXStoredViewer::ShowView() called."
<<
G4endl
;
95
#endif
96
}
97
98
void
G4XXXStoredViewer::KernelVisitDecision
() {
99
100
// If there's a significant difference with the last view parameters
101
// of either the scene handler or this viewer, trigger a rebuild.
102
103
typedef
std::list<G4String> Store;
104
Store& store =
105
static_cast<
G4XXXStoredSceneHandler
&
>
(
fSceneHandler
).fStore;
106
if
(store.empty() ||
CompareForKernelVisit
(
fLastVP
)) {
107
NeedKernelVisit
();
// Sets fNeedKernelVisit.
108
}
109
fLastVP
=
fVP
;
110
}
111
112
G4bool
G4XXXStoredViewer::CompareForKernelVisit
(
G4ViewParameters
& lastVP)
113
{
114
// Typical comparison. Taken from OpenGL.
115
if
(
116
(lastVP.
GetDrawingStyle
() !=
fVP
.
GetDrawingStyle
()) ||
117
(lastVP.
GetNumberOfCloudPoints
() !=
fVP
.
GetNumberOfCloudPoints
()) ||
118
(lastVP.
IsAuxEdgeVisible
() !=
fVP
.
IsAuxEdgeVisible
()) ||
119
(lastVP.
IsCulling
() !=
fVP
.
IsCulling
()) ||
120
(lastVP.
IsCullingInvisible
() !=
fVP
.
IsCullingInvisible
()) ||
121
(lastVP.
IsDensityCulling
() !=
fVP
.
IsDensityCulling
()) ||
122
(lastVP.
IsCullingCovered
() !=
fVP
.
IsCullingCovered
()) ||
123
(lastVP.
GetCBDAlgorithmNumber
() !=
124
fVP
.
GetCBDAlgorithmNumber
()) ||
125
// No need to visit kernel if section plane changes.
126
// No need to visit kernel if cutaway planes change.
127
(lastVP.
IsExplode
() !=
fVP
.
IsExplode
()) ||
128
(lastVP.
GetNoOfSides
() !=
fVP
.
GetNoOfSides
()) ||
129
(lastVP.
IsMarkerNotHidden
() !=
fVP
.
IsMarkerNotHidden
()) ||
130
(lastVP.
GetDefaultVisAttributes
()->
GetColour
() !=
131
fVP
.
GetDefaultVisAttributes
()->
GetColour
()) ||
132
(lastVP.
GetDefaultTextVisAttributes
()->
GetColour
() !=
133
fVP
.
GetDefaultTextVisAttributes
()->
GetColour
()) ||
134
(lastVP.
GetBackgroundColour
()!=
fVP
.
GetBackgroundColour
())||
135
(lastVP.
GetVisAttributesModifiers
() !=
136
fVP
.
GetVisAttributesModifiers
())
137
) {
138
return
true
;
139
}
140
141
if
(lastVP.
IsDensityCulling
() &&
142
(lastVP.
GetVisibleDensity
() !=
fVP
.
GetVisibleDensity
()))
143
return
true
;
144
145
if
(lastVP.
GetCBDAlgorithmNumber
() > 0) {
146
if
(lastVP.
GetCBDParameters
().size() !=
fVP
.
GetCBDParameters
().size())
return
true
;
147
else
if
(lastVP.
GetCBDParameters
() !=
fVP
.
GetCBDParameters
())
return
true
;
148
}
149
150
if
(lastVP.
IsExplode
() &&
151
(lastVP.
GetExplodeFactor
() !=
fVP
.
GetExplodeFactor
()))
152
return
true
;
153
154
return
false
;
155
}
156
157
void
G4XXXStoredViewer::DrawFromStore
() {
158
typedef
std::list<G4String> Store;
159
typedef
std::list<G4String>::iterator StoreIterator;
160
Store& store =
161
static_cast<
G4XXXStoredSceneHandler
&
>
(
fSceneHandler
).fStore;
162
// Write to a file for testing...
163
static
G4int
iCount = 0;
164
std::ostringstream oss;
165
oss <<
fName
<<
'.'
<< iCount++ <<
".out"
;
166
std::ofstream ofs(oss.str().c_str());
167
for
(StoreIterator i = store.begin(); i != store.end(); ++i) {
168
ofs << *i;
169
}
170
ofs.close();
171
}
geant4
tree
geant4-10.6-release
source
visualization
XXX
src
G4XXXStoredViewer.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:58
using
1.8.2 with
ECCE GitHub integration