#include <ttable.h>
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 | |
| TTableEntry * | getTableEntry (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< TTableEntry > | table |
| 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 | |
Definition at line 231 of file ttable.h.
| 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 | ( | ) |
| void TrackingTable::AddRow | ( | int | bodyID, | |
| Body::BodyType | type, | |||
| int | sceneId, | |||
| int | SceneNode, | |||
| Condition | condition, | |||
| TTableEntry::TransformMode | mode, | |||
| float | scale | |||
| ) |
Adds new row to table.
| 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.
| 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
| 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
| 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
| 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.
| row | - row where to update paramter | |
| scale | - new value of scale for specified row |
Definition at line 428 of file ttable.cpp.
| void TrackingTable::SetTransformMode | ( | int | row, | |
| TTableEntry::TransformMode | mod | |||
| ) |
Set transformation mode to specified row.
| row | - row where to update paramter | |
| mod | - new value of transformation mode for specified row |
Definition at line 433 of file ttable.cpp.
| void TrackingTable::SetCondition | ( | int | row, | |
| Condition | condition | |||
| ) |
Set another condition to specified row.
| 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.
| 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.
| 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
| 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;
| 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 | ( | ) |
| wxString TrackingTable::GetAsString | ( | ) |
Return all table as string.
| 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 }
std::vector<TTableEntry> TrackingTable::table [private] |
int TrackingTable::iterator [private] |
int TrackingTable::idBody [private] |
Body::BodyType TrackingTable::type [private] |
int TrackingTable::SceneId [private] |
int TrackingTable::SceneNodeID [private] |
1.5.5