The base context class for defining a how events are handled. It also is responsible drawing UI elements in both screen space and in viewer world space. While the main viewer handles basic view manipulation, all other interactions should be handled with a context.
More...
#include <Context.h>
|
| Context () |
| Constructor.
|
|
virtual | ~Context () |
| Virtual destructor.
|
|
virtual void | drawGL (int vWidth, int vHeight) |
| The draw function for the context. More...
|
|
virtual bool | selectGL (const GLScene *scene, const GLCamera &camera, int vWidth, int vHeight, int *selectPoint) |
| Performs selection based on a click on screen space. Uses the OpenGL selection mechanism. More...
|
|
virtual ContextResult | handleMouse (SDL_Event &e) |
| Give the context the opportunity to respond to a mouse event. More...
|
|
virtual ContextResult | handleKeyboard (SDL_Event &e) |
| Give the context the opportunity to respond to a keyboard event. More...
|
|
virtual void | update () |
| Allow the context to update any time-dependent state it might have to the given global time.
|
|
virtual void | newGLContext () |
| Callback for when the OpenGL context is changed.
|
|
virtual void | activate () |
| Called when the context is activated.
|
|
virtual void | deactivate () |
| Called when the context is deactivated.
|
|
|
void | uiSetup (int vWidth, int vHeight) |
| UI setup - handles the configuration of the opengl context for orthographic rendering. More...
|
|
void | uiShutdown () |
| Cleans up the OpenGL state after having drawn the UI elements of the context.
|
|
virtual void | drawUIGL (int vWidth, int vHeight, bool select=false) |
| Draw UI elements into the context. More...
|
|
virtual void | draw3DGL (bool select=false) |
| Draw context elements into the 3D world. More...
|
|
void | getOpenGLView () |
| Updates the various view matrices: modelview, projection, and view.
|
|
void | writeText (const std::string &txt, const Vector2 &pos, bool currColor=false) const |
| Writes the given text at the given location. More...
|
|
void | writeText (const std::string &txt, const Vector3 &pos, bool currColor=false) const |
| Writes the given text at the given 3D location. More...
|
|
void | writeTextRadially (const std::string &txt, const Vector2 &pos, const Vector2 &dir, bool currColor=false) const |
| Writes the given text at the given location, but anchored based on the radial direction given. More...
|
|
void | writeAlignedText (const std::string &txt, const Vector2 &pos, TextWriter::Alignment align, bool currColor=false) const |
| Writes the given text aligned to the given location. More...
|
|
void | writeToScreen (const std::string &txt, TextWriter::Alignment align, int fontSize, float hPad=0.f, float vPad=0.f, bool currColor=false, bool trans=true) const |
| Writes the given text to the screen based on the given alignment. More...
|
|
|
double | _modViewMat [16] |
| The current model view matrix.
|
|
double | _projMat [16] |
| The current projection matrix.
|
|
int | _viewMat [4] |
| The current viewport parameters.
|
|
The base context class for defining a how events are handled. It also is responsible drawing UI elements in both screen space and in viewer world space. While the main viewer handles basic view manipulation, all other interactions should be handled with a context.
virtual void Menge::SceneGraph::Context::draw3DGL |
( |
bool |
select = false | ) |
|
|
inlineprotectedvirtual |
virtual void Menge::SceneGraph::Context::drawGL |
( |
int |
vWidth, |
|
|
int |
vHeight |
|
) |
| |
|
inlinevirtual |
virtual void Menge::SceneGraph::Context::drawUIGL |
( |
int |
vWidth, |
|
|
int |
vHeight, |
|
|
bool |
select = false |
|
) |
| |
|
inlineprotectedvirtual |
Draw UI elements into the context.
- Parameters
-
vWidth | The width of the viewport (in pixels). |
vHeight | The height of the viewport (in pixels). |
select | Defines if the drawing is being done for selection purposes (true) or visualization (false). |
Reimplemented in Menge::BaseAgentContext.
Give the context the opportunity to respond to a mouse event.
- Parameters
-
e | The SDL event with the mouse event data. |
- Returns
- A ContextResult instance reporting if the event was handled and if redrawing is necessary.
Reimplemented in Menge::SceneGraph::ContextSwitcher.
virtual bool Menge::SceneGraph::Context::selectGL |
( |
const GLScene * |
scene, |
|
|
const GLCamera & |
camera, |
|
|
int |
vWidth, |
|
|
int |
vHeight, |
|
|
int * |
selectPoint |
|
) |
| |
|
inlinevirtual |
Performs selection based on a click on screen space. Uses the OpenGL selection mechanism.
- Parameters
-
scene | The scene to select in. |
camera | The camera. |
vWidth | The width of the viewport. |
vHeight | The height of the viewport. |
selectPoint | The point (in screen space) at which object selection should take place. |
- Returns
- A boolean indicating whether a redraw needs to take place.
Reimplemented in Menge::SceneGraph::SelectContext, Menge::BaseAgentContext, and Menge::SceneGraph::ContextSwitcher.
void Menge::SceneGraph::Context::uiSetup |
( |
int |
vWidth, |
|
|
int |
vHeight |
|
) |
| |
|
protected |
UI setup - handles the configuration of the opengl context for orthographic rendering.
- Parameters
-
vWidth | The width of the view (in pixels). |
vHeight | The height of the view (in pixels). |
void Menge::SceneGraph::Context::writeAlignedText |
( |
const std::string & |
txt, |
|
|
const Vector2 & |
pos, |
|
|
TextWriter::Alignment |
align, |
|
|
bool |
currColor = false |
|
) |
| const |
|
protected |
Writes the given text aligned to the given location.
- Parameters
-
txt | The text to write to the screen. |
pos | The position, in world coordinates, to place the text |
align | TextWriter alignment specification. |
currColor | Indicates if the current opengl color should be used (true) or the text writer's default color should be used (false). |
void Menge::SceneGraph::Context::writeText |
( |
const std::string & |
txt, |
|
|
const Vector2 & |
pos, |
|
|
bool |
currColor = false |
|
) |
| const |
|
protected |
Writes the given text at the given location.
- Parameters
-
txt | The text to write to the screen. |
pos | The position, in world coordinates, to place the text |
currColor | Indicates if the current opengl color should be used (true) or the text writer's default color should be used (false). |
void Menge::SceneGraph::Context::writeText |
( |
const std::string & |
txt, |
|
|
const Vector3 & |
pos, |
|
|
bool |
currColor = false |
|
) |
| const |
|
protected |
Writes the given text at the given 3D location.
- Parameters
-
txt | The text to write to the screen. |
pos | The position, in world coordinates, to place the text |
currColor | Indicates if the current opengl color should be used (true) or the text writer's default color should be used (false). |
void Menge::SceneGraph::Context::writeTextRadially |
( |
const std::string & |
txt, |
|
|
const Vector2 & |
pos, |
|
|
const Vector2 & |
dir, |
|
|
bool |
currColor = false |
|
) |
| const |
|
protected |
Writes the given text at the given location, but anchored based on the radial direction given.
- Parameters
-
txt | The text to write to the screen. |
pos | The position, in world coordinates, to place the text |
dir | A vector representing the direction of the radius at whose end the text should be placed. Direction defined in world coordinates |
currColor | Indicates if the current opengl color should be used (true) or the text writer's default color should be used (false). |
void Menge::SceneGraph::Context::writeToScreen |
( |
const std::string & |
txt, |
|
|
TextWriter::Alignment |
align, |
|
|
int |
fontSize, |
|
|
float |
hPad = 0.f , |
|
|
float |
vPad = 0.f , |
|
|
bool |
currColor = false , |
|
|
bool |
trans = true |
|
) |
| const |
|
protected |
Writes the given text to the screen based on the given alignment.
The text will be written to one of 9 locations:
- Top left corner, top center, top right corner
- left center, screen center, right center
- bottom left corner, bottom center, bottom right corner
- Parameters
-
txt | The text to write to the screen. |
align | TextWriter alignment specification. |
fontSize | The size of the text to write. |
hPad | The number of pixels to pad the text horizontally. |
vPad | The number of pixels to pad the text vertically. |
currColor | Indicates if the current opengl color should be used (true) or the text writer's default color should be used (false). |
trans | Determines if the text is printed transparently (true) or not (false). |
The documentation for this class was generated from the following files:
- src/menge/MengeCore/SceneGraph/Context.h
- src/menge/MengeCore/SceneGraph/Context.cpp