Implementation of TouchArea using TUIO API for QML application



  • Hello,
    For one of my project We implemented a QML plugin not to be dependent to QT evolutions on multitouch Touchareas.
    It works perfectely using Windows event. But we need to be abble to touch 2 separated touch screens simultaneously.
    We found the TUIO implementation, and I started adding the code into my plugin. It works but we have to manage every thing inside :

    • ToucheArea overlaping / Depth
    • toucheArea coordinate computations
    • TUIO send the globale normalised position of the touch point in the whole windows desktop
      My class is defined like this:
      @class QDeclarativeTouchArea : public QDeclarativeItem , TUIO::TuioListener
      {@

    I have several questions:

    • In My QML Application I have a List of QDeclarativeTouchArea, How to sort them from the one at the top to the one at the bottom? Since in QML the z property AND the instanciation order defined both the depth of hte instance?
    • How to get the coordinates of the touche Area in the global windwos desktop?

    Here is a simplified illustration of the situation:
    !http://imageshack.us/a/img197/2268/ppx1.jpg
    (TUIO Illustration)!



  • Hello I manage to go forward I try to generat an QtouchEvent, and to post it to the QApplication, in order to use the native QT filtering:
    @bool QDeclarativeTouchArea::event(QEvent *event)@
    @bool QDeclarativeTouchArea::sceneEventFilter(QGraphicsItem *i, QEvent *event)@

    The problem is:

    • the coordinate of the point coming from TUIO is correct
    • the event is send
    • But none of my touch areas received the events!!
    • The native windows touch events are received properly!

    Here after is the code for the TUIO to QT event mapping function.
    @bool QDeclarativeTouchArea::tuioToQtEvent(TUIO::TuioCursor *tcur, QEvent::Type eventType)
    {
    //Create Event structure
    QTouchEvent event(eventType);
    QListQTouchEvent::TouchPoint touchPoints = event.touchPoints();
    QTouchEvent::TouchPoint p;

    //Get Normalized globale position
    QPointF lp;
    lp.setX(tcur->getPosition().getX());
    lp.setY(tcur->getPosition().getY());
    
    int id = tcur->getCursorID();
    
    //Set Values
    p.setNormalizedPos(lp);
    p.setId(id);
    
    //p.setPressure(point->pressure);
    //p.setRect(point->area);
    //p.setScreenPos(point->area.center());
    
    switch (eventType) {
        case QEvent::TouchBegin:
        {
            p.setState(Qt::TouchPointPressed );
            touchPoints.append(p);
            break;
        }
        case QEvent::TouchUpdate:
        {
            p.setState(Qt::TouchPointMoved);
            touchPoints.append(p);
            break;
        }
        case QEvent::TouchEnd:
        {
            p.setState(Qt::TouchPointReleased );
            touchPoints.append(p);
            //touchPoints. Update Existing
            break;
        }
        default:
        {
            break;
        }
    }
    
    //copy data into event structure
    event.setTouchPoints(touchPoints);
    
    //Send Event to main application
    qDebug()<< "QDeclarativeTouchArea::tuioToQtEvent"<< "QApplication::sendEvent(QApplication::instance(), &event)";
    QApplication::sendEvent(QApplication::instance(), &event);
    
    return true;
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.