-
Notifications
You must be signed in to change notification settings - Fork 0
/
PendulumGraphicsItem.h
52 lines (41 loc) · 1.24 KB
/
PendulumGraphicsItem.h
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
#ifndef PENDULUMGRAPHICSITEM_H
#define PENDULUMGRAPHICSITEM_H
#include <QGraphicsItem>
#include <QPointF>
#include <QSizeF>
enum ColorOfBall{
Yellow,
Blue,
Red,
Green
};
class PendulumGraphicsItem : public QGraphicsItem
{
public:
PendulumGraphicsItem( QGraphicsItem *parent = nullptr );
PendulumGraphicsItem( QPointF centerOfBall, double radius,
QGraphicsItem *parent = nullptr );
PendulumGraphicsItem( QPointF centerOfBall, double radius,
ColorOfBall colorOfBall,
QGraphicsItem *parent = nullptr );
void setCenterOfBall(QPointF centerOfBall);
void setRadius(double radius);
void setSize();
void setIndex(int index);
QPointF getCenterOfBall() const;
double getRadius() const;
QSizeF getSize() const;
int getIndex() const;
void setColor(ColorOfBall colorBall);
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
private:
int index = 0;
double radius;
QPointF centerOfBall;
QSizeF pendulumGraphicsItemSize;
ColorOfBall colorOfBall = ColorOfBall::Yellow;
};
#endif // PENDULUMGRAPHICSITEM_H