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

Last change on this file since 894 was 893, checked in by garnier, 17 years ago

make 3.80 added because 3.81 is bad

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