Stellarium
0.20.4
|
Provide the main interface to all operations of projecting coordinates from sky to screen. More...
#include <StelProjector.hpp>
Data Structures | |
class | Mat4dTransform |
class | ModelViewTranform |
Allows to define non linear operations in addition to the standard linear (Matrix 4d) ModelView transformation. More... | |
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) | |
Public Member Functions | |
virtual | ~StelProjector () |
Destructor. | |
virtual QString | getNameI18 () const =0 |
Get a human-readable name for this projection type. | |
virtual QString | getDescriptionI18 () const |
Get a human-readable short description for this projection type. | |
QString | getHtmlSummary () const |
Get a HTML version of the short description for this projection type. | |
virtual float | getMaxFov () const =0 |
Get the maximum FOV apperture in degree. | |
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. | |
virtual float | deltaZoom (float fov) const =0 |
Return the small zoom increment to use at the given FOV for nice movements. | |
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) | |
virtual float | viewScalingFactorToFov (float vsf) const =0 |
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians. | |
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 Vec4i & | getViewport () const |
Get the lower left corner of the viewport and the width, height. | |
Vector2< qreal > | getViewportCenter () const |
Get the center of the viewport relative to the lower left corner of the screen. | |
Vector2< qreal > | getViewportCenterOffset () const |
int | getViewportPosX () const |
Get the horizontal viewport offset in pixels. | |
int | getViewportPosY () const |
Get the vertical viewport offset in pixels. | |
int | getViewportWidth () const |
Get the viewport width in pixels. | |
int | getViewportHeight () const |
Get the viewport height in pixels. | |
qreal | getDevicePixelsPerPixel () const |
Get the number of device pixels per "Device Independent Pixels" (value is usually 1, but 2 for mac retina screens). | |
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 SphericalCap & | getBoundingCap () const |
Return a SphericalCap containing the whole viewport. | |
float | getPixelPerRadAtCenter () const |
Get size of a radian in pixels at the center of the viewport disk. | |
float | getFov () const |
Get the current FOV diameter in degrees. | |
bool | needGlFrontFaceCW () const |
Get whether front faces need to be oriented in the clockwise direction. | |
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) | |
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) |
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. | |
Mat4f | getProjectionMatrix () const |
Get the current projection matrix. | |
StelProjectorMaskType | getMaskType (void) const |
Get the current type of the mask if any. | |
Static Public Member Functions | |
static const QString | maskTypeToString (StelProjectorMaskType type) |
Get a string description of a StelProjectorMaskType. | |
static StelProjectorMaskType | stringToMaskType (const QString &s) |
Get a StelProjectorMaskType from a string description. | |
Protected Member Functions | |
StelProjector (ModelViewTranformP amodelViewTransform) | |
Private constructor. Only StelCore can create instances of StelProjector. | |
virtual bool | hasDiscontinuity () const =0 |
Return whether the projection presents discontinuities. Used for optimization. | |
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. | |
virtual void | computeBoundingCap () |
Initialize the bounding cap. | |
Protected Attributes | |
ModelViewTranformP | modelViewTransform |
float | flipHorz |
float | flipVert |
float | pixelPerRad |
StelProjectorMaskType | maskType |
double | zNear |
double | oneOverZNearMinusZFar |
Vec4i | viewportXywh |
Vector2< qreal > | viewportCenter |
Vector2< qreal > | viewportCenterOffset |
qreal | viewportFovDiameter |
bool | gravityLabels |
float | defaultAngleForGravityText |
SphericalCap | boundingCap |
qreal | devicePixelsPerPixel |
qreal | widthStretch |
Friends | |
class | StelPainter |
class | StelCore |
The StelProjector also defines the viewport size and position. All positions in pixels are in real device pixels, which is not the same as device independent pixels. On a mac with retina screen, there are 2 device pixels per pixels. 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.
bool StelProjector::checkInViewport | ( | const Vec3d & | pos | ) | const |
TODO Optimize by storing viewportXywh[1] + viewportXywh[3] and viewportXywh[0] + viewportXywh[2] already computed
bool StelProjector::checkInViewport | ( | const Vec3f & | pos | ) | const |
TODO Optimize by storing viewportXywh[1] + viewportXywh[3] and viewportXywh[0] + viewportXywh[2] already computed
|
pure virtual |
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, StelProjectorMiller, StelProjectorSinusoidal, StelProjectorOrthographic, StelProjectorMercator, StelProjectorCylinder, StelProjectorHammer, StelProjectorFisheye, StelProjectorStereographic, StelProjectorEqualArea, and StelProjectorPerspective.
bool StelProjector::getFlagGravityLabels | ( | ) | const |
SphericalRegionP StelProjector::getViewportConvexPolygon | ( | float | marginX = 0. , |
float | marginY = 0. |
||
) | const |
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. |
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).
|
protectedpure virtual |
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.
v | the vector in the current frame. |
win | the projected vector in the viewport 2D frame. |
v | the vector in the current frame. |
win | the projected vector in the viewport 2D frame. |
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. |
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. |
bool StelProjector::projectInPlace | ( | Vec3d & | vd | ) | const |
vd | the vector in the current frame. |
bool StelProjector::projectInPlace | ( | Vec3f & | v | ) | const |
v | the vector in the current frame. |
bool StelProjector::projectLineCheck | ( | const Vec3d & | v1, |
Vec3d & | win1, | ||
const Vec3d & | v2, | ||
Vec3d & | win2 | ||
) | const |
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. |