![]() |
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure |
#include <StelPainter.hpp>
Public Types | |
enum | SphericalPolygonDrawMode { SphericalPolygonDrawModeFill = 0, SphericalPolygonDrawModeBoundary = 1, SphericalPolygonDrawModeTextureFill = 2 } |
enum | ShadeModel { ShadeModelFlat = 0x1D00, ShadeModelSmooth = 0x1D01 } |
enum | DrawingMode { Points = 0x0000, Lines = 0x0001, LineLoop = 0x0002, LineStrip = 0x0003, Triangles = 0x0004, TriangleStrip = 0x0005, TriangleFan = 0x0006 } |
Public Member Functions | |
StelPainter (const StelProjectorP &prj) | |
const StelProjectorP & | getProjector () const |
void | setProjector (const StelProjectorP &p) |
void | drawViewportShape (void) |
void | drawText (float x, float y, const QString &str, float angleDeg=0.f, float xshift=0.f, float yshift=0.f, bool noGravity=true) const |
void | drawText (const Vec3d &v, const QString &str, float angleDeg=0.f, float xshift=0.f, float yshift=0.f, bool noGravity=true) const |
void | drawSphericalRegion (const SphericalRegion *region, SphericalPolygonDrawMode drawMode=SphericalPolygonDrawModeFill, const SphericalCap *clippingCap=NULL, bool doSubDivise=true) |
void | drawGreatCircleArcs (const StelVertexArray &va, const SphericalCap *clippingCap=NULL, bool doSubDivide=true) |
void | drawSphericalTriangles (const StelVertexArray &va, bool textured, const SphericalCap *clippingCap=NULL, bool doSubDivide=true) |
void | drawSmallCircleArc (const Vec3d &start, const Vec3d &stop, const Vec3d &rotCenter, void(*viewportEdgeIntersectCallback)(const Vec3d &screenPos, const Vec3d &direction, void *userData)=NULL, void *userData=NULL) |
void | drawGreatCircleArc (const Vec3d &start, const Vec3d &stop, const SphericalCap *clippingCap=NULL, void(*viewportEdgeIntersectCallback)(const Vec3d &screenPos, const Vec3d &direction, void *userData)=NULL, void *userData=NULL) |
void | drawCircle (float x, float y, float r) |
void | drawSprite2dMode (float x, float y, float radius) |
void | drawSprite2dMode (const Vec3d &v, float radius) |
void | drawSprite2dMode (float x, float y, float radius, float rotation) |
void | drawPoint2d (float x, float y) |
void | drawLine2d (float x1, float y1, float x2, float y2) |
void | drawRect2d (float x, float y, float width, float height, bool textured=true) |
void | sSphere (float radius, float oneMinusOblateness, int slices, int stacks, int orientInside=0, bool flipTexture=false) |
void | sCylinder (float radius, float height, int slices, int orientInside=0) |
void | sFanDisk (float radius, int innerFanSlices, int level) |
void | sRing (float rMin, float rMax, int slices, int stacks, int orientInside) |
void | sSphereMap (float radius, int slices, int stacks, float textureFov=2.f *M_PI, int orientInside=0) |
void | setFont (const QFont &font) |
void | setColor (float r, float g, float b, float a=1.f) |
Vec4f | getColor () const |
StelPainterLight & | getLight () |
StelPainterMaterial & | getMaterial () |
QFontMetrics | getFontMetrics () const |
void | setPointSize (qreal size) |
void | setShadeModel (ShadeModel m) |
void | enableTexture2d (bool b) |
void | setVertexPointer (int size, int type, const void *pointer) |
void | setTexCoordPointer (int size, int type, const void *pointer) |
void | setColorPointer (int size, int type, const void *pointer) |
void | setNormalPointer (int type, const void *pointer) |
void | enableClientStates (bool vertex, bool texture=false, bool color=false, bool normal=false) |
void | setArrays (const Vec3d *vertice, const Vec2f *texCoords=NULL, const Vec3f *colorArray=NULL, const Vec3f *normalArray=NULL) |
void | drawFromArray (DrawingMode mode, int count, int offset=0, bool doProj=true, const unsigned int *indices=NULL) |
Static Public Member Functions | |
static void | initSystemGLInfo () |
static void | setQPainter (QPainter *qPainter) |
Classes | |
struct | ArrayDesc |
Struct describing one opengl array. |
All coordinates are converted using the StelProjector instance passed at construction. Because openGL is not thread safe, only one instance of StelPainter can exist at a time, enforcing thread safety. As a coding rule, no openGL calls should be performed when no instance of StelPainter exist. Typical usage is to create a local instance of StelPainter where drawing operations are needed.
const StelProjectorP& StelPainter::getProjector | ( | ) | const [inline] |
Return the instance of projector associated to this painter.
void StelPainter::drawViewportShape | ( | void | ) |
Fill with black around the viewport.
void StelPainter::drawText | ( | float | x, | |
float | y, | |||
const QString & | str, | |||
float | angleDeg = 0.f , |
|||
float | xshift = 0.f , |
|||
float | yshift = 0.f , |
|||
bool | noGravity = true | |||
) | const |
Draw the string at the given position and angle with the given font.
If the gravity label flag is set, uses drawTextGravity180.
font | the font to use for display | |
x | horizontal position of the lower left corner of the first character of the text in pixel. | |
y | horizontal position of the lower left corner of the first character of the text in pixel. | |
str | the text to print. | |
angleDeg | rotation angle in degree. Rotation is around x,y. | |
xshift | shift in pixel in the rotated x direction. | |
yshift | shift in pixel in the rotated y direction. | |
noGravity | don't take into account the fact that the text should be written with gravity. |
void StelPainter::drawSphericalRegion | ( | const SphericalRegion * | region, | |
SphericalPolygonDrawMode | drawMode = SphericalPolygonDrawModeFill , |
|||
const SphericalCap * | clippingCap = NULL , |
|||
bool | doSubDivise = true | |||
) |
Draw the given SphericalRegion.
region | The SphericalRegion to draw. | |
drawMode | define whether to draw the outline or the fill or both. | |
boundaryColor | use this color for drawing the boundary only if the drawMode is SphericalPolygonDrawModeFillAndBoundary. | |
clippingCap | if not set to NULL, tells the painter to try to clip part of the region outside the cap. Typically set that to false if you think that the region is fully contained in the viewport. |
void StelPainter::drawSmallCircleArc | ( | const Vec3d & | start, | |
const Vec3d & | stop, | |||
const Vec3d & | rotCenter, | |||
void(*)(const Vec3d &screenPos, const Vec3d &direction, void *userData) | viewportEdgeIntersectCallback = NULL , |
|||
void * | userData = NULL | |||
) |
Draw a small circle arc between points start and stop with rotation point in rotCenter.
The angle between start and stop must be < 180 deg. The algorithm ensures that the line will look smooth, even for non linear distortion. Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the screen 2d position, direction of the currently drawn arc toward the inside of the viewport. If rotCenter is equal to 0,0,0, the method draws a great circle.
void StelPainter::drawGreatCircleArc | ( | const Vec3d & | start, | |
const Vec3d & | stop, | |||
const SphericalCap * | clippingCap = NULL , |
|||
void(*)(const Vec3d &screenPos, const Vec3d &direction, void *userData) | viewportEdgeIntersectCallback = NULL , |
|||
void * | userData = NULL | |||
) |
Draw a great circle arc between points start and stop.
The angle between start and stop must be < 180 deg. The algorithm ensures that the line will look smooth, even for non linear distortion. Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the screen 2d position, direction of the currently drawn arc toward the inside of the viewport.
clippingCap | if not set to NULL, tells the painter to try to clip part of the region outside the cap. |
void StelPainter::drawCircle | ( | float | x, | |
float | y, | |||
float | r | |||
) |
Draw a simple circle, 2d viewport coordinates in pixel.
void StelPainter::drawSprite2dMode | ( | float | x, | |
float | y, | |||
float | radius | |||
) |
Draw a square using the current texture at the given projected 2d position.
This method is not thread safe.
x | x position in the viewport in pixel. | |
y | y position in the viewport in pixel. | |
radius | the half size of a square side in pixel. |
void StelPainter::drawSprite2dMode | ( | float | x, | |
float | y, | |||
float | radius, | |||
float | rotation | |||
) |
Draw a rotated square using the current texture at the given projected 2d position.
This method is not thread safe.
x | x position in the viewport in pixel. | |
y | y position in the viewport in pixel. | |
radius | the half size of a square side in pixel. | |
rotation | rotation angle in degree. |
void StelPainter::drawPoint2d | ( | float | x, | |
float | y | |||
) |
Draw a GL_POINT at the given position.
x | x position in the viewport in pixels. | |
y | y position in the viewport in pixels. |
void StelPainter::drawLine2d | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2 | |||
) |
Draw a line between the 2 points.
x1 | x position of point 1 in the viewport in pixels. | |
y1 | y position of point 1 in the viewport in pixels. | |
x2 | x position of point 2 in the viewport in pixels. | |
y2 | y position of point 2 in the viewport in pixels. |
void StelPainter::drawRect2d | ( | float | x, | |
float | y, | |||
float | width, | |||
float | height, | |||
bool | textured = true | |||
) |
Draw a rectangle using the current texture at the given projected 2d position.
This method is not thread safe.
x | x position of the top left corner in the viewport in pixel. | |
y | y position of the tope left corner in the viewport in pixel. | |
width | width in pixel. | |
height | height in pixel. |
void StelPainter::sSphere | ( | float | radius, | |
float | oneMinusOblateness, | |||
int | slices, | |||
int | stacks, | |||
int | orientInside = 0 , |
|||
bool | flipTexture = false | |||
) |
Re-implementation of gluSphere : glu is overridden for non-standard projection.
void StelPainter::sCylinder | ( | float | radius, | |
float | height, | |||
int | slices, | |||
int | orientInside = 0 | |||
) |
Re-implementation of gluCylinder : glu is overridden for non-standard projection.
void StelPainter::sFanDisk | ( | float | radius, | |
int | innerFanSlices, | |||
int | level | |||
) |
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 refinement. The number of slices of the outmost circle is (innerFanSlices<<level).
radius | the radius of the disk. | |
innerFanSlices | the number of slices. | |
level | the numbe of concentric circles. |
void StelPainter::sRing | ( | float | rMin, | |
float | rMax, | |||
int | slices, | |||
int | stacks, | |||
int | orientInside | |||
) |
Draw a ring with a radial texturing.
void StelPainter::sSphereMap | ( | float | radius, | |
int | slices, | |||
int | stacks, | |||
float | textureFov = 2.f *M_PI , |
|||
int | orientInside = 0 | |||
) |
Draw a fisheye texture in a sphere.
void StelPainter::setFont | ( | const QFont & | font | ) |
Set the font to use for subsequent text drawing.
void StelPainter::setColor | ( | float | r, | |
float | g, | |||
float | b, | |||
float | a = 1.f | |||
) |
Set the color to use for subsequent drawing.
Vec4f StelPainter::getColor | ( | ) | const |
Get the color currently used for drawing.
StelPainterLight& StelPainter::getLight | ( | ) | [inline] |
Get the light.
StelPainterMaterial& StelPainter::getMaterial | ( | ) | [inline] |
Get the material.
QFontMetrics StelPainter::getFontMetrics | ( | ) | const |
Get the font metrics for the current font.
static void StelPainter::initSystemGLInfo | ( | ) | [static] |
Get some informations about the OS openGL capacities.
This method needs to be called once at init.
static void StelPainter::setQPainter | ( | QPainter * | qPainter | ) | [static] |
Set the QPainter to use for performing some drawing operations.
void StelPainter::setPointSize | ( | qreal | size | ) |
Sets the point size to use with draw().
This function has no effect if a shader program is in use, or on OpenGL/ES 2.0. Shader programs must set the point size in the vertex shader.
void StelPainter::setShadeModel | ( | ShadeModel | m | ) |
Define the current shade model used when interpolating between vertex.
void StelPainter::enableTexture2d | ( | bool | b | ) |
Set whether texturing is enabled.
void StelPainter::setVertexPointer | ( | int | size, | |
int | type, | |||
const void * | pointer | |||
) | [inline] |
use instead of glVertexPointer
void StelPainter::setTexCoordPointer | ( | int | size, | |
int | type, | |||
const void * | pointer | |||
) | [inline] |
use instead of glTexCoordPointer
void StelPainter::setColorPointer | ( | int | size, | |
int | type, | |||
const void * | pointer | |||
) | [inline] |
use instead of glColorPointer
void StelPainter::setNormalPointer | ( | int | type, | |
const void * | pointer | |||
) | [inline] |
use instead of glNormalPointer
void StelPainter::enableClientStates | ( | bool | vertex, | |
bool | texture = false , |
|||
bool | color = false , |
|||
bool | normal = false | |||
) |
use instead of glEnableClient
void StelPainter::setArrays | ( | const Vec3d * | vertice, | |
const Vec2f * | texCoords = NULL , |
|||
const Vec3f * | colorArray = NULL , |
|||
const Vec3f * | normalArray = NULL | |||
) |
convenience method that enable and set all the given arrays.
It is equivalent to calling enableClientState and set the array pointer for each arrays.
void StelPainter::drawFromArray | ( | DrawingMode | mode, | |
int | count, | |||
int | offset = 0 , |
|||
bool | doProj = true , |
|||
const unsigned int * | indices = NULL | |||
) |
Draws primitives using vertices from the arrays specified by setVertexArray().
The type of primitive to draw is specified by mode. If indices is NULL, this operation will consume count values from the enabled arrays, starting at offset. Else it will consume count elements of indices, starting at offset, which are used to index into the enabled arrays.