-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3.0 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library.
-*/
-
-#ifndef INCLUDED_TUIOLISTENER_H
-#define INCLUDED_TUIOLISTENER_H
-
-#include "TuioObject.h"
-#include "TuioCursor.h"
-#include "TuioBlob.h"
-
-namespace TUIO {
-
- /**
- * The TuioListener interface provides a simple callback infrastructure which is used by the {@link TuioClient} class
- * to dispatch TUIO events to all registered instances of classes that implement the TuioListener interface defined here.
- * Any class that implements the TuioListener interface is required to implement all of the callback methods defined here.
- * The {@link TuioClient} makes use of these interface methods in order to dispatch TUIO events to all registered TuioListener implementations.
- *
- * public class MyTuioListener implements TuioListener
- * ...
- * MyTuioListener listener = new MyTuioListener();
- * TuioClient client = new TuioClient();
- * client.addTuioListener(listener);
- * client.start();
- *
- *
- * @author Martin Kaltenbrunner
- * @version 1.1.6
- */
- class LIBDECL TuioListener {
-
- public:
- /**
- * The destructor is doing nothing in particular.
- */
- virtual ~TuioListener(){};
-
- /**
- * This callback method is invoked by the TuioClient when a new TuioObject is added to the session.
- *
- * @param tobj the TuioObject reference associated to the addTuioObject event
- */
- virtual void addTuioObject(TuioObject *tobj)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioObject is updated during the session.
- *
- * @param tobj the TuioObject reference associated to the updateTuioObject event
- */
- virtual void updateTuioObject(TuioObject *tobj)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioObject is removed from the session.
- *
- * @param tobj the TuioObject reference associated to the removeTuioObject event
- */
- virtual void removeTuioObject(TuioObject *tobj)=0;
-
- /**
- * This callback method is invoked by the TuioClient when a new TuioCursor is added to the session.
- *
- * @param tcur the TuioCursor reference associated to the addTuioCursor event
- */
- virtual void addTuioCursor(TuioCursor *tcur)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioCursor is updated during the session.
- *
- * @param tcur the TuioCursor reference associated to the updateTuioCursor event
- */
- virtual void updateTuioCursor(TuioCursor *tcur)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioCursor is removed from the session.
- *
- * @param tcur the TuioCursor reference associated to the removeTuioCursor event
- */
- virtual void removeTuioCursor(TuioCursor *tcur)=0;
-
- /**
- * This callback method is invoked by the TuioClient when a new TuioBlob is added to the session.
- *
- * @param tcur the TuioBlob reference associated to the addTuioBlob event
- */
- virtual void addTuioBlob(TuioBlob *tblb)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioBlob is updated during the session.
- *
- * @param tblb the TuioBlob reference associated to the updateTuioBlob event
- */
- virtual void updateTuioBlob(TuioBlob *tblb)=0;
-
- /**
- * This callback method is invoked by the TuioClient when an existing TuioBlob is removed from the session.
- *
- * @param tblb the TuioBlob reference associated to the removeTuioBlob event
- */
- virtual void removeTuioBlob(TuioBlob *tblb)=0;
-
- /**
- * This callback method is invoked by the TuioClient to mark the end of a received TUIO message bundle.
- *
- * @param ftime the TuioTime associated to the current TUIO message bundle
- */
- virtual void refresh(TuioTime ftime)=0;
- };
-}
-#endif /* INCLUDED_TUIOLISTENER_H */
diff --git a/modules/touch/ext/libTUIO/TUIO/TuioManager.cpp b/modules/touch/ext/libTUIO/TUIO/TuioManager.cpp
deleted file mode 100644
index db16a61d0f..0000000000
--- a/modules/touch/ext/libTUIO/TUIO/TuioManager.cpp
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- TUIO C++ Library
- Copyright (c) 2005-2016 Martin Kaltenbrunner
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3.0 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library.
-*/
-
-#include "TuioManager.h"
-using namespace TUIO;
-
-
-TuioManager::TuioManager()
- : currentFrameTime(TuioTime::getSystemTime())
- , currentFrame(-1)
- , maxCursorID(-1)
- , maxBlobID(-1)
- , sessionID(-1)
- , updateObject(false)
- , updateCursor(false)
- , updateBlob(false)
- , verbose(false)
- , invert_x(false)
- , invert_y(false)
- , invert_a(false)
-{
-
-}
-
-TuioManager::~TuioManager() {
-}
-
-
-TuioObject* TuioManager::addTuioObject(int f_id, float x, float y, float a) {
- sessionID++;
- TuioObject *tobj = new TuioObject(currentFrameTime, sessionID, f_id, x, y, a);
- objectList.push_back(tobj);
- updateObject = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioObject(tobj);
-
- if (verbose)
- std::cout << "add obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << std::endl;
-
- return tobj;
-}
-
-void TuioManager::addExternalTuioObject(TuioObject *tobj) {
- if (tobj==NULL) return;
- tobj->setSessionID(sessionID++);
- objectList.push_back(tobj);
- updateObject = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioObject(tobj);
-
- if (verbose)
- std::cout << "add obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << std::endl;
-}
-
-void TuioManager::updateTuioObject(TuioObject *tobj, float x, float y, float a) {
- if (tobj==NULL) return;
- if (tobj->getTuioTime()==currentFrameTime) return;
- tobj->update(currentFrameTime,x,y,a);
- updateObject = true;
-
- if (tobj->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioObject(tobj);
-
- if (verbose)
- std::cout << "set obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle()
- << " " << tobj->getXSpeed() << " " << tobj->getYSpeed() << " " << tobj->getRotationSpeed() << " " << tobj->getMotionAccel() << " " << tobj->getRotationAccel() << std::endl;
- }
-}
-
-void TuioManager::updateExternalTuioObject(TuioObject *tobj) {
- if (tobj==NULL) return;
- updateObject = true;
-
- if (tobj->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioObject(tobj);
-
- if (verbose)
- std::cout << "set obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle()
- << " " << tobj->getXSpeed() << " " << tobj->getYSpeed() << " " << tobj->getRotationSpeed() << " " << tobj->getMotionAccel() << " " << tobj->getRotationAccel() << std::endl;
- }
-}
-
-void TuioManager::removeTuioObject(TuioObject *tobj) {
- if (tobj==NULL) return;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->removeTuioObject(tobj);
-
- if (verbose)
- std::cout << "del obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ")" << std::endl;
-
- objectList.remove(tobj);
- delete tobj;
- updateObject = true;
-}
-
-void TuioManager::removeExternalTuioObject(TuioObject *tobj) {
- if (tobj==NULL) return;
- objectList.remove(tobj);
- updateObject = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->removeTuioObject(tobj);
-
- if (verbose)
- std::cout << "del obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ")" << std::endl;
-}
-
-TuioCursor* TuioManager::addTuioCursor(float x, float y) {
- sessionID++;
-
- int cursorID = (int)cursorList.size();
- if ((int)(cursorList.size())<=maxCursorID) {
- std::list::iterator closestCursor = freeCursorList.begin();
-
- for(std::list::iterator iter = freeCursorList.begin();iter!= freeCursorList.end(); iter++) {
- if((*iter)->getDistance(x,y)<(*closestCursor)->getDistance(x,y)) closestCursor = iter;
- }
-
- TuioCursor *freeCursor = (*closestCursor);
- cursorID = (*closestCursor)->getCursorID();
- freeCursorList.erase(closestCursor);
- delete freeCursor;
- } else maxCursorID = cursorID;
-
- TuioCursor *tcur = new TuioCursor(currentFrameTime, sessionID, cursorID, x, y);
- cursorList.push_back(tcur);
- updateCursor = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioCursor(tcur);
-
- if (verbose)
- std::cout << "add cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY() << std::endl;
-
- return tcur;
-}
-
-void TuioManager::addExternalTuioCursor(TuioCursor *tcur) {
- if (tcur==NULL) return;
- tcur->setSessionID(sessionID++);
- cursorList.push_back(tcur);
- updateCursor = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioCursor(tcur);
-
- if (verbose)
- std::cout << "add cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY() << std::endl;
-}
-
-void TuioManager::updateTuioCursor(TuioCursor *tcur,float x, float y) {
- if (tcur==NULL) return;
- //if (tcur->getTuioTime()==currentFrameTime) return;
- tcur->update(currentFrameTime,x,y);
- updateCursor = true;
-
- if (tcur->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioCursor(tcur);
-
- if (verbose)
- std::cout << "set cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
- << " " << tcur->getXSpeed() << " " << tcur->getYSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;
- }
-}
-
-void TuioManager::updateExternalTuioCursor(TuioCursor *tcur) {
- if (tcur==NULL) return;
- updateCursor = true;
-
- if (tcur->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioCursor(tcur);
-
- if (verbose)
- std::cout << "set cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
- << " " << tcur->getXSpeed() << " " << tcur->getYSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;
- }
-}
-
-void TuioManager::removeTuioCursor(TuioCursor *tcur) {
- if (tcur==NULL) return;
-
- cursorList.remove(tcur);
- tcur->remove(currentFrameTime);
- updateCursor = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->removeTuioCursor(tcur);
-
- if (verbose)
- std::cout << "del cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ")" << std::endl;
-
- if (tcur->getCursorID()==maxCursorID) {
- maxCursorID = -1;
- delete tcur;
-
- if (cursorList.size()>0) {
- std::list::iterator clist;
- for (clist=cursorList.begin(); clist != cursorList.end(); clist++) {
- int cursorID = (*clist)->getCursorID();
- if (cursorID>maxCursorID) maxCursorID=cursorID;
- }
-
- freeCursorBuffer.clear();
- for (std::list::iterator flist=freeCursorList.begin(); flist != freeCursorList.end(); flist++) {
- TuioCursor *freeCursor = (*flist);
- if (freeCursor->getCursorID()>maxCursorID) delete freeCursor;
- else freeCursorBuffer.push_back(freeCursor);
- }
-
- freeCursorList = freeCursorBuffer;
-
- } else {
- for (std::list::iterator flist=freeCursorList.begin(); flist != freeCursorList.end(); flist++) {
- TuioCursor *freeCursor = (*flist);
- delete freeCursor;
- }
- freeCursorList.clear();
- }
- } else if (tcur->getCursorID()::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->removeTuioCursor(tcur);
-
- if (verbose)
- std::cout << "del cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ")" << std::endl;
-}
-
-TuioBlob* TuioManager::addTuioBlob(float x, float y, float a, float w, float h, float f) {
- sessionID++;
-
- int blobID = (int)blobList.size();
- if ((int)(blobList.size())<=maxBlobID) {
- std::list::iterator closestBlob = freeBlobList.begin();
-
- for(std::list::iterator iter = freeBlobList.begin();iter!= freeBlobList.end(); iter++) {
- if((*iter)->getDistance(x,y)<(*closestBlob)->getDistance(x,y)) closestBlob = iter;
- }
-
- TuioBlob *freeBlob = (*closestBlob);
- blobID = (*closestBlob)->getBlobID();
- freeBlobList.erase(closestBlob);
- delete freeBlob;
- } else maxBlobID = blobID;
-
- TuioBlob *tblb = new TuioBlob(currentFrameTime, sessionID, blobID, x, y, a, w, h, f);
- blobList.push_back(tblb);
- updateBlob = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioBlob(tblb);
-
- if (verbose)
- std::cout << "add blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ") " << tblb->getX() << " " << tblb->getY() << " " << tblb->getAngle() << " " << tblb->getWidth() << " " << tblb->getHeight() << " " << tblb->getArea() << std::endl;
-
- return tblb;
-}
-
-void TuioManager::addExternalTuioBlob(TuioBlob *tblb) {
- if (tblb==NULL) return;
-
- int blobID = (int)blobList.size();
- if (blobID <= maxBlobID) {
- std::list::iterator closestBlob = freeBlobList.begin();
-
- for(std::list::iterator iter = freeBlobList.begin();iter!= freeBlobList.end(); iter++) {
- if((*iter)->getDistance(tblb->getX(),tblb->getY())<(*closestBlob)->getDistance(tblb->getX(),tblb->getY())) closestBlob = iter;
- }
-
- TuioBlob *freeBlob = (*closestBlob);
- blobID = (*closestBlob)->getBlobID();
- freeBlobList.erase(closestBlob);
- delete freeBlob;
- } else maxBlobID = blobID;
-
- tblb->setSessionID(sessionID++);
- tblb->setBlobID(blobID);
-
- blobList.push_back(tblb);
- updateBlob = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->addTuioBlob(tblb);
-
- if (verbose)
- std::cout << "add blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ") " << tblb->getX() << " " << tblb->getY() << " " << tblb->getAngle() << " " << tblb->getWidth() << " " << tblb->getHeight() << " " << tblb->getArea() << std::endl;
-}
-
-void TuioManager::updateTuioBlob(TuioBlob *tblb,float x, float y, float a, float w, float h, float f) {
- if (tblb==NULL) return;
- if (tblb->getTuioTime()==currentFrameTime) return;
- tblb->update(currentFrameTime,x,y,a,w,h,f);
- updateBlob = true;
-
- if (tblb->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioBlob(tblb);
-
- if (verbose)
- std::cout << "set blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ") " << tblb->getX() << " " << tblb->getY() << " " << tblb->getAngle() << " " << tblb->getWidth() << " " << tblb->getHeight() << " " << tblb->getArea()
- << " " << tblb->getXSpeed() << " " << tblb->getYSpeed() << " " << tblb->getRotationSpeed() << " " << tblb->getMotionAccel()<< " " << tblb->getRotationAccel() << " " << std::endl;
- }
-}
-
-void TuioManager::updateExternalTuioBlob(TuioBlob *tblb) {
- if (tblb==NULL) return;
- updateBlob = true;
-
- if (tblb->isMoving()) {
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->updateTuioBlob(tblb);
-
- if (verbose)
- std::cout << "set blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ") " << tblb->getX() << " " << tblb->getY() << " " << tblb->getAngle() << " " << tblb->getWidth() << " " << tblb->getHeight() << " " << tblb->getArea()
- << " " << tblb->getXSpeed() << " " << tblb->getYSpeed() << " " << tblb->getRotationSpeed() << " " << tblb->getMotionAccel()<< " " << tblb->getRotationAccel() << " " << std::endl;
- }
-}
-
-void TuioManager::removeTuioBlob(TuioBlob *tblb) {
- if (tblb==NULL) return;
-
- blobList.remove(tblb);
- tblb->remove(currentFrameTime);
- updateBlob = true;
-
- for (std::list::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++)
- (*listener)->removeTuioBlob(tblb);
-
- if (verbose)
- std::cout << "del blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ")" << std::endl;
-
- if (tblb->getBlobID()==maxBlobID) {
- maxBlobID = -1;
- delete tblb;
-
- if (blobList.size()>0) {
- std::list