Notice: Undefined offset: 1 in /home/developpez/www/developpez-com/upload/qt/doc/redir.php on line 39 Qt 4.7: QWSCalibratedMouseHandler Class Reference
Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QWSCalibratedMouseHandler Class Reference

The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux. More...

 #include <QWSCalibratedMouseHandler>

Inherits: QWSMouseHandler.

Reimplemented Public Functions

virtual void calibrate ( const QWSPointerCalibrationData * data )
virtual void clearCalibration ()

Protected Functions

void readCalibration ()
bool sendFiltered ( const QPoint & position, int state )
void setFilterSize ( int size )
QPoint transform ( const QPoint & position )
void writeCalibration ()

Detailed Description

The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux.

Note that this class is only available in Qt for Embedded Linux.

Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see the pointer handling documentation for details. In general, custom mouse drivers can be implemented by subclassing the QWSMouseHandler class. But when the system device does not have a fixed mapping between device and screen coordinates and/or produces noisy events (e.g., a touchscreen), you should derive from the QWSCalibratedMouseHandler class instead to take advantage of its calibration functionality. As always, you must also create a mouse driver plugin (derived from QMouseDriverPlugin); the implementation of the QMouseDriverFactory class will then automatically detect the plugin, and load the driver into the server application at run-time using Qt's plugin system.

QWSCalibratedMouseHandler provides an implementation of the calibrate() function to update the calibration parameters based on coordinate mapping of the given calibration data. The calibration data is represented by an QWSPointerCalibrationData object. The linear transformation between device coordinates and screen coordinates is performed by calling the transform() function explicitly on the points passed to the QWSMouseHandler::mouseChanged() function. Use the clearCalibration() function to make the mouse driver return mouse events in raw device coordinates and not in screen coordinates.

The calibration parameters are recalculated whenever calibrate() is called, and they can be stored using the writeCalibration() function. Previously written parameters can be retrieved at any time using the readCalibration() function (calibration parameters are always read when the class is instantiated). Note that the calibration parameters is written to and read from the file currently specified by the POINTERCAL_FILE environment variable; the default file is /etc/pointercal.

To achieve noise reduction, QWSCalibratedMouseHandler provides the sendFiltered() function. Use this function instead of mouseChanged() whenever a mouse event occurs. The filter's size can be manipulated using the setFilterSize() function.

See also QWSMouseHandler, QWSPointerCalibrationData, and Mouse Calibration Example.

Member Function Documentation

void QWSCalibratedMouseHandler::calibrate ( const QWSPointerCalibrationData * data ) [virtual]

Reimplemented from QWSMouseHandler::calibrate().

Updates the calibration parameters based on coordinate mapping of the given data.

Create an instance of the QWSPointerCalibrationData class, fill in the device and screen coordinates and pass that object to the mouse driver using this function.

See also clearCalibration() and transform().

void QWSCalibratedMouseHandler::clearCalibration () [virtual]

Reimplemented from QWSMouseHandler::clearCalibration().

Clears the current calibration, i.e., makes the mouse driver return mouse events in raw device coordinates instead of screen coordinates.

See also calibrate().

void QWSCalibratedMouseHandler::readCalibration () [protected]

Reads previously written calibration parameters which are stored in /etc/pointercal (separated by whitespace and in alphabetical order).

You can override the default /etc/pointercal by specifying another file using the POINTERCAL_FILE environment variable.

See also writeCalibration().

bool QWSCalibratedMouseHandler::sendFiltered ( const QPoint & position, int state ) [protected]

Notifies the system of a new mouse event after applying a noise reduction filter. Returns true if the filtering process is successful; otherwise returns false. Note that if the filtering process failes, the system is not notified about the event.

The given position is the global position of the mouse. The state parameter is a bitmask of the Qt::MouseButton enum's values indicating which mouse buttons are pressed.

The noice is reduced by calculating an average position from a collection of mouse event positions and then calling the mouseChanged() function with the new position. The number of positions that is used is determined by the filter size.

See also mouseChanged() and setFilterSize().

void QWSCalibratedMouseHandler::setFilterSize ( int size ) [protected]

Sets the size of the filter used in noise reduction to the given size.

The sendFiltered() function reduces noice by calculating an average position from a collection of mouse event positions. The filter size determines the number of positions that forms the basis for these calculations.

See also sendFiltered().

QPoint QWSCalibratedMouseHandler::transform ( const QPoint & position ) [protected]

Transforms the given position from device coordinates to screen coordinates, and returns the transformed position.

This function is typically called explicitly on the points passed to the QWSMouseHandler::mouseChanged() function.

This implementation is a linear transformation using 7 parameters (a, b, c, d, e, f and s) to transform the device coordinates (Xd, Yd) into screen coordinates (Xs, Ys) using the following equations:

 s*Xs = a*Xd + b*Yd + c
 s*Ys = d*Xd + e*Yd + f

See also mouseChanged().

void QWSCalibratedMouseHandler::writeCalibration () [protected]

Saves the current calibration parameters in /etc/pointercal (separated by whitespace and in alphabetical order).

You can override the default /etc/pointercal by specifying another file using the POINTERCAL_FILE environment variable.

See also readCalibration().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web