blob: ae406ca4b0e7a2c2ccdc9bc07069526aea19ead9 (
plain)
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
|
#ifndef STICKMAN_H
#define STICKMAN_H
#include <QGraphicsItem>
const int LimbCount = 16;
class Node;
class QTimer;
class StickMan: public QObject, public QGraphicsItem
{
Q_OBJECT
Q_PROPERTY(QColor penColor WRITE setPenColor READ penColor)
Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor)
Q_PROPERTY(bool isDead WRITE setIsDead READ isDead)
public:
StickMan();
~StickMan();
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
int nodeCount() const;
Node *node(int idx) const;
void setDrawSticks(bool on);
bool drawSticks() const { return m_sticks; }
QColor penColor() const { return m_penColor; }
void setPenColor(const QColor &color) { m_penColor = color; }
QColor fillColor() const { return m_fillColor; }
void setFillColor(const QColor &color) { m_fillColor = color; }
bool isDead() const { return m_isDead; }
void setIsDead(bool isDead) { m_isDead = isDead; }
public slots:
void stabilize();
protected:
void timerEvent(QTimerEvent *e);
private:
QPointF posFor(int idx) const;
Node **m_nodes;
qreal *m_perfectBoneLengths;
uint m_sticks : 1;
uint m_isDead : 1;
uint m_reserved : 30;
QPixmap m_pixmap;
QColor m_penColor;
QColor m_fillColor;
};
#endif // STICKMAN_H
|