-
Notifications
You must be signed in to change notification settings - Fork 0
/
patient.h
69 lines (57 loc) · 1.7 KB
/
patient.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef PATIENT_H
#define PATIENT_H
#include <QObject>
#include <QWidget>
#include <QGraphicsPixmapItem>
#include <QGraphicsEffect>
#include <QGraphicsColorizeEffect>
#include <QTimer>
#include <QPainter>
#include <QPixmap>
#include "doctor.h"
#include <QtMath>
class patient : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
patient(Doctor& doctor, int size, QWidget *parent = nullptr);
~patient();
void paint(QPainter* painter, QStyleOptionGraphicsItem*, QWidget*);
//patient code related functions
void generate_code_string();
QString get_code_string() const;
int get_distance() const;
QGraphicsColorizeEffect* get_effect();
public slots:
void random_walk();
void reset_parameters();
void animation_controller();
//change color transparency when within a certain distance from doctor
void distance_calc();
private:
int index = 0;
QTimer* timer;
QTimer* timer2;
QTimer* timer3;
//original position & time interval
// int horizontal = 225 + std::rand() % 400;
// int vertical = 225 + std::rand() % 400;
int horizontal = 50 + std::rand() % 900;
int vertical = 200 + std::rand() % 500;
int interval = 1000 + std::rand() % 4000;
//control random walk speed & directions
double speed = 5;
int horizontal_change = -1 + std::rand() % 3;
int vertical_change = (horizontal_change == 0) ? -1 + std::rand() % 3 : 0;
//control patient's animation
int animation_state = 0;
//distance with doctor
Doctor* doctor_ptr;
double distance = 1000;
//patient code generated
int string_size;
QString code_string;
//highlight effect
QGraphicsColorizeEffect* effect;
};
#endif // PATIENT_H