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
G4ViewParameters.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ViewParameters.hh
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 19th July 1996
30
//
31
// Class description
32
//
33
// View parameters and options.
34
//
35
// THE STANDARD VIEW AND ALL THAT.
36
//
37
// In GEANT4 visualization, we have the concept of a "Standard
38
// View". This is the view when the complete set of objects being
39
// viewed is comfortably in view from any viewpoint. It is defined by
40
// the "Bounding Extent" of "visible" objects when initially
41
// registered in the scene, and by the View Parameters.
42
//
43
// There is also the "Standard Target Point", which is the centre of
44
// the Bounding Extent (note that this belongs to the scene and is
45
// stored in the G4Scene object). The "Current Target Point", defined
46
// relative to the Standard Target Point, is changed by the
47
// "dolly" and "zoom" commands, and can be reset to the Standard
48
// Target Point with the "/vis/viewer/reset" command.
49
//
50
// Also, the "Standard Camera Position" is the "Standard Camera
51
// Distance" along the Viewpoint Direction vector from the Standard
52
// Target Point. The Standard Camera Distance is the radius of the
53
// Bounding Extent divided by fFieldHalfAngle. It is not stored
54
// explicitly because of the singularity at fFieldHalfAngle = 0,
55
// which implies parallel projection.
56
//
57
// Similarly, the "Current Camera Position" is the "Current Camera
58
// Distance" along the Viewpoint Direction vector from the Current
59
// Target Point. The Current Camera Distance is given by the formulae
60
// below, but note that it can be negative, meaning that the camera
61
// has moved *beyond* the Current Target Point, which is
62
// conceptually possible, but which might give some problems when
63
// setting up the view matrix - see, for example, G4OpenGLView::SetView ().
64
//
65
// All viewers are expected to keep the "Up Vector" vertical unless
66
// RotationStyle is freeRotation.
67
//
68
// Finally, the view is magnified by the "Zoom Factor" which is
69
// reset to 1 by the "/vis/viewer/reset" command.
70
//
71
// The algorithms for calculating various useful quantities from the
72
// View Parameters, such as GetCameraDistance, are described below.
73
74
#ifndef G4VIEWPARAMETERS_HH
75
#define G4VIEWPARAMETERS_HH
76
77
#include <
CLHEP/Units/SystemOfUnits.h
>
78
#include "
G4Vector3D.hh
"
79
#include "
G4Point3D.hh
"
80
#include "
G4Plane3D.hh
"
81
#include "
G4VisAttributes.hh
"
82
#include "
G4VMarker.hh
"
83
#include "
G4ModelingParameters.hh
"
84
85
#include <vector>
86
#include <utility>
87
88
typedef
std::vector<G4Plane3D>
G4Planes
;
89
90
class
G4ViewParameters
{
91
92
public
:
// With description
93
94
enum
DrawingStyle
{
95
wireframe
,
// Draw edges - no hidden line removal.
96
hlr
,
// Draw edges - hidden lines removed.
97
hsr
,
// Draw surfaces - hidden surfaces removed.
98
hlhsr
,
// Draw surfaces and edges - hidden removed.
99
cloud
// Draw volume as a cloud of dots.
100
};
101
102
enum
CutawayMode
{
103
cutawayUnion
,
// Union (addition) of result of each cutaway plane.
104
cutawayIntersection
// Intersection (multiplication) " .
105
};
106
107
enum
RotationStyle
{
108
constrainUpDirection
,
// Standard, HEP convention.
109
freeRotation
// Free, Google-like rotation, using mouse-grab.
110
};
111
112
friend
std::ostream&
operator
<<
113
(std::ostream&,
const
DrawingStyle
&);
114
115
friend
std::ostream&
operator
<<
116
(std::ostream&,
const
G4ViewParameters
&);
117
118
G4ViewParameters
();
119
~G4ViewParameters
();
120
121
// Note: uses default assignment operator and copy constructor.
122
123
G4bool
operator !=
(
const
G4ViewParameters
&)
const
;
124
125
// Get and Is functions.
126
DrawingStyle
GetDrawingStyle
()
const
;
127
G4int
GetNumberOfCloudPoints
()
const
;
128
G4bool
IsAuxEdgeVisible
()
const
;
129
G4bool
IsCulling
()
const
;
130
G4bool
IsCullingInvisible
()
const
;
131
G4bool
IsDensityCulling
()
const
;
132
G4double
GetVisibleDensity
()
const
;
133
G4bool
IsCullingCovered
()
const
;
134
G4int
GetCBDAlgorithmNumber
()
const
;
135
const
std::vector<G4double>&
GetCBDParameters
()
const
;
136
G4bool
IsSection
()
const
;
137
const
G4Plane3D
&
GetSectionPlane
()
const
;
138
G4bool
IsCutaway
()
const
;
139
CutawayMode
GetCutawayMode
()
const
;
140
const
G4Planes
&
GetCutawayPlanes
()
const
;
141
G4bool
IsExplode
()
const
;
142
G4double
GetExplodeFactor
()
const
;
143
const
G4Point3D
&
GetExplodeCentre
()
const
;
144
G4int
GetNoOfSides
()
const
;
145
const
G4Vector3D
&
GetViewpointDirection
()
const
;
146
const
G4Vector3D
&
GetUpVector
()
const
;
147
G4double
GetFieldHalfAngle
()
const
;
148
G4double
GetZoomFactor
()
const
;
149
const
G4Vector3D
&
GetScaleFactor
()
const
;
150
const
G4Point3D
&
GetCurrentTargetPoint
()
const
;
151
G4double
GetDolly
()
const
;
152
G4bool
GetLightsMoveWithCamera
()
const
;
153
const
G4Vector3D
&
GetLightpointDirection
()
const
;
// Relative...
154
G4Vector3D
&
GetActualLightpointDirection
();
// Actual...
155
// ... depending on GetLightsMoveWithCamera.
156
const
G4VisAttributes
*
GetDefaultVisAttributes
()
const
;
157
const
G4VisAttributes
*
GetDefaultTextVisAttributes
()
const
;
158
const
G4VMarker
&
GetDefaultMarker
()
const
;
159
G4double
GetGlobalMarkerScale
()
const
;
160
G4double
GetGlobalLineWidthScale
()
const
;
161
G4bool
IsMarkerNotHidden
()
const
;
162
unsigned
int
GetWindowSizeHintX
()
const
;
163
unsigned
int
GetWindowSizeHintY
()
const
;
164
G4int
GetWindowAbsoluteLocationHintX
(
G4int
)
const
;
165
G4int
GetWindowAbsoluteLocationHintY
(
G4int
)
const
;
166
G4int
GetWindowLocationHintX
()
const
;
167
G4int
GetWindowLocationHintY
()
const
;
168
const
G4String
&
GetXGeometryString
()
const
;
169
// GetXGeometryString is intended to be parsed by XParseGeometry.
170
// It contains the size information, as in GetWindowSizeHint, but
171
// may also contain the window position, e.g., "600x600-0+200. The
172
// viewer should use this in preference to GetWindowSizeHint, since
173
// it contains more information. (The size information in
174
// GetXGeometryString and GetWindowSizeHint is guaranteed to be
175
// identical.)
176
bool
IsWindowSizeHintX
()
const
;
177
bool
IsWindowSizeHintY
()
const
;
178
bool
IsWindowLocationHintX
()
const
;
179
bool
IsWindowLocationHintY
()
const
;
180
G4bool
IsAutoRefresh
()
const
;
181
const
G4Colour
&
GetBackgroundColour
()
const
;
182
G4bool
IsPicking
()
const
;
183
RotationStyle
GetRotationStyle
()
const
;
184
const
std::vector<G4ModelingParameters::VisAttributesModifier>&
185
GetVisAttributesModifiers
()
const
;
186
G4double
GetStartTime
()
const
;
187
G4double
GetEndTime
()
const
;
188
G4double
GetFadeFactor
()
const
;
189
G4bool
IsDisplayHeadTime
()
const
;
190
G4double
GetDisplayHeadTimeX
()
const
;
191
G4double
GetDisplayHeadTimeY
()
const
;
192
G4double
GetDisplayHeadTimeSize
()
const
;
193
G4double
GetDisplayHeadTimeRed
()
const
;
194
G4double
GetDisplayHeadTimeGreen
()
const
;
195
G4double
GetDisplayHeadTimeBlue
()
const
;
196
G4bool
IsDisplayLightFront
()
const
;
197
G4double
GetDisplayLightFrontX
()
const
;
198
G4double
GetDisplayLightFrontY
()
const
;
199
G4double
GetDisplayLightFrontZ
()
const
;
200
G4double
GetDisplayLightFrontT
()
const
;
201
G4double
GetDisplayLightFrontRed
()
const
;
202
G4double
GetDisplayLightFrontGreen
()
const
;
203
G4double
GetDisplayLightFrontBlue
()
const
;
204
205
// Here Follow functions to evaluate useful quantities as a
206
// function of the radius of the Bounding Extent of the object being
207
// viewed. Call them in the order given - for efficiency, later
208
// functions depend on the results of earlier ones (Store the
209
// results of earlier functions in your own temporary variables -
210
// see, for example, G4OpenGLView::SetView ().)
211
G4double
GetCameraDistance
(
G4double
radius
)
const
;
212
G4double
GetNearDistance
(
G4double
cameraDistance,
G4double
radius
)
const
;
213
G4double
GetFarDistance
(
G4double
cameraDistance,
214
G4double
nearDistance,
G4double
radius
)
const
;
215
G4double
GetFrontHalfHeight
(
G4double
nearDistance,
G4double
radius
)
const
;
216
217
// Set, Add, Multiply, Increment, Unset and Clear functions.
218
void
SetDrawingStyle
(
G4ViewParameters::DrawingStyle
style);
219
G4int
SetNumberOfCloudPoints
(
G4int
);
// Returns number actually set.
220
void
SetAuxEdgeVisible
(
G4bool
);
221
void
SetCulling
(
G4bool
);
222
void
SetCullingInvisible
(
G4bool
);
223
void
SetDensityCulling
(
G4bool
);
224
void
SetVisibleDensity
(
G4double
visibleDensity);
225
void
SetCullingCovered
(
G4bool
);
226
void
SetCBDAlgorithmNumber
(
G4int
);
227
void
SetCBDParameters
(
const
std::vector<G4double>&);
228
void
SetSectionPlane
(
const
G4Plane3D
& sectionPlane);
229
void
UnsetSectionPlane
();
230
void
SetCutawayMode
(
CutawayMode
);
231
void
AddCutawayPlane
(
const
G4Plane3D
& cutawayPlane);
232
void
ChangeCutawayPlane
(
size_t
index,
const
G4Plane3D
& cutawayPlane);
233
void
ClearCutawayPlanes
();
234
void
SetExplodeFactor
(
G4double
explodeFactor);
235
void
UnsetExplodeFactor
();
236
void
SetExplodeCentre
(
const
G4Point3D
& explodeCentre);
237
G4int
SetNoOfSides
(
G4int
nSides);
// Returns number actually set.
238
void
SetViewpointDirection
(
const
G4Vector3D
& viewpointDirection);
239
// Calls the following to get lightpoint direction right too.
240
void
SetViewAndLights
(
const
G4Vector3D
& viewpointDirection);
241
// Also sets lightpoint direction according to G4bool fLightsMoveWithCamera.
242
void
SetUpVector
(
const
G4Vector3D
& upVector);
243
void
SetFieldHalfAngle
(
G4double
fieldHalfAngle);
244
void
SetOrthogonalProjection
();
// This and next use SetFieldHalfAngle.
245
void
SetPerspectiveProjection
(
G4double
fieldHalfAngle = 30. *
CLHEP::deg
);
246
void
SetZoomFactor
(
G4double
zoomFactor);
247
void
MultiplyZoomFactor
(
G4double
zoomFactorMultiplier);
248
void
SetScaleFactor
(
const
G4Vector3D
& scaleFactor);
249
void
MultiplyScaleFactor
(
const
G4Vector3D
& scaleFactorMultiplier);
250
void
SetCurrentTargetPoint
(
const
G4Point3D
& currentTargetPoint);
251
void
SetDolly
(
G4double
dolly);
252
void
IncrementDolly
(
G4double
dollyIncrement);
253
void
SetLightpointDirection
(
const
G4Vector3D
& lightpointDirection);
254
void
SetLightsMoveWithCamera
(
G4bool
moves);
255
void
SetPan
(
G4double
right
,
G4double
up);
256
void
IncrementPan
(
G4double
right
,
G4double
up);
257
// Increment currentTarget point perpendicular to viewpoint direction.
258
void
IncrementPan
(
G4double
right
,
G4double
up,
G4double
forward
);
259
// Increment currentTarget point also along viewpoint direction.
260
void
SetDefaultVisAttributes
(
const
G4VisAttributes
&);
261
void
SetDefaultColour
(
const
G4Colour
&);
// Uses SetDefaultVisAttributes.
262
void
SetDefaultTextVisAttributes
(
const
G4VisAttributes
&);
263
void
SetDefaultTextColour
(
const
G4Colour
&);
// SetDefaultTextVisAttributes.
264
void
SetDefaultMarker
(
const
G4VMarker
& defaultMarker);
265
void
SetGlobalMarkerScale
(
G4double
globalMarkerScale);
266
void
SetGlobalLineWidthScale
(
G4double
globalLineWidthScale);
267
void
SetMarkerHidden
();
268
void
SetMarkerNotHidden
();
269
void
SetWindowSizeHint
(
G4int
xHint,
G4int
yHint);
270
void
SetWindowLocationHint
(
G4int
xHint,
G4int
yHint);
271
void
SetXGeometryString
(
const
G4String
&);
272
void
SetAutoRefresh
(
G4bool
);
273
void
SetBackgroundColour
(
const
G4Colour
&);
274
void
SetPicking
(
G4bool
);
275
void
SetRotationStyle
(
RotationStyle
);
276
void
ClearVisAttributesModifiers
();
277
void
AddVisAttributesModifier
(
const
G4ModelingParameters::VisAttributesModifier
&);
278
void
SetStartTime
(
G4double
);
279
void
SetEndTime
(
G4double
);
280
void
SetFadeFactor
(
G4double
);
281
void
SetDisplayHeadTime
(
G4bool
);
282
void
SetDisplayHeadTimeX
(
G4double
);
283
void
SetDisplayHeadTimeY
(
G4double
);
284
void
SetDisplayHeadTimeSize
(
G4double
);
285
void
SetDisplayHeadTimeRed
(
G4double
);
286
void
SetDisplayHeadTimeGreen
(
G4double
);
287
void
SetDisplayHeadTimeBlue
(
G4double
);
288
void
SetDisplayLightFront
(
G4bool
);
289
void
SetDisplayLightFrontX
(
G4double
);
290
void
SetDisplayLightFrontY
(
G4double
);
291
void
SetDisplayLightFrontZ
(
G4double
);
292
void
SetDisplayLightFrontT
(
G4double
);
293
void
SetDisplayLightFrontRed
(
G4double
);
294
void
SetDisplayLightFrontGreen
(
G4double
);
295
void
SetDisplayLightFrontBlue
(
G4double
);
296
297
// Command dumping functions.
298
// For camera commands we need to provide the standard target point from
299
// the current scene.
300
G4String
CameraAndLightingCommands
(
const
G4Point3D
standardTargetPoint)
const
;
301
G4String
DrawingStyleCommands
()
const
;
302
G4String
SceneModifyingCommands
()
const
;
303
G4String
TouchableCommands
()
const
;
304
G4String
TimeWindowCommands
()
const
;
305
306
// Other functions.
307
void
PrintDifferences
(
const
G4ViewParameters
&
v
)
const
;
308
309
// Interpolation
310
// Returns a null pointer when no more to be done. For example:
311
// do {
312
// G4ViewParameters* vp =
313
// G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
314
// if (!vp) break;
315
// ...
316
// } while (true);
317
// Assumes equal intervals
318
static
G4ViewParameters
*
CatmullRomCubicSplineInterpolation
319
(
const
std::vector<G4ViewParameters>& views,
320
G4int
nInterpolationPoints = 50);
// No of interpolations points per interval
321
322
private
:
323
324
G4int
ParseGeometry
(
const
char
*
string
,
G4int
*
x
,
G4int
*
y
,
unsigned
int
*width,
unsigned
int
*height);
325
G4int
ReadInteger
(
char
*
string
,
char
**NextString);
326
327
DrawingStyle
fDrawingStyle
;
// Drawing style.
328
G4int
fNumberOfCloudPoints
;
// For drawing in cloud style.
329
// <= 0 means use viewer default.
330
G4bool
fAuxEdgeVisible
;
// Auxiliary edge visibility.
331
G4bool
fCulling
;
// Culling requested.
332
G4bool
fCullInvisible
;
// Cull (don't Draw) invisible objects.
333
G4bool
fDensityCulling
;
// Density culling requested. If so...
334
G4double
fVisibleDensity
;
// ...density lower than this not drawn.
335
G4bool
fCullCovered
;
// Cull daughters covered by opaque mothers.
336
G4int
fCBDAlgorithmNumber
;
// Colour by density algorithm number.
337
std::vector<G4double>
fCBDParameters
;
// Colour by density parameters.
338
G4bool
fSection
;
// Section drawing requested (DCUT in GEANT3).
339
G4Plane3D
fSectionPlane
;
// Cut plane for section drawing (DCUT).
340
CutawayMode
fCutawayMode
;
// Cutaway mode.
341
G4Planes
fCutawayPlanes
;
// Set of planes used for cutaway.
342
G4double
fExplodeFactor
;
// Explode along radius by this factor...
343
G4Point3D
fExplodeCentre
;
// ...about this centre.
344
G4int
fNoOfSides
;
// ...if polygon approximates circle.
345
G4Vector3D
fViewpointDirection
;
346
G4Vector3D
fUpVector
;
// Up vector. (Warning: MUST NOT be parallel
347
// to fViewpointDirection!)
348
G4double
fFieldHalfAngle
;
// Radius / camara distance, 0 for parallel.
349
G4double
fZoomFactor
;
// Magnification relative to Standard View.
350
G4Vector3D
fScaleFactor
;
// (Non-uniform) scale/magnification factor.
351
G4Point3D
fCurrentTargetPoint
;
// Relative to standard target point.
352
G4double
fDolly
;
// Distance towards current target point.
353
G4bool
fLightsMoveWithCamera
;
354
G4Vector3D
fRelativeLightpointDirection
;
355
// i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
356
G4Vector3D
fActualLightpointDirection
;
357
G4VisAttributes
fDefaultVisAttributes
;
358
G4VisAttributes
fDefaultTextVisAttributes
;
359
G4VMarker
fDefaultMarker
;
360
G4double
fGlobalMarkerScale
;
361
G4double
fGlobalLineWidthScale
;
362
G4bool
fMarkerNotHidden
;
363
// True if transients are to be drawn and not hidden by
364
// hidden-line-hidden-surface removal algorithms, e.g., z-buffer
365
// testing; false if they are to be hidden-line-hidden-surface
366
// removed.
367
G4int
fWindowSizeHintX
;
// Size hints for pixel-based window systems.
368
G4int
fWindowSizeHintY
;
369
G4int
fWindowLocationHintX
;
// Location hints for pixel-based window systems.
370
G4int
fWindowLocationHintY
;
371
G4bool
fWindowLocationHintXNegative
;
// Reference of location hints for pixel-based window systems.
372
G4bool
fWindowLocationHintYNegative
;
373
G4String
fXGeometryString
;
// If non-null, geometry string for X Windows.
374
G4int
fGeometryMask
;
// Corresponding mask.
375
G4bool
fAutoRefresh
;
// ...after change of view parameters.
376
G4Colour
fBackgroundColour
;
377
G4bool
fPicking
;
// Request picking.
378
RotationStyle
fRotationStyle
;
// Rotation style.
379
std::vector<G4ModelingParameters::VisAttributesModifier>
fVisAttributesModifiers
;
380
G4double
fStartTime
,
fEndTime
;
// Time range (e.g., for trajectory steps).
381
G4double
fFadeFactor
;
// 0: no fade; 1: maximum fade with time within range.
382
G4bool
fDisplayHeadTime
;
// Display head time (fEndTime) in 2D text.
383
G4double
fDisplayHeadTimeX
,
fDisplayHeadTimeY
;
// 2D screen coords.
384
G4double
fDisplayHeadTimeSize
;
// Screen size.
385
G4double
fDisplayHeadTimeRed
,
fDisplayHeadTimeGreen
,
fDisplayHeadTimeBlue
;
386
G4bool
fDisplayLightFront
;
// Display light front at head time originating at
387
G4double
fDisplayLightFrontX
,
fDisplayLightFrontY
,
fDisplayLightFrontZ
,
388
fDisplayLightFrontT
;
389
G4double
fDisplayLightFrontRed
,
fDisplayLightFrontGreen
,
fDisplayLightFrontBlue
;
390
391
enum
{
// Constants for geometry mask in ParseGeometry and related functions.
392
fNoValue
= 0,
393
fXValue
= 0x0001,
394
fYValue
= 0x0002,
395
fWidthValue
= 0x0004,
396
fHeightValue
= 0x0008,
397
fAllValues
= 0x000F,
398
fXNegative
= 0x0010,
399
fYNegative
= 0x0020
400
};
401
};
402
403
#include "G4ViewParameters.icc"
404
405
#endif
geant4
tree
geant4-10.6-release
source
visualization
management
include
G4ViewParameters.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:55
using
1.8.2 with
ECCE GitHub integration