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

Last change on this file since 536 was 531, checked in by garnier, 18 years ago

r660@mac-90108: laurentgarnier | 2007-06-25 16:10:12 +0200
ajout de fichiers NON modifies

  • Property svn:mime-type set to text/cpp
File size: 13.1 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.25 2006/09/19 16:02:31 allison Exp $
28// GEANT4 tag $Name: geant4-08-02-patch-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
164 // Here Follow functions to evaluate the above algorithms as a
165 // function of the radius of the Bounding Sphere of the object being
166 // viewed. Call them in the order given - for efficiency, later
167 // functions depend on the results of earlier ones (Store the
168 // results of earlier functions in your own temporary variables -
169 // see, for example, G4OpenGLView::SetView ().)
170 G4double GetCameraDistance (G4double radius) const;
171 G4double GetNearDistance (G4double cameraDistance, G4double radius) const;
172 G4double GetFarDistance (G4double cameraDistance,
173 G4double nearDistance, G4double radius) const;
174 G4double GetFrontHalfHeight (G4double nearDistance, G4double radius) const;
175
176 // Set, Add, Multiply, Increment, Unset and Clear functions.
177 void SetDrawingStyle (G4ViewParameters::DrawingStyle style);
178 void SetAuxEdgeVisible (G4bool);
179 void SetRepStyle (G4ViewParameters::RepStyle style);
180 void SetCulling (G4bool);
181 void SetCullingInvisible (G4bool);
182 void SetDensityCulling (G4bool);
183 void SetVisibleDensity (G4double visibleDensity);
184 void SetCullingCovered (G4bool);
185 void SetSectionPlane (const G4Plane3D& sectionPlane);
186 void UnsetSectionPlane ();
187 void SetCutawayMode (CutawayMode);
188 void AddCutawayPlane (const G4Plane3D& cutawayPlane);
189 void ChangeCutawayPlane (size_t index, const G4Plane3D& cutawayPlane);
190 void ClearCutawayPlanes ();
191 void SetExplodeFactor (G4double explodeFactor);
192 void UnsetExplodeFactor ();
193 void SetExplodeCentre (const G4Point3D& explodeCentre);
194 G4int SetNoOfSides (G4int nSides); // Returns actual number set.
195 void SetViewpointDirection (const G4Vector3D& viewpointDirection);
196 // Calls the following to get lightpoint direction right too.
197 void SetViewAndLights (const G4Vector3D& viewpointDirection);
198 // Also sets lightpoint direction according to G4bool fLightsMoveWithCamera.
199 void SetUpVector (const G4Vector3D& upVector);
200 void SetFieldHalfAngle (G4double fieldHalfAngle);
201 void SetZoomFactor (G4double zoomFactor);
202 void MultiplyZoomFactor (G4double zoomFactorMultiplier);
203 void SetScaleFactor (const G4Vector3D& scaleFactor);
204 void MultiplyScaleFactor (const G4Vector3D& scaleFactorMultiplier);
205 void SetCurrentTargetPoint (const G4Point3D& currentTargetPoint);
206 void SetDolly (G4double dolly);
207 void IncrementDolly (G4double dollyIncrement);
208 void SetLightpointDirection (const G4Vector3D& lightpointDirection);
209 void SetLightsMoveWithCamera (G4bool moves);
210 void SetPan (G4double right, G4double up);
211 void IncrementPan (G4double right, G4double up);
212 void SetDefaultVisAttributes (const G4VisAttributes&);
213 void SetDefaultTextVisAttributes (const G4VisAttributes&);
214 void SetDefaultMarker (const G4VMarker& defaultMarker);
215 void SetGlobalMarkerScale (G4double globalMarkerScale);
216 void SetGlobalLineWidthScale (G4double globalLineWidthScale);
217 void SetMarkerHidden ();
218 void SetMarkerNotHidden ();
219 void SetWindowSizeHint (G4int xHint, G4int yHint);
220 void SetXGeometryString (const G4String&);
221 void SetAutoRefresh (G4bool);
222 void SetBackgroundColour (const G4Colour&);
223
224 void PrintDifferences (const G4ViewParameters& v) const;
225
226private:
227
228 DrawingStyle fDrawingStyle; // Drawing style.
229 G4bool fAuxEdgeVisible; // Auxiliary edge visibility.
230 RepStyle fRepStyle; // Representation style.
231 G4bool fCulling; // Culling requested.
232 G4bool fCullInvisible; // Cull (don't Draw) invisible objects.
233 G4bool fDensityCulling; // Density culling requested. If so...
234 G4double fVisibleDensity; // ...density lower than this not drawn.
235 G4bool fCullCovered; // Cull daughters covered by opaque mothers.
236 G4bool fSection; // Section drawing requested (DCUT in GEANT3).
237 G4Plane3D fSectionPlane; // Cut plane for section drawing (DCUT).
238 CutawayMode fCutawayMode; // Cutaway mode.
239 G4Planes fCutawayPlanes; // Set of planes used for cutaway.
240 G4double fExplodeFactor; // Explode along radius by this factor...
241 G4Point3D fExplodeCentre; // ...about this centre.
242 G4int fNoOfSides; // ...if polygon approximates circle.
243 G4Vector3D fViewpointDirection;
244 G4Vector3D fUpVector; // Up vector. (Warning: MUST NOT be parallel
245 // to fViewpointDirection!)
246 G4double fFieldHalfAngle; // Radius / camara distance, 0 for parallel.
247 G4double fZoomFactor; // Magnification relative to Standard View.
248 G4Vector3D fScaleFactor; // (Non-uniform) scale/magnification factor.
249 G4Point3D fCurrentTargetPoint; // Relative to standard target point.
250 G4double fDolly; // Distance towards current target point.
251 G4bool fLightsMoveWithCamera;
252 G4Vector3D fRelativeLightpointDirection;
253 // i.e., rel. to object or camera accoding to G4bool fLightsMoveWithCamera.
254 G4Vector3D fActualLightpointDirection;
255 G4VisAttributes fDefaultVisAttributes;
256 G4VisAttributes fDefaultTextVisAttributes;
257 G4VMarker fDefaultMarker;
258 G4double fGlobalMarkerScale;
259 G4double fGlobalLineWidthScale;
260 G4bool fMarkerNotHidden;
261 // True if transients are to be drawn and not hidden by
262 // hidden-line-hidden-surface removal algorithms, e.g., z-buffer
263 // testing; false if they are to be hidden-line-hidden-surface
264 // removed.
265 G4int fWindowSizeHintX; // Size hints for pixel-based window systems.
266 G4int fWindowSizeHintY;
267 G4String fXGeometryString; // If non-null, geometry string for X Windows.
268 G4bool fAutoRefresh; // ...after change of view parameters.
269 G4Colour fBackgroundColour;
270};
271
272#include "G4ViewParameters.icc"
273
274#endif
Note: See TracBrowser for help on using the repository browser.