Stellarium 0.12.1
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
StelProjector Class Referenceabstract

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

#include <StelProjector.hpp>

Classes

class  GLSLProjector
 Base class for classes implementing vertex projection in GLSL. More...
 
class  Mat4dTransform
 
class  ModelViewTranform
 
struct  StelProjectorParams
 Contains all the param needed to initialize a StelProjector. More...
 

Public Types

enum  StelProjectorMaskType { MaskNone, MaskDisk }
 Define viewport mask types. More...
 
typedef QSharedPointer
< ModelViewTranform
ModelViewTranformP
 Shared pointer on a ModelViewTranform instance (implement reference counting) More...
 

Public Member Functions

virtual ~StelProjector ()
 Destructor. More...
 
virtual QString getNameI18 () const =0
 Get a human-readable name for this projection type. More...
 
virtual QString getDescriptionI18 () const
 Get a human-readable short description for this projection type. More...
 
QString getHtmlSummary () const
 Get a HTML version of the short description for this projection type. More...
 
virtual float getMaxFov () const =0
 Get the maximum FOV apperture in degree. More...
 
virtual bool forward (Vec3f &v) const =0
 Apply the transformation in the forward direction in place. More...
 
virtual bool backward (Vec3d &v) const =0
 Apply the transformation in the backward projection in place. More...
 
virtual float deltaZoom (float fov) const =0
 Return the small zoom increment to use at the given FOV for nice movements. More...
 
bool intersectViewportDiscontinuity (const Vec3d &p1, const Vec3d &p2) const
 Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity. More...
 
bool intersectViewportDiscontinuity (const SphericalCap &cap) const
 
virtual float fovToViewScalingFactor (float fov) const =0
 Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) More...
 
virtual float viewScalingFactorToFov (float vsf) const =0
 Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians. More...
 
bool getFlagGravityLabels () const
 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. More...
 
const Vec4igetViewport () const
 Get the lower left corner of the viewport and the width, height. More...
 
Vec2f getViewportCenter () const
 Get the center of the viewport relative to the lower left corner of the screen. More...
 
int getViewportPosX () const
 Get the horizontal viewport offset in pixels. More...
 
int getViewportPosY () const
 Get the vertical viewport offset in pixels. More...
 
int getViewportWidth () const
 Get the viewport width in pixels. More...
 
int getViewportHeight () const
 Get the viewport height in pixels. More...
 
SphericalRegionP getViewportConvexPolygon (float marginX=0., float marginY=0.) const
 Return a convex polygon on the sphere which includes the viewport in the current frame. More...
 
const SphericalCapgetBoundingCap () const
 Return a SphericalCap containing the whole viewport. More...
 
float getPixelPerRadAtCenter () const
 Get size of a radian in pixels at the center of the viewport disk. More...
 
float getFov () const
 Get the current FOV diameter in degrees. More...
 
bool flipFrontBackFace () const
 Get whether front faces need to be oriented in the clockwise direction. More...
 
bool checkInViewport (const Vec3d &pos) const
 Check to see if a 2d position is inside the viewport. More...
 
bool checkInViewport (const Vec3f &pos) const
 Check to see if a 2d position is inside the viewport. More...
 
Vec3d viewPortIntersect (const Vec3d &p1, const Vec3d &p2) const
 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) More...
 
bool project (const Vec3d &v, Vec3d &win) const
 Project the vector v from the current frame into the viewport. More...
 
bool project (const Vec3f &v, Vec3f &win) const
 Project the vector v from the current frame into the viewport. More...
 
virtual void project (int n, const Vec3d *in, Vec3f *out)
 
virtual void project (int n, const Vec3f *in, Vec3f *out)
 
virtual GLSLProjectorgetGLSLProjector ()
 Return the GLSLProjector to provide GLSL projection functionality. More...
 
bool projectInPlace (Vec3d &vd) const
 Project the vector v from the current frame into the viewport. More...
 
bool projectInPlace (Vec3f &v) const
 Project the vector v from the current frame into the viewport. More...
 
bool projectCheck (const Vec3d &v, Vec3d &win) const
 Project the vector v from the current frame into the viewport. More...
 
bool projectCheck (const Vec3f &v, Vec3f &win) const
 Project the vector v from the current frame into the viewport. More...
 
bool unProject (const Vec3d &win, Vec3d &v) const
 Project the vector v from the viewport frame into the current frame. More...
 
bool unProject (double x, double y, Vec3d &v) const
 
bool projectLineCheck (const Vec3d &v1, Vec3d &win1, const Vec3d &v2, Vec3d &win2) const
 Project the vectors v1 and v2 from the current frame into the viewport. More...
 
ModelViewTranformP getModelViewTransform () const
 Get the current model view matrix. More...
 
Mat4f getProjectionMatrix () const
 Get the current projection matrix. More...
 
StelProjectorMaskType getMaskType (void) const
 Get the current type of the mask if any. More...
 
Vec4i getViewportXywh () const
 Get viewport extents. More...
 
bool useGravityLabels () const
 Should label text align with the horizon? More...
 
float getDefaultAngleForGravityText () const
 Return the rotation angle to apply to gravity text (only if gravityLabels is false) . More...
 
Vec2f getViewportCenterAbsolute () const
 Get center of the viewport on the screen in pixels. More...
 
float getViewportFovDiameter ()
 Get diameter of the FOV disk in pixels. More...
 

Static Public Member Functions

static const QString maskTypeToString (StelProjectorMaskType type)
 Get a string description of a StelProjectorMaskType. More...
 
static StelProjectorMaskType stringToMaskType (const QString &s)
 Get a StelProjectorMaskType from a string description. More...
 

Protected Member Functions

 StelProjector (ModelViewTranformP amodelViewTransform)
 Private constructor. Only StelCore can create instances of StelProjector. More...
 
virtual bool hasDiscontinuity () const =0
 Return whether the projection presents discontinuities. Used for optimization. More...
 
virtual bool intersectViewportDiscontinuityInternal (const Vec3d &p1, const Vec3d &p2) const =0
 Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity. More...
 
virtual bool intersectViewportDiscontinuityInternal (const Vec3d &capN, double capD) const =0
 Determine whether a cap intersects with a projection discontinuity. More...
 
virtual void computeBoundingCap ()
 Initialize the bounding cap. More...
 

Protected Attributes

ModelViewTranformP modelViewTransform
 
float flipHorz
 
float flipVert
 
float pixelPerRad
 
StelProjectorMaskType maskType
 
float zNear
 
float oneOverZNearMinusZFar
 
Vec4i viewportXywh
 
Vec2f viewportCenter
 
float viewportFovDiameter
 
bool gravityLabels
 
float defautAngleForGravityText
 
SphericalCap boundingCap
 
bool disableShaderProjection
 If true, shader projection is disabled. 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, see StelRenderer and its backends.

See Also
StelProjectorP

Definition at line 38 of file StelProjector.hpp.

Member Typedef Documentation

Shared pointer on a ModelViewTranform instance (implement reference counting)

Definition at line 79 of file StelProjector.hpp.

Member Enumeration Documentation

Define viewport mask types.

Enumerator
MaskNone 

Regular - no mask.

MaskDisk 

For disk viewport mode (circular mask to seem like bins/telescope)

Definition at line 175 of file StelProjector.hpp.

Constructor & Destructor Documentation

virtual StelProjector::~StelProjector ( )
inlinevirtual

Destructor.

Definition at line 198 of file StelProjector.hpp.

StelProjector::StelProjector ( ModelViewTranformP  amodelViewTransform)
inlineprotected

Private constructor. Only StelCore can create instances of StelProjector.

Definition at line 408 of file StelProjector.hpp.

Member Function Documentation

virtual bool StelProjector::backward ( Vec3d v) const
pure virtual
bool StelProjector::checkInViewport ( const Vec3d pos) const

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

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

virtual void StelProjector::computeBoundingCap ( )
protectedvirtual

Initialize the bounding cap.

Reimplemented in StelProjector2d.

virtual float StelProjector::deltaZoom ( float  fov) const
pure virtual
bool StelProjector::flipFrontBackFace ( ) const
inline

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

Definition at line 270 of file StelProjector.hpp.

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?

Implemented in StelProjector2d, StelProjectorOrthographic, StelProjectorMercator, StelProjectorCylinder, StelProjectorHammer, StelProjectorFisheye, StelProjectorStereographic, StelProjectorEqualArea, and StelProjectorPerspective.

virtual float StelProjector::fovToViewScalingFactor ( float  fov) const
pure virtual
const SphericalCap& StelProjector::getBoundingCap ( ) const

Return a SphericalCap containing the whole viewport.

float StelProjector::getDefaultAngleForGravityText ( ) const
inline

Return the rotation angle to apply to gravity text (only if gravityLabels is false) .

Definition at line 389 of file StelProjector.hpp.

virtual QString StelProjector::getDescriptionI18 ( ) const
inlinevirtual
bool StelProjector::getFlagGravityLabels ( ) const

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.

float StelProjector::getFov ( ) const

Get the current FOV diameter in degrees.

virtual GLSLProjector* StelProjector::getGLSLProjector ( )
inlinevirtual

Return the GLSLProjector to provide GLSL projection functionality.

This can return NULL if the StelProjector implementation does not support GLSL projection.

Reimplemented in StelProjectorStereographic.

Definition at line 310 of file StelProjector.hpp.

QString StelProjector::getHtmlSummary ( ) const

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

StelProjectorMaskType StelProjector::getMaskType ( void  ) const

Get the current type of the mask if any.

virtual float StelProjector::getMaxFov ( ) const
pure virtual
ModelViewTranformP StelProjector::getModelViewTransform ( ) const

Get the current model view matrix.

virtual QString StelProjector::getNameI18 ( ) const
pure virtual
float StelProjector::getPixelPerRadAtCenter ( ) const

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

Mat4f StelProjector::getProjectionMatrix ( ) const
inline

Get the current projection matrix.

Definition at line 357 of file StelProjector.hpp.

const Vec4i& StelProjector::getViewport ( ) const

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

Vec2f StelProjector::getViewportCenter ( ) const

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

Vec2f StelProjector::getViewportCenterAbsolute ( ) const
inline

Get center of the viewport on the screen in pixels.

Definition at line 395 of file StelProjector.hpp.

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
marginXan extra margin in pixel which extends the polygon size in the X direction.
marginYan 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).
float StelProjector::getViewportFovDiameter ( )
inline

Get diameter of the FOV disk in pixels.

Definition at line 401 of file StelProjector.hpp.

int StelProjector::getViewportHeight ( ) const

Get the viewport height in pixels.

int StelProjector::getViewportPosX ( ) const

Get the horizontal viewport offset in pixels.

int StelProjector::getViewportPosY ( ) const

Get the vertical viewport offset in pixels.

int StelProjector::getViewportWidth ( ) const

Get the viewport width in pixels.

Vec4i StelProjector::getViewportXywh ( ) const
inline

Get viewport extents.

Definition at line 377 of file StelProjector.hpp.

virtual bool StelProjector::hasDiscontinuity ( ) const
protectedpure virtual
bool StelProjector::intersectViewportDiscontinuity ( const Vec3d p1,
const Vec3d p2 
) const

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 p1,
const Vec3d p2 
) const
protectedpure 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).

Implemented in StelProjector2d, StelProjectorOrthographic, StelProjectorMercator, StelProjectorCylinder, StelProjectorHammer, StelProjectorFisheye, StelProjectorStereographic, StelProjectorEqualArea, and StelProjectorPerspective.

virtual bool StelProjector::intersectViewportDiscontinuityInternal ( const Vec3d capN,
double  capD 
) const
protectedpure virtual
static const QString StelProjector::maskTypeToString ( StelProjectorMaskType  type)
static

Get a string description of a StelProjectorMaskType.

bool StelProjector::project ( const Vec3d v,
Vec3d win 
) const

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

Parameters
vthe vector in the current frame.
winthe projected vector in the viewport 2D frame.
Returns
true if the projected coordinate is valid.
bool StelProjector::project ( const Vec3f v,
Vec3f win 
) const

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

Parameters
vthe vector in the current frame.
winthe projected vector in the viewport 2D frame.
Returns
true if the projected coordinate is valid.
bool StelProjector::projectCheck ( const Vec3d v,
Vec3d win 
) const

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

Parameters
vthe direction vector in the current frame. Does not need to be normalized.
winthe 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

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

Parameters
vthe direction vector in the current frame. Does not need to be normalized.
winthe 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::projectInPlace ( Vec3d vd) const

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

Parameters
vdthe vector in the current frame.
Returns
true if the projected coordinate is valid.
bool StelProjector::projectInPlace ( Vec3f v) const

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

Parameters
vthe 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

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

Parameters
v1the first vector in the current frame.
v2the second vector in the current frame.
win1the first projected vector in the viewport 2D frame.
win2the second projected vector in the viewport 2D frame.
Returns
true if at least one of the projected vector is within the viewport.
static StelProjectorMaskType StelProjector::stringToMaskType ( const QString &  s)
static

Get a StelProjectorMaskType from a string description.

bool StelProjector::unProject ( const Vec3d win,
Vec3d v 
) const

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

Parameters
winthe vector in the viewport 2D frame. win[0] and win[1] are in screen pixels, win[2] is unused.
vthe unprojected direction vector in the current frame.
Returns
true if the projected coordinate is valid.
bool StelProjector::useGravityLabels ( ) const
inline

Should label text align with the horizon?

Definition at line 383 of file StelProjector.hpp.

Vec3d StelProjector::viewPortIntersect ( const Vec3d p1,
const Vec3d p2 
) const

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)

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

Member Data Documentation

bool StelProjector::disableShaderProjection
protected

If true, shader projection is disabled.

Set when an attempt to set up shader projection fails.

Definition at line 442 of file StelProjector.hpp.


The documentation for this class was generated from the following file: