1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<?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/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<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>
<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 class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. 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>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
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>
</body>
</html>
|