Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

StelProjector Class Reference

Provide the main interface to all operations of projecting coordinates from sky to screen. More...

#include <StelProjector.hpp>

Inherited by StelProjector2d, StelProjectorCylinder, StelProjectorEqualArea, StelProjectorFisheye, StelProjectorHammer, StelProjectorMercator, StelProjectorOrthographic, StelProjectorPerspective, and StelProjectorStereographic.

List of all members.

Public Types

enum  StelProjectorMaskType { MaskNone, MaskDisk }

Public Member Functions

virtual ~StelProjector ()
virtual QString getNameI18 () const =0
virtual QString getDescriptionI18 () const
QString getHtmlSummary () const
virtual float getMaxFov () const =0
virtual bool forward (Vec3f &v) const =0
virtual bool backward (Vec3d &v) const =0
virtual float deltaZoom (float fov) const =0
bool intersectViewportDiscontinuity (const Vec3d &p1, const Vec3d &p2) const
bool intersectViewportDiscontinuity (const SphericalCap &cap) const
virtual float fovToViewScalingFactor (float fov) const =0
virtual float viewScalingFactorToFov (float vsf) const =0
bool getFlagGravityLabels () const
const Vec4igetViewport () const
Vec2f getViewportCenter () const
int getViewportPosX () const
int getViewportPosY () const
int getViewportWidth () const
int getViewportHeight () const
SphericalRegionP getViewportConvexPolygon (float marginX=0., float marginY=0.) const
const SphericalCapgetBoundingCap () const
float getPixelPerRadAtCenter () const
float getFov () const
bool needGlFrontFaceCW () const
bool checkInViewport (const Vec3d &pos) const
bool checkInViewport (const Vec3f &pos) const
Vec3d viewPortIntersect (const Vec3d &p1, const Vec3d &p2) const
bool project (const Vec3d &v, Vec3d &win) const
bool project (const Vec3f &v, Vec3f &win) const
virtual void project (int n, const Vec3d *in, Vec3f *out)
virtual void project (int n, const Vec3f *in, Vec3f *out)
bool projectInPlace (Vec3d &vd) const
bool projectInPlace (Vec3f &v) const
bool projectCheck (const Vec3d &v, Vec3d &win) const
bool projectCheck (const Vec3f &v, Vec3f &win) const
bool unProject (const Vec3d &win, Vec3d &v) const
bool unProject (double x, double y, Vec3d &v) const
bool projectLineCheck (const Vec3d &v1, Vec3d &win1, const Vec3d &v2, Vec3d &win2) const
const Mat4dgetModelViewMatrix () const
Mat4f getProjectionMatrix () const
StelProjectorMaskType getMaskType (void) const

Static Public Member Functions

static const QString maskTypeToString (StelProjectorMaskType type)
static StelProjectorMaskType stringToMaskType (const QString &s)

Protected Member Functions

 StelProjector (const Mat4d &modelViewMat)
virtual bool hasDiscontinuity () const =0
virtual bool intersectViewportDiscontinuityInternal (const Vec3d &p1, const Vec3d &p2) const =0
virtual bool intersectViewportDiscontinuityInternal (const Vec3d &capN, double capD) const =0
virtual void computeBoundingCap ()

Protected Attributes

Mat4d modelViewMatrix
Mat4f modelViewMatrixf
float flipHorz
float flipVert
float pixelPerRad
StelProjectorMaskType maskType
float zNear
float oneOverZNearMinusZFar
Vec4i viewportXywh
Vec2f viewportCenter
float viewportFovDiameter
bool gravityLabels
SphericalCap boundingCap

Classes

struct  StelProjectorParams
 Contains all the param needed to initialize a StelProjector. More...


Detailed Description

Provide the main interface to all operations of projecting coordinates from sky to screen.

The StelProjector also defines the viewport size and position. All methods from this class are threadsafe. The usual usage is to create local instances of StelProjectorP using the getProjection() method from StelCore where needed. For performing drawing using a particular projection, refer to the StelPainter class.

See also:
StelProjectorP

Member Enumeration Documentation

Define viewport mask types.

Enumerator:
MaskNone  Regular - no mask.
MaskDisk  For disk viewport mode (circular mask to seem like bins/telescope).


Constructor & Destructor Documentation

virtual StelProjector::~StelProjector (  )  [inline, virtual]

Destructor.

StelProjector::StelProjector ( const Mat4d modelViewMat  )  [inline, protected]

Private constructor. Only StelCore can create instances of StelProjector.


Member Function Documentation

virtual QString StelProjector::getNameI18 (  )  const [pure virtual]

Get a human-readable name for this projection type.

virtual QString StelProjector::getDescriptionI18 (  )  const [inline, virtual]

Get a human-readable short description for this projection type.

QString StelProjector::getHtmlSummary (  )  const

Get a HTML version of the short description for this projection type.

virtual float StelProjector::getMaxFov (  )  const [pure virtual]

Get the maximum FOV apperture in degree.

virtual bool StelProjector::forward ( Vec3f v  )  const [pure virtual]

Apply the transformation in the forward direction in place.

After transformation v[2] will always contain the length of the original v: sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]) regardless of the projection type. This makes it possible to implement depth buffer testing in a way independent of the projection type. I would like to return the squared length instead of the length because of performance reasons. But then far away objects are not textured any more, perhaps because of a depth buffer overflow although the depth test is disabled?

virtual bool StelProjector::backward ( Vec3d v  )  const [pure virtual]

Apply the transformation in the backward projection in place.

virtual float StelProjector::deltaZoom ( float  fov  )  const [pure virtual]

Return the small zoom increment to use at the given FOV for nice movements.

bool StelProjector::intersectViewportDiscontinuity ( const Vec3d p1,
const Vec3d p2 
) const [inline]

Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity.

For many projections without discontinuity, this should return always false, but for other like cylindrical projection it will return true if the line cuts the wrap-around line (i.e. at lon=180 if the observer look at lon=0).

virtual float StelProjector::fovToViewScalingFactor ( float  fov  )  const [pure virtual]

Convert a Field Of View radius value in radians in ViewScalingFactor (used internally).

virtual float StelProjector::viewScalingFactorToFov ( float  vsf  )  const [pure virtual]

Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.

bool StelProjector::getFlagGravityLabels (  )  const [inline]

Get the current state of the flag which decides whether to arrage labels so that they are aligned with the bottom of a 2d screen, or a 3d dome.

const Vec4i& StelProjector::getViewport (  )  const [inline]

Get the lower left corner of the viewport and the width, height.

Vec2f StelProjector::getViewportCenter (  )  const [inline]

Get the center of the viewport relative to the lower left corner of the screen.

int StelProjector::getViewportPosX (  )  const [inline]

Get the horizontal viewport offset in pixels.

int StelProjector::getViewportPosY (  )  const [inline]

Get the vertical viewport offset in pixels.

int StelProjector::getViewportWidth (  )  const [inline]

Get the viewport width in pixels.

int StelProjector::getViewportHeight (  )  const [inline]

Get the viewport height in pixels.

SphericalRegionP StelProjector::getViewportConvexPolygon ( float  marginX = 0.,
float  marginY = 0. 
) const

Return a convex polygon on the sphere which includes the viewport in the current frame.

Parameters:
marginX an extra margin in pixel which extends the polygon size in the X direction.
marginY an extra margin in pixel which extends the polygon size in the Y direction.
Returns:
a SphericalConvexPolygon or the special fullSky region if the viewport cannot be represented by a convex polygon (e.g. if aperture > 180 deg).

const SphericalCap& StelProjector::getBoundingCap (  )  const [inline]

Return a SphericalCap containing the whole viewport.

float StelProjector::getPixelPerRadAtCenter (  )  const [inline]

Get size of a radian in pixels at the center of the viewport disk.

float StelProjector::getFov (  )  const [inline]

Get the current FOV diameter in degree.

bool StelProjector::needGlFrontFaceCW (  )  const [inline]

Get whether front faces need to be oriented in the clockwise direction.

bool StelProjector::checkInViewport ( const Vec3d pos  )  const [inline]

Check to see if a 2d position is inside the viewport.

TODO Optimize by storing viewportXywh[1] + viewportXywh[3] and viewportXywh[0] + viewportXywh[2] already computed

bool StelProjector::checkInViewport ( const Vec3f pos  )  const [inline]

Check to see if a 2d position is inside the viewport.

TODO Optimize by storing viewportXywh[1] + viewportXywh[3] and viewportXywh[0] + viewportXywh[2] already computed

Vec3d StelProjector::viewPortIntersect ( const Vec3d p1,
const Vec3d p2 
) const [inline]

Return the position where the 2 2D point p1 and p2 cross the viewport edge P1 must be inside the viewport and P2 outside (check with checkInViewport() before calling this method).

bool StelProjector::project ( const Vec3d v,
Vec3d win 
) const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
v the vector in the current frame.
win the projected vector in the viewport 2D frame.
Returns:
true if the projected coordinate is valid.

bool StelProjector::project ( const Vec3f v,
Vec3f win 
) const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
v the vector in the current frame.
win the projected vector in the viewport 2D frame.
Returns:
true if the projected coordinate is valid.

bool StelProjector::projectInPlace ( Vec3d vd  )  const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
vd the vector in the current frame.
Returns:
true if the projected coordinate is valid.

bool StelProjector::projectInPlace ( Vec3f v  )  const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
v the vector in the current frame.
Returns:
true if the projected coordinate is valid.

bool StelProjector::projectCheck ( const Vec3d v,
Vec3d win 
) const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
v the direction vector in the current frame. Does not need to be normalized.
win the projected vector in the viewport 2D frame. win[0] and win[1] are in screen pixels, win[2] is unused.
Returns:
true if the projected point is inside the viewport.

bool StelProjector::projectCheck ( const Vec3f v,
Vec3f win 
) const [inline]

Project the vector v from the current frame into the viewport.

Parameters:
v the direction vector in the current frame. Does not need to be normalized.
win the projected vector in the viewport 2D frame. win[0] and win[1] are in screen pixels, win[2] is unused.
Returns:
true if the projected point is inside the viewport.

bool StelProjector::unProject ( const Vec3d win,
Vec3d v 
) const [inline]

Project the vector v from the viewport frame into the current frame.

Parameters:
win the vector in the viewport 2D frame. win[0] and win[1] are in screen pixels, win[2] is unused.
v the unprojected direction vector in the current frame.
Returns:
true if the projected coordinate is valid.

bool StelProjector::projectLineCheck ( const Vec3d v1,
Vec3d win1,
const Vec3d v2,
Vec3d win2 
) const [inline]

Project the vectors v1 and v2 from the current frame into the viewport.

Parameters:
v1 the first vector in the current frame.
v2 the second vector in the current frame.
win1 the first projected vector in the viewport 2D frame.
win2 the second projected vector in the viewport 2D frame.
Returns:
true if at least one of the projected vector is within the viewport.

const Mat4d& StelProjector::getModelViewMatrix (  )  const [inline]

Get the current model view matrix.

Mat4f StelProjector::getProjectionMatrix (  )  const [inline]

Get the current projection matrix.

static const QString StelProjector::maskTypeToString ( StelProjectorMaskType  type  )  [static]

Get a string description of a StelProjectorMaskType.

static StelProjectorMaskType StelProjector::stringToMaskType ( const QString &  s  )  [static]

Get a StelProjectorMaskType from a string description.

StelProjectorMaskType StelProjector::getMaskType ( void   )  const [inline]

Get the current type of the mask if any.

virtual bool StelProjector::hasDiscontinuity (  )  const [protected, pure virtual]

Return whether the projection presents discontinuities. Used for optimization.

virtual bool StelProjector::intersectViewportDiscontinuityInternal ( const Vec3d p1,
const Vec3d p2 
) const [protected, pure virtual]

Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity.

For many projections without discontinuity, this should return always false, but for other like cylindrical projection it will return true if the line cuts the wrap-around line (i.e. at lon=180 if the observer look at lon=0).

virtual bool StelProjector::intersectViewportDiscontinuityInternal ( const Vec3d capN,
double  capD 
) const [protected, pure virtual]

Determine whether a cap intersects with a projection discontinuity.

virtual void StelProjector::computeBoundingCap (  )  [protected, virtual]

Initialize the bounding cap.


Generated on Wed Jun 2 13:11:14 2010 for Stellarium by  doxygen 1.5.5