|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QWSCalibratedMouseHandler Class Reference
[QtGui module]

The QWSCalibratedMouseHandler class provides basic functionality for implementing a mouse handler that needs calibration. More...

    #include <QWSCalibratedMouseHandler>

Inherits QWSMouseHandler.

Inherited by QWSTslibMouseHandler.

- List of all members, including inherited members

### Public Functions

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

- 7 public functions inherited from QWSMouseHandler

### 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 basic functionality for implementing a mouse handler that needs calibration.

Derive from this class to create a handler when the device doesn't have a fixed mapping between device coordinates and/or produces noisy events. A touchscreen is a good example of such a device.

The QWSCalibratedMouseHandler provides linear transformation between device coordinates and screen coordinates by calling transform(). This implementation uses 7 parameters a, b, c, d, e, f, s to transform the device coordinates (Xd, Yd) into screen coordinates (Xs, Ys) using the following equations:

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

The parameters are stored in `/etc/pointercal` (separated by whitespace and in alphabetical order), and are read when the class is instantiated. The calibration parameters are recalculated whenever calibrate() is called.

To achieve noise reduction, use the sendFiltered() function instead of mouseChanged() whenever a mouse event occurs.

## Member Function Documentation

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

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

Reimplemented from QWSMouseHandler.

### void QWSCalibratedMouseHandler::clearCalibration () `[virtual]`

Clears the current calibration.

After this function is called the mouse handler will return mouse events in raw device coordinates and not in screen coordinates.

Reimplemented from QWSMouseHandler.

### void QWSCalibratedMouseHandler::readCalibration () `[protected]`

Reads previously written calibration parameters.

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 mouseChanged() was called; otherwise returns false.

The given position is the global position of the mouse. The state parameter is a bitmask of Qt::MouseButtons indicating which mouse buttons are pressed.

See also mouseChanged().

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

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

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.

### void QWSCalibratedMouseHandler::writeCalibration () `[protected]`

Save the current calibration parameters.