Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Implementation of TouchArea using TUIO API for QML application
Forum Updated to NodeBB v4.3 + New Features

Implementation of TouchArea using TUIO API for QML application

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 1 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sil20
    wrote on last edited by
    #1

    Hello,
    I am implementing a TUIO API interface for multiple touch screen able to touch several touch screen simultaneously.

    Is is nearly working:

    I have several instance of a class :

    @class SdcnApplicationViewer
    : public QDeclarativeView, TUIO::TuioListener@

    For every TUIO Event I use a Qt function to emit deep asome touch event and reach the touch areas

    @//Send Event to main application
    QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
    qAppPriv->translateRawTouchEvent(this,QTouchEvent::TouchScreen,touchPointsList);@

    have for the moment 3 instance of my SdcnApplicationViewer

    • one receives All event of translateRawTouchEvent
    • one receives All only the Touchbegin event of translateRawTouchEvent
    • one receives no event of translateRawTouchEvent

    Does someone has information of about the translateRawTouchEvent and how it dispatches data from application to toucareas

    --

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sil20
      wrote on last edited by
      #2

      Hi,
      I finaly succeeded !!

      All I had to do is to create one static background Widget which is parent of all SdcnApplicationViewer instance -using setParent methode.
      Then I call translaterawTouchEvent on this static widget

      For future debug feature I need to trace the touchEvents from this backgroundwidget but the event is not call with touch event , only updatedisplay and mouse over.

      What Method should I overload to trace touch events??
      Here after is the SdcnBackgroundWidget class I made:
      @class SdcnBackgroundWidget
      : public QWidget
      {
      Q_OBJECT
      public:
      explicit SdcnBackgroundWidget ( QWidget * parent = 0, Qt::WindowFlags f = 0 );
      virtual ~SdcnBackgroundWidget ( );

      protected:
      bool event ( QEvent* event );
      };
      @
      @SdcnBackgroundWidget::SdcnBackgroundWidget ( QWidget * parent, Qt::WindowFlags f )
      :QWidget( parent, f )
      {

      }
      SdcnBackgroundWidget::~SdcnBackgroundWidget()
      {
      }
      //-----------------------------------------------------------------------------
      bool SdcnBackgroundWidget::event( QEvent* event )
      {
      qDebug()<< "SdcnBackgroundWidget::event" << event->type();
      }@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sil20
        wrote on last edited by
        #3

        Hi,
        I improve the implementation but it required a modification in QTGui4.dll.
        The idea was to set a specific pressure that allow to filter touch event.
        System touch event pressure are only 0 or 1, so I added a static member
        touchEventPressurFilter which allow to ignore those.

        @void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
        QTouchEvent::DeviceType deviceType,
        const QListQTouchEvent::TouchPoint &touchPoints)
        {
        QApplicationPrivate *d = self;
        typedef QPair<Qt::TouchPointStates, QListQTouchEvent::TouchPoint > StatesAndTouchPoints;
        QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;

        //TestTuio
        if(touchEventPressurFilter>=0)
            for (int i = 0; i < touchPoints.count(); ++i)
            {
                QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
                if(touchPoint.pressure()!=touchEventPressurFilter)
                {
                    //qDebug()<< "Ignore WM_TOUCH Events: filter on pressure value: "<<touchPoint.pressure()<< touchEventPressurFilter;
                    return;
                }
            }@
        

        The only problem left is when my application is creating popup (a framed window which can be moved), they do not take touch event into account.

        the popup is made of a class Q_DECL_EXPORT SdcnPopup: public QMainWindow

        all instance are set to be children of the global SdcnBackgroundWidget whici is parent of all other application viewer:
        @// Parent is null when TUIO is not active
        setParent( SdcnBackgroundWidget::getInstance() );@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sil20
          wrote on last edited by
          #4

          Conclusion:
          Hello,
          I am implementing a TUIO API interface for multiple touch screen able to touch several touch screen simultaneously.
          It is working!

          0./ I add a modiffication into:
          qapplication_p.h
          @public:
          //Add a filter to completely ignore touch event if they do not match the pressure value
          //only when touchEventPressurFilter>0 !!
          static qreal touchEventPressurFilter;@
          and also into gui\kern@el\qapplication.cpp
          so the methode translateRawTouchEvent can ignore touch event based on a pressure value
          @//Add a filter to completely ignore touch event if they do not match the pressure value
          //only when touchEventPressurFilter>0 !!
          qreal QApplicationPrivate::touchEventPressurFilter = -1;@

          @void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
          QTouchEvent::DeviceType deviceType,
          const QListQTouchEvent::TouchPoint &touchPoints)
          {
          QApplicationPrivate *d = self;
          typedef QPair<Qt::TouchPointStates, QListQTouchEvent::TouchPoint > StatesAndTouchPoints;
          QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;

          //TestTuio
          if(touchEventPressurFilter>=0)
              for (int i = 0; i < touchPoints.count(); ++i)
              {
                  QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
                  if(touchPoint.pressure()!=touchEventPressurFilter)
                  {
                      //qDebug()<< "Ignore WM_TOUCH Events: filter on pressure value: "<<touchPoint.pressure()<< touchEventPressurFilter;
                      return;
                  }
              }@
          

          1./ I have several instance of a class :

          @class SdcnTUIOApplicationViewer
          : public QDeclarativeView, TUIO::TuioListener@

          2./ Only one instance is listening the TUIO UDP frames All instance are child of a static global background widget, setparent() is called during initialisation:
          The filter/pressure value is also set once during initialisation of one of the ApplicationViewer instance
          @ //GlobalWidget use for multitouch
          if(globalWidget==NULL)
          {

                  //globalWidget Must fill the virtual desktop
                  globalWidget = new SdcnBackgroundWidget( 0, Qt::Tool|Qt::FramelessWindowHint );
          
                  //Set geometry instead of maximized !
                  ((QWidget*)globalWidget)->setGeometry(0,0,mGlobalVirtualScreenWidth,mGlobalVirtualScreenHeight);
          
                  globalWidget->m_initialSize.setWidth( mGlobalVirtualScreenWidth );
                  globalWidget->m_initialSize.setHeight( mGlobalVirtualScreenHeight );
          
                  ((QWidget*)globalWidget)->setVisible(true);
                  //Set the background color of the globalwidget
                  ((QWidget*)globalWidget)->setStyleSheet("* { background-color: rgb(50, 50, 50); }");
                  this->setParent(globalWidget);
          
                  //Main application :
                  QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
                  //Set pressure filter value to ignore system nativ touch events
                  qAppPriv->touchEventPressurFilter=TUIO_PRESSURE_VALUE;
              }
              else
                  this->setParent(globalWidget);@
          

          3./ The translateRawTouchEvent methode is then alled on the top most widget of the application (even detached popup)

          @ //Main application :
          QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();

          //Get the topest widget, even Detached popup windows:
          QWidget* lToplevelWidget= QApplication::topLevelAt(QPoint(posInScreen.x(), posInScreen.y()));
          qAppPriv->translateRawTouchEvent(lToplevelWidget,QTouchEvent::TouchScreen,touchPointsList);@
          
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved