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

Last change on this file since 1169 was 954, checked in by garnier, 17 years ago

remise a jour

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