Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 184

Advertising
background image

KTD-S0057-I

Page 180 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


QRectF boundingRect () const;

QPainterPath shape () const;

void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

protected:

void advance (int step);

private:
qreal

angle;

qreal

speed;

qreal

mouseEyeDirection;

QColor

color;

};

#endif


File mouse.cpp (header with Qt

TM

license see 'main.cpp'):

#include <QtGui/QGraphicsScene>
#include <QtGui/QPainter>
#include <QtGui/QStyleOption>

#include <math.h>
#include "mouse.h"

static const double Pi = 3.14159265358979323846264338327950288419717;
static double TwoPi = 2.0 * Pi;

static qreal normalizeAngle (qreal angle)
{

while (angle < 0)

angle += TwoPi;

while (angle > TwoPi)

angle -= TwoPi;

return

angle;

}


Mouse::Mouse ()

: angle (0), speed (0), mouseEyeDirection (0), color (qrand () % 256, qrand () % 256, qrand () % 256)

{

setRotation (qrand () % (360 * 16));

}


QRectF Mouse::boundingRect () const
{

qreal adjust = 0.5;

return QRectF (-18 - adjust, -22 - adjust, 36 + adjust, 60 + adjust);

}

Advertising
This manual is related to the following products: