Project

General

Profile

TUIO Scol plugin
sTuio.cpp
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OpenSpace3D
4 For the latest info, see http://www.openspace3d.com
5 
6 Copyright (c) 2012 I-maginer
7 
8 This program is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/copyleft/lesser.txt
21 
22 -----------------------------------------------------------------------------
23 */
24 
25 #include "sTuio.h"
26 
27 extern int TUIO_CURSOR_ADD_CB;
28 extern int TUIO_CURSOR_REMOVE_CB;
29 extern int TUIO_CURSOR_UPDATE_CB;
30 extern int TUIO_OBJECT_ADD_CB;
31 extern int TUIO_OBJECT_REMOVE_CB;
32 extern int TUIO_OBJECT_UPDATE_CB;
33 
35 {
36  m_port = port;
37 
38  m_tuioClient = new TUIO::TuioClient(m_port);
39  m_tuioClient->addTuioListener(this);
40 }
41 
43 {
44  if(m_tuioClient->isConnected())
45  m_tuioClient->disconnect();
46  SAFE_DELETE(m_tuioClient);
47 }
48 
50 {
51  m_tuioClient->connect();
52  return m_tuioClient->isConnected();
53 }
54 
56 {
57  m_tuioClient->disconnect();
58 }
59 
61 {
62  return m_tuioClient->isConnected();
63 }
64 
65 void STuioClient::addTuioObject(TUIO::TuioObject *tobj)
66 {
67  SCbData* data = new SCbData(tobj->getSymbolID(), tobj->getX(), tobj->getY(), tobj->getAngle(), tobj->getXSpeed(), tobj->getYSpeed(), tobj->getRotationSpeed());
68  OBJpostEvent(TUIO_OBJECT_ADD_CB, SCOL_PTR this, (int)data);
69 }
70 
71 void STuioClient::updateTuioObject(TUIO::TuioObject *tobj)
72 {
73  SCbData* data = new SCbData(tobj->getSymbolID(), tobj->getX(), tobj->getY(), tobj->getAngle(), tobj->getXSpeed(), tobj->getYSpeed(), tobj->getRotationSpeed());
74  OBJpostEvent(TUIO_OBJECT_UPDATE_CB, SCOL_PTR this, (int)data);
75 }
76 
77 void STuioClient::removeTuioObject(TUIO::TuioObject *tobj)
78 {
79  OBJpostEvent(TUIO_OBJECT_REMOVE_CB, SCOL_PTR this, (int)tobj->getSymbolID());
80 }
81 
82 void STuioClient::addTuioCursor(TUIO::TuioCursor *tcur)
83 {
84  SCbData* data = new SCbData(tcur->getCursorID(), tcur->getX(), tcur->getY(), tcur->getXSpeed(), tcur->getYSpeed());
85  OBJpostEvent(TUIO_CURSOR_ADD_CB, SCOL_PTR this, (int)data);
86 }
87 
88 void STuioClient::updateTuioCursor(TUIO::TuioCursor *tcur)
89 {
90  SCbData* data = new SCbData(tcur->getCursorID(), tcur->getX(), tcur->getY(), tcur->getXSpeed(), tcur->getYSpeed());
91  OBJpostEvent(TUIO_CURSOR_UPDATE_CB, SCOL_PTR this, (int)data);
92 }
93 
94 void STuioClient::removeTuioCursor(TUIO::TuioCursor *tcur)
95 {
96  OBJpostEvent(TUIO_CURSOR_REMOVE_CB, SCOL_PTR this, (int)tcur->getCursorID());
97 }
98 
99 //TODO
100 void STuioClient::addTuioBlob(TUIO::TuioBlob *tblb)
101 {
102  //OBJpostEvent(TUIO_CURSOR_REMOVE_CB, SCOL_PTR this, (int)tcur->getCursorID());
103 }
104 
105 void STuioClient::updateTuioBlob(TUIO::TuioBlob *tblb)
106 {
107  //OBJpostEvent(TUIO_CURSOR_REMOVE_CB, SCOL_PTR this, (int)tcur->getCursorID());
108 }
109 
110 void STuioClient::removeTuioBlob(TUIO::TuioBlob *tblb)
111 {
112  //OBJpostEvent(TUIO_CURSOR_REMOVE_CB, SCOL_PTR this, (int)tcur->getCursorID());
113 }
114 
115 void STuioClient::refresh(TUIO::TuioTime frameTime)
116 {
117 }
void Disconnect()
Definition: sTuio.cpp:55
bool Connect()
Definition: sTuio.cpp:49
~STuioClient()
Definition: sTuio.cpp:42
bool IsConnected()
Definition: sTuio.cpp:60
STuioClient(int port)
Definition: sTuio.cpp:34
Definition: sTuio.h:39