source: trunk/source/visualization/management/include/G4ViewParameters.hh @ 850

Last change on this file since 850 was 850, checked in by garnier, 16 years ago

geant4.8.2 beta

  • Property svn:mime-type set to text/cpp
File size: 13.5 KB
Line 
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: G4ViewParameters.hh,v 1.28 2008/04/28 16:14:12 allison Exp $
28// GEANT4 tag $Name: HEAD $
29//
30//
31// John Allison  19th July 1996
32//
33// Class description
34//
35// View parameters and options.
36//
37// THE STANDARD VIEW AND ALL THAT.
38//
39// In GEANT4 visualization, we have the concept of a "Standard
40// View".  This is the view when the complete set of objects being
41// viewed is comfortably in view from any viewpoint.  It is defined by
42// the "Bounding Sphere" of "visible" objects when initially
43// registered in the scene, and by the View Parameters.
44//
45// There is also the "Standard Target Point", which is the centre of
46// the Bounding Sphere (note that this belongs to the scene and is
47// stored in the G4Scene object).  The "Current Target Point", defined
48// relative to the Standard Target Point, is changed by the
49// "dolly" and "zoom" commands, and can be reset to the Standard
50// Target Point with the "/vis/viewer/reset" command.
51//
52// Also, the "Standard Camera Position" is the "Standard Camera
53// Distance" along the Viewpoint Direction vector from the Standard
54// Target Point.  The Standard Camera Distance is the radius of the
55// Bounding Sphere divided by fFieldHalfAngle.  It is not stored
56// explicitly because of the singularity at fFieldHalfAngle = 0,
57// which implies parallel projection.
58//
59// Similarly, the "Current Camera Position" is the "Current Camera
60// Distance" along the Viewpoint Direction vector from the Current
61// Target Point.  The Current Camera Distance is given by the formulae
62// below, but note that it can be negative, meaning that the camera
63// has moved *beyond* the Current Target Point, which is
64// conceptually possible, but which might give some problems when
65// setting up the view matrix - see, for example, G4OpenGLView::SetView ().
66//
67// All viewers are expected to keep the "Up Vector" vertical.
68//
69// Finally, the view is magnified by the "Zoom Factor" which is
70// reset to 1 by the "/vis/viewer/reset" command.
71//
72// The algorithms for calculating various useful quantities from the
73// View Parameters, such as GetCameraDistance, are described below.
74
75#ifndef G4VIEWPARAMETERS_HH
76#define G4VIEWPARAMETERS_HH
77
78#include <vector>
79#include "G4Vector3D.hh"
80#include "G4Point3D.hh"
81#include "G4Plane3D.hh"
82#include "G4VisAttributes.hh"
83#include "G4VMarker.hh"
84
85typedef std::vector<G4Plane3D> G4Planes;
86
87class G4ViewParameters {
88
89public: // With description
90
91  enum DrawingStyle {
92    wireframe,  // Draw edges    - no hidden line removal.
93    hlr,        // Draw edges    - hidden lines removed.
94    hsr,        // Draw surfaces - hidden surfaces removed.
95    hlhsr       // Draw surfaces and edges - hidden removed.
96  };
97
98  enum RepStyle {
99    polyhedron, // Use G4Polyhedron.
100    nurbs       // Use G4NURBS.
101  };
102
103  enum CutawayMode {
104    cutawayUnion,       // Union (addition) of result of each cutaway plane.
105    cutawayIntersection // Intersection (multiplication) " .
106  };
107
108  friend std::ostream& operator << (std::ostream&,
109                                      const DrawingStyle&);
110
111  friend std::ostream& operator << (std::ostream&,
112                                      const G4ViewParameters&);
113
114  G4ViewParameters ();
115  ~G4ViewParameters ();
116
117  // Note: uses default assignment operator and copy constructor.
118
119  G4bool operator != (const G4ViewParameters&) const;
120
121  // Get and Is functions.
122        DrawingStyle     GetDrawingStyle         () const;
123        G4bool           IsAuxEdgeVisible        () const;
124        RepStyle         GetRepStyle             () const;
125        G4bool           IsCulling               () const;
126        G4bool           IsCullingInvisible      () const;
127        G4bool           IsDensityCulling        () const;
128        G4double         GetVisibleDensity       () const;
129        G4bool           IsCullingCovered        () const;
130        G4bool           IsSection               () const;
131  const G4Plane3D&       GetSectionPlane         () const;
132        G4bool           IsCutaway               () const;
133        CutawayMode      GetCutawayMode          () const;
134  const G4Planes&        GetCutawayPlanes        () const;
135        G4bool           IsExplode               () const;
136        G4double         GetExplodeFactor        () const;
137  const G4Point3D&       GetExplodeCentre        () const;
138        G4int            GetNoOfSides            () const;
139  const G4Vector3D&      GetViewpointDirection   () const;
140  const G4Vector3D&      GetUpVector             () const;
141        G4double         GetFieldHalfAngle       () const;
142        G4double         GetZoomFactor           () const;
143  const G4Vector3D&      GetScaleFactor          () const;
144  const G4Point3D&       GetCurrentTargetPoint   () const;
145        G4double         GetDolly                () const;
146        G4bool           GetLightsMoveWithCamera () const;
147  const G4Vector3D&      GetLightpointDirection  () const;  // Relative...
148        G4Vector3D&      GetActualLightpointDirection  ();  // Actual...
149  // ... depending on GetLightsMoveWithCamera.
150  const G4VisAttributes* GetDefaultVisAttributes () const;
151  const G4VisAttributes* GetDefaultTextVisAttributes () const;
152  const G4VMarker&       GetDefaultMarker        () const;
153        G4double         GetGlobalMarkerScale    () const;
154        G4double         GetGlobalLineWidthScale () const;
155        G4bool           IsMarkerNotHidden       () const;
156        G4int            GetWindowSizeHintX      () const;
157        G4int            GetWindowSizeHintY      () const;
158  const G4String&        GetXGeometryString      () const;
159  // If non-null, can be interpreted with XParseGeometry (see man
160  // pages).  Supercedes GetWindowSizeHintX/Y.
161        G4bool           IsAutoRefresh           () const;
162  const G4Colour&        GetBackgroundColour     () const;
163        G4bool           IsPicking               () const;
164
165  // Here Follow functions to evaluate the above algorithms as a
166  // function of the radius of the Bounding Sphere of the object being
167  // viewed.  Call them in the order given - for efficiency, later
168  // functions depend on the results of earlier ones (Store the
169  // results of earlier functions in your own temporary variables -
170  // see, for example, G4OpenGLView::SetView ().)
171  G4double GetCameraDistance  (G4double radius) const;
172  G4double GetNearDistance    (G4double cameraDistance, G4double radius) const;
173  G4double GetFarDistance     (G4double cameraDistance,
174                               G4double nearDistance, G4double radius) const;
175  G4double GetFrontHalfHeight (G4double nearDistance, G4double radius) const;
176
177  // Set, Add, Multiply, Increment, Unset and Clear functions.
178  void SetDrawingStyle         (G4ViewParameters::DrawingStyle style);
179  void SetAuxEdgeVisible       (G4bool);
180  void SetRepStyle             (G4ViewParameters::RepStyle style);
181  void SetCulling              (G4bool);
182  void SetCullingInvisible     (G4bool);
183  void SetDensityCulling       (G4bool);
184  void SetVisibleDensity       (G4double visibleDensity);
185  void SetCullingCovered       (G4bool);
186  void SetSectionPlane         (const G4Plane3D& sectionPlane);
187  void UnsetSectionPlane       ();
188  void SetCutawayMode          (CutawayMode);
189  void AddCutawayPlane         (const G4Plane3D& cutawayPlane);
190  void ChangeCutawayPlane      (size_t index, const G4Plane3D& cutawayPlane);
191  void ClearCutawayPlanes      ();
192  void SetExplodeFactor        (G4double explodeFactor);
193  void UnsetExplodeFactor      ();
194  void SetExplodeCentre        (const G4Point3D& explodeCentre);
195  G4int SetNoOfSides           (G4int nSides);  // Returns actual number set.
196  void SetViewpointDirection   (const G4Vector3D& viewpointDirection);
197  // Calls the following to get lightpoint direction right too.
198  void SetViewAndLights        (const G4Vector3D& viewpointDirection);
199  // Also sets lightpoint direction according to G4bool fLightsMoveWithCamera.
200  void SetUpVector             (const G4Vector3D& upVector);
201  void SetFieldHalfAngle       (G4double fieldHalfAngle);
202  void SetZoomFactor           (G4double zoomFactor);
203  void MultiplyZoomFactor      (G4double zoomFactorMultiplier);
204  void SetScaleFactor          (const G4Vector3D& scaleFactor);
205  void MultiplyScaleFactor     (const G4Vector3D& scaleFactorMultiplier);
206  void SetCurrentTargetPoint   (const G4Point3D& currentTargetPoint);
207  void SetDolly                (G4double dolly);
208  void IncrementDolly          (G4double dollyIncrement);
209  void SetLightpointDirection  (const G4Vector3D& lightpointDirection);
210  void SetLightsMoveWithCamera (G4bool moves);
211  void SetPan                  (G4double right, G4double up);
212  void IncrementPan            (G4double right, G4double up);
213  // Increment currentTarget point perpendicular to viewpoint direction.
214  void IncrementPan            (G4double right, G4double up, G4double forward);
215  // Increment currentTarget point also along viewpoint direction.
216  void SetDefaultVisAttributes (const G4VisAttributes&);
217  void SetDefaultTextVisAttributes (const G4VisAttributes&);
218  void SetDefaultMarker        (const G4VMarker& defaultMarker);
219  void SetGlobalMarkerScale    (G4double globalMarkerScale);
220  void SetGlobalLineWidthScale (G4double globalLineWidthScale);
221  void SetMarkerHidden         ();
222  void SetMarkerNotHidden      ();
223  void SetWindowSizeHint       (G4int xHint, G4int yHint);
224  void SetXGeometryString      (const G4String&);
225  void SetAutoRefresh          (G4bool);
226  void SetBackgroundColour     (const G4Colour&);
227  void SetPicking              (G4bool);
228
229  void PrintDifferences (const G4ViewParameters& v) const;
230
231private:
232
233  DrawingStyle fDrawingStyle;    // Drawing style.
234  G4bool       fAuxEdgeVisible;  // Auxiliary edge visibility.
235  RepStyle     fRepStyle;        // Representation style.
236  G4bool       fCulling;         // Culling requested.
237  G4bool       fCullInvisible;   // Cull (don't Draw) invisible objects.
238  G4bool       fDensityCulling;  // Density culling requested.  If so...
239  G4double     fVisibleDensity;  // ...density lower than this not drawn.
240  G4bool       fCullCovered;     // Cull daughters covered by opaque mothers.
241  G4bool       fSection;         // Section drawing requested (DCUT in GEANT3).
242  G4Plane3D    fSectionPlane;    // Cut plane for section drawing (DCUT).
243  CutawayMode  fCutawayMode;     // Cutaway mode.
244  G4Planes     fCutawayPlanes;   // Set of planes used for cutaway.
245  G4double     fExplodeFactor;   // Explode along radius by this factor...
246  G4Point3D    fExplodeCentre;   // ...about this centre.
247  G4int        fNoOfSides;       // ...if polygon approximates circle.
248  G4Vector3D   fViewpointDirection;
249  G4Vector3D   fUpVector;        // Up vector.  (Warning: MUST NOT be parallel
250                                 // to fViewpointDirection!)
251  G4double     fFieldHalfAngle;  // Radius / camara distance, 0 for parallel.
252  G4double     fZoomFactor;      // Magnification relative to Standard View.
253  G4Vector3D   fScaleFactor;     // (Non-uniform) scale/magnification factor.
254  G4Point3D    fCurrentTargetPoint;  // Relative to standard target point.
255  G4double     fDolly;           // Distance towards current target point.
256  G4bool       fLightsMoveWithCamera;
257  G4Vector3D   fRelativeLightpointDirection;
258  // i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
259  G4Vector3D   fActualLightpointDirection;
260  G4VisAttributes fDefaultVisAttributes;
261  G4VisAttributes fDefaultTextVisAttributes;
262  G4VMarker    fDefaultMarker;
263  G4double     fGlobalMarkerScale;
264  G4double     fGlobalLineWidthScale;
265  G4bool       fMarkerNotHidden;
266  // True if transients are to be drawn and not hidden by
267  // hidden-line-hidden-surface removal algorithms, e.g., z-buffer
268  // testing; false if they are to be hidden-line-hidden-surface
269  // removed.
270  G4int        fWindowSizeHintX; // Size hints for pixel-based window systems.
271  G4int        fWindowSizeHintY;
272  G4String     fXGeometryString; // If non-null, geometry string for X Windows.
273  G4bool       fAutoRefresh;     // ...after change of view parameters.
274  G4Colour     fBackgroundColour;
275  G4bool       fPicking;         // Request picking.
276};
277
278#include "G4ViewParameters.icc"
279
280#endif
Note: See TracBrowser for help on using the repository browser.