source: trunk/geant4/visualization/management/include/G4ViewParameters.hh@ 594

Last change on this file since 594 was 593, checked in by garnier, 18 years ago

r627@mac-90108: laurentgarnier | 2007-11-09 07:57:42 +0100
modif dans les includes directives

  • Property svn:mime-type set to text/cpp
File size: 13.3 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.26 2007/04/03 13:33:16 allison Exp $
28// GEANT4 tag $Name: geant4-09-00-ref-01 $
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 void SetDefaultVisAttributes (const G4VisAttributes&);
214 void SetDefaultTextVisAttributes (const G4VisAttributes&);
215 void SetDefaultMarker (const G4VMarker& defaultMarker);
216 void SetGlobalMarkerScale (G4double globalMarkerScale);
217 void SetGlobalLineWidthScale (G4double globalLineWidthScale);
218 void SetMarkerHidden ();
219 void SetMarkerNotHidden ();
220 void SetWindowSizeHint (G4int xHint, G4int yHint);
221 void SetXGeometryString (const G4String&);
222 void SetAutoRefresh (G4bool);
223 void SetBackgroundColour (const G4Colour&);
224 void SetPicking (G4bool);
225
226 void PrintDifferences (const G4ViewParameters& v) const;
227
228private:
229
230 DrawingStyle fDrawingStyle; // Drawing style.
231 G4bool fAuxEdgeVisible; // Auxiliary edge visibility.
232 RepStyle fRepStyle; // Representation style.
233 G4bool fCulling; // Culling requested.
234 G4bool fCullInvisible; // Cull (don't Draw) invisible objects.
235 G4bool fDensityCulling; // Density culling requested. If so...
236 G4double fVisibleDensity; // ...density lower than this not drawn.
237 G4bool fCullCovered; // Cull daughters covered by opaque mothers.
238 G4bool fSection; // Section drawing requested (DCUT in GEANT3).
239 G4Plane3D fSectionPlane; // Cut plane for section drawing (DCUT).
240 CutawayMode fCutawayMode; // Cutaway mode.
241 G4Planes fCutawayPlanes; // Set of planes used for cutaway.
242 G4double fExplodeFactor; // Explode along radius by this factor...
243 G4Point3D fExplodeCentre; // ...about this centre.
244 G4int fNoOfSides; // ...if polygon approximates circle.
245 G4Vector3D fViewpointDirection;
246 G4Vector3D fUpVector; // Up vector. (Warning: MUST NOT be parallel
247 // to fViewpointDirection!)
248 G4double fFieldHalfAngle; // Radius / camara distance, 0 for parallel.
249 G4double fZoomFactor; // Magnification relative to Standard View.
250 G4Vector3D fScaleFactor; // (Non-uniform) scale/magnification factor.
251 G4Point3D fCurrentTargetPoint; // Relative to standard target point.
252 G4double fDolly; // Distance towards current target point.
253 G4bool fLightsMoveWithCamera;
254 G4Vector3D fRelativeLightpointDirection;
255 // i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
256 G4Vector3D fActualLightpointDirection;
257 G4VisAttributes fDefaultVisAttributes;
258 G4VisAttributes fDefaultTextVisAttributes;
259 G4VMarker fDefaultMarker;
260 G4double fGlobalMarkerScale;
261 G4double fGlobalLineWidthScale;
262 G4bool fMarkerNotHidden;
263 // True if transients are to be drawn and not hidden by
264 // hidden-line-hidden-surface removal algorithms, e.g., z-buffer
265 // testing; false if they are to be hidden-line-hidden-surface
266 // removed.
267 G4int fWindowSizeHintX; // Size hints for pixel-based window systems.
268 G4int fWindowSizeHintY;
269 G4String fXGeometryString; // If non-null, geometry string for X Windows.
270 G4bool fAutoRefresh; // ...after change of view parameters.
271 G4Colour fBackgroundColour;
272 G4bool fPicking; // Request picking.
273};
274
275#include "G4ViewParameters.icc"
276
277#endif
Note: See TracBrowser for help on using the repository browser.