Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Menge::SceneGraph::Context Class Reference

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>

Inheritance diagram for Menge::SceneGraph::Context:
Menge::BFSM::FsmContext Menge::BFSM::StateContext Menge::BFSM::VelCompContext Menge::BFSM::VelModContext Menge::SceneGraph::ContextSwitcher Menge::SceneGraph::SelectContext Menge::BFSM::ConstDirVCContext Menge::BFSM::ConstVCContext Menge::BFSM::GoalVCContext Menge::BFSM::NavMeshVCContext Menge::BFSM::RoadMapVCContext Menge::BFSM::VecFieldVCContext Menge::BFSM::ZeroVCContext Menge::BFSM::ScaleVMContext Menge::BaseAgentContext

Public Member Functions

 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.
 

Protected Member Functions

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...
 

Protected Attributes

double _modViewMat [16]
 The current model view matrix.
 
double _projMat [16]
 The current projection matrix.
 
int _viewMat [4]
 The current viewport parameters.
 

Detailed Description

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.

Member Function Documentation

virtual void Menge::SceneGraph::Context::draw3DGL ( bool  select = false)
inlineprotectedvirtual

Draw context elements into the 3D world.

Parameters
selectDefines if the drawing is being done for selection purposes (true) or visualization (false).

Reimplemented in Menge::BaseAgentContext, and ORCATypeAgentContext< Agent >.

virtual void Menge::SceneGraph::Context::drawGL ( int  vWidth,
int  vHeight 
)
inlinevirtual

The draw function for the context.

Parameters
vWidthThe width of the viewport (in pixels).
vHeightThe height of the viewport (in pixels).

Reimplemented in Menge::BaseAgentContext, and Menge::SceneGraph::ContextSwitcher.

virtual void Menge::SceneGraph::Context::drawUIGL ( int  vWidth,
int  vHeight,
bool  select = false 
)
inlineprotectedvirtual

Draw UI elements into the context.

Parameters
vWidthThe width of the viewport (in pixels).
vHeightThe height of the viewport (in pixels).
selectDefines if the drawing is being done for selection purposes (true) or visualization (false).

Reimplemented in Menge::BaseAgentContext.

virtual ContextResult Menge::SceneGraph::Context::handleKeyboard ( SDL_Event e)
inlinevirtual

Give the context the opportunity to respond to a keyboard event.

Parameters
eThe SDL event with the keyboard event data.
Returns
A ContextResult instance reporting if the event was handled and if redrawing is necessary.

Reimplemented in Menge::BFSM::NavMeshVCContext, Menge::BFSM::VecFieldVCContext, Menge::SceneGraph::ContextSwitcher, Menge::BaseAgentContext, Menge::BFSM::StateContext, Menge::BFSM::FsmContext, and ORCATypeAgentContext< Agent >.

virtual ContextResult Menge::SceneGraph::Context::handleMouse ( SDL_Event e)
inlinevirtual

Give the context the opportunity to respond to a mouse event.

Parameters
eThe 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
sceneThe scene to select in.
cameraThe camera.
vWidthThe width of the viewport.
vHeightThe height of the viewport.
selectPointThe 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
vWidthThe width of the view (in pixels).
vHeightThe 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
txtThe text to write to the screen.
posThe position, in world coordinates, to place the text
alignTextWriter alignment specification.
currColorIndicates 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
txtThe text to write to the screen.
posThe position, in world coordinates, to place the text
currColorIndicates 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
txtThe text to write to the screen.
posThe position, in world coordinates, to place the text
currColorIndicates 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
txtThe text to write to the screen.
posThe position, in world coordinates, to place the text
dirA vector representing the direction of the radius at whose end the text should be placed. Direction defined in world coordinates
currColorIndicates 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
txtThe text to write to the screen.
alignTextWriter alignment specification.
fontSizeThe size of the text to write.
hPadThe number of pixels to pad the text horizontally.
vPadThe number of pixels to pad the text vertically.
currColorIndicates if the current opengl color should be used (true) or the text writer's default color should be used (false).
transDetermines if the text is printed transparently (true) or not (false).

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