<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qmouse_qws.cpp --> <title>Qt 4.8: QWSCalibratedMouseHandler Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li><a href="qtgui.html">QtGui</a></li> <li>QWSCalibratedMouseHandler</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">QWSCalibratedMouseHandler Class Reference</h1> <!-- $$$QWSCalibratedMouseHandler-brief --> <p>The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux. <a href="#details">More...</a></p> <!-- @@@QWSCalibratedMouseHandler --> <pre class="cpp"> <span class="preprocessor">#include <QWSCalibratedMouseHandler></span></pre><p><b>Inherits: </b><a href="qwsmousehandler.html">QWSMouseHandler</a>.</p> <ul> <li><a href="qwscalibratedmousehandler-members.html">List of all members, including inherited members</a></li> </ul> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#calibrate">calibrate</a></b> ( const QWSPointerCalibrationData * <i>data</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#clearCalibration">clearCalibration</a></b> ()</td></tr> </table> <ul> <li class="fn">9 public functions inherited from <a href="qwsmousehandler.html#public-functions">QWSMouseHandler</a></li> </ul> <a name="protected-functions"></a> <h2>Protected Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#readCalibration">readCalibration</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#sendFiltered">sendFiltered</a></b> ( const QPoint & <i>position</i>, int <i>state</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#setFilterSize">setFilterSize</a></b> ( int <i>size</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#transform">transform</a></b> ( const QPoint & <i>position</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qwscalibratedmousehandler.html#writeCalibration">writeCalibration</a></b> ()</td></tr> </table> <a name="details"></a> <!-- $$$QWSCalibratedMouseHandler-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The QWSCalibratedMouseHandler class provides mouse calibration and noise reduction in Qt for Embedded Linux.</p> <p>Note that this class is only available in <a href="qt-embedded-linux.html">Qt for Embedded Linux</a>.</p> <p><a href="qt-embedded-linux.html">Qt for Embedded Linux</a> provides ready-made drivers for several mouse protocols, see the <a href="qt-embedded-pointer.html">pointer handling</a> documentation for details. In general, custom mouse drivers can be implemented by subclassing the <a href="qwsmousehandler.html">QWSMouseHandler</a> 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 <a href="qmousedriverplugin.html">QMouseDriverPlugin</a>); the implementation of the <a href="qmousedriverfactory.html">QMouseDriverFactory</a> class will then automatically detect the plugin, and load the driver into the server application at run-time using Qt's <a href="plugins-howto.html">plugin system</a>.</p> <p>QWSCalibratedMouseHandler provides an implementation of the <a href="qwscalibratedmousehandler.html#calibrate">calibrate</a>() function to update the calibration parameters based on coordinate mapping of the given calibration data. The calibration data is represented by an <a href="qwspointercalibrationdata.html">QWSPointerCalibrationData</a> object. The linear transformation between device coordinates and screen coordinates is performed by calling the <a href="qwscalibratedmousehandler.html#transform">transform</a>() function explicitly on the points passed to the <a href="qwsmousehandler.html#mouseChanged">QWSMouseHandler::mouseChanged</a>() function. Use the <a href="qwscalibratedmousehandler.html#clearCalibration">clearCalibration</a>() function to make the mouse driver return mouse events in raw device coordinates and not in screen coordinates.</p> <p>The calibration parameters are recalculated whenever <a href="qwscalibratedmousehandler.html#calibrate">calibrate</a>() is called, and they can be stored using the <a href="qwscalibratedmousehandler.html#writeCalibration">writeCalibration</a>() function. Previously written parameters can be retrieved at any time using the <a href="qwscalibratedmousehandler.html#readCalibration">readCalibration</a>() 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 <a href="qt-embedded-envvars.html#pointercal-file">POINTERCAL_FILE</a> environment variable; the default file is <tt>/etc/pointercal</tt>.</p> <p>To achieve noise reduction, QWSCalibratedMouseHandler provides the <a href="qwscalibratedmousehandler.html#sendFiltered">sendFiltered</a>() function. Use this function instead of <a href="qwsmousehandler.html#mouseChanged">mouseChanged</a>() whenever a mouse event occurs. The filter's size can be manipulated using the <a href="qwscalibratedmousehandler.html#setFilterSize">setFilterSize</a>() function.</p> </div> <p><b>See also </b><a href="qwsmousehandler.html">QWSMouseHandler</a>, <a href="qwspointercalibrationdata.html">QWSPointerCalibrationData</a>, and <a href="qws-mousecalibration.html">Mouse Calibration Example</a>.</p> <!-- @@@QWSCalibratedMouseHandler --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$calibrate[overload1]$$$calibrateconstQWSPointerCalibrationData* --> <h3 class="fn"><a name="calibrate"></a><span class="type">void</span> QWSCalibratedMouseHandler::<span class="name">calibrate</span> ( const <span class="type"><a href="qwspointercalibrationdata.html">QWSPointerCalibrationData</a></span> * <i>data</i> )<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qwsmousehandler.html#calibrate">QWSMouseHandler::calibrate</a>().</p> <p>Updates the calibration parameters based on coordinate mapping of the given <i>data</i>.</p> <p>Create an instance of the <a href="qwspointercalibrationdata.html">QWSPointerCalibrationData</a> class, fill in the device and screen coordinates and pass that object to the mouse driver using this function.</p> <p><b>See also </b><a href="qwscalibratedmousehandler.html#clearCalibration">clearCalibration</a>() and <a href="qwscalibratedmousehandler.html#transform">transform</a>().</p> <!-- @@@calibrate --> <!-- $$$clearCalibration[overload1]$$$clearCalibration --> <h3 class="fn"><a name="clearCalibration"></a><span class="type">void</span> QWSCalibratedMouseHandler::<span class="name">clearCalibration</span> ()<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qwsmousehandler.html#clearCalibration">QWSMouseHandler::clearCalibration</a>().</p> <p>Clears the current calibration, i.e., makes the mouse driver return mouse events in raw device coordinates instead of screen coordinates.</p> <p><b>See also </b><a href="qwscalibratedmousehandler.html#calibrate">calibrate</a>().</p> <!-- @@@clearCalibration --> <!-- $$$readCalibration[overload1]$$$readCalibration --> <h3 class="fn"><a name="readCalibration"></a><span class="type">void</span> QWSCalibratedMouseHandler::<span class="name">readCalibration</span> ()<tt> [protected]</tt></h3> <p>Reads previously written calibration parameters which are stored in <tt>/etc/pointercal</tt> (separated by whitespace and in alphabetical order).</p> <p>You can override the default <tt>/etc/pointercal</tt> by specifying another file using the <a href="qt-embedded-envvars.html#pointercal-file">POINTERCAL_FILE</a> environment variable.</p> <p><b>See also </b><a href="qwscalibratedmousehandler.html#writeCalibration">writeCalibration</a>().</p> <!-- @@@readCalibration --> <!-- $$$sendFiltered[overload1]$$$sendFilteredconstQPoint&int --> <h3 class="fn"><a name="sendFiltered"></a><span class="type">bool</span> QWSCalibratedMouseHandler::<span class="name">sendFiltered</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>position</i>, <span class="type">int</span> <i>state</i> )<tt> [protected]</tt></h3> <p>Notifies the system of a new mouse event <i>after</i> 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.</p> <p>The given <i>position</i> is the global position of the mouse. The <i>state</i> parameter is a bitmask of the <a href="qt.html#MouseButton-enum">Qt::MouseButton</a> enum's values indicating which mouse buttons are pressed.</p> <p>The noice is reduced by calculating an average position from a collection of mouse event positions and then calling the <a href="qwsmousehandler.html#mouseChanged">mouseChanged</a>() function with the new position. The number of positions that is used is determined by the filter size.</p> <p><b>See also </b><a href="qwsmousehandler.html#mouseChanged">mouseChanged</a>() and <a href="qwscalibratedmousehandler.html#setFilterSize">setFilterSize</a>().</p> <!-- @@@sendFiltered --> <!-- $$$setFilterSize[overload1]$$$setFilterSizeint --> <h3 class="fn"><a name="setFilterSize"></a><span class="type">void</span> QWSCalibratedMouseHandler::<span class="name">setFilterSize</span> ( <span class="type">int</span> <i>size</i> )<tt> [protected]</tt></h3> <p>Sets the size of the filter used in noise reduction to the given <i>size</i>.</p> <p>The <a href="qwscalibratedmousehandler.html#sendFiltered">sendFiltered</a>() 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.</p> <p><b>See also </b><a href="qwscalibratedmousehandler.html#sendFiltered">sendFiltered</a>().</p> <!-- @@@setFilterSize --> <!-- $$$transform[overload1]$$$transformconstQPoint& --> <h3 class="fn"><a name="transform"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QWSCalibratedMouseHandler::<span class="name">transform</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>position</i> )<tt> [protected]</tt></h3> <p>Transforms the given <i>position</i> from device coordinates to screen coordinates, and returns the transformed position.</p> <p>This function is typically called explicitly on the points passed to the <a href="qwsmousehandler.html#mouseChanged">QWSMouseHandler::mouseChanged</a>() function.</p> <p>This implementation is a linear transformation using 7 parameters (<tt>a</tt>, <tt>b</tt>, <tt>c</tt>, <tt>d</tt>, <tt>e</tt>, <tt>f</tt> and <tt>s</tt>) to transform the device coordinates (<tt>Xd</tt>, <tt>Yd</tt>) into screen coordinates (<tt>Xs</tt>, <tt>Ys</tt>) using the following equations:</p> <pre class="cpp"> s<span class="operator">*</span>Xs <span class="operator">=</span> a<span class="operator">*</span>Xd <span class="operator">+</span> b<span class="operator">*</span>Yd <span class="operator">+</span> c s<span class="operator">*</span>Ys <span class="operator">=</span> d<span class="operator">*</span>Xd <span class="operator">+</span> e<span class="operator">*</span>Yd <span class="operator">+</span> f</pre> <p><b>See also </b><a href="qwsmousehandler.html#mouseChanged">mouseChanged</a>().</p> <!-- @@@transform --> <!-- $$$writeCalibration[overload1]$$$writeCalibration --> <h3 class="fn"><a name="writeCalibration"></a><span class="type">void</span> QWSCalibratedMouseHandler::<span class="name">writeCalibration</span> ()<tt> [protected]</tt></h3> <p>Saves the current calibration parameters in <tt>/etc/pointercal</tt> (separated by whitespace and in alphabetical order).</p> <p>You can override the default <tt>/etc/pointercal</tt> by specifying another file using the <a href="qt-embedded-envvars.html#pointercal-file">POINTERCAL_FILE</a> environment variable.</p> <p><b>See also </b><a href="qwscalibratedmousehandler.html#readCalibration">readCalibration</a>().</p> <!-- @@@writeCalibration --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>