Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ViewParameters.hh
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// 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
78#include "G4Vector3D.hh"
79#include "G4Point3D.hh"
80#include "G4Plane3D.hh"
81#include "G4VisAttributes.hh"
82#include "G4VMarker.hh"
84
85#include <vector>
86#include <utility>
87
88typedef std::vector<G4Plane3D> G4Planes;
89
91
92public: // With description
93
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
103 cutawayUnion, // Union (addition) of result of each cutaway plane.
104 cutawayIntersection // Intersection (multiplication) " .
105 };
106
108 constrainUpDirection, // Standard, HEP convention.
109 freeRotation // Free, Google-like rotation, using mouse-grab.
110 };
111
112 enum SMROption { // Special Mesh Rendering Option
115 };
116
117 friend std::ostream& operator <<
118 (std::ostream&, DrawingStyle);
119
120 friend std::ostream& operator <<
121 (std::ostream&, SMROption);
122
123 friend std::ostream& operator <<
124 (std::ostream&, const G4ViewParameters&);
125
128
129 // Note: uses default assignment operator and copy constructor.
130
132
133 // Get and Is functions.
143 const std::vector<G4double>& GetCBDParameters () const;
145 const G4Plane3D& GetSectionPlane () const;
148 const G4Planes& GetCutawayPlanes () const;
154 const G4Vector3D& GetUpVector () const;
157 const G4Vector3D& GetScaleFactor () const;
161 const G4Vector3D& GetLightpointDirection () const; // Relative...
163 // ... depending on GetLightsMoveWithCamera.
170 unsigned int GetWindowSizeHintX () const;
171 unsigned int GetWindowSizeHintY () const;
179 // GetXGeometryString is intended to be parsed by XParseGeometry.
180 // It contains the size information, as in GetWindowSizeHint, but
181 // may also contain the window position, e.g., "600x600-0+200. The
182 // viewer should use this in preference to GetWindowSizeHint, since
183 // it contains more information. (The size information in
184 // GetXGeometryString and GetWindowSizeHint is guaranteed to be
185 // identical.)
186 bool IsWindowSizeHintX () const;
187 bool IsWindowSizeHintY () const;
194 const std::vector<G4ModelingParameters::VisAttributesModifier>&
216 const std::vector<G4ModelingParameters::PVNameCopyNo>& GetSpecialMeshVolumes() const;
217
218 // Here Follow functions to evaluate useful quantities as a
219 // function of the radius of the Bounding Extent of the object being
220 // viewed. Call them in the order given - for efficiency, later
221 // functions depend on the results of earlier ones (Store the
222 // results of earlier functions in your own temporary variables -
223 // see, for example, G4OpenGLView::SetView ().)
224 G4double GetCameraDistance (G4double radius) const;
225 G4double GetNearDistance (G4double cameraDistance, G4double radius) const;
226 G4double GetFarDistance (G4double cameraDistance,
227 G4double nearDistance, G4double radius) const;
228 G4double GetFrontHalfHeight (G4double nearDistance, G4double radius) const;
229
230 // Set, Add, Multiply, Increment, Unset and Clear functions.
232 G4int SetNumberOfCloudPoints (G4int); // Returns number actually set.
237 void SetVisibleDensity (G4double visibleDensity);
240 void SetCBDParameters (const std::vector<G4double>&);
241 void SetSectionPlane (const G4Plane3D& sectionPlane);
244 void AddCutawayPlane (const G4Plane3D& cutawayPlane);
245 void ChangeCutawayPlane (size_t index, const G4Plane3D& cutawayPlane);
247 void SetExplodeFactor (G4double explodeFactor);
249 void SetExplodeCentre (const G4Point3D& explodeCentre);
250 G4int SetNoOfSides (G4int nSides); // Returns number actually set.
251 void SetViewpointDirection (const G4Vector3D& viewpointDirection);
252 // Calls the following to get lightpoint direction right too.
253 void SetViewAndLights (const G4Vector3D& viewpointDirection);
254 // Also sets lightpoint direction according to G4bool fLightsMoveWithCamera.
255 void SetUpVector (const G4Vector3D& upVector);
256 void SetFieldHalfAngle (G4double fieldHalfAngle);
257 void SetOrthogonalProjection (); // This and next use SetFieldHalfAngle.
258 void SetPerspectiveProjection(G4double fieldHalfAngle = 30. * CLHEP::deg);
259 void SetZoomFactor (G4double zoomFactor);
260 void MultiplyZoomFactor (G4double zoomFactorMultiplier);
261 void SetScaleFactor (const G4Vector3D& scaleFactor);
262 void MultiplyScaleFactor (const G4Vector3D& scaleFactorMultiplier);
263 void SetCurrentTargetPoint (const G4Point3D& currentTargetPoint);
264 void SetDolly (G4double dolly);
265 void IncrementDolly (G4double dollyIncrement);
266 void SetLightpointDirection (const G4Vector3D& lightpointDirection);
268 void SetPan (G4double right, G4double up);
269 void IncrementPan (G4double right, G4double up);
270 // Increment currentTarget point perpendicular to viewpoint direction.
271 void IncrementPan (G4double right, G4double up, G4double forward);
272 // Increment currentTarget point also along viewpoint direction.
274 void SetDefaultColour (const G4Colour&); // Uses SetDefaultVisAttributes.
276 void SetDefaultTextColour (const G4Colour&); // SetDefaultTextVisAttributes.
277 void SetDefaultMarker (const G4VMarker& defaultMarker);
278 void SetGlobalMarkerScale (G4double globalMarkerScale);
279 void SetGlobalLineWidthScale (G4double globalLineWidthScale);
282 void SetWindowSizeHint (G4int xHint, G4int yHint);
283 void SetWindowLocationHint (G4int xHint, G4int yHint);
284 void SetXGeometryString (const G4String&);
311 void SetSpecialMeshVolumes (const std::vector<G4ModelingParameters::PVNameCopyNo>&);
312
313 // Command dumping functions.
314 // For camera commands we need to provide the standard target point from
315 // the current scene.
316 G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const;
321
322 // Other functions.
323 void PrintDifferences (const G4ViewParameters& v) const;
324
325 // Interpolation
326 // Returns a null pointer when no more to be done. For example:
327 // do {
328 // G4ViewParameters* vp =
329 // G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
330 // if (!vp) break;
331 // ...
332 // } while (true);
333 // Assumes equal intervals
335 (const std::vector<G4ViewParameters>& views,
336 G4int nInterpolationPoints = 50); // No of interpolations points per interval
337
338private:
339
340 G4int ParseGeometry ( const char *string, G4int *x, G4int *y, unsigned int *width, unsigned int *height);
341 G4int ReadInteger(char *string, char **NextString);
342
343 DrawingStyle fDrawingStyle; // Drawing style.
344 G4int fNumberOfCloudPoints; // For drawing in cloud style.
345 // <= 0 means use viewer default.
346 G4bool fAuxEdgeVisible; // Auxiliary edge visibility.
347 G4bool fCulling; // Culling requested.
348 G4bool fCullInvisible; // Cull (don't Draw) invisible objects.
349 G4bool fDensityCulling; // Density culling requested. If so...
350 G4double fVisibleDensity; // ...density lower than this not drawn.
351 G4bool fCullCovered; // Cull daughters covered by opaque mothers.
352 G4int fCBDAlgorithmNumber; // Colour by density algorithm number.
353 std::vector<G4double> fCBDParameters; // Colour by density parameters.
354 G4bool fSection; // Section drawing requested (DCUT in GEANT3).
355 G4Plane3D fSectionPlane; // Cut plane for section drawing (DCUT).
356 CutawayMode fCutawayMode; // Cutaway mode.
357 G4Planes fCutawayPlanes; // Set of planes used for cutaway.
358 G4double fExplodeFactor; // Explode along radius by this factor...
359 G4Point3D fExplodeCentre; // ...about this centre.
360 G4int fNoOfSides; // ...if polygon approximates circle.
361 G4Vector3D fViewpointDirection;
362 G4Vector3D fUpVector; // Up vector. (Warning: MUST NOT be parallel
363 // to fViewpointDirection!)
364 G4double fFieldHalfAngle; // Radius / camara distance, 0 for parallel.
365 G4double fZoomFactor; // Magnification relative to Standard View.
366 G4Vector3D fScaleFactor; // (Non-uniform) scale/magnification factor.
367 G4Point3D fCurrentTargetPoint; // Relative to standard target point.
368 G4double fDolly; // Distance towards current target point.
369 G4bool fLightsMoveWithCamera;
370 G4Vector3D fRelativeLightpointDirection;
371 // i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
372 G4Vector3D fActualLightpointDirection;
373 G4VisAttributes fDefaultVisAttributes;
374 G4VisAttributes fDefaultTextVisAttributes;
375 G4VMarker fDefaultMarker;
376 G4double fGlobalMarkerScale;
377 G4double fGlobalLineWidthScale;
378 G4bool fMarkerNotHidden;
379 // True if transients are to be drawn and not hidden by
380 // hidden-line-hidden-surface removal algorithms, e.g., z-buffer
381 // testing; false if they are to be hidden-line-hidden-surface
382 // removed.
383 G4int fWindowSizeHintX; // Size hints for pixel-based window systems.
384 G4int fWindowSizeHintY;
385 G4int fWindowLocationHintX; // Location hints for pixel-based window systems.
386 G4int fWindowLocationHintY;
387 G4bool fWindowLocationHintXNegative; // Reference of location hints for pixel-based window systems.
388 G4bool fWindowLocationHintYNegative;
389 G4String fXGeometryString; // If non-null, geometry string for X Windows.
390 G4int fGeometryMask; // Corresponding mask.
391 G4bool fAutoRefresh; // ...after change of view parameters.
392 G4Colour fBackgroundColour;
393 G4bool fPicking; // Request picking.
394 RotationStyle fRotationStyle; // Rotation style.
395 std::vector<G4ModelingParameters::VisAttributesModifier> fVisAttributesModifiers;
396 G4double fStartTime, fEndTime; // Time range (e.g., for trajectory steps).
397 G4double fFadeFactor; // 0: no fade; 1: maximum fade with time within range.
398 G4bool fDisplayHeadTime; // Display head time (fEndTime) in 2D text.
399 G4double fDisplayHeadTimeX, fDisplayHeadTimeY; // 2D screen coords.
400 G4double fDisplayHeadTimeSize; // Screen size.
401 G4double fDisplayHeadTimeRed, fDisplayHeadTimeGreen, fDisplayHeadTimeBlue;
402 G4bool fDisplayLightFront;// Display light front at head time originating at
403 G4double fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ,
404 fDisplayLightFrontT;
405 G4double fDisplayLightFrontRed, fDisplayLightFrontGreen, fDisplayLightFrontBlue;
406 G4bool fSpecialMeshRendering; // Request special rendering of parameterised volumes
407 SMROption fSpecialMeshRenderingOption; // Special rendering option
408 std::vector<G4ModelingParameters::PVNameCopyNo> fSpecialMeshVolumes; // If empty, all meshes.
409
410 enum { // Constants for geometry mask in ParseGeometry and related functions.
411 fNoValue = 0,
412 fXValue = 0x0001,
413 fYValue = 0x0002,
414 fWidthValue = 0x0004,
415 fHeightValue = 0x0008,
416 fAllValues = 0x000F,
417 fXNegative = 0x0010,
418 fYNegative = 0x0020
419 };
420};
421
422#include "G4ViewParameters.icc"
423
424#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::vector< G4Plane3D > G4Planes
void SetCBDParameters(const std::vector< G4double > &)
bool IsWindowLocationHintY() const
G4int GetWindowLocationHintX() const
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetScaleFactor(const G4Vector3D &scaleFactor)
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
G4int SetNumberOfCloudPoints(G4int)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4int SetNoOfSides(G4int nSides)
void SetViewAndLights(const G4Vector3D &viewpointDirection)
const G4Vector3D & GetScaleFactor() const
G4double GetDisplayLightFrontX() const
void SetAutoRefresh(G4bool)
void SetBackgroundColour(const G4Colour &)
const G4String & GetXGeometryString() const
void SetGlobalMarkerScale(G4double globalMarkerScale)
void SetExplodeCentre(const G4Point3D &explodeCentre)
void SetDisplayLightFrontY(G4double)
G4bool IsDisplayHeadTime() const
G4double GetDisplayHeadTimeSize() const
G4int GetNoOfSides() const
G4bool IsSpecialMeshRendering() const
G4double GetDisplayHeadTimeBlue() const
G4int GetWindowAbsoluteLocationHintY(G4int) const
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
CutawayMode GetCutawayMode() const
G4double GetDisplayHeadTimeY() const
G4double GetCameraDistance(G4double radius) const
bool IsWindowLocationHintX() const
G4double GetExplodeFactor() const
void PrintDifferences(const G4ViewParameters &v) const
G4int GetNumberOfCloudPoints() const
void SetSpecialMeshRenderingOption(SMROption)
G4bool IsMarkerNotHidden() const
void SetDisplayHeadTimeBlue(G4double)
void SetVisibleDensity(G4double visibleDensity)
unsigned int GetWindowSizeHintX() const
G4double GetGlobalLineWidthScale() const
void SetPerspectiveProjection(G4double fieldHalfAngle=30. *CLHEP::deg)
G4bool IsCutaway() const
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4Vector3D & GetActualLightpointDirection()
void SetDefaultColour(const G4Colour &)
void SetCulling(G4bool)
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
void SetDisplayLightFrontT(G4double)
void UnsetSectionPlane()
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
bool IsWindowSizeHintX() const
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetLightpointDirection() const
void SetDefaultTextColour(const G4Colour &)
void SetDisplayHeadTimeX(G4double)
void SetXGeometryString(const G4String &)
void SetDefaultVisAttributes(const G4VisAttributes &)
void SetFieldHalfAngle(G4double fieldHalfAngle)
void SetCullingCovered(G4bool)
const G4Vector3D & GetViewpointDirection() const
void ClearCutawayPlanes()
G4bool IsSection() const
void SetExplodeFactor(G4double explodeFactor)
G4double GetDisplayHeadTimeX() const
void SetGlobalLineWidthScale(G4double globalLineWidthScale)
const G4Point3D & GetCurrentTargetPoint() const
G4double GetDisplayLightFrontRed() const
G4bool IsPicking() const
void SetCBDAlgorithmNumber(G4int)
void SetStartTime(G4double)
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
void SetSpecialMeshVolumes(const std::vector< G4ModelingParameters::PVNameCopyNo > &)
void SetPicking(G4bool)
G4double GetFieldHalfAngle() const
bool IsWindowSizeHintY() const
void SetDisplayLightFrontBlue(G4double)
G4bool IsCulling() const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
void SetMarkerHidden()
void SetDisplayHeadTime(G4bool)
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4double GetZoomFactor() const
void SetDolly(G4double dolly)
void SetDisplayHeadTimeY(G4double)
void SetDensityCulling(G4bool)
void SetOrthogonalProjection()
G4int GetWindowAbsoluteLocationHintX(G4int) const
G4bool IsExplode() const
void SetDisplayLightFrontZ(G4double)
G4String SceneModifyingCommands() const
const G4VMarker & GetDefaultMarker() const
G4double GetStartTime() const
G4double GetDisplayLightFrontBlue() const
void SetWindowSizeHint(G4int xHint, G4int yHint)
void SetDefaultMarker(const G4VMarker &defaultMarker)
void IncrementPan(G4double right, G4double up)
void SetDisplayLightFront(G4bool)
void SetWindowLocationHint(G4int xHint, G4int yHint)
void SetDisplayLightFrontRed(G4double)
const G4Vector3D & GetUpVector() const
void SetDisplayHeadTimeSize(G4double)
G4String TimeWindowCommands() const
G4String TouchableCommands() const
void SetMarkerNotHidden()
const std::vector< G4double > & GetCBDParameters() const
void SetDisplayHeadTimeRed(G4double)
G4int GetCBDAlgorithmNumber() const
G4double GetEndTime() const
G4double GetDisplayLightFrontZ() const
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4double GetFadeFactor() const
G4double GetDisplayHeadTimeRed() const
G4double GetGlobalMarkerScale() const
G4bool IsCullingInvisible() const
void SetZoomFactor(G4double zoomFactor)
void UnsetExplodeFactor()
G4double GetDisplayLightFrontT() const
const G4VisAttributes * GetDefaultVisAttributes() const
void SetCullingInvisible(G4bool)
void SetUpVector(const G4Vector3D &upVector)
G4double GetDisplayLightFrontY() const
void SetEndTime(G4double)
void SetPan(G4double right, G4double up)
G4bool IsDisplayLightFront() const
G4bool IsWindowLocationHintXNegative() const
void SetFadeFactor(G4double)
G4bool IsWindowLocationHintYNegative() const
const G4Planes & GetCutawayPlanes() const
RotationStyle GetRotationStyle() const
G4int GetWindowLocationHintY() const
void SetCutawayMode(CutawayMode)
G4double GetDisplayHeadTimeGreen() const
void SetSpecialMeshRendering(G4bool)
G4bool IsDensityCulling() const
void SetDefaultTextVisAttributes(const G4VisAttributes &)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetDisplayLightFrontX(G4double)
void SetLightsMoveWithCamera(G4bool moves)
void SetDisplayHeadTimeGreen(G4double)
G4double GetDisplayLightFrontGreen() const
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
G4String DrawingStyleCommands() const
void SetRotationStyle(RotationStyle)
G4bool IsAutoRefresh() const
G4double GetVisibleDensity() const
SMROption GetSpecialMeshRenderingOption() const
unsigned int GetWindowSizeHintY() const
G4bool operator!=(const G4ViewParameters &) const
G4bool GetLightsMoveWithCamera() const
void IncrementDolly(G4double dollyIncrement)
void SetSectionPlane(const G4Plane3D &sectionPlane)
void SetAuxEdgeVisible(G4bool)
void SetDisplayLightFrontGreen(G4double)
const G4Point3D & GetExplodeCentre() const
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
DrawingStyle GetDrawingStyle() const
void ClearVisAttributesModifiers()
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
G4bool IsAuxEdgeVisible() const
G4double GetDolly() const