Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

StateControl Class Reference

Class that maintains the osg world and handles any changes to the state of the world. More...

#include <StateControl.h>

Collaboration diagram for StateControl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 StateControl (Dispatcher *disp)
 ~StateControl ()
bool location (int loc_id, shared_ptr< string > desc, unsigned int capacity, double dist, double s, int tile, double width, double height, double x, double y, double rot)
bool drv (int Rt, int Ri_a, int Ri_b, int Ri_d, double ts, double te)
bool load (int Rt, int Ri, int C, double ts, double tf)
bool unload (int Rt, int Ri, int C, double ts, double te)
bool setspdinviz (int R, double s)
bool trnew (int Rt, shared_ptr< string > desc, int Ri, double s)
bool trdel (int Rt)
bool newcarg (int C, shared_ptr< string > desc, int Ri)
bool rmcarg (int C)
bool arc (int Ri_a, int Ri_b)
osg::Group * getOsgRoot ()
bool adjustTimeFlow (double adj)
double getTimeFlow ()
double getTime ()
void pause ()
int selectObject (TraplasObject *obj)
TraplasObjectgetLastSelected ()
int deselectObject (TraplasObject *obj)
void clearSelection ()

Private Member Functions

bool readMapping (int)
void updateHudText (TraplasObject *upd)

Private Attributes

Dispatcherdis
UserInterfaceui
osgProducer::Viewer * view
string trackingCamName
string previousCamName
map< int, TraplasObject * > world
vector< TraplasObject * > selected
osg::Group * osgRoot
map< int, string > tileMap
double tilescale
string transmodel
double transscale
string cargomodel
double cargoscale
pthread_t osg_update_loop
double pausetime

Friends

void * go (void *none)

Detailed Description

Class that maintains the osg world and handles any changes to the state of the world.

StateControl maintains information about relations between the classes in TraplasObject.h and OSG.

osg_in_statecontrol.png

osg uml class diagram. For a more comprehensive view see the manual.

Definition at line 91 of file StateControl.h.


Constructor & Destructor Documentation

StateControl::StateControl Dispatcher disp  ) 
 

Constructor

Parameters:
disp A reference to the dispatcher that called the constructor.

Definition at line 148 of file StateControl.cpp.

References CARGO, dis, go, LOCATION, osg_update_loop, osgRoot, pausetime, readMapping(), TRANSPORT, ui, and view.

Here is the call graph for this function:

StateControl::~StateControl  ) 
 

Destructor

Definition at line 222 of file StateControl.cpp.

References ui.


Member Function Documentation

bool StateControl::adjustTimeFlow double  adj  ) 
 

Adds the specified amount to the timeFlowFactor (or timescale) in MessageController.

Parameters:
adj The amount to add to the timeFlowFactor.
Returns:
true if succesfull, false if there was an error.

Definition at line 571 of file StateControl.cpp.

References dis, Dispatcher::getTimeFlow(), and Dispatcher::setTimeFlow().

Referenced by UserInterface::buttonAction().

Here is the call graph for this function:

bool StateControl::arc int  Ri_a,
int  Ri_b
 

Creates an one-way arc between two infrastructure resources.

Parameters:
Ri_a The infrastructure recource from where the arc is coming.
Ri_b The infrastructure resource that is the destination of this arc.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 554 of file StateControl.cpp.

References Infrastructure::addArc(), TraplasObject::getModel(), and world.

Referenced by Dispatcher::arcparse().

Here is the call graph for this function:

void StateControl::clearSelection  ) 
 

Clears all selections. Removes information texts from the HUD.

Definition at line 636 of file StateControl.cpp.

References UserInterface::rmHUDText(), selected, and ui.

Referenced by UserInterface::selectionAction().

Here is the call graph for this function:

int StateControl::deselectObject TraplasObject obj  ) 
 

removes one object from the selection. If information about this object is also being displayed in the HUD it, too is removed.

Parameters:
obj The object to deselect.
Returns:
The number of objects selected.

Definition at line 621 of file StateControl.cpp.

References UserInterface::rmHUDText(), selected, TraplasObject::toString(), and ui.

Referenced by rmcarg(), UserInterface::selectionAction(), and trdel().

Here is the call graph for this function:

bool StateControl::drv int  Rt,
int  Ri_a,
int  Ri_b,
int  Ri_d,
double  ts,
double  te
 

Sets a drive action on the specified transport resource.

Parameters:
Rt The identifier of the transport that is going to do the drive action.
Ri_a The identifier of the current location of the transport.
Ri_b The identifer of the location where the transport will be after the drive action finishes.
Ri_d The identifer of the final destination of this transport resource's planning.
ts The starting time of the drive action.
te The time at which the drive action is completed.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 279 of file StateControl.cpp.

References dis, TraplasObject::getModel(), TraplasObject::getPosition(), Dispatcher::getTimeFlow(), Transport::setDestination(), AnimationPathTimedCallback::setTimeReference(), and world.

Referenced by Dispatcher::drvparse().

Here is the call graph for this function:

TraplasObject * StateControl::getLastSelected  ) 
 

Returns:
The last selected object.

Definition at line 614 of file StateControl.cpp.

References selected.

osg::Group* StateControl::getOsgRoot  )  [inline]
 

Returns:
The root of the osg-scene that is contained in StateControl.

Definition at line 206 of file StateControl.h.

References osgRoot.

Referenced by go().

double StateControl::getTime  ) 
 

Returns:
The current time.

Definition at line 584 of file StateControl.cpp.

References dis, and Dispatcher::getTime().

Referenced by UserInterface::createHud(), and UserInterface::updateClock().

Here is the call graph for this function:

double StateControl::getTimeFlow  ) 
 

Returns:
The current timescaling.

Definition at line 580 of file StateControl.cpp.

References dis, and Dispatcher::getTimeFlow().

Referenced by UserInterface::createHud(), and UserInterface::updateClock().

Here is the call graph for this function:

bool StateControl::load int  Rt,
int  Ri,
int  C,
double  ts,
double  tf
 

Sets an load action for the specified transport resource.

Parameters:
Rt The identifier of the transport.
Ri The identifier of the locaiton where the load action takes place.
C The identifier of the cargo object.
ts Starting time of the load action.
tf Time at which the load action if finished.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 324 of file StateControl.cpp.

References TraplasObject::getModel(), TraplasObject::isSelected(), Infrastructure::removeCarg(), Transport::setCargo(), updateHudText(), and world.

Referenced by Dispatcher::loadparse().

Here is the call graph for this function:

bool StateControl::location int  loc_id,
shared_ptr< string >  desc,
unsigned int  capacity,
double  dist,
double  s,
int  tile,
double  width,
double  height,
double  x,
double  y,
double  rot
 

Creates a new location object and loads the relevant osg-model.

Parameters:
loc_id The identifier of the new location object.
desc Description of the infrastructure resource.
capacity The capacity of the new infrastructure resource associated with this location object.
dist The distance of the infrastructure resource.
s The maximum speed in this infrastructure resource.
tile The type of tile to load to represent this infrastructure resource.
width The width of the tile.
height The height of the tile.
x The x-coordinate of the tile in the osg-graph.
y The y-coordinate of the tile in the osg-graph.
rot The orientation of the tile in the osg-graph.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 226 of file StateControl.cpp.

References TraplasObject::initLabel(), LOCATION, osgRoot, TraplasObject::setDescription(), TraplasObject::setLabel(), tileMap, tilescale, and world.

Referenced by Dispatcher::locationparse().

Here is the call graph for this function:

bool StateControl::newcarg int  C,
shared_ptr< string >  desc,
int  Ri
 

Creates a new cargo object

Parameters:
C The identifier of the new cargo object.
desc Description of the cargo object.
Ri The location at which the cargo object is to be placed.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 492 of file StateControl.cpp.

References Infrastructure::addCarg(), CARGO, cargomodel, cargoscale, TraplasObject::getModel(), TraplasObject::initLabel(), TraplasObject::setDescription(), TraplasObject::setLabel(), and world.

Referenced by Dispatcher::newcargparse().

Here is the call graph for this function:

void StateControl::pause  ) 
 

Pauses the visualisation.

Definition at line 588 of file StateControl.cpp.

References dis, Dispatcher::getTimeFlow(), pausetime, and Dispatcher::setTimeFlow().

Referenced by UserInterface::buttonAction(), and UserEventHandler::handle().

Here is the call graph for this function:

bool StateControl::readMapping int   )  [private]
 

Definition at line 165 of file StateControl.cpp.

References CARGO, cargomodel, cargoscale, LOCATION, tileMap, tilescale, transmodel, TRANSPORT, and transscale.

Referenced by StateControl().

bool StateControl::rmcarg int  C  ) 
 

Removes the specified cargo object from the visualisation.

Parameters:
C The identifier of the cargo object to remove.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 534 of file StateControl.cpp.

References deselectObject(), TraplasObject::getModel(), TraplasObject::isSelected(), and world.

Referenced by Dispatcher::rmcargparse().

Here is the call graph for this function:

int StateControl::selectObject TraplasObject obj  ) 
 

Adds an object to the vector with selected objects. Adds information about the object to the HUD.

Parameters:
obj The object that has been selected.
Returns:
The number of objects selected.

Definition at line 601 of file StateControl.cpp.

References TraplasObject::select(), selected, UserInterface::setHUDText(), TraplasObject::toString(), and ui.

Referenced by UserInterface::selectionAction().

Here is the call graph for this function:

bool StateControl::setspdinviz int  R,
double  s
 

Sets the speed for the specified resource. Can be a transport resource or an infrastructure resource.

Parameters:
R The identifier of the resource that is to have it's speed adjusted.
s The new speed.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 412 of file StateControl.cpp.

References TraplasObject::isSelected(), Transport::setSpeed(), updateHudText(), and world.

Referenced by Dispatcher::setspdparse().

Here is the call graph for this function:

bool StateControl::trdel int  Rt  ) 
 

Removes the specified transport resource from the visualisation.

Parameters:
Rt The identifier of te transport resource to be removed.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 470 of file StateControl.cpp.

References deselectObject(), Transport::getCargo(), TraplasObject::getModel(), TraplasObject::isSelected(), osgRoot, and world.

Referenced by Dispatcher::trdelparse().

Here is the call graph for this function:

bool StateControl::trnew int  Rt,
shared_ptr< string >  desc,
int  Ri,
double  s
 

Creates a new transport object and loads the relevant osg-model.

Parameters:
Rt The identifier of the new transport resource.
desc Description of the transport resource.
Ri The identifier of the infrastructure resource where the new transport is to be placed.
s The speed of the new transport.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 426 of file StateControl.cpp.

References TraplasObject::getPosition(), TraplasObject::initLabel(), osgRoot, TraplasObject::setDescription(), TraplasObject::setLabel(), transmodel, TRANSPORT, transscale, and world.

Referenced by Dispatcher::trnewparse().

Here is the call graph for this function:

bool StateControl::unload int  Rt,
int  Ri,
int  C,
double  ts,
double  te
 

Sets an unload action for the specified transport resource.

Parameters:
Rt The identifier of the transport.
Ri The identifier of the locaiton where the unload action takes place.
C The identifier of the cargo object.
ts Starting time of the unload action.
te Time at which the unload action if finished.
Returns:
true if sucessfull, false if there has been an error.

Definition at line 364 of file StateControl.cpp.

References Infrastructure::addCarg(), Transport::clearCargo(), Transport::getCargo(), TraplasObject::getModel(), TraplasObject::isSelected(), updateHudText(), and world.

Referenced by Dispatcher::unloadparse().

Here is the call graph for this function:

void StateControl::updateHudText TraplasObject upd  )  [private]
 

Definition at line 675 of file StateControl.cpp.

References UserInterface::rmHUDText(), UserInterface::setHUDText(), TraplasObject::toString(), and ui.

Referenced by load(), setspdinviz(), and unload().

Here is the call graph for this function:


Friends And Related Function Documentation

void* go void *  none  )  [friend]
 

The thread responsible for initializing osg, setting up a viewer and starting an osg loop lives in this function.

Parameters:
none The StateControl instance this thread is responsible for.
Returns:
A void pointer. Used by pthread_create().

Definition at line 106 of file StateControl.cpp.

Referenced by StateControl().


Member Data Documentation

string StateControl::cargomodel [private]
 

Definition at line 274 of file StateControl.h.

Referenced by newcarg(), and readMapping().

double StateControl::cargoscale [private]
 

Definition at line 275 of file StateControl.h.

Referenced by newcarg(), and readMapping().

Dispatcher* StateControl::dis [private]
 

Definition at line 262 of file StateControl.h.

Referenced by adjustTimeFlow(), drv(), getTime(), getTimeFlow(), go(), pause(), and StateControl().

pthread_t StateControl::osg_update_loop [private]
 

Definition at line 276 of file StateControl.h.

Referenced by StateControl().

osg::Group* StateControl::osgRoot [private]
 

Definition at line 269 of file StateControl.h.

Referenced by getOsgRoot(), location(), StateControl(), trdel(), and trnew().

double StateControl::pausetime [private]
 

Definition at line 279 of file StateControl.h.

Referenced by pause(), and StateControl().

string StateControl::previousCamName [private]
 

Definition at line 266 of file StateControl.h.

vector<TraplasObject*> StateControl::selected [private]
 

Definition at line 268 of file StateControl.h.

Referenced by clearSelection(), deselectObject(), getLastSelected(), and selectObject().

map<int, string> StateControl::tileMap [private]
 

Definition at line 270 of file StateControl.h.

Referenced by location(), and readMapping().

double StateControl::tilescale [private]
 

Definition at line 271 of file StateControl.h.

Referenced by location(), and readMapping().

string StateControl::trackingCamName [private]
 

Definition at line 265 of file StateControl.h.

string StateControl::transmodel [private]
 

Definition at line 272 of file StateControl.h.

Referenced by readMapping(), and trnew().

double StateControl::transscale [private]
 

Definition at line 273 of file StateControl.h.

Referenced by readMapping(), and trnew().

UserInterface* StateControl::ui [private]
 

Definition at line 263 of file StateControl.h.

Referenced by clearSelection(), deselectObject(), go(), selectObject(), StateControl(), updateHudText(), and ~StateControl().

osgProducer::Viewer* StateControl::view [private]
 

Definition at line 264 of file StateControl.h.

Referenced by go(), and StateControl().

map<int, TraplasObject*> StateControl::world [private]
 

Definition at line 267 of file StateControl.h.

Referenced by arc(), drv(), load(), location(), newcarg(), rmcarg(), setspdinviz(), trdel(), trnew(), and unload().


The documentation for this class was generated from the following files:
Generated on Mon Jun 19 10:22:22 2006 for TraplasVisualisation by  doxygen 1.4.4