示例#1
0
void Calibrate::mouseReleaseEvent( QMouseEvent *e )
{
qDebug("Calibrate::mouseReleaseEvent(%d,%d)", e->pos().x(), e->pos().y());
	penPos += e->pos();
	samples++;
	penPos /= samples;

	if (location < 5) {
qDebug(" entering %d samples as penPos %d,%d", samples, penPos.x(), penPos.y() );
		cal.x[location] = e->pos().x();
		cal.y[location] = e->pos().y();
		location++;
		penPos  = QPoint();
		samples = 0;
	}
	if (location < 5) {
		moveCrosshair(QPoint(cal.xfb[location], cal.yfb[location]));
	} else {
		showCross = FALSE;
		repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 );
		if (performCalculation()) {
			hide();
			emit accept();
		} else {
			qDebug("nochmal");
			reset();
		}
	}
}
示例#2
0
void Calibrate::timeout()
{
    QPoint target = fromDevice( cd.screenPoints[location] );

    bool doneX = false;
    bool doneY = false;
    QPoint newPos( crossPos.x() + dx, crossPos.y() + dy );

    if ( abs(crossPos.x() - target.x()) <= abs(dx) ) {
      newPos.setX( target.x() );
      doneX = true;
    }

    if ( abs(crossPos.y() - target.y()) <= abs(dy) ) {
      newPos.setY(target.y());
      doneY = true;
    }

    if ( doneX && doneY ) {
      penPos = QPoint();
      timer->stop();
    }
    moveCrosshair( newPos );
}