ComputerGraphik TU WIEN
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Legend Class Reference

Displays a Legend that contains text. More...

#include <legend.hpp>

Inheritance diagram for Legend:
SceneObject

Public Member Functions

 Legend (Scene *_scene, MouseSemantics *_mouse, Texture *_texture, float upperleftx, float upperlefty, float xstep, float ystep)
 
virtual ~Legend ()
 
void setShader (Shader *shader)
 
void draw ()
 
void update (double deltaT)
 
void prepareText ()
 
void setActiveSelector (std::string _sText)
 
- Public Member Functions inherited from SceneObject
 SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1))
 
 SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 
virtual ~SceneObject ()
 
ModelgetModel () const
 
ShadergetShader () const
 
glm::mat4 getModelMatrix () const
 
glm::mat4 getGlobalModelMatrix () const
 
std::string getName () const
 
std::shared_ptr< SceneObjectgetParent () const
 
void setAnimationTime (double time)
 
bool setAnimation (const Animation &anim)
 
bool delChild (size_t idx)
 
bool getChild (size_t idx, std::shared_ptr< SceneObject > &child) const
 
bool addChild (std::shared_ptr< SceneObject > &child)
 
bool remEffect (const std::string &name)
 
SceneObjectgetEffect (const std::string &name) const
 
bool addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect)
 
bool doNotRender ()
 
bool getIsVolSun ()
 
virtual void reset ()
 
virtual void draw () const
 
virtual bool animate (double time)
 

Private Member Functions

float calculateScaleFactor ()
 
void renderText (const char *text, float x, float y, float sx, float sy)
 
void updatePosition (bool reset)
 
void calcFPS (double deltaT)
 

Private Attributes

float upperleftx
 
float upperlefty
 
float ystep
 
float xstep
 
float xreset
 
float yreset
 
float maxXposText
 
float maxYposText
 
float offsetX
 
float offsetY
 
std::string selectorText
 
glm::vec2 latestPos
 
GLFWwindow * window
 
MouseSemanticsmouse
 
LegendBackgroundbackground
 
int frameCount
 
double accumulatedTime
 
int FPS
 
FT_Library ft
 
FT_Face face
 
std::map< char, GLuint > charTexHandleMap
 
std::map< char, GlyphcharGlyphMap
 
GLuint vboPositions
 
Texturetexture
 

Additional Inherited Members

- Public Types inherited from SceneObject
typedef std::vector< std::pair< double, glm::mat4 > > Animation
 
- Protected Attributes inherited from SceneObject
GLuint vao
 
Scenescene
 
Modelmodel
 
Shadershader
 
glm::mat4 modelMatrix
 
std::string name
 
std::weak_ptr< SceneObjectparent
 
std::vector< std::shared_ptr< SceneObject > > childs
 
std::map< std::string, std::unique_ptr< SceneObject > > effectChilds
 
size_t animIDX
 
Animation animation
 
bool norender
 
bool isVolSun
 

Detailed Description

Displays a Legend that contains text.

Design
The Legend uses the freetype class in order to support rendering of text. The freetype library allows loading of characters as textures that can be rendered. An additional class LegendBackground is defined and used by the legend in order to render the background. Since different shaders are needed for rendering textures and background, the background rendering is encapsulated in a seperate class.
Implementation
In the constructor of legend, images of all ascii characters are loaded and saved as textures on the gpu. This allows for selection of corresponding textures during the runtime instead of loading them at runtime, suffering hughe performance losses. Textures of characters are loaded with the FT_Library ft and are stored as FT_Face face. Each face defines the parameters with which a texture should be rendered. These parameters specify the offset from the base, its with and height. These parameters are contained in a FT_GlyphSlot. Therefore, the struct Glyph that corresponds to such a slot has been created. Here, the parameters are inserted and for each character a entry in the std::map<char,Glyph> charGlyphMap will be created. This map will be used together with std::map<char, GLuint charTexHandleMap to find corresponding glyphs and texture handles for each character during the runtime. If one want's to render additional lines of text, the draw function in legend.cpp must be modified. Currently, following crucial information is displayed:
  • Cursor speed: this is the computed scaling of the mouse that lies in the range [m,M] as defined in MouseSemantics
  • Scale factor: a scalar that is multiplied with the scale factor from above. The user can adjust this value if the mouse is too slow/fast
  • Scale function: the standard or inverse scale function from the paper can be used.
  • Selection mode: defines if a compute shader or a quad tree is used for calculating the distance.
  • Distance: the current distance between the mouse and the nearest object is displayed.
  • FPS: frames per second
Author
Felix

Constructor & Destructor Documentation

Legend::Legend ( Scene _scene,
MouseSemantics _mouse,
Texture _texture,
float  upperleftx,
float  upperlefty,
float  xstep,
float  ystep 
)
Legend::~Legend ( )
virtual

Member Function Documentation

void Legend::calcFPS ( double  deltaT)
private
float Legend::calculateScaleFactor ( )
private
void Legend::draw ( )
void Legend::prepareText ( )
void Legend::renderText ( const char *  text,
float  x,
float  y,
float  sx,
float  sy 
)
private
void Legend::setActiveSelector ( std::string  _sText)
inline
void Legend::setShader ( Shader shader)
virtual

Reimplemented from SceneObject.

void Legend::update ( double  deltaT)
virtual

Reimplemented from SceneObject.

void Legend::updatePosition ( bool  reset)
private

Member Data Documentation

double Legend::accumulatedTime
private
LegendBackground* Legend::background
private
std::map<char, Glyph> Legend::charGlyphMap
private
std::map<char, GLuint> Legend::charTexHandleMap
private
FT_Face Legend::face
private
int Legend::FPS
private
int Legend::frameCount
private
FT_Library Legend::ft
private
glm::vec2 Legend::latestPos
private
float Legend::maxXposText
private
float Legend::maxYposText
private
MouseSemantics* Legend::mouse
private
float Legend::offsetX
private
float Legend::offsetY
private
std::string Legend::selectorText
private
Texture* Legend::texture
private
float Legend::upperleftx
private
float Legend::upperlefty
private
GLuint Legend::vboPositions
private
GLFWwindow* Legend::window
private
float Legend::xreset
private
float Legend::xstep
private
float Legend::yreset
private
float Legend::ystep
private

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