Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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// $Id$
28//
29//
30// John Allison 19th July 1996
31//
32// Class description
33//
34// View parameters and options.
35//
36// THE STANDARD VIEW AND ALL THAT.
37//
38// In GEANT4 visualization, we have the concept of a "Standard
39// View". This is the view when the complete set of objects being
40// viewed is comfortably in view from any viewpoint. It is defined by
41// the "Bounding Sphere" of "visible" objects when initially
42// registered in the scene, and by the View Parameters.
43//
44// There is also the "Standard Target Point", which is the centre of
45// the Bounding Sphere (note that this belongs to the scene and is
46// stored in the G4Scene object). The "Current Target Point", defined
47// relative to the Standard Target Point, is changed by the
48// "dolly" and "zoom" commands, and can be reset to the Standard
49// Target Point with the "/vis/viewer/reset" command.
50//
51// Also, the "Standard Camera Position" is the "Standard Camera
52// Distance" along the Viewpoint Direction vector from the Standard
53// Target Point. The Standard Camera Distance is the radius of the
54// Bounding Sphere divided by fFieldHalfAngle. It is not stored
55// explicitly because of the singularity at fFieldHalfAngle = 0,
56// which implies parallel projection.
57//
58// Similarly, the "Current Camera Position" is the "Current Camera
59// Distance" along the Viewpoint Direction vector from the Current
60// Target Point. The Current Camera Distance is given by the formulae
61// below, but note that it can be negative, meaning that the camera
62// has moved *beyond* the Current Target Point, which is
63// conceptually possible, but which might give some problems when
64// setting up the view matrix - see, for example, G4OpenGLView::SetView ().
65//
66// All viewers are expected to keep the "Up Vector" vertical.
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 };
100
101 enum RepStyle {
102 polyhedron, // Use G4Polyhedron.
103 nurbs // Use G4NURBS.
104 };
105
107 cutawayUnion, // Union (addition) of result of each cutaway plane.
108 cutawayIntersection // Intersection (multiplication) " .
109 };
110
112 constrainUpDirection, // Standard, HEP convention.
113 freeRotation // Free, Google-like rotation, using mouse-grab.
114 };
115
116 friend std::ostream& operator << (std::ostream&,
117 const DrawingStyle&);
118
119 friend std::ostream& operator << (std::ostream&,
120 const G4ViewParameters&);
121
124
125 // Note: uses default assignment operator and copy constructor.
126
128
129 // Get and Is functions.
139 const G4Plane3D& GetSectionPlane () const;
142 const G4Planes& GetCutawayPlanes () const;
148 const G4Vector3D& GetUpVector () const;
151 const G4Vector3D& GetScaleFactor () const;
155 const G4Vector3D& GetLightpointDirection () const; // Relative...
157 // ... depending on GetLightsMoveWithCamera.
164 unsigned int GetWindowSizeHintX () const;
165 unsigned int GetWindowSizeHintY () const;
171 // GetXGeometryString is intended to be parsed by XParseGeometry.
172 // It contains the size information, as in GetWindowSizeHint, but
173 // may also contain the window position, e.g., "600x600-0+200. The
174 // viewer should use this in preference to GetWindowSizeHint, since
175 // it contains more information. (The size information in
176 // GetXGeometryString and GetWindowSizeHint is guaranteed to be
177 // identical.)
178 bool IsWindowSizeHintX () const;
179 bool IsWindowSizeHintY () const;
186 const std::vector<G4ModelingParameters::VisAttributesModifier>&
188
189 // Here Follow functions to evaluate useful quantities as a
190 // function of the radius of the Bounding Sphere of the object being
191 // viewed. Call them in the order given - for efficiency, later
192 // functions depend on the results of earlier ones (Store the
193 // results of earlier functions in your own temporary variables -
194 // see, for example, G4OpenGLView::SetView ().)
195 G4double GetCameraDistance (G4double radius) const;
196 G4double GetNearDistance (G4double cameraDistance, G4double radius) const;
197 G4double GetFarDistance (G4double cameraDistance,
198 G4double nearDistance, G4double radius) const;
199 G4double GetFrontHalfHeight (G4double nearDistance, G4double radius) const;
200
201 // Set, Add, Multiply, Increment, Unset and Clear functions.
208 void SetVisibleDensity (G4double visibleDensity);
210 void SetSectionPlane (const G4Plane3D& sectionPlane);
213 void AddCutawayPlane (const G4Plane3D& cutawayPlane);
214 void ChangeCutawayPlane (size_t index, const G4Plane3D& cutawayPlane);
216 void SetExplodeFactor (G4double explodeFactor);
218 void SetExplodeCentre (const G4Point3D& explodeCentre);
219 G4int SetNoOfSides (G4int nSides); // Returns actual number set.
220 void SetViewpointDirection (const G4Vector3D& viewpointDirection);
221 // Calls the following to get lightpoint direction right too.
222 void SetViewAndLights (const G4Vector3D& viewpointDirection);
223 // Also sets lightpoint direction according to G4bool fLightsMoveWithCamera.
224 void SetUpVector (const G4Vector3D& upVector);
225 void SetFieldHalfAngle (G4double fieldHalfAngle);
226 void SetOrthogonalProjection (); // This and next use SetFieldHalfAngle.
227 void SetPerspectiveProjection(G4double fieldHalfAngle = 30. * CLHEP::deg);
228 void SetZoomFactor (G4double zoomFactor);
229 void MultiplyZoomFactor (G4double zoomFactorMultiplier);
230 void SetScaleFactor (const G4Vector3D& scaleFactor);
231 void MultiplyScaleFactor (const G4Vector3D& scaleFactorMultiplier);
232 void SetCurrentTargetPoint (const G4Point3D& currentTargetPoint);
233 void SetDolly (G4double dolly);
234 void IncrementDolly (G4double dollyIncrement);
235 void SetLightpointDirection (const G4Vector3D& lightpointDirection);
237 void SetPan (G4double right, G4double up);
238 void IncrementPan (G4double right, G4double up);
239 // Increment currentTarget point perpendicular to viewpoint direction.
240 void IncrementPan (G4double right, G4double up, G4double forward);
241 // Increment currentTarget point also along viewpoint direction.
243 void SetDefaultColour (const G4Colour&); // Uses SetDefaultVisAttributes.
245 void SetDefaultTextColour (const G4Colour&); // SetDefaultTextVisAttributes.
246 void SetDefaultMarker (const G4VMarker& defaultMarker);
247 void SetGlobalMarkerScale (G4double globalMarkerScale);
248 void SetGlobalLineWidthScale (G4double globalLineWidthScale);
251 void SetWindowSizeHint (G4int xHint, G4int yHint);
252 void SetWindowLocationHint (G4int xHint, G4int yHint);
253 void SetXGeometryString (const G4String&);
260
261 // Command dumping functions.
262 // For camera commands we need to provide the standard target point from
263 // the current scene.
264 G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const;
268
269 // Other functions.
270 void PrintDifferences (const G4ViewParameters& v) const;
271
272private:
273
274 G4int ParseGeometry ( const char *string, G4int *x, G4int *y, unsigned int *width, unsigned int *height);
275 G4int ReadInteger(char *string, char **NextString);
276
277 DrawingStyle fDrawingStyle; // Drawing style.
278 G4bool fAuxEdgeVisible; // Auxiliary edge visibility.
279 RepStyle fRepStyle; // Representation style.
280 G4bool fCulling; // Culling requested.
281 G4bool fCullInvisible; // Cull (don't Draw) invisible objects.
282 G4bool fDensityCulling; // Density culling requested. If so...
283 G4double fVisibleDensity; // ...density lower than this not drawn.
284 G4bool fCullCovered; // Cull daughters covered by opaque mothers.
285 G4bool fSection; // Section drawing requested (DCUT in GEANT3).
286 G4Plane3D fSectionPlane; // Cut plane for section drawing (DCUT).
287 CutawayMode fCutawayMode; // Cutaway mode.
288 G4Planes fCutawayPlanes; // Set of planes used for cutaway.
289 G4double fExplodeFactor; // Explode along radius by this factor...
290 G4Point3D fExplodeCentre; // ...about this centre.
291 G4int fNoOfSides; // ...if polygon approximates circle.
292 G4Vector3D fViewpointDirection;
293 G4Vector3D fUpVector; // Up vector. (Warning: MUST NOT be parallel
294 // to fViewpointDirection!)
295 G4double fFieldHalfAngle; // Radius / camara distance, 0 for parallel.
296 G4double fZoomFactor; // Magnification relative to Standard View.
297 G4Vector3D fScaleFactor; // (Non-uniform) scale/magnification factor.
298 G4Point3D fCurrentTargetPoint; // Relative to standard target point.
299 G4double fDolly; // Distance towards current target point.
300 G4bool fLightsMoveWithCamera;
301 G4Vector3D fRelativeLightpointDirection;
302 // i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
303 G4Vector3D fActualLightpointDirection;
304 G4VisAttributes fDefaultVisAttributes;
305 G4VisAttributes fDefaultTextVisAttributes;
306 G4VMarker fDefaultMarker;
307 G4double fGlobalMarkerScale;
308 G4double fGlobalLineWidthScale;
309 G4bool fMarkerNotHidden;
310 // True if transients are to be drawn and not hidden by
311 // hidden-line-hidden-surface removal algorithms, e.g., z-buffer
312 // testing; false if they are to be hidden-line-hidden-surface
313 // removed.
314 G4int fWindowSizeHintX; // Size hints for pixel-based window systems.
315 G4int fWindowSizeHintY;
316 G4int fWindowLocationHintX; // Location hints for pixel-based window systems.
317 G4int fWindowLocationHintY;
318 G4bool fWindowLocationHintXNegative; // Reference of location hints for pixel-based window systems.
319 G4bool fWindowLocationHintYNegative;
320 G4String fXGeometryString; // If non-null, geometry string for X Windows.
321 G4int fGeometryMask; // Corresponding mask.
322 G4bool fAutoRefresh; // ...after change of view parameters.
323 G4Colour fBackgroundColour;
324 G4bool fPicking; // Request picking.
325 RotationStyle fRotationStyle; // Rotation style.
326 std::vector<G4ModelingParameters::VisAttributesModifier>
327 fVisAttributesModifiers;
328
329 enum { // Constants for geometry mask in ParseGeometry and related functions.
330 fNoValue = 0,
331 fXValue = 0x0001,
332 fYValue = 0x0002,
333 fWidthValue = 0x0004,
334 fHeightValue = 0x0008,
335 fAllValues = 0x000F,
336 fXNegative = 0x0010,
337 fYNegative = 0x0020
338 };
339};
340
341#include "G4ViewParameters.icc"
342
343#endif
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
std::vector< G4Plane3D > G4Planes
bool IsWindowLocationHintY() const
G4int GetWindowLocationHintX() const
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetScaleFactor(const G4Vector3D &scaleFactor)
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
G4int SetNoOfSides(G4int nSides)
void SetViewAndLights(const G4Vector3D &viewpointDirection)
const G4Vector3D & GetScaleFactor() const
void SetAutoRefresh(G4bool)
void SetBackgroundColour(const G4Colour &)
const G4String & GetXGeometryString() const
void SetGlobalMarkerScale(G4double globalMarkerScale)
void SetExplodeCentre(const G4Point3D &explodeCentre)
G4int GetNoOfSides() const
G4int GetWindowAbsoluteLocationHintY(G4int) const
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
CutawayMode GetCutawayMode() const
G4double GetCameraDistance(G4double radius) const
bool IsWindowLocationHintX() const
G4double GetExplodeFactor() const
void PrintDifferences(const G4ViewParameters &v) const
G4bool IsMarkerNotHidden() const
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 UnsetSectionPlane()
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
bool IsWindowSizeHintX() const
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetLightpointDirection() const
void SetDefaultTextColour(const G4Colour &)
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)
void SetGlobalLineWidthScale(G4double globalLineWidthScale)
const G4Point3D & GetCurrentTargetPoint() const
G4bool IsPicking() const
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
void SetPicking(G4bool)
G4double GetFieldHalfAngle() const
bool IsWindowSizeHintY() const
G4bool IsCulling() const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
void SetMarkerHidden()
friend std::ostream & operator<<(std::ostream &, const DrawingStyle &)
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4double GetZoomFactor() const
void SetDolly(G4double dolly)
void SetDensityCulling(G4bool)
void SetOrthogonalProjection()
G4int GetWindowAbsoluteLocationHintX(G4int) const
G4bool IsExplode() const
G4String SceneModifyingCommands() const
const G4VMarker & GetDefaultMarker() const
void SetWindowSizeHint(G4int xHint, G4int yHint)
void SetDefaultMarker(const G4VMarker &defaultMarker)
void IncrementPan(G4double right, G4double up)
void SetWindowLocationHint(G4int xHint, G4int yHint)
const G4Vector3D & GetUpVector() const
G4String TouchableCommands() const
void SetMarkerNotHidden()
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
G4double GetGlobalMarkerScale() const
G4bool IsCullingInvisible() const
void SetZoomFactor(G4double zoomFactor)
void UnsetExplodeFactor()
RepStyle GetRepStyle() const
const G4VisAttributes * GetDefaultVisAttributes() const
void SetCullingInvisible(G4bool)
void SetRepStyle(G4ViewParameters::RepStyle style)
void SetUpVector(const G4Vector3D &upVector)
void SetPan(G4double right, G4double up)
const G4Planes & GetCutawayPlanes() const
RotationStyle GetRotationStyle() const
G4int GetWindowLocationHintY() const
void SetCutawayMode(CutawayMode)
G4bool IsDensityCulling() const
void SetDefaultTextVisAttributes(const G4VisAttributes &)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetLightsMoveWithCamera(G4bool moves)
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
G4String DrawingStyleCommands() const
void SetRotationStyle(RotationStyle)
G4bool IsAutoRefresh() const
G4double GetVisibleDensity() 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)
const G4Point3D & GetExplodeCentre() const
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
DrawingStyle GetDrawingStyle() const
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
G4bool IsAuxEdgeVisible() const
G4double GetDolly() const