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

Context class for displaying various characteristics of the Agents::BaseAgent class. More...

#include <BaseAgentContext.h>

Inheritance diagram for Menge::BaseAgentContext:
Menge::SceneGraph::SelectContext Menge::SceneGraph::Context ORCATypeAgentContext< Agent >

Public Types

enum  BACState { DEFAULT_ST, TYPE_AGENT_ID_ST }
 Definition of the state of the context. More...
 

Public Member Functions

 BaseAgentContext (VisAgent **agents, size_t agtCount, BFSM::FsmContext *fsmCtx=0x0)
 Construtor. More...
 
virtual ~BaseAgentContext ()
 Virtual destructor.
 
void setFSMContext (BFSM::FsmContext *ctx)
 Sets the fsm context. More...
 
virtual SceneGraph::ContextResult handleKeyboard (SDL_Event &e)
 Give the context the opportunity to respond to a keyboard event. More...
 
virtual void drawGL (int vWidth, int vHeight)
 The draw function for the context. More...
 
virtual bool selectGL (const SceneGraph::GLScene *scene, const SceneGraph::GLCamera &camera, int vWidth, int vHeight, int *selectPoint)
 Performs selection based on a click on screen space. Uses the OpenGL selection mechanism. More...
 
virtual void activate ()
 Called when the context is activated.
 
- Public Member Functions inherited from Menge::SceneGraph::Context
 Context ()
 Constructor.
 
virtual ~Context ()
 Virtual destructor.
 
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 deactivate ()
 Called when the context is deactivated.
 

Protected Member Functions

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...
 
virtual std::string contextName () const
 Returns the name of the context for display. More...
 
virtual std::string agentText (const Agents::BaseAgent *agent) const
 Creates a formatted string to be printed in the context for a particular agent. More...
 
void drawNbrRadius (const Agents::BaseAgent *agt)
 Function for drawing neighbor radius.
 
void drawNeighbors (const Agents::BaseAgent *agt)
 Function for drawing neighbor distances.
 
void drawMaxSpeed (const Agents::BaseAgent *agt)
 Function for drawing neighbor distances.
 
void drawVelocity (const Agents::BaseAgent *agt)
 Function for drawing current velocity.
 
void drawPrefVelocity (const Agents::BaseAgent *agt)
 Function for drawing the preferred velocity.
 
void drawOrientation (const Agents::BaseAgent *agt)
 Function for drawing current orientation.
 
void beginIDTyping ()
 Begins the agent typing state.
 
void finishIDTyping ()
 Finish agent typing state.
 
void cancelIDTyping ()
 Cancels the agent typing state.
 
void drawIDTyping ()
 Draws the id typing state.
 
void addIDDigit (const char digit)
 Adds a digit to the typed value.
 
- 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.
 
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

VisAgent_selected
 The currently selected visualization agent.
 
BACState _state
 The state of the context.
 
bool _showNbrRadius
 Determines if the neighbor distance is rendered.
 
bool _showNbr
 Determines if the neighbors are indicated in the view.
 
bool _showMaxSpd
 Determines if the circle of maximum speed is displayed.
 
bool _showVel
 Determines if the current velocity is displayed.
 
bool _showPrefVel
 Determines if the preferred velocity is displayed.
 
bool _showOrient
 Determines if the orientation of the agent is displayed.
 
VisAgent ** _visAgents
 A pointer to the agents in the scene.
 
size_t _agtCount
 The number of agents in the scene.
 
char _digits [MAX_TYPE_DIGITS+1]
 The character array for typing numbers into.
 
unsigned int _digitCount
 Number of typed digits.
 
BFSM::FsmContext_fsmCtx
 An optional finite state machine context to visualize the computation of agent behavior.
 
- 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.
 

Static Protected Attributes

static const float Y = 0.01f
 The drawing depth for the 3D elements.
 
static const unsigned int MAX_TYPE_DIGITS = 10
 The maximum number of digits for typing.
 

Detailed Description

Context class for displaying various characteristics of the Agents::BaseAgent class.

Member Enumeration Documentation

Definition of the state of the context.

Enumerator
DEFAULT_ST 

The default operating state.

TYPE_AGENT_ID_ST 

Typing in an agent selection.

Constructor & Destructor Documentation

Menge::BaseAgentContext::BaseAgentContext ( VisAgent **  agents,
size_t  agtCount,
BFSM::FsmContext fsmCtx = 0x0 
)

Construtor.

Parameters
agentsAn array of pointers to VisAgent instances.
agtCountThe number of agents contained in the array.
fsmCtxA context to visualize an agent's BFSM state.

Member Function Documentation

std::string Menge::BaseAgentContext::agentText ( const Agents::BaseAgent agent) const
protectedvirtual

Creates a formatted string to be printed in the context for a particular agent.

Parameters
agentThe agent whose data is to be displayed.
Returns
A formatted string for display in the context's 2D gui.

Reimplemented in ORCATypeAgentContext< Agent >.

virtual std::string Menge::BaseAgentContext::contextName ( ) const
inlineprotectedvirtual

Returns the name of the context for display.

Returns
The name of this context.

Reimplemented in ORCATypeAgentContext< Agent >, ORCATypeAgentContext< Agent >, and ORCATypeAgentContext< Agent >.

void Menge::BaseAgentContext::draw3DGL ( bool  select = false)
protectedvirtual

Draw context elements into the 3D world.

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

Reimplemented from Menge::SceneGraph::Context.

Reimplemented in ORCATypeAgentContext< Agent >.

void Menge::BaseAgentContext::drawGL ( int  vWidth,
int  vHeight 
)
virtual

The draw function for the context.

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

Reimplemented from Menge::SceneGraph::Context.

void Menge::BaseAgentContext::drawUIGL ( int  vWidth,
int  vHeight,
bool  select = false 
)
protectedvirtual

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

SceneGraph::ContextResult Menge::BaseAgentContext::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.

Reimplemented in ORCATypeAgentContext< Agent >.

bool Menge::BaseAgentContext::selectGL ( const SceneGraph::GLScene scene,
const SceneGraph::GLCamera camera,
int  vWidth,
int  vHeight,
int *  selectPoint 
)
virtual

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

void Menge::BaseAgentContext::setFSMContext ( BFSM::FsmContext ctx)
inline

Sets the fsm context.

Parameters
ctxThe context for the finite state machine.

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