front_idill/extern/fajran-npTuioClient/TuioClient/TuioContainer.h
author bastiena
Fri, 06 Apr 2012 10:44:54 +0200
changeset 21 e4e5f02787a1
child 24 2bdf5d51d434
permissions -rw-r--r--
Front IDILL : Added Communication extern named fajran-npTuioClient It contains the project generating a dll used as a browser plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
	TUIO C++ Library - part of the reacTIVision project
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	http://reactivision.sourceforge.net/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
	Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
    This program is free software; you can redistribute it and/or modify
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
    it under the terms of the GNU General Public License as published by
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
    the Free Software Foundation; either version 2 of the License, or
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
    (at your option) any later version.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
    This program is distributed in the hope that it will be useful,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
    GNU General Public License for more details.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
    You should have received a copy of the GNU General Public License
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
    along with this program; if not, write to the Free Software
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
*/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
#ifndef INCLUDED_TUIOCONTAINER_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
#define INCLUDED_TUIOCONTAINER_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
#include <list>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
#include <math.h>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
#include "TuioPoint.h"
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
#include <iostream>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
#define TUIO_ADDED 0
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
#define TUIO_UPDATED 1
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
#define TUIO_REMOVED 2
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
class TuioContainer: public TuioPoint {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
	protected:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
	long session_id;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
	float xpos, ypos;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
	float x_speed, y_speed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
	float motion_speed, motion_accel;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
	std::list<TuioPoint> path;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
	int state;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
	public:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
	TuioContainer (long s_id, float xpos, float ypos):TuioPoint(xpos,ypos) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
		this->session_id = s_id;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
		this->x_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
		this->y_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
		this->motion_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
		this->motion_accel = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
		state = TUIO_ADDED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
	TuioContainer (TuioContainer *tuioContainer):TuioPoint(tuioContainer) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
		this->session_id = tuioContainer->getSessionID();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
		this->x_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
		this->y_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
		this->motion_speed = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    63
		this->motion_accel = 0.0f;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    64
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    65
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    66
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
		state = TUIO_ADDED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    69
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    70
	virtual ~TuioContainer(){};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    71
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    72
	virtual void update (float xpos, float ypos,float xspeed, float yspeed,float maccel) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
		TuioPoint::update(xpos, ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    74
		this->x_speed = xspeed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    75
		this->y_speed = yspeed;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    76
		this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    77
		this->motion_accel = maccel;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    78
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    79
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    80
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    81
		state = TUIO_UPDATED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    82
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    83
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    84
	virtual void update (TuioContainer *tuioContainer) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    85
		TuioPoint::update(tuioContainer);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    86
		this->x_speed = tuioContainer->getXSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    87
		this->y_speed =  tuioContainer->getYSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    88
		this->motion_speed =  tuioContainer->getMotionSpeed();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    89
		this->motion_accel = tuioContainer->getMotionAccel();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    90
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    91
		path.push_back(p);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    92
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    93
		state = TUIO_UPDATED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    94
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    95
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    96
	virtual long getSessionID() { return session_id; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    97
				 				 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    98
	virtual TuioPoint getPosition() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    99
		TuioPoint p(xpos,ypos);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   100
		return p;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   101
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   102
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   103
	 virtual std::list<TuioPoint> getPath() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   104
		return path;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   105
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   106
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   107
	virtual void remove() {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   108
		state = TUIO_REMOVED;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   109
		timestamp = TUIO_UNDEFINED;		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   110
	}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   111
				 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   112
	virtual float getXSpeed() { return x_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   113
	virtual float getYSpeed() { return y_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   114
	virtual float getMotionSpeed() { return motion_speed; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   115
	virtual float getMotionAccel() { return motion_accel; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   116
	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   117
	virtual int getState() { return state; };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   118
	virtual void setUpdateTime(long timestamp) { 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   119
		this->timestamp = timestamp;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   120
		TuioPoint *lastPoint = &path.back();
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   121
		if (lastPoint!=NULL) lastPoint->setUpdateTime(timestamp);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   122
	};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   123
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   124
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   125
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
   126
#endif