front_idill/extern/fajran-npTuioClient/TuioClient/TuioContainer.h
changeset 30 45c889eae324
parent 29 fcf435874395
child 31 2c7fc855eba8
equal deleted inserted replaced
29:fcf435874395 30:45c889eae324
     1 /*
       
     2     TUIO C++ Library - part of the reacTIVision project
       
     3     http://reactivision.sourceforge.net/
       
     4 
       
     5     Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
       
     6     
       
     7     This program is free software; you can redistribute it and/or modify
       
     8     it under the terms of the GNU General Public License as published by
       
     9     the Free Software Foundation; either version 2 of the License, or
       
    10     (at your option) any later version.
       
    11 
       
    12     This program is distributed in the hope that it will be useful,
       
    13     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15     GNU General Public License for more details.
       
    16 
       
    17     You should have received a copy of the GNU General Public License
       
    18     along with this program; if not, write to the Free Software
       
    19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    20 */
       
    21 
       
    22 /*
       
    23     Modified by alexandre.bastien@iri.centrepompidou.fr to manage TUIO strings.
       
    24 */
       
    25 
       
    26 #ifndef INCLUDED_TUIOCONTAINER_H
       
    27 #define INCLUDED_TUIOCONTAINER_H
       
    28 
       
    29 #include <list>
       
    30 #include <math.h>
       
    31 #include "TuioPoint.h"
       
    32 #include <iostream>
       
    33 
       
    34 #define TUIO_ADDED 0
       
    35 #define TUIO_UPDATED 1
       
    36 #define TUIO_REMOVED 2
       
    37 
       
    38 class TuioContainer: public TuioPoint {
       
    39 
       
    40     protected:
       
    41     long session_id;
       
    42     float xpos, ypos, zpos;
       
    43     float x_speed, y_speed;
       
    44     float motion_speed, motion_accel;
       
    45     std::list<TuioPoint> path;
       
    46     
       
    47     int state;
       
    48     
       
    49     public:
       
    50     TuioContainer (long s_id, float xpos, float ypos):TuioPoint(xpos,ypos) {
       
    51         this->session_id = s_id;
       
    52         this->x_speed = 0.0f;
       
    53         this->y_speed = 0.0f;
       
    54         this->motion_speed = 0.0f;
       
    55         this->motion_accel = 0.0f;
       
    56         TuioPoint p(xpos,ypos);
       
    57         path.push_back(p);
       
    58         
       
    59         state = TUIO_ADDED;
       
    60     };
       
    61 
       
    62     /*
       
    63     * Surchargé par alexandre.bastien@iri.centrepompidou.fr
       
    64     */
       
    65     TuioContainer (long s_id, float xpos, float ypos, float zpos):TuioPoint(xpos,ypos,zpos) {
       
    66         this->session_id = s_id;
       
    67         this->x_speed = 0.0f;
       
    68         this->y_speed = 0.0f;
       
    69         this->motion_speed = 0.0f;
       
    70         this->motion_accel = 0.0f;
       
    71         TuioPoint p(xpos,ypos,zpos);
       
    72         path.push_back(p);
       
    73         
       
    74         state = TUIO_ADDED;
       
    75     };
       
    76 
       
    77     /*
       
    78     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
    79     */
       
    80     TuioContainer (TuioContainer *tuioContainer):TuioPoint(tuioContainer) {
       
    81         this->session_id = tuioContainer->getSessionID();
       
    82         this->x_speed = 0.0f;
       
    83         this->y_speed = 0.0f;
       
    84         this->motion_speed = 0.0f;
       
    85         this->motion_accel = 0.0f;
       
    86         TuioPoint p(xpos,ypos,zpos);
       
    87         path.push_back(p);
       
    88         
       
    89         state = TUIO_ADDED;
       
    90     };
       
    91     
       
    92     virtual ~TuioContainer(){};
       
    93 
       
    94     virtual void update (float xpos, float ypos,float xspeed, float yspeed,float maccel) {
       
    95         TuioPoint::update(xpos, ypos);
       
    96         this->x_speed = xspeed;
       
    97         this->y_speed = yspeed;
       
    98         this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed);
       
    99         this->motion_accel = maccel;
       
   100         TuioPoint p(xpos,ypos);
       
   101         path.push_back(p);
       
   102         
       
   103         state = TUIO_UPDATED;
       
   104     };
       
   105 
       
   106     /*
       
   107     * Surchargé par alexandre.bastien@iri.centrepompidou.fr
       
   108     */
       
   109     virtual void update (float xpos, float ypos, float zpos, float xspeed, float yspeed,float maccel) {
       
   110         TuioPoint::update(xpos, ypos, zpos);
       
   111         this->x_speed = xspeed;
       
   112         this->y_speed = yspeed;
       
   113         this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed);
       
   114         this->motion_accel = maccel;
       
   115         TuioPoint p(xpos,ypos,zpos);
       
   116         path.push_back(p);
       
   117         
       
   118         state = TUIO_UPDATED;
       
   119     };
       
   120 
       
   121     /*
       
   122     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
   123     */
       
   124     virtual void update (TuioContainer *tuioContainer) {
       
   125         TuioPoint::update(tuioContainer);
       
   126         this->x_speed = tuioContainer->getXSpeed();
       
   127         this->y_speed =  tuioContainer->getYSpeed();
       
   128         this->motion_speed =  tuioContainer->getMotionSpeed();
       
   129         this->motion_accel = tuioContainer->getMotionAccel();
       
   130         TuioPoint p(xpos,ypos,zpos);
       
   131         path.push_back(p);
       
   132         
       
   133         state = TUIO_UPDATED;
       
   134     };
       
   135     
       
   136     virtual long getSessionID() { return session_id; };
       
   137     
       
   138     /*
       
   139     * Modifié par alexandre.bastien@iri.centrepompidou.fr
       
   140     */
       
   141     virtual TuioPoint getPosition() {
       
   142         TuioPoint p(xpos,ypos,zpos);
       
   143         return p;
       
   144     };
       
   145 
       
   146      virtual std::list<TuioPoint> getPath() {
       
   147         return path;
       
   148     };
       
   149     
       
   150     virtual void remove() {
       
   151         state = TUIO_REMOVED;
       
   152         timestamp = TUIO_UNDEFINED;        
       
   153     }
       
   154                  
       
   155     virtual float getXSpeed() { return x_speed; };
       
   156     virtual float getYSpeed() { return y_speed; };
       
   157     virtual float getMotionSpeed() { return motion_speed; };
       
   158     virtual float getMotionAccel() { return motion_accel; };
       
   159     
       
   160     virtual int getState() { return state; };
       
   161     virtual void setUpdateTime(long timestamp) { 
       
   162         this->timestamp = timestamp;
       
   163         TuioPoint *lastPoint = &path.back();
       
   164         if (lastPoint!=NULL) lastPoint->setUpdateTime(timestamp);
       
   165     };
       
   166 
       
   167 };
       
   168 
       
   169 #endif