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 Attributes | List of all members
Menge::BFSM::FsmContext Class Reference

Base context for finite state machine elements. More...

#include <FsmContext.h>

Inheritance diagram for Menge::BFSM::FsmContext:
Menge::SceneGraph::Context

Public Member Functions

 FsmContext (FSM *fsm)
 Constructor. More...
 
virtual ~FsmContext ()
 Destructor.
 
virtual SceneGraph::ContextResult handleKeyboard (SDL_Event &e)
 Give the context the opportunity to respond to a keyboard event. More...
 
virtual void drawUIGL (const Agents::BaseAgent *agt, int vWidth, int vHeight, bool select=false)
 Draw UI elements into the context. More...
 
virtual void draw3DGL (const Agents::BaseAgent *agt, bool select=false)
 Draw context elements into the 3D world. More...
 
void addStateContext (size_t id, StateContext *context)
 Adds a state context to the fsm context. More...
 
- Public Member Functions inherited from Menge::SceneGraph::Context
 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 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 Attributes

FSM_fsm
 The underlying finite state machine.
 
bool _drawVC
 Determines if the velocity component is displayed in the 3D context.
 
bool _drawTrans
 Determines if the transition is displayed in the 3D context.
 
StateContext_currStateCtx
 The context for the state currently being displayed.
 
StateContextMap _states
 The contexts for the given states.
 
- Protected Attributes inherited from Menge::SceneGraph::Context
double _modViewMat [16]
 The current model view matrix.
 
double _projMat [16]
 The current projection matrix.
 
int _viewMat [4]
 The current viewport parameters.
 

Additional Inherited Members

- Protected Member Functions inherited from Menge::SceneGraph::Context
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...
 

Detailed Description

Base context for finite state machine elements.

This differs from the standard scene graph context by being dependent on an input agent.

Constructor & Destructor Documentation

Menge::BFSM::FsmContext::FsmContext ( FSM fsm)

Constructor.

Parameters
fsmA pointer to the underlying fsm. The context will not delete the fsm.

Member Function Documentation

void Menge::BFSM::FsmContext::addStateContext ( size_t  id,
StateContext context 
)

Adds a state context to the fsm context.

Each call should provide a unique state. In debug mode, this is tested using an assertion.

These contexts will be deleted when the FsmContext is deleted.

Parameters
idThe globally unique id of the state.
contextA pointer to the context for the given state.
void Menge::BFSM::FsmContext::draw3DGL ( const Agents::BaseAgent agt,
bool  select = false 
)
virtual

Draw context elements into the 3D world.

Parameters
agtThe particular agent for which the FSM is being visualized.
selectDefines if the drawing is being done for selection purposes (true) or visualization (false).
void Menge::BFSM::FsmContext::drawUIGL ( const Agents::BaseAgent agt,
int  vWidth,
int  vHeight,
bool  select = false 
)
virtual

Draw UI elements into the context.

Parameters
agtThe particular agent for which the FSM is being visualized.
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).
SceneGraph::ContextResult Menge::BFSM::FsmContext::handleKeyboard ( SDL_Event e)
virtual

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 from Menge::SceneGraph::Context.


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