root / SketchupMT Plugin / MultitouchSU / TuioSuDump.cpp @ 38
View | Annotate | Download (10.3 KB)
| 1 | /*
|
|---|---|
| 2 | TUIO C++ Example - part of the reacTIVision project |
| 3 | http://reactivision.sourceforge.net/ |
| 4 | |
| 5 | Copyright (c) 2005-2009 Martin Kaltenbrunner <[email protected]> |
| 6 | |
| 7 | Permission is hereby granted, free of charge, to any person obtaining |
| 8 | a copy of this software and associated documentation files |
| 9 | (the "Software"), to deal in the Software without restriction, |
| 10 | including without limitation the rights to use, copy, modify, merge, |
| 11 | publish, distribute, sublicense, and/or sell copies of the Software, |
| 12 | and to permit persons to whom the Software is furnished to do so, |
| 13 | subject to the following conditions: |
| 14 | |
| 15 | The above copyright notice and this permission notice shall be |
| 16 | included in all copies or substantial portions of the Software. |
| 17 | |
| 18 | Any person wishing to distribute modifications to the Software is |
| 19 | requested to send the modifications to the original developer so that |
| 20 | they can be incorporated into the canonical version. |
| 21 | |
| 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 25 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 26 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 27 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 28 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 29 | */ |
| 30 | |
| 31 | #include <wx/string.h> |
| 32 | #include "TuioSuDump.h" |
| 33 | #include "debugging.h" |
| 34 | #include "MultitouchSu.h" |
| 35 | #include "RubyClass.h" |
| 36 | #include "MtSuGlobals.h" |
| 37 | ////extern wxString g_wxStringMsg;
|
| 38 | ////extern HWND g_hWndSketchUp;
|
| 39 | ////extern UINT g_MtSuUserMsgNum;
|
| 40 | ////extern structMtSuTuioData g_MtSuTuioData;
|
| 41 | // ----------------------------------------------------------------------------
|
| 42 | void TuioDump::addTuioObject(TuioObject *tobj)
|
| 43 | // ----------------------------------------------------------------------------
|
| 44 | {
|
| 45 | //std::cout << "add obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << std::endl;
|
| 46 | wxString msg = _T("");
|
| 47 | msg << _T("add obj ") << tobj->getSymbolID() << _T(" (") << tobj->getSessionID() << _T(") ")<< tobj->getX() << _T(" ") << tobj->getY() << _T(" ") << tobj->getAngle() ; //_T("\n"); |
| 48 | |
| 49 | #if defined(LOGGING_TUIO)
|
| 50 | LOGIT( _T("[%s]"), msg.c_str());
|
| 51 | #endif
|
| 52 | |
| 53 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 54 | g_MtSuTuioData.clear(); |
| 55 | g_MtSuTuioData.symbolID = tobj->getSymbolID(); |
| 56 | g_MtSuTuioData.sessionID = tobj->getSessionID(); |
| 57 | g_MtSuTuioData.positionX = tobj->getX(); |
| 58 | g_MtSuTuioData.positionY = tobj->getY(); |
| 59 | g_MtSuTuioData.angle = tobj->getAngle() ; |
| 60 | g_MtSuTuioData.packetMsg = msg; |
| 61 | WORD wParam = 0;
|
| 62 | LPARAM lParam = (LPARAM)tobj; |
| 63 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 64 | if (lresult) ; //shush unused warning |
| 65 | } |
| 66 | // ----------------------------------------------------------------------------
|
| 67 | void TuioDump::updateTuioObject(TuioObject *tobj)
|
| 68 | // ----------------------------------------------------------------------------
|
| 69 | {
|
| 70 | //std::cout << "set obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle()
|
| 71 | // << " " << tobj->getMotionSpeed() << " " << tobj->getRotationSpeed() << " " << tobj->getMotionAccel() << " " << tobj->getRotationAccel() << std::endl;
|
| 72 | wxString msg = _T("");
|
| 73 | msg << _T("set obj ") << tobj->getSymbolID() << _T(" (") << tobj->getSessionID() << _T(") ")<< tobj->getX() << _T(" ") << tobj->getY() << _T(" ") << tobj->getAngle() |
| 74 | << _T(" ") << tobj->getMotionSpeed() << _T(" ") << tobj->getRotationSpeed() << _T(" ") << tobj->getMotionAccel() << _T(" ") << tobj->getRotationAccel() ; //_T("\n"); |
| 75 | |
| 76 | #if defined(LOGGING_TUIO)
|
| 77 | LOGIT( _T("[%s]"), msg.c_str());
|
| 78 | #endif
|
| 79 | |
| 80 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 81 | g_MtSuTuioData.clear(); |
| 82 | |
| 83 | g_MtSuTuioData.symbolID = tobj->getSymbolID(); |
| 84 | g_MtSuTuioData.sessionID = tobj->getSessionID(); |
| 85 | g_MtSuTuioData.positionX = tobj->getX(); |
| 86 | g_MtSuTuioData.positionY = tobj->getY(); |
| 87 | g_MtSuTuioData.angle = tobj->getAngle() ; |
| 88 | |
| 89 | g_MtSuTuioData.motionSpeed = tobj->getMotionSpeed(); |
| 90 | g_MtSuTuioData.rotationSpeed = tobj->getRotationSpeed(); |
| 91 | g_MtSuTuioData.motionAccel = tobj->getMotionAccel(); |
| 92 | g_MtSuTuioData.rotationAccel = tobj->getRotationAccel(); |
| 93 | |
| 94 | g_MtSuTuioData.packetMsg = msg; |
| 95 | WORD wParam = 0;
|
| 96 | LPARAM lParam = (LPARAM)tobj; |
| 97 | |
| 98 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 99 | if (lresult) ;
|
| 100 | } |
| 101 | // ----------------------------------------------------------------------------
|
| 102 | void TuioDump::removeTuioObject(TuioObject *tobj)
|
| 103 | // ----------------------------------------------------------------------------
|
| 104 | {
|
| 105 | //std::cout << "del obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << ")" << std::endl;
|
| 106 | wxString msg = _T("");
|
| 107 | msg << _T("del obj ") << tobj->getSymbolID() << _T(" (") << tobj->getSessionID() << _T(")") ; //_T("\n"); |
| 108 | |
| 109 | #if defined(LOGGING_TUIO)
|
| 110 | LOGIT( _T("[%s]"), msg.c_str());
|
| 111 | #endif
|
| 112 | |
| 113 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 114 | g_MtSuTuioData.clear(); |
| 115 | |
| 116 | g_MtSuTuioData.symbolID = tobj->getSymbolID(); |
| 117 | g_MtSuTuioData.sessionID = tobj->getSessionID(); |
| 118 | |
| 119 | g_MtSuTuioData.packetMsg = msg; |
| 120 | WORD wParam = 0;
|
| 121 | LPARAM lParam = (LPARAM)tobj; |
| 122 | |
| 123 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 124 | if (lresult) ;//shush unused compiler warning msg
|
| 125 | } |
| 126 | // ----------------------------------------------------------------------------
|
| 127 | void TuioDump::addTuioCursor(TuioCursor *tcur)
|
| 128 | // ----------------------------------------------------------------------------
|
| 129 | {
|
| 130 | //std::cout << "add cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY() << std::endl;
|
| 131 | wxString msg = _T("");
|
| 132 | msg << _T("add cur ") << tcur->getCursorID() << _T(" (") << tcur->getSessionID() << _T(") ") << tcur->getX() << _T(" ") << tcur->getY() ; //_T("\n"); |
| 133 | |
| 134 | #if defined(LOGGING_TUIO)
|
| 135 | LOGIT( _T("[%s]"), msg.c_str());
|
| 136 | #endif
|
| 137 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 138 | g_MtSuTuioData.clear(); |
| 139 | |
| 140 | g_MtSuTuioData.symbolID = tcur->getCursorID(); |
| 141 | g_MtSuTuioData.sessionID = tcur->getSessionID(); |
| 142 | g_MtSuTuioData.positionX = tcur->getX(); |
| 143 | g_MtSuTuioData.positionY = tcur->getY(); |
| 144 | |
| 145 | g_MtSuTuioData.packetMsg = msg; |
| 146 | WORD wParam = 0;
|
| 147 | LPARAM lParam = (LPARAM)tcur; |
| 148 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 149 | if (lresult) ;
|
| 150 | } |
| 151 | // ----------------------------------------------------------------------------
|
| 152 | void TuioDump::updateTuioCursor(TuioCursor *tcur)
|
| 153 | // ----------------------------------------------------------------------------
|
| 154 | {
|
| 155 | //std::cout << "set cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
|
| 156 | // << " " << tcur->getMotionSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;
|
| 157 | wxString msg = _T("");
|
| 158 | msg << _T("set cur ") << tcur->getCursorID() << _T(" (") << tcur->getSessionID() << _T(") ") << tcur->getX() << _T(" ") << tcur->getY() |
| 159 | << _T(" ") << tcur->getMotionSpeed() << _T(" ") << tcur->getMotionAccel() << _T(" ") ; //_T("\n"); |
| 160 | #if defined(LOGGING_TUIO)
|
| 161 | LOGIT( _T("[%s]"), msg.c_str());
|
| 162 | #endif
|
| 163 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 164 | g_MtSuTuioData.clear(); |
| 165 | |
| 166 | g_MtSuTuioData.symbolID = tcur->getCursorID(); |
| 167 | g_MtSuTuioData.sessionID = tcur->getSessionID(); |
| 168 | g_MtSuTuioData.positionX = tcur->getX(); |
| 169 | g_MtSuTuioData.positionY = tcur->getY(); |
| 170 | g_MtSuTuioData.motionSpeed = tcur->getMotionSpeed();; |
| 171 | g_MtSuTuioData.motionAccel = tcur->getMotionAccel(); |
| 172 | |
| 173 | g_MtSuTuioData.packetMsg = msg; |
| 174 | WORD wParam = 0;
|
| 175 | LPARAM lParam = (LPARAM)tcur; |
| 176 | |
| 177 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 178 | if (lresult) ;
|
| 179 | } |
| 180 | // ----------------------------------------------------------------------------
|
| 181 | void TuioDump::removeTuioCursor(TuioCursor *tcur)
|
| 182 | // ----------------------------------------------------------------------------
|
| 183 | {
|
| 184 | //std::cout << "del cur " << tcur->getCursorID() << " (" << tcur->getSessionID() << ")" << std::endl;
|
| 185 | wxString msg = _T("");
|
| 186 | msg << _T("del cur ") << tcur->getCursorID() << _T(" (") << tcur->getSessionID() << _T(")") ; //_T("\n"); |
| 187 | |
| 188 | #if defined(LOGGING_TUIO)
|
| 189 | LOGIT( _T("[%s]"), msg.c_str());
|
| 190 | #endif
|
| 191 | |
| 192 | // Post the data to SketchUp to allowing synchronous entry into embeded Ruby
|
| 193 | g_MtSuTuioData.clear(); |
| 194 | |
| 195 | g_MtSuTuioData.symbolID = tcur->getCursorID(); |
| 196 | g_MtSuTuioData.sessionID = tcur->getSessionID(); |
| 197 | |
| 198 | g_MtSuTuioData.packetMsg = msg; |
| 199 | WORD wParam = 0;
|
| 200 | LPARAM lParam = (LPARAM)tcur; |
| 201 | |
| 202 | long lresult = ::SendMessage( g_hWndSketchUp, g_MtSuUserMsgNum, wParam, lParam);
|
| 203 | if (lresult) ;
|
| 204 | } |
| 205 | // ----------------------------------------------------------------------------
|
| 206 | void TuioDump::refresh(TuioTime frameTime)
|
| 207 | // ----------------------------------------------------------------------------
|
| 208 | {
|
| 209 | //std::cout << "refresh " << frameTime.getTotalMilliseconds() << std::endl;
|
| 210 | //wxString msg = _T("");
|
| 211 | //msg << _T("refresh ") << frameTime.getTotalMilliseconds() ; //_T("\n");
|
| 212 | //#if defined(LOGGING)
|
| 213 | //LOGIT( _T("[%s]"), msg.c_str());
|
| 214 | //#endif
|
| 215 | //if( MultitouchSUApp::pRubyClassHandler )
|
| 216 | // MultitouchSUApp::pRubyClassHandler->Call_Ruby_OnTuioDataMethod(msg);
|
| 217 | //g_MtSuTuioData.packetMsg
|
| 218 | } |
| 219 | |
| 220 | //// ----------------------------------------------------------------------------
|
| 221 | //int TuioDump::main(int argc, char* argv[])
|
| 222 | //// ----------------------------------------------------------------------------
|
| 223 | //{
|
| 224 | // if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){
|
| 225 | // std::cout << "usage: TuioDump [port]\n";
|
| 226 | // return 0;
|
| 227 | // }
|
| 228 | //
|
| 229 | // int port = 3333;
|
| 230 | // if( argc >= 2 ) port = atoi( argv[1] );
|
| 231 | //
|
| 232 | // TuioDump dump;
|
| 233 | // TuioClient client(port);
|
| 234 | // client.addTuioListener(&dump);
|
| 235 | // client.addTuioListener(this);
|
| 236 | // client.connect(true); // blocking I/O
|
| 237 | //
|
| 238 | // return 0;
|
| 239 | //}
|
| 240 | |
| 241 |
