2 Copyright (C) 2001, 2006 United States Government as represented by
3 the Administrator of the National Aeronautics and Space Administration.
6 package gov
.nasa
.worldwind
;
8 import gov
.nasa
.worldwind
.geom
.*;
11 * The <code>View</code> provides an interface for communicating current viewing state and viewing state chages. For
12 * example calling {@link #getLatitude} and {@link #setLatitude} will get and set the View latitude coordinate.
14 * <code>Views</code> contain both fixed state and computed state. The computed state is typically updated during a call
15 * to the {@link #apply} method. Most accessor methods in this interface return the computed state that was set during
16 * the most recent call to <code>apply()</code>.
18 * Implementations may impose constraints on any state variable. Following the above example, simple constraints on View
19 * latitude coordinates may be queried by calling {@link #normalizeLatitude}. However additional environmental factors
20 * may constrain View state variables in a manner that cannot be easliy predicted. For this reason, setting a state
21 * variable does not guarantee the specified state change will occur. When exact knowledge of viewing state is required,
22 * calling {@link #getLatitude}, immediately after a call to {@link #apply} will return the correct latitude
25 * <code>View</code> provides a coordinate transformation from <code>Model</code> coordinates to eye coordinates,
26 * following the OpenGL convention of a left-handed coordinate system with origin at the eye point and looking down the
27 * negative Z axis. <code>View</code> also provides a transformation from eye coordinates to screen coordinates,
28 * following the OpenGL convention of an origin in the lower left hand screen corner.
30 * @author Paul Collins
31 * @version $Id: View.java 2060 2007-06-14 22:41:20Z dcollins $
32 * @see gov.nasa.worldwind.ViewStateIterator
33 * @see gov.nasa.worldwind.geom.Frustum
35 public interface View
extends WWObject
38 * Calculates and applies <code>View's</code> internal state to the graphics context in <code>DrawContext</code>.
39 * All subsequently rendered objects use this new state. Upon return, the OpenGL graphics context reflects the
40 * values of this view, as do any computed values of the view, such as the model-view matrix, projection matrix and
41 * <code>Frustum</code>.
43 * @param dc the current World Wind drawing context on which <code>View's</code> state will apply.
44 * @throws IllegalArgumentException if <code>dc</code> is null, or if the <code>Globe</code> or <code>GL</code>
45 * instances in <code>dc</code> are null.
47 void apply(DrawContext dc
);
50 * Gets the 'model-view' matrix computed in <code>apply()</code>, which transforms model coordinates to eye
51 * coordinates (where the eye is located at the origin, facing down the negative-z axis). This matrix is constructed
52 * using the model space translation and orientation specific to each implementation of <code>View</code>.
54 * @return the current model-view matrix.
56 Matrix
getModelViewMatrix();
59 * Gets the 'projection' matrix computed in <code>apply()</code>, which transforms eye coordinates to screen
60 * coordinates. This matrix is constructed using the projection parameters specific to each implementation of
61 * <code>View</code> (e.g. field-of-view). The {@link #getFrustum} method returns the geometry corresponding to this
64 * @return the current projection matrix.
66 Matrix
getProjectionMatrix();
69 * Gets a Rectangle representing the window bounds (x, y, width, height) of the viewport, computed in
70 * <code>apply()</code>. Implementations of <code>View</code> will configure themselves to render in this viewport.
72 * @return the current window bounds of the viewport.
74 java
.awt
.Rectangle
getViewport();
77 * Gets the viewing <code>Frustum</code> in eye coordinates, computed in <code>apply()</code>. The
78 * <code>Frustum</code> is the portion of viewable space defined by three sets of parallel 'clipping' planes. The
79 * method {@link #getFrustumInModelCoordinates} maintains the shape of this <code>Frustum</code>, but it has been
80 * translated and aligned with the eye in model space.
82 * @return the current viewing frustum in eye coordinates.
87 * Gets the viewing <code>Frustum</code> transformed to model coordinates. Model coordinate frustums are useful for
88 * performing visibility tests against world geometry.
90 * @return the current viewing frustum in model coordinates.
92 Frustum
getFrustumInModelCoordinates();
95 * Gets the horizontal field-of-view angle (the angle of visibility) associated with this <code>View</code>, or null
96 * if the <code>View</code> implementation does not support a field-of-view.
98 * @return horizontal field-of-view angle, or null if none exists.
100 Angle
getFieldOfView();
103 * Sets the horiziontal field-of-view angle (the angle of visibillity) associated with this <code>View</code>. This
104 * call may be ignored by implementations that do not support a field-of-view.
106 * @param newFov the new horizontal field-of-view angle.
107 * @throws IllegalArgumentException if <code>newFov</code> is null.
109 void setFieldOfView(Angle newFov
);
112 * Defines and applies a new model-view matrix in which the world origin is located at <code>referenceCenter</code>.
113 * Geometry rendered after a call to <code>pushReferenceCenter</code> should be transformed with respect to
114 * <code>referenceCenter</code>, rather than the canonical origin (0, 0, 0). Calls to
115 * <code>pushReferenceCenter</code> must be followed by {@link #popReferenceCenter} after rendering is complete.
116 * Note that calls to {@link #getModelViewMatrix} will not return reference-center model-view matrix, but the
119 * @param dc the current World Wind drawing context on which new model-view state will be applied.
120 * @param referenceCenter the location to become the new world origin.
121 * @return a new model-view matrix with origin is at <code>referenceCenter</code>, or null if this method failed.
122 * @throws IllegalArgumentException if <code>referenceCenter</code> is null, if <code>dc</code> is null, or if the
123 * <code>Globe</code> or <code>GL</code> instances in <code>dc</code> are null.
125 Matrix
pushReferenceCenter(DrawContext dc
, Vec4 referenceCenter
);
128 * Removes the model-view matrix on top of the matrix stack, and restores the original matrix.
130 * @param dc the current World Wind drawing context on which the original matrix will be restored.
131 * @throws IllegalArgumentException if <code>dc</code> is null, or if the <code>Globe</code> or <code>GL</code>
132 * instances in <code>dc</code> are null.
134 void popReferenceCenter(DrawContext dc
);
137 * Gets the <code>View</code> eye position in model coordinates.
139 * @return the eye position in model coordinates.
144 * Gets the <code>View</code> y-axis orientation in model coordinates.
146 * @return the y-axis vector in model coordinates.
151 * Gets the <code>View</code> z-axis orientation in model coordinates.
153 * @return the z-axis vector in model coordinates.
155 Vec4
getForwardVector();
158 * Gets the <code>View</code> latitude position.
160 * @return the current latitude positon.
165 * Sets the <code>View</code> eye point to the new latitude coordinate.
167 * @param newLatitude the new latitude position.
168 * @throws IllegalArgumentException if <code>newLatitude</code> is null.
170 void setLatitude(Angle newLatitude
);
173 * Gets the <code>View</code> longitude position.
175 * @return the current longitude positon.
177 Angle
getLongitude();
180 * Sets the <code>View</code> eye point to the new longitude coordinate.
182 * @param newLongitude the new longitude position.
183 * @throws IllegalArgumentException if <code>newLongitude</code> is null.
185 void setLongitude(Angle newLongitude
);
188 * Gets the <code>View</code> eye altitude above the analytical globe radius.
190 * @return the <code>View's</code> altitude above the globe radius.
192 double getAltitude();
195 * Sets the <code>View</code> eye point to the new altitude above the analytical globe radius.
197 * @param newAltitude the new eye altitude above the globe radius.
199 void setAltitude(double newAltitude
);
202 * Sets the <code>View</code> eye point to the new (latitude, longitude) coordinate. This has the effect of calling
203 * {@link #setLatitude} and {@link #setLongitude}.
205 * @param newLatLon the latitude and longitude coordinate of the eye point.
207 void setLatLon(LatLon newLatLon
);
210 // * Gets the geographic (latitude, longitude, elevation) coordinate of the <code>View's</code> eye point.
212 // * @return the latitude and longitude coordinates of the eye point.
214 // Position getLatLonAltitude();
217 * Sets the <code>View</code> eye point to the new (latitude, longitude, elevation) coordinate. This has the effect
218 * of calling {@link #setLatitude}, {@link #setLongitude} and {@link #setAltitude}.
220 * @param newPosition the latitude, longitude and elevation coordinate of the eye point.
222 void setLatLonAltitude(Position newPosition
);
225 * Gets the <code>View's</code> angle from true North.
227 * @return the angle from true North.
232 * Sets the <code>View's</code> angle to true North.
234 * @param newHeading the new angle to true North.
235 * @throws IllegalArgumentException if <code>newHeading</code> is null.
237 void setHeading(Angle newHeading
);
240 * Gets the <code>View's</code> angle from the plane tangent to the surface.
242 * @return the angle from the surface tangent plane.
247 * Sets the <code>View's</code> angle to the plane tangent to the surface.
249 * @param newPitch the new angle to the surface tangent plane.
250 * @throws IllegalArgumentException if <code>newPitch</code> is null.
252 void setPitch(Angle newPitch
);
255 * Gets the <code>View's</code> angle about its local z-axis.
257 * @return the angle about the local z-axis.
262 * Sets the <code>View's</code> angle about its local z-axis.
264 * @param newRoll the new angle about the local z-axis.
265 * @throws IllegalArgumentException if <code>newRoll</code> is null.
267 void setRoll(Angle newRoll
);
270 * Gets the <code>View's</code> translation in its forward direction.
272 * @return translation along the forward direction.
277 * Sets the <code>View's</code> translation in its forward direction.
279 * @param newZoom translation along the forward direction.
281 void setZoom(double newZoom
);
284 * Normalizes latitude coordinates to values acceptable to this <code>View</code> implementation.
286 * @param latitude the latitude to normalize.
287 * @return the (possibly) normalized latitude.
289 Angle
normalizeLatitude(Angle latitude
);
292 * Normalizes longitude coordinates to values acceptable to this <code>View</code> implementation.
294 * @param longitude the longitude to normalize.
295 * @return the (possibly) normalized longitude.
297 Angle
normalizeLongitude(Angle longitude
);
300 * Normalizes altitude coordinates to values acceptable to this <code>View</code> implementation.
302 * @param altitude the altitude to normalize.
303 * @return the (possibly) normalized altitude.
305 double normalizeAltitude(double altitude
);
308 * Normalizes heading coordinates to values acceptable to this <code>View</code> implementation.
310 * @param heading the altitude to normalize.
311 * @return the (possibly) normalized heading.
313 Angle
normalizeHeading(Angle heading
);
316 * Normalizes pitch coordinates to values acceptable to this <code>View</code> implementation.
318 * @param pitch the altitude to normalize.
319 * @return the (possibly) normalized pitch.
321 Angle
normalizePitch(Angle pitch
);
324 * Normalizes roll coordinates to values acceptable to this <code>View</code> implementation.
326 * @param roll the altitude to normalize.
327 * @return the (possibly) normalized roll.
329 Angle
normalizeRoll(Angle roll
);
332 * Normalizes zoom coordinates to values acceptable to this <code>View</code> implementation.
334 * @param zoom the altitude to normalize.
335 * @return the (possibly) normalized zoom.
337 double normalizeZoom(double zoom
);
340 * Iterates over <code>View</code> state changes in <code>ViewStateIterator</code> and applies them to the
341 * <code>View</code>. The <code>View</code> will automatically refresh and request state from
342 * <code>viewStateIterator</code> until the iteration is complete, or <code>View</code> has been stopped by invoking
343 * {@link #stopIterating}.
345 * @param viewStateIterator the <code>ViewStateIterator</code> to iterate over.
347 void iterateOver(ViewStateIterator viewStateIterator
);
350 * Returns true when <code>View</code> is actively iterating over an instance of <code>ViewStateIterator</code>.
352 * @return true when iterating over <code>ViewStateIterator</code>; false otherwise.
354 boolean isIterating();
357 * Immediately stops all active iteration over <code>ViewStateIterator</code>.
359 void stopIterating();
362 * Computes a line, in model coordinates, originating from the eye point, and passing throught the point contained
363 * by (x, y) on the <code>View's</code> projection plane (or after projection into model space).
365 * @param x the horizontal coordinate originating from the left side of <code>View's</code> projection plane.
366 * @param y the vertical coordinate originating from the top of <code>View's</code> projection plane.
367 * @return a line beginning at the <code>View's</code> eye point and passing throught (x, y) transformed into model
370 Line
computeRayFromScreenPoint(double x
, double y
);
373 * Computes the intersection of a line originating from the eye point (passing throught (x, y)) with the last
374 * rendered <code>SectorGeometry</code>, or the last analytical <code>Globe</code> if no rendered geometry exists.
376 * @param x the horizontal coordinate originating from the left side of <code>View's</code> projection plane.
377 * @param y the vertical coordinate originating from the top of <code>View's</code> projection plane.
378 * @return the point on the surface in polar coordiantes.
380 Position
computePositionFromScreenPoint(double x
, double y
);
383 * Computes the screen-aligned dimension (in meters) that a screen pixel would cover at a given distance (also in
384 * meters). This computation assumes that pixels dimensions are square, and therefore returns a single dimension.
386 * @param distance the distance from the eye point, in eye coordinates, along the z-axis. This value must be
387 * positive but is otherwise unbounded.
388 * @return the dimension of a pixel (in meters) at the given distance.
389 * @throws IllegalArgumentException if <code>distance</code> is negative.
391 double computePixelSizeAtDistance(double distance
);
394 * Gets the distance from the <code>View's</code> eye point to the horizon point on the last rendered
395 * <code>Globe</code>.
397 * @return the distance from the eye point to the horizon (in meters).
399 double computeHorizonDistance();
402 * Maps a <code>Point</code> in model (cartesian) coordinates to a <code>Point</code> in screen coordinates. The
403 * returned x and y are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If
404 * the model point cannot be sucessfully mapped, this will return null.
406 * @param modelPoint the model coordinate <code>Point</code> to project.
407 * @return the mapped screen coordinate <code>Point</code>.
408 * @throws IllegalArgumentException if <code>modelPoint</code> is null.
410 Vec4
project(Vec4 modelPoint
);
413 * Maps a <code>Point</code> in screen coordinates to a <code>Point</code> in model coordinates. The input x and y
414 * are relative to the lower left hand screen corner, while z is the screen depth-coordinate. If the screen point
415 * cannot be sucessfully mapped, this will return null.
417 * @param windowPoint the window coordinate <code>Point</code> to project.
418 * @return the mapped screen coordinate <code>Point</code>.
419 * @throws IllegalArgumentException if <code>windowPoint</code> is null.
421 Vec4
unProject(Vec4 windowPoint
);