TrackingTable Class Reference

#include <ttable.h>

List of all members.

Public Member Functions

 TrackingTable ()
 Constructor.
 ~TrackingTable ()
 destructor
void AddRow (int bodyID, Body::BodyType type, int sceneId, int SceneNode, Condition condition, TTableEntry::TransformMode mode, float scale)
 Adds new row to table.
void AddRow (int bodyID, Body::BodyType type, int sceneId, int SceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale)
 Adds new row to table.
void UpdateRow (int bodyID, Body::BodyType type, int sceneID, int sceneNode, Condition condition, TTableEntry::TransformMode mode, float scale)
 Update table entry or add new one.
void UpdateRow (int row, Condition condition, TTableEntry::TransformMode mode, float scale)
 Update specified row with new condition, transformation mode and scale.
int GetFirstRow (int idBody, Body::BodyType type, int scene, int sceneNode)
 returns index to first row with specified key;
int GetNextRow ()
 returns next row with key used in previous GetFirstRow() method call...
int GetSceneID (int row)
int GetSceneNodeID (int row)
void SetScale (int row, float scale)
 Set scale parameter to entry on specified row.
void SetTransformMode (int row, TTableEntry::TransformMode mod)
 Set transformation mode to specified row.
void SetCondition (int row, Condition condition)
 Set another condition to specified row.
float GetScale (int row)
 returns value of scale on specified row
TTableEntry::TransformMode GetTransformationMode (int row)
 returns transformation mode from specified row
Condition GetCondition (int row)
 returns Condition object of specified row
TTableEntrygetTableEntry (int row)
 returns table entry
void ProcessTable (Body::BodyType type, int bodyID, MATRIX bodyMatrix, int buttons, float ctrl1, float ctrl2, VRUT::SceneModule *module)
 Compares table with parameters and generate transformation events.
bool InsertLine (int bodyID, Body::BodyType type, int sceneID, int sceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale)
 Insert a line with specified values returns true if line was added.
bool EraseLine (int bodyID, Body::BodyType type, int sceneID, int sceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale)
 Find and delete line. returns true if line was deleted.
void ClearTable ()
 clear all table
wxString GetAsString ()
 Return all table as string.
void WriteToLog ()

Private Attributes

std::vector< TTableEntrytable
 implementation of table
int iterator
 Iterator helps to browse rows with the same tracked device.
int idBody
 Body identificator. It helps to browse rows with the same tracked device.
Body::BodyType type
 the type of tracked device. It helps to browse rows with the same device
int SceneId
 identificator of scene
int SceneNodeID
 identificator od node in scene graph


Detailed Description

Tracking table. It connects the node of specified scene and tracked device and making scene transformations based on transformation of tracked device. The transformation is also subject to specified condition. Table can have more then one row with connection between specific Tracked device and Node of scene It is because there may be more then one condition on how to handle with transformations Please be sure to use exclusive Conditions on the rows connecting the same scene nodes and tracked devices

Definition at line 231 of file ttable.h.


Constructor & Destructor Documentation

TrackingTable::TrackingTable (  ) 

Constructor.

Definition at line 357 of file ttable.cpp.

00358 {
00359        iterator    = -1;
00360        idBody     = -1;
00361        SceneId     = -1;
00362        SceneNodeID = -1;
00363 }

TrackingTable::~TrackingTable (  ) 

destructor

Definition at line 364 of file ttable.cpp.

00365 {}


Member Function Documentation

void TrackingTable::AddRow ( int  bodyID,
Body::BodyType  type,
int  sceneId,
int  SceneNode,
Condition  condition,
TTableEntry::TransformMode  mode,
float  scale 
)

Adds new row to table.

Parameters:
bodyID Number identificator of tracked device
type The type of specified body
sceneId - Identificator of scene
SceneNode Identificator of node in scene graph

Definition at line 366 of file ttable.cpp.

00367 {
00368        TTableEntry entry(bodyID, type, sceneId, SceneNode, condition, mode,scale);
00369        table.push_back(entry);
00370 }

void TrackingTable::AddRow ( int  bodyID,
Body::BodyType  type,
int  sceneId,
int  SceneNode,
int  pressed,
int  released,
float  ctrl1,
float  ctrl2,
TTableEntry::TransformMode  mode,
float  scale 
)

Adds new row to table.

Parameters:
bodyID Number identificator of tracked device
type The type of specified body
sceneId - Identificator of scene
SceneNode Identificator of node in scene graph
pressed - parameter of Condition (see Condition class description)
released - parameter of Condition
ctrl1 - parameter of Condition
ctrl2 - parameter of Condition

Definition at line 371 of file ttable.cpp.

00372 {
00373        Condition condition(pressed,released,ctrl1, ctrl2);
00374        TTableEntry entry(bodyID, type, sceneId, SceneNode, condition, mode,scale);
00375        table.push_back(entry);
00376 }

void TrackingTable::UpdateRow ( int  bodyID,
Body::BodyType  type,
int  sceneID,
int  sceneNode,
Condition  condition,
TTableEntry::TransformMode  mode,
float  scale 
)

Update table entry or add new one.

If there is no row with specified: bodyID, type, sceneId and SceneNode it adds new one. If there are some lines. First of them will be updated

Parameters:
bodyID Part of the primary key : Tracked device number identificator
type Part of the primary key : Tracked device type identificator
sceneID Part of the primary key : Id of the scene
sceneNode Part of the primary key : Identificator of the node in scene graph
condition Condition parameter to be updated
mode Transformation Mode parameter to be updated
scale Scale parameter to be updated

Definition at line 377 of file ttable.cpp.

00378 {
00379        int iter = this->GetFirstRow(bodyID, type, sceneID, sceneNode);
00380        if (iter == -1)
00381        {
00382               AddRow(bodyID, type, sceneID, sceneNode, condition, mode, scale);
00383        }
00384        else
00385        {
00386               UpdateRow(iter, condition, mode, scale);
00387        }
00388 }

void TrackingTable::UpdateRow ( int  row,
Condition  condition,
TTableEntry::TransformMode  mode,
float  scale 
)

Update specified row with new condition, transformation mode and scale.

if specified row is not in scope of table nothing will be done

Parameters:
row - number of row to be updated - use GetFirstRow() or GetNextRow() to determine this parameter
condition Condition parameter to be updated
mode Transformation Mode parameter to be updated
scale Scale parameter to be updated

Definition at line 389 of file ttable.cpp.

00390 {
00391        if (row >= (int)table.size()) return;
00392        table[row].SetCondition(condition);
00393        table[row].SetTransformMode(mode);
00394        table[row].SetScale(scale);
00395 }

int TrackingTable::GetFirstRow ( int  idBody,
Body::BodyType  type,
int  scene,
int  sceneNode 
)

returns index to first row with specified key;

-1 is returned if no row was found

Parameters:
idBody Number identificator of tracked device.
type The type of specified body.
scene Identificator of scene.
sceneNode Identificator of node in scene graph.

Definition at line 397 of file ttable.cpp.

00398 {
00399        iterator = -1;
00400        this->idBody = idBody;
00401        this->type = type;
00402        this->SceneId = scene;
00403        this->SceneNodeID = sceneNode;
00404        for (size_t i = 0; i < table.size(); i++)
00405        {
00406               if (table[i].GetBodyID() == idBody && table[i].GetBodyType() == type && table[i].GetSceneID() == scene && table[i].GetSceneNodeID() == sceneNode)
00407               {
00408                      iterator = (int)i;
00409                      return iterator;
00410               }
00411        }
00412        return iterator;
00413 }

int TrackingTable::GetNextRow (  ) 

returns next row with key used in previous GetFirstRow() method call...

if -1 is returned no new line was found;

Definition at line 414 of file ttable.cpp.

00415 {
00416        if (iterator == -1) iterator = 0;
00417        for (size_t i = iterator; i < table.size(); i++)
00418        {
00419               if (table[i].GetBodyID() == idBody && table[i].GetBodyType() == type && table[i].GetSceneID() == SceneId && table[i].GetSceneNodeID() == SceneNodeID)
00420               {
00421                      iterator = (int)i;
00422                      return iterator;
00423               }
00424        }
00425        iterator = -1;
00426        return iterator;
00427 }

int TrackingTable::GetSceneID ( int  row  ) 

Definition at line 453 of file ttable.cpp.

00454 {
00455        //if (row >= (int)table.size()) return ;
00456        return table[row].GetSceneID();
00457 }

int TrackingTable::GetSceneNodeID ( int  row  ) 

Definition at line 458 of file ttable.cpp.

00459 {
00460        //if (row >= (int)table.size()) return ;
00461        return table[row].GetSceneNodeID();
00462 }

void TrackingTable::SetScale ( int  row,
float  scale 
)

Set scale parameter to entry on specified row.

Parameters:
row - row where to update paramter
scale - new value of scale for specified row

Definition at line 428 of file ttable.cpp.

00429 {
00430        if (row >= (int)table.size()) return;
00431        table[row].SetScale(scale);
00432 }

void TrackingTable::SetTransformMode ( int  row,
TTableEntry::TransformMode  mod 
)

Set transformation mode to specified row.

Parameters:
row - row where to update paramter
mod - new value of transformation mode for specified row

Definition at line 433 of file ttable.cpp.

00434 {
00435        if (row >= (int)table.size()) return;
00436        table[row].SetTransformMode(mod);
00437 }

void TrackingTable::SetCondition ( int  row,
Condition  condition 
)

Set another condition to specified row.

Parameters:
row - row where to update paramter
condition - new value of condition for specified row (see Condition class description)

Definition at line 438 of file ttable.cpp.

00439 {
00440        if (row >= (int)table.size()) return;
00441        table[row].SetCondition(cond);
00442 }

float TrackingTable::GetScale ( int  row  ) 

returns value of scale on specified row

Definition at line 443 of file ttable.cpp.

00444 {
00445        //if (row >= (int)table.size()) return 0;
00446        return table[row].GetScale();
00447 }

TTableEntry::TransformMode TrackingTable::GetTransformationMode ( int  row  ) 

returns transformation mode from specified row

Definition at line 448 of file ttable.cpp.

00449 {
00450        //if (row >= (int)table.size()) return ;
00451        return table[row].GetTransformationMode();
00452 }

Condition TrackingTable::GetCondition ( int  row  ) 

returns Condition object of specified row

Definition at line 463 of file ttable.cpp.

00464 {
00465        //if (row >= (int)table.size()) return ;
00466        return table[row].GetCondition();
00467 }

TTableEntry * TrackingTable::getTableEntry ( int  row  ) 

returns table entry

please avoid to use this method

Definition at line 468 of file ttable.cpp.

00469 {
00470        //if (row >= (int)table.size()) return ;
00471        return &table[row];
00472 }

void TrackingTable::ProcessTable ( Body::BodyType  type,
int  bodyID,
MATRIX  bodyMatrix,
int  buttons,
float  ctrl1,
float  ctrl2,
VRUT::SceneModule module 
)

Compares table with parameters and generate transformation events.

Parameters:
type The type of tracked device
bodyID The number identificator of tracked device
bodyMatrix Current Matrix with transformation and rotation of tracked device
buttons Mask of currently pressed buttons
ctrl1 Current value of Control 1 (Flystick 2 joystick left-right)
ctrl2 Current value of Control 2 (Flystick 3 joystick up-down)

Definition at line 473 of file ttable.cpp.

00474 {
00475 //     LOG(wxT("Processing table..."));
00476 //     LOG(wxString::Format(wxT("type %i, id %i"), type, bodyID));
00477        if (ctrl1 < -1 || ctrl1 > 1) ctrl1 = 0;
00478        if (ctrl2 < -1 || ctrl2 > 1) ctrl2 = 0;
00479        for (size_t i = 0 ; i < table.size(); i++)
00480        {
00481 //            LOG(wxString::Format(wxT("Entries:: type %i, id %i"), (int)table[i].GetBodyType(), table[i].GetBodyID()));
00482               if (bodyID == table[i].GetBodyID() && type == (int)table[i].GetBodyType())
00483               {
00484 //                   LOG(wxT("Entry found..."));
00485                      table[i].generateEvent(bodyMatrix, buttons, ctrl1, ctrl2, module);
00486               }
00487        }
00488 }

bool TrackingTable::InsertLine ( int  bodyID,
Body::BodyType  type,
int  sceneID,
int  sceneNode,
int  pressed,
int  released,
float  ctrl1,
float  ctrl2,
TTableEntry::TransformMode  mode,
float  scale 
)

Insert a line with specified values returns true if line was added.

This method shloud be useful when the table is controlled by events this method works nearly as the AddRow, the differene is that it checks if there is not the same line and also checks validity of condition parameters (pressed, released, ctrl1, ctrl2) (Some devices do not have buttons or controls so they shouldn't affect transformations). If there is already a line with the same values nothing will be done

Parameters:
bodyID Part of the primary key : Tracked device number identificator
type Part of the primary key : Tracked device type identificator
sceneID Part of the primary key : Id of the scene
sceneNode Part of the primary key : Identificator of the node in scene graph
condition Condition parameter to be updated
mode Transformation Mode parameter to be updated
scale Scale parameter to be updated

Definition at line 489 of file ttable.cpp.

00490 {
00491        if (type != Body::B6DF2) // check if the body doesn't have controls
00492        {
00493               ctrl1 = ctrl2 = 0;
00494        }
00495        if (type == Body::B6D || type == Body::B3D || type == Body::BGL) // check if the body doesn't have buttons
00496        {
00497               pressed = released = 0;
00498        }
00499        std::vector<TTableEntry>::iterator i;
00500        for (i = table.begin(); i != table.end(); i++)
00501        {
00502               Condition cond = (*i).GetCondition();
00503               if ((*i).GetBodyID()             == bodyID    &&
00504                      (*i).GetBodyType()           == type      &&
00505                      (*i).GetSceneID()            == sceneID   &&
00506                      (*i).GetSceneNodeID()        == sceneNode &&
00507                      cond.PressedMask()           == pressed   &&
00508                      cond.ReleasedMask()          == released  &&
00509                      cond.Control1()              == ctrl1     &&
00510                      cond.Control2()              == ctrl2       &&
00511                      (*i).GetTransformationMode() == mode      &&
00512                      (*i).GetScale()              == scale       ) return false;
00513        }
00514        // if not returned after the same row found...
00515        this->AddRow(bodyID, type, sceneID, sceneNode, pressed, released, ctrl1, ctrl2, mode, scale);
00516        return true;
00517 }

bool TrackingTable::EraseLine ( int  bodyID,
Body::BodyType  type,
int  sceneID,
int  sceneNode,
int  pressed,
int  released,
float  ctrl1,
float  ctrl2,
TTableEntry::TransformMode  mode,
float  scale 
)

Find and delete line. returns true if line was deleted.

ths method should be useful when the table is controlled by events. Condition parameters are checked for validity (pressed, released, ctrl1, ctrl2) and corrected. (Some devices specified with the type doesn't have any button or control)
Note that this method goes through table and deletes first occurence of the line. If there are some duplicities they will be not deleted. Please be sure to not inserting duplicities while using this class or call this method until it returns false;

Parameters:
bodyID Part of the primary key : Tracked device number identificator
type Part of the primary key : Tracked device type identificator
sceneID Part of the primary key : Id of the scene
sceneNode Part of the primary key : Identificator of the node in scene graph
condition Condition parameter to be updated
mode Transformation Mode parameter to be updated
scale Scale parameter to be updated

Definition at line 518 of file ttable.cpp.

00519 {
00520        if (type != Body::B6DF2) // check if the body doesn't have controls
00521        {
00522               ctrl1 = ctrl2 = 0;
00523        }
00524        if (type == Body::B6D || type == Body::B3D || type == Body::BGL) // check if the body doesn't have buttons
00525        {
00526               pressed = released = 0;
00527        }
00528        std::vector<TTableEntry>::iterator i;
00529        for (i = table.begin(); i != table.end(); i++)
00530        {
00531               Condition cond = (*i).GetCondition();
00532               if ((*i).GetBodyID()             == bodyID    &&
00533                      (*i).GetBodyType()           == type      &&
00534                      (*i).GetSceneID()            == sceneID   &&
00535                      (*i).GetSceneNodeID()        == sceneNode &&
00536                      cond.PressedMask()           == pressed   &&
00537                      cond.ReleasedMask()          == released  &&
00538                      cond.Control1()              == ctrl1     &&
00539                      cond.Control2()              == ctrl2       &&
00540                      (*i).GetTransformationMode() == mode      &&
00541                      (*i).GetScale()              == scale       )
00542               {
00543                      table.erase(i);
00544                      return true;
00545               }
00546        }
00547        return false;
00548 }

void TrackingTable::ClearTable (  ) 

clear all table

Definition at line 549 of file ttable.cpp.

00550 {
00551        table.clear();
00552 }

wxString TrackingTable::GetAsString (  ) 

Return all table as string.

Parameters:
lineSeparator - character (op possibly string) used as separator to differ lines of the table
atributeSeparator - character (or possibly string) used as separator to differ atributes within the line

Definition at line 554 of file ttable.cpp.

00555 {
00556        wxString dump = wxT("");
00557        size_t  max = table.size();
00558        for (size_t i = 0; i < max; i++)
00559        {
00560               dump << table[i].GetAsString() << wxT("\n");
00561        }
00562        return dump;
00563 }

void TrackingTable::WriteToLog (  ) 

Definition at line 564 of file ttable.cpp.

00565 {
00566        size_t max = table.size();
00567        if (max == 0) 
00568        {
00569               LOG(wxT("<TrackingManipulator> Table empty!"));
00570               return;
00571        }
00572        else
00573        {
00574               wxString dump = wxT("<TrackingManipulator> Table: (scene node type id mode pressed released ctrl1 ctrl2 scale)\n");
00575               for (size_t i = 0; i < max; i++)
00576               {
00577                      Condition c = table[i].GetCondition();
00578                      dump << table[i].GetSceneID() << wxT(" ") << table[i].GetSceneNodeID()
00579                              << wxT(" ") << table[i].GetBodyType() << wxT(" ") << table[i].GetBodyID()
00580                              << wxT(" ") << table[i].GetTransformationMode() << wxT(" ") << c.PressedMask()
00581                              << wxT(" ") << c.ReleasedMask() << wxT(" ") << c.Control1() << wxT(" ") << c.Control2()
00582                              << wxT(" ") << table[i].GetScale() <<wxT("\n");
00583               }
00584               LOG(dump);
00585        }
00586 }


Member Data Documentation

std::vector<TTableEntry> TrackingTable::table [private]

implementation of table

Definition at line 235 of file ttable.h.

int TrackingTable::iterator [private]

Iterator helps to browse rows with the same tracked device.

Definition at line 237 of file ttable.h.

int TrackingTable::idBody [private]

Body identificator. It helps to browse rows with the same tracked device.

Definition at line 239 of file ttable.h.

the type of tracked device. It helps to browse rows with the same device

Definition at line 241 of file ttable.h.

int TrackingTable::SceneId [private]

identificator of scene

Definition at line 243 of file ttable.h.

identificator od node in scene graph

Definition at line 245 of file ttable.h.


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

Generated on Tue Mar 10 14:41:39 2009 for VRUT by  doxygen 1.5.5