Projector.hpp   StelProjector.hpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _PROJECTOR_HPP_ #ifndef _STELPROJECTOR_HPP_
#define _PROJECTOR_HPP_ #define _STELPROJECTOR_HPP_
#include "GLee.h" #include "StelProjectorType.hpp"
#include "fixx11h.h" #include "VecMath.hpp"
#include "vecmath.h" #include "StelSphereGeometry.hpp"
#include "Mapping.hpp"
#include "SphereGeometry.hpp" //! @class StelProjector
//! Provide the main interface to all operations of projecting coordinates
#include <QString> from sky to screen.
#include <QObject> //! The StelProjector also defines the viewport size and position.
#include <QList> //! All methods from this class are threadsafe. The usual usage is to creat
#include <QMap> e local instances of StelProjectorP using the
//! getProjection() method from StelCore where needed.
class SFont; //! For performing drawing using a particular projection, refer to the Stel
Painter class.
//! @class Projector //! @sa StelProjectorP
//! Provides functions for drawing operations which are performed with some class StelProjector
sort of
//! "projection" according to the current projection mode. This projection
//! distorts the shape of the objects to be drawn and make the necessary ca
lls
//! to OpenGL to draw the required object. This class overrides a number of
openGL
//! functions to enable non-linear projection, such as fisheye or stereogra
phic
//! projections. This class also provide drawing primitives that are optimi
zed
//! according to the projection mode.
class Projector : public QObject
{ {
Q_OBJECT;
public: public:
friend class StelPainter;
friend class StelCore;
//! @enum StelProjectorMaskType
//! Define viewport mask types
enum StelProjectorMaskType
{
MaskNone, //!< Regular - no mask.
MaskDisk //!< For disk viewport mode (circular mask t
o seem like bins/telescope)
};
//! Supported reference frame types //! @struct StelProjectorParams
enum FrameType //! Contains all the param needed to initialize a StelProjector
struct StelProjectorParams
{ {
FrameLocal, StelProjectorParams() : viewportXywh(0), fov(60.), gravityLa
FrameHelio, bels(false), maskType(MaskNone), viewportCenter(0., 0.), flipHorz(false), f
FrameEarthEqu, lipVert(false) {;}
FrameJ2000 Vector4<int> viewportXywh; //! posX, posY, width, height
double fov; //! FOV in degrees
bool gravityLabels; //! the flag to use gravity l
abels or not
StelProjectorMaskType maskType; //! The current projector
mask
double zNear, zFar; //! Near and far clipping pla
nes
Vec2d viewportCenter; //! Viewport center in screen
pixel
double viewportFovDiameter; //! diameter of the FOV disk
in pixel
bool flipHorz, flipVert; //! Whether to flip in horizo
ntal or vertical directions
}; };
//! Destructor
virtual ~StelProjector() {;}
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Main constructor // Methods which must be reimplemented by all instance of StelProjec
Projector(const Vector4<GLint>& viewport, double _fov = 60.); tor
~Projector(); //! Get a human-readable name for this projection type
virtual QString getNameI18() const = 0;
//! Initialise the Projector. //! Get a human-readable short description for this projection type
//! - Sets the viewport size according to the window/screen size and virtual QString getDescriptionI18() const {return "No description";}
settings //! Get a HTML version of the short description for this projection
//! in the ini parser object. type
//! - Sets the maximum field of view for each projection type. QString getHtmlSummary() const;
//! - Register each projection type. //! Get the maximum FOV apperture in degree
//! - Sets the flag to use gravity labels or not according to the in virtual double getMaxFov() const = 0;
i parser //! Apply the transformation in the forward direction in place.
//! object. //! After transformation v[2] will always contain the length of the
//! - Sets the default projection mode and field of view. original v: sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2])
//! - Sets whether to use GL points or a spite, according to the ini //! regardless of the projection type. This makes it possible to imp
parser lement depth buffer testing in a way independent of the
//! object and the detected hardware capabilities. //! projection type. I would like to return the squared length inste
void init(); ad of the length because of performance reasons.
//! But then far away objects are not textured any more, perhaps bec
//! Set the standard modelview matrices used for projection. ause of a depth buffer overflow although
// TODO: more complete description of what they are used for. //! the depth test is disabled?
//! @param _matEarthEquToEye ??? virtual bool forward(Vec3d &v) const = 0;
//! @param _matHelioToEye //! Apply the transformation in the backward projection in place.
//! @param _matLocalToEye virtual bool backward(Vec3d &v) const = 0;
//! @param _matJ2000ToEye //! Return the small zoom increment to use at the given FOV for nice
void setModelviewMatrices(const Mat4d& _matEarthEquToEye, movements
const Mat4d& _matHelioToEye, virtual double deltaZoom(double fov) const = 0;
const Mat4d& _matLocalToEye,
const Mat4d& _matJ2000ToEye); //! Convert a Field Of View radius value in radians in ViewScalingFa
ctor (used internally)
virtual double fovToViewScalingFactor(double fov) const = 0;
//! Convert a ViewScalingFactor value (used internally) in Field Of
View radius in radians
virtual double viewScalingFactorToFov(double vsf) const = 0;
//! Get the current state of the flag which decides whether to //! Get the current state of the flag which decides whether to
//! arrage labels so that they are aligned with the bottom of a 2d //! arrage labels so that they are aligned with the bottom of a 2d
//! screen, or a 3d dome. //! screen, or a 3d dome.
bool getFlagGravityLabels() const { return gravityLabels; } bool getFlagGravityLabels() const { return gravityLabels; }
//! Register a new projection mapping.
void registerProjectionMapping(Mapping *c);
////////////////////////////////////////////////////////////////////
///////
//! @enum ProjectorMaskType Methods for controlling viewport and mas
k.
enum ProjectorMaskType
{
Disk, //!< For disk viewport mode (circular mask to seem l
ike bins/telescope)
None //!< Regular - no mask.
};
//! Get a string description of a ProjectorMaskType.
static const QString maskTypeToString(ProjectorMaskType type);
//! Get a ProjectorMaskType from a string description.
static ProjectorMaskType stringToMaskType(const QString &s);
//! Get the current type of the mask if any.
ProjectorMaskType getMaskType(void) const {return maskType;}
//! Set the mask type.
void setMaskType(ProjectorMaskType m) {maskType = m; }
//! Set up the view port dimensions and position.
//! Define viewport size, center(relative to lower left corner)
//! and diameter of FOV disk.
//! @param x The x-position of the viewport.
//! @param y The y-position of the viewport.
//! @param w The width of the viewport.
//! @param h The height of the viewport.
//! @param cx The center of the viewport in the x axis (relative to
left edge).
//! @param cy The center of the viewport in the y axis (relative to
bottom edge).
//! @param fovDiam The field of view diameter.
void setViewport(int x, int y, int w, int h, double cx, double cy, d
ouble fovDiam);
//! Get the lower left corner of the viewport and the width, height. //! Get the lower left corner of the viewport and the width, height.
const Vector4<GLint>& getViewport(void) const {return viewportXywh;} const Vec4i& getViewport(void) const {return viewportXywh;}
//! Get the center of the viewport relative to the lower left corner . //! Get the center of the viewport relative to the lower left corner of the screen.
Vec2d getViewportCenter(void) const Vec2d getViewportCenter(void) const
{ {
return Vec2d(viewportCenter[0]-viewportXywh[0],viewportCente r[1]-viewportXywh[1]); return Vec2d(viewportCenter[0]-viewportXywh[0],viewportCente r[1]-viewportXywh[1]);
} }
//! Get the diameter of the FOV disk.
double getViewportFovDiameter(void) const {return viewportFovDiamete
r;}
//! Get the horizontal viewport offset in pixels. //! Get the horizontal viewport offset in pixels.
int getViewportPosX(void) const {return viewportXywh[0];} int getViewportPosX(void) const {return viewportXywh[0];}
//! Get the vertical viewport offset in pixels. //! Get the vertical viewport offset in pixels.
int getViewportPosY(void) const {return viewportXywh[1];} int getViewportPosY(void) const {return viewportXywh[1];}
//! Get the viewport width in pixels. //! Get the viewport width in pixels.
int getViewportWidth(void) const {return viewportXywh[2];} int getViewportWidth(void) const {return viewportXywh[2];}
//! Get the viewport height in pixels. //! Get the viewport height in pixels.
int getViewportHeight(void) const {return viewportXywh[3];} int getViewportHeight(void) const {return viewportXywh[3];}
//! Get the maximum ratio between the viewport height and width
float getViewportRatio() const {return getViewportWidth()>getViewpor
tHeight() ? getViewportWidth()/getViewportHeight() : getViewportHeight()/ge
tViewportWidth();}
//! Handle the resizing of the window.
void windowHasBeenResized(int width,int height);
//! Return a polygon matching precisely the real viewport defined by
//! the area on the screen where projection is valid.
//! Normally, nothing should be drawn outside this area. This viewpo
rt
//! is usually the rectangle defined by the screen, but in case of
//! non-linear projection, it can also be a more complex shape.
QList<Vec2d> getViewportVertices2d() const;
//! Return a convex polygon on the sphere which includes the viewpor t in the current frame. //! Return a convex polygon on the sphere which includes the viewpor t in the current frame.
//! @param marginX an extra margin in pixel which extends the polygo n size in the X direction //! @param marginX an extra margin in pixel which extends the polygo n size in the X direction
//! @param marginY an extra margin in pixel which extends the polygo n size in the Y direction //! @param marginY an extra margin in pixel which extends the polygo n size in the Y direction
//! @TODO Should be unified with unprojectViewport
StelGeom::ConvexPolygon getViewportConvexPolygon(double marginX=0., double marginY=0.) const; StelGeom::ConvexPolygon getViewportConvexPolygon(double marginX=0., double marginY=0.) const;
//! Un-project the entire viewport depending on mapping, maskType, //! Un-project the entire viewport depending on mapping, maskType,
//! viewportFovDiameter, viewportCenter, and viewport dimensions. //! viewportFovDiameter, viewportCenter, and viewport dimensions.
StelGeom::ConvexS unprojectViewport(void) const; //! @TODO Should be unified with getViewportConvexPolygon
StelGeom::ConvexS unprojectViewport() const;
//! Set whether a disk mask must be drawn over the viewport.
void setViewportMaskDisk(void) {setMaskType(Projector::Disk);}
//! Get whether a disk mask must be drawn over the viewport.
bool getViewportMaskDisk(void) const {return getMaskType()==Projecto
r::Disk;}
//! Set whether no mask must be drawn over the viewport.
void setViewportMaskNone(void) {setMaskType(Projector::None);}
//! Set the clipping planes.
// TODO: A better explanation.
void setClippingPlanes(double znear, double zfar);
//! Get the clipping planes.
// TODO: A better explanation.
void getClippingPlanes(double* zn, double* zf) const {*zn = zNear; *
zf = zFar;}
//////////////////////////////////////////////////////////////////// //! Return a Halfspace containing the whole viewport
/////// StelGeom::HalfSpace getBoundingHalfSpace() const;
// Methods for controlling the PROJECTION matrix
// TODO Doxygen docs: What is this for?
bool needGlFrontFaceCW(void) const {return (flipHorz*flipVert < 0.0)
;}
//! Get whether the GL_POINT_SPRITE extension is available now.
bool getflagGlPointSprite() const {return flagGlPointSprite;}
//! Set the Field of View in degrees.
void setFov(double f);
//! Get the Field of View in degrees.
double getFov(void) const {return fov;}
//! Get size of a radian in pixels at the center of the viewport dis k //! Get size of a radian in pixels at the center of the viewport dis k
double getPixelPerRadAtCenter(void) const {return pixelPerRad;} double getPixelPerRadAtCenter(void) const {return pixelPerRad;}
//! Set the maximum field of View in degrees. //! Get the current FOV diameter in degree
void setMaxFov(double max); double getFov() const {return 360./M_PI*viewScalingFactorToFov(0.5*v
//! Get the maximum field of View in degrees. iewportFovDiameter/pixelPerRad);}
double getMaxFov(void) const {return maxFov;}
//! Return the initial default FOV in degree. //! Get whether front faces need to be oriented in the clockwise dir
double getInitFov() const {return initFov;} ection
bool needGlFrontFaceCW(void) const {return (flipHorz*flipVert < 0.0)
;}
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Full projection methods // Full projection methods
//! Check to see if a 2d position is inside the viewport. //! Check to see if a 2d position is inside the viewport.
//! TODO Optimize by storing viewportXywh[1] + viewportXywh[3] and v iewportXywh[0] + viewportXywh[2] already computed
bool checkInViewport(const Vec3d& pos) const bool checkInViewport(const Vec3d& pos) const
{return (pos[1]>=viewportXywh[1] && pos[0]>=viewportXywh[0] {
&& return (pos[1]>=viewportXywh[1] && pos[0]>=viewportXywh[0] &
pos[1]<=(viewportXywh[1] + viewportXywh[3]) && pos[0]<=(view &
portXywh[0] + viewportXywh[2]));} pos[1]<=(viewportXywh[1] + viewportXywh[3]) && pos[0
]<=(viewportXywh[0] + viewportXywh[2]));
}
//! Return the position where the 2 2D point p1 and p2 cross the vie
wport edge
//! P1 must be inside the viewport and P2 outside (check with checkI
nViewport() before calling this method)
Vec3d viewPortIntersect(const Vec3d& p1, const Vec3d& p2) const
{
Vec3d v1=p1;
Vec3d v2=p2;
Vec3d v;
for (int i=0;i<8;++i)
{
v=(v1+v2)*0.5;
if (!checkInViewport(v))
v2=v;
else
v1=v;
}
return v;
}
//! Project the vector v from the current frame into the viewport. //! Project the vector v from the current frame into the viewport.
//! @param v the vector in the current frame. //! @param v the vector in the current frame.
//! @param win the projected vector in the viewport 2D frame. //! @param win the projected vector in the viewport 2D frame.
//! @return true if the projected coordinate is valid. //! @return true if the projected coordinate is valid.
bool project(const Vec3d& v, Vec3d& win) const bool project(const Vec3d& v, Vec3d& win) const
{ {
// really important speedup: // really important speedup:
win[0] = modelViewMatrix.r[0]*v[0] + modelViewMatrix.r[4]*v[ 1] win[0] = modelViewMatrix.r[0]*v[0] + modelViewMatrix.r[4]*v[ 1]
+ modelViewMatrix.r[8]*v[2] + modelViewMatri x.r[12]; + modelViewMatrix.r[8]*v[2] + modelViewMatri x.r[12];
win[1] = modelViewMatrix.r[1]*v[0] + modelViewMatrix.r[5]*v[ 1] win[1] = modelViewMatrix.r[1]*v[0] + modelViewMatrix.r[5]*v[ 1]
+ modelViewMatrix.r[9]*v[2] + modelViewMatri x.r[13]; + modelViewMatrix.r[9]*v[2] + modelViewMatri x.r[13];
win[2] = modelViewMatrix.r[2]*v[0] + modelViewMatrix.r[6]*v[ 1] win[2] = modelViewMatrix.r[2]*v[0] + modelViewMatrix.r[6]*v[ 1]
+ modelViewMatrix.r[10]*v[2] + modelViewMatr ix.r[14]; + modelViewMatrix.r[10]*v[2] + modelViewMatr ix.r[14];
const bool rval = mapping->forward(win); const bool rval = forward(win);
// very important: even when the projected point comes from an // very important: even when the projected point comes from an
// invisible region of the sky (rval=false), we must finish // invisible region of the sky (rval=false), we must finish
// reprojecting, so that OpenGl can successfully eliminate // reprojecting, so that OpenGl can successfully eliminate
// polygons by culling. // polygons by culling.
win[0] = viewportCenter[0] + flipHorz * pixelPerRad * win[0] ; win[0] = viewportCenter[0] + flipHorz * pixelPerRad * win[0] ;
win[1] = viewportCenter[1] + flipVert * pixelPerRad * win[1] ; win[1] = viewportCenter[1] + flipVert * pixelPerRad * win[1] ;
win[2] = (win[2] - zNear) / (zNear - zFar); win[2] = (win[2] - zNear) * oneOverZNearMinusZFar;
return rval; return rval;
} }
//! Project the vector v from the current frame into the viewport. //! Project the vector v from the current frame into the viewport.
//! @param v the vector in the current frame. //! @param v the vector in the current frame.
//! @param win the projected vector in the viewport 2D frame. //! @param win the projected vector in the viewport 2D frame.
//! @return true if the projected point is inside the viewport. //! @return true if the projected point is inside the viewport.
bool projectCheck(const Vec3d& v, Vec3d& win) const {return (project (v, win) && checkInViewport(win));} bool projectCheck(const Vec3d& v, Vec3d& win) const {return (project (v, win) && checkInViewport(win));}
//! Project the vector v from the viewport frame into the current fr ame. //! Project the vector v from the viewport frame into the current fr ame.
skipping to change at line 260 skipping to change at line 213
//! Project the vectors v1 and v2 from the current frame into the vi ewport. //! Project the vectors v1 and v2 from the current frame into the vi ewport.
//! @param v1 the first vector in the current frame. //! @param v1 the first vector in the current frame.
//! @param v2 the second vector in the current frame. //! @param v2 the second vector in the current frame.
//! @param win1 the first projected vector in the viewport 2D frame. //! @param win1 the first projected vector in the viewport 2D frame.
//! @param win2 the second projected vector in the viewport 2D frame . //! @param win2 the second projected vector in the viewport 2D frame .
//! @return true if at least one of the projected vector is within t he viewport. //! @return true if at least one of the projected vector is within t he viewport.
bool projectLineCheck(const Vec3d& v1, Vec3d& win1, const Vec3d& v2, Vec3d& win2) const bool projectLineCheck(const Vec3d& v1, Vec3d& win1, const Vec3d& v2, Vec3d& win2) const
{return project(v1, win1) && project(v2, win2) && (checkInVi ewport(win1) || checkInViewport(win2));} {return project(v1, win1) && project(v2, win2) && (checkInVi ewport(win1) || checkInViewport(win2));}
//! Set the frame in which we want to draw from now on. //! Get the current model view matrix.
//! The frame will be the current one until this method or setCustom const Mat4d& getModelViewMatrix() const {return modelViewMatrix;}
Frame is called again.
//! @param frameType the type.
void setCurrentFrame(FrameType frameType) const;
//! Set a custom model view matrix.
//! The new setting remains active until the next call to setCurrent
Frame or setCustomFrame.
//! @param m the openGL MODELVIEW matrix to use.
void setCustomFrame(const Mat4d& m) const;
//! Set the current projection mapping to use.
//! The mapping must have been registered before being used.
//! @param mappingId a string which can be e.g. "perspective", "ster
eographic", "fisheye", "cylinder".
void setCurrentMapping(const QString& mappingId);
//! Get the current Mapping used by the Projection
const Mapping& getCurrentMapping(void) const {return *mapping;}
//! Get the list of all the registered mappings
//! @return a map associating each mappingId to its instance
const QMap<QString,const Mapping*>& getAllMappings() const {return p
rojectionMapping;}
////////////////////////////////////////////////////////////////////
///////
// Standard methods for drawing primitives in general (non-linear) m
ode
////////////////////////////////////////////////////////////////////
///////
//! Fill with black around the viewport.
void drawViewportShape(void);
//! Generalisation of glVertex3v for non-linear projections.
//! This method does not manage the lighting operations properly.
void drawVertex3v(const Vec3d& v) const
{
Vec3d win;
project(v, win);
glVertex3dv(win);
}
//! Convenience function.
//! @sa drawVertex3v
void drawVertex3(double x, double y, double z) const {drawVertex3v(V
ec3d(x, y, z));}
//! Draw the string at the given position and angle with the given f
ont.
//! If the gravity label flag is set, uses drawTextGravity180.
//! @param font the font to use for display
//! @param x horizontal position of the lower left corner of the fir
st character of the text in pixel.
//! @param y horizontal position of the lower left corner of the fir
st character of the text in pixel.
//! @param str the text to print.
//! @param angleDeg rotation angle in degree. Rotation is around x,y
.
//! @param xshift shift in pixel in the rotated x direction.
//! @param yshift shift in pixel in the rotated y direction.
//! @param noGravity don't take into account the fact that the text
should be written with gravity.
void drawText(const SFont* font, float x, float y, const QString& st
r, float angleDeg=0.f,
float xshift=0.f, float yshift=0.f, bool noGravity=tru
e) const;
//! Draw the given polygon
//! @param poly The polygon to draw
void drawPolygon(const StelGeom::Polygon& poly) const;
//! Draw a parallel arc in the current frame. The arc start from po
int start
//! going in the positive longitude direction and with the given len
gth in radian.
//! @param start the starting position of the parallel in the curren
t frame.
//! @param length the angular length in radian (or distance on the u
nit sphere).
//! @param labelAxis if true display a label indicating the latitude
at begining and at the end of the arc.
//! @param textColor color to use for rendering text. If NULL use th
e current openGL painting color.
//! @param nbSeg if not==-1,indicate how many line segments should b
e used for drawing the arc, if==-1
//! this value is automatically adjusted to prevent seeing the curve
as a polygon.
//! @param font the font to use for display
void drawParallel(const Vec3d& start, double length, bool labelAxis=
false,
const SFont* font=NULL, const Vec4f* textColor=NUL
L, int nbSeg=-1) const;
//! Draw a meridian arc in the current frame. The arc starts from po
int start
//! going in the positive latitude direction if longitude is in [0;1
80], in the negative direction
//! otherwise, and with the given length in radian. The length can b
e up to 2 pi.
//! @param start the starting position of the meridian in the curren
t frame.
//! @param length the angular length in radian (or distance on the u
nit sphere).
//! @param labelAxis if true display a label indicating the longitud
e at begining and at the end of the arc.
//! @param textColor color to use for rendering text. If NULL use th
e current openGL painting color.
//! @param nbSeg if not==-1,indicate how many line segments should b
e used for drawing the arc, if==-1
//! this value is automatically adjusted to prevent seeing the curve
as a polygon.
//! @param font the font to use for display
//! @param useDMS if true display label in DD:MM:SS. Normal is HH:MM
:SS
void drawMeridian(const Vec3d& start, double length, bool labelAxis=
false,
const SFont* font=NULL, const Vec4
f* textColor=NULL, int nbSeg=-1, bool useDMS=false) const;
//! draw a simple circle, 2d viewport coordinates in pixel
void drawCircle(double x,double y,double r) const;
//! Draw a square using the current texture at the given projected 2
d position.
//! @param x x position in the viewport in pixel.
//! @param y y position in the viewport in pixel.
//! @param size the size of a square side in pixel.
void drawSprite2dMode(double x, double y, double size) const;
//! Draw a rotated square using the current texture at the given pro
jected 2d position.
//! @param x x position in the viewport in pixel.
//! @param y y position in the viewport in pixel.
//! @param size the size of a square side in pixel.
//! @param rotation rotation angle in degree.
void drawSprite2dMode(double x, double y, double size, double rotati
on) const;
//! Draw a rotated rectangle using the current texture at the given
projected 2d position.
//! @param x x position in the viewport in pixel.
//! @param y y position in the viewport in pixel.
//! @param sizex the size of the rectangle x side in pixel.
//! @param sizey the size of the rectangle y side in pixel.
//! @param rotation rotation angle in degree.
void drawRectSprite2dMode(double x, double y, double sizex, double s
izey, double rotation) const;
//! Draw a GL_POINT at the given position.
//! @param x x position in the viewport in pixels.
//! @param y y position in the viewport in pixels.
void drawPoint2d(double x, double y) const;
//! Re-implementation of gluSphere : glu is overridden for non-stand
ard projection.
void sSphere(GLdouble radius, GLdouble oneMinusOblateness,
GLint slices, GLint stacks, int orientInside = 0) const
;
//! Re-implementation of gluCylinder : glu is overridden for non-sta
ndard projection.
void sCylinder(GLdouble radius, GLdouble height, GLint slices, GLint
stacks, int orientInside = 0) const;
//! Draw a disk with a special texturing mode having texture center
at center of disk.
//! The disk is made up of concentric circles with increasing refine
ment.
//! The number of slices of the outmost circle is (innerFanSlices<<l
evel).
//! @param radius the radius of the disk.
//! @param innerFanSlices the number of slices.
//! @param level the numbe of concentric circles.
void sFanDisk(double radius,int innerFanSlices,int level) const;
//! Draw a disk with a special texturing mode having texture center
at center.
//! @param radius the radius of the disk.
//! @param slices the number of slices.
//! @param stacks ???
//! @param orientInside ???
void sDisk(GLdouble radius, GLint slices, GLint stacks, int orientIn
side = 0) const;
//! Draw a ring with a radial texturing.
void sRing(GLdouble rMin, GLdouble rMax, GLint slices, GLint stacks,
int orientInside) const;
//! Draw a fisheye texture in a sphere.
void sSphereMap(GLdouble radius, GLint slices, GLint stacks,
double textureFov = 2.*M_PI, int orientInside = 0)
const;
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods for linear mode //! Get a string description of a StelProjectorMaskType.
//////////////////////////////////////////////////////////////////// static const QString maskTypeToString(StelProjectorMaskType type);
/////// //! Get a StelProjectorMaskType from a string description.
static StelProjectorMaskType stringToMaskType(const QString &s);
//! Reimplementation of gluCylinder for use in linear mode. //! Get the current type of the mask if any.
void sCylinderLinear(GLdouble radius, GLdouble height, GLint slices, StelProjectorMaskType getMaskType(void) const {return maskType;}
GLint stacks,
int orientInside = 0) const;
//! Reimplementation of gluSphere for use in linear mode.
void sSphereLinear(GLdouble radius, GLdouble oneMinusOblateness, GLi
nt slices,
GLint stacks, int orientInside = 0) const;
public slots:
//! Set the flag with decides whether to arrage labels so that
//! they are aligned with the bottom of a 2d screen, or a 3d dome.
void setFlagGravityLabels(bool gravity) { gravityLabels = gravity; }
//! Get the state of the horizontal flip.
//! @return True if flipped horizontally, else false.
bool getFlipHorz(void) const {return (flipHorz < 0.0);}
//! Get the state of the vertical flip.
//! @return True if flipped vertically, else false.
bool getFlipVert(void) const {return (flipVert < 0.0);}
//! Set the horizontal flip status.
//! @param flip The new value (true = flipped, false = unflipped).
void setFlipHorz(bool flip) {
flipHorz = flip ? -1.0 : 1.0;
glFrontFace(needGlFrontFaceCW()?GL_CW:GL_CCW);
}
//! Set the vertical flip status.
//! @param flip The new value (true = flipped, false = unflipped).
void setFlipVert(bool flip) {
flipVert = flip ? -1.0 : 1.0;
glFrontFace(needGlFrontFaceCW()?GL_CW:GL_CCW);
}
//! Set the initial field of view. Updates configuration file. protected:
//! @param fov the new value for initial field of view in decimal de //! Private constructor. Only StelCore can create instances of StelP
grees. rojector.
void setInitFov(double fov) {initFov=fov;} StelProjector(const Mat4d& modelViewMat) : modelViewMatrix(modelView
Mat) {;}
private: private:
//! Initialise the StelProjector from a param instance
void init(const StelProjectorParams& param);
void drawTextGravity180(const SFont* font, float x, float y, const Q StelProjectorMaskType maskType; // The current projector mask
String& str, double zNear, oneOverZNearMinusZFar; // Near and far clipping plane
bool speedOptimize = 1, float xshift = 0, floa s
t yshift = 0) const; Vec4i viewportXywh; // Viewport parameters
//! Init the real openGL Matrices to a 2d orthographic projection
void initGlMatrixOrtho2d(void) const;
//! The current projector mask
ProjectorMaskType maskType;
double initFov; // initial default FOV in degree
double fov; // Field of view in degree
double minFov; // Minimum fov in degree
double maxFov; // Maximum fov in degree
double zNear, zFar; // Near and far clipping planes
Vector4<GLint> viewportXywh; // Viewport parameters
Vec2d viewportCenter; // Viewport center in screen pixel Vec2d viewportCenter; // Viewport center in screen pixel
double viewportFovDiameter; // diameter of a circle with 180 degr double viewportFovDiameter; // diameter of the FOV disk in pixel
ees diameter in screen pixel
Mat4d projectionMatrix; // Projection matrix
double pixelPerRad; // pixel per rad at the center of the viewport disk double pixelPerRad; // pixel per rad at the center of the viewport disk
double flipHorz,flipVert; // Whether to flip in horizontal or v ertical directions double flipHorz,flipVert; // Whether to flip in horizontal or v ertical directions
Mat4d matEarthEquToEye; // Modelview Matrix for earth equator
ial projection
Mat4d matJ2000ToEye; // for precessed equ coords
Mat4d matHelioToEye; // Modelview Matrix for earth equator
ial projection
Mat4d matLocalToEye; // Modelview Matrix for earth equator
ial projection
bool gravityLabels; // should label text align with the h orizon? bool gravityLabels; // should label text align with the h orizon?
Mat4d modelViewMatrix; // openGL MODELVIEW Matrix
bool flagGlPointSprite; // Define whether glPointSprite is ac
tivated
mutable Mat4d modelViewMatrix; // openGL MODELVIEW Matrix
const Mapping *mapping;
QMap<QString,const Mapping*> projectionMapping;
QString currentProjectionType; // Type of the projection currently u
sed
}; };
#endif // _PROJECTOR_HPP_ #endif // _STELPROJECTOR_HPP_
 End of changes. 31 change blocks. 
449 lines changed or deleted 150 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/